Metadata-Version: 2.4
Name: oeeil
Version: 0.1.0
Summary: Python package for processing, analysing and visualising OEEIL environmental sensor data
Author: Hajar Abdaoui, Ines Yous
License-Expression: Apache-2.0
Project-URL: Repository, https://github.com/NathalieAnemon/oeeil_package
Project-URL: Issues, https://github.com/NathalieAnemon/oeeil_package/issues
Keywords: air pollution,environmental exposure,portable sensors,microsensors,air quality,data processing
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Requires-Dist: numpy
Requires-Dist: pandas
Requires-Dist: matplotlib
Requires-Dist: geopy
Requires-Dist: reportlab
Requires-Dist: scikit-learn
Requires-Dist: tzdata
Dynamic: license-file

# OEEIL

**OEEIL** is a Python package for the automated processing, analysis, visualisation, and summarisation of data collected from portable environmental air-pollution microsensors.

The package was developed as part of the 2025–2026 Master's degree in Health Engineering – Health Data Science at the University of Lille (UFR3S–ILIS), by **Hâjar Abdaoui** and **Ines Yous**, under the supervision of **Dr Stephan Gabet**. 

The work was conducted within the **OEEIL Working Group (GT OEEIL)**, a multidisciplinary group bringing together Dr Stephan Gabet (University of Lille), **Nathalie Redon (IMT Nord Europe and Anemon Sensors)**, **Sahar Masmoudi (IMT Nord Europe)**, other researchers, PhD students and a postdoctoral researcher from IMT Nord Europe, as well as the two authors of this package. The working group aims to develop a structured and reproducible methodological framework for the processing and analysis of data collected from portable air-quality microsensors.

Its initial development and validation were carried out using data from the **OEEIL sensor** (*Outil d'Évaluation de l'Exposition Individuelle*), a portable environmental microsensor developed within IMT Nord Europe and used for individual air-pollution exposure assessment.

Current package version: **0.1.0**

---

## Purpose

Fixed air-quality monitoring stations provide reliable reference measurements but do not fully capture the spatial and temporal variability of an individual's real-world exposure.

Portable microsensors can complement these systems by collecting measurements close to individuals during daily activities and across different microenvironments. However, the resulting datasets require several processing steps before they can be interpreted reliably: harmonisation of heterogeneous files, time alignment, quality control, missing-data management, GPS processing, contextual enrichment, exposure analysis, visualisation, and reporting.

OEEIL provides these steps in a **modular, configurable, reproducible, and reusable Python pipeline**.

The package currently contains **32 main processing functions** organised around six functional areas, together with an additional public utility for imputation reporting.

---

## Main principles

The package was designed around four principles:

- **Modularity** – functions can be used independently or combined into a complete pipeline.
- **Configurability** – thresholds, time windows, variable names, and processing criteria can be adapted to the study.
- **Reproducibility** – identical data and parameters are intended to produce identical processing results.
- **Adaptability** – the architecture is designed to be reusable beyond the OEEIL sensor, although transfer to other devices must be validated for each use case.

---

## Installation

Once the package is available from PyPI:

```bash
pip install oeeil
```

For a local wheel:

```bash
pip install oeeil-0.1.0-py3-none-any.whl
```

OEEIL requires Python **3.10 or later**.

Main dependencies:

- numpy
- pandas
- matplotlib
- geopy
- reportlab
- scikit-learn
- tzdata

---

## Quick start

The public API is intentionally flat: functions can be imported directly from `oeeil` without knowing the internal module structure.

```python
from oeeil import (
    standardize_db,
    convert_timezone,
    filter_pollutant_outliers,
    impute_missing_values,
    classify_exposure_level,
    visualize_exposure,
)
```

Example:

```python
from oeeil import standardize_db

df_standardized = standardize_db(df)
```

Several functions return both processed data and metadata. Refer to each function's docstring for its complete signature, parameters, output columns, and return objects.

---

# Functions

## 1. Acquisition and standardisation

### `standardize_db`
Harmonises raw OEEIL datasets originating from different sensor generations and source structures. It standardises column names and data types and produces a common internal structure for downstream functions.

### `convert_timezone`
Converts OEEIL timestamps from UTC to a user-selected local time zone and adds local datetime information.

### `aggregate_close_gps_points`
Groups nearly identical GPS positions according to a user-defined distance threshold to reduce spatial redundancy during stationary periods.

### `synchronize_oeeil_campaign`
Synchronises several OEEIL DataFrames from the same campaign onto a common temporal basis while preserving sensor identifiers. The matching window is configurable to account for sensor resolution and clock offsets.

### `synchronize_with_reference`
Temporally synchronises an OEEIL dataset with an external reference dataset such as a regulatory air-quality station, fixed monitoring sensor, meteorological dataset, or another reference time series. The function handles differences in temporal resolution by aggregating the higher-frequency dataset around the lower-frequency grid. The current implementation keeps OEEIL and reference variables explicitly separated using suffixes, including when both inputs initially use identical column names.

### `identify_calibration_pairs`
Identifies OEEIL measurements located within a configurable geodesic radius of reference monitoring stations or other geolocated calibration points.

---

## 2. Preprocessing, signal quality and gas-signal normalisation, cross-sensitivity correction, and calibration

### `detect_extinction_periods`
Detects sensor shutdowns or acquisition gaps from timestamps and identifies post-restart warm-up periods. Affected observations can be flagged or removed.

### `detect_pollution_events`
Detects local pollution events using rolling statistics and a moving z-score. The function can add rolling means, z-scores, flags, and event labels.

### `filter_pollutant_outliers`
Detects short-duration instrumental spikes in pollutant signals. The current implementation uses time-based parameters such as amplitude threshold, maximum spike duration in seconds, and rolling-window duration in seconds. It infers the sampling interval from timestamps and converts durations into the appropriate number of observations. Artefacts can be replaced with `NaN` or retained with traceability flags.

### `manage_missing_suppression`
Applies configurable completeness criteria to identify and remove excessively incomplete data windows or sensors.

### `impute_missing_values`
Imputes missing measurements using temporal linear interpolation or K-nearest-neighbours (`KNN`) imputation, with traceability information for processed variables.

### `print_imputation_report`
Prints a readable summary of the imputation performed by `impute_missing_values`.

### `flag_environmental_conditions`
Adds a classification of environmental acquisition conditions according to configurable temperature and relative-humidity thresholds.

### `normalize_gas_percentage`

Provides a generalised framework for gas-signal normalisation, optional linear cross-sensitivity correction and linear deconvolution of multiple gas signals such as NO₂, O₃, and VOC.

### `convert_mv_to_concentration`

Converts raw or corrected gas-sensor signals from millivolts into concentration units using calibration against reference measurements. 

## 3. Data processing and contextual enrichment

### `interpolate_gps_coordinates`
Interpolates short gaps in latitude and longitude using temporal linear interpolation and adds traceability information.

### `compute_displacement_speed`
Calculates displacement speed in km/h between consecutive geolocated observations.

### `classify_transport_mode`
Classifies observations into mobility categories from calculated speed. Categories include stationary periods, walking, bicycle/scooter, urban motorised transport, heavy transport, and train/motorway conditions.

### `classify_indoor_outdoor_co2`
Classifies observations as indoor, outdoor, or transition states from CO₂ measurements using configurable decision thresholds.

### `detect_cov_outliers`
Detects artefacts specific to the VOC signal and can flag them or replace affected values with missing values.

### `normalize_cov_percentage`
Normalises cleaned VOC measurements to a robust 0–100% scale. This VOC-specific function is retained for compatibility; for multi-gas processing or cross-sensitivity correction, use `normalize_gas_percentage`.

### `classify_indoor_outdoor_cov`
Combines CO₂-based information with VOC information to refine indoor/outdoor classification.

### `correlate_transport_environment`
Corrects physically inconsistent combinations between transport-mode and environment classifications according to explicit decision rules.

---

## 4. Advanced exposure analysis

### `classify_exposure_level`
Assigns qualitative exposure levels to selected pollutants using configurable thresholds: low, moderate, high, and very high.

### `compute_exposure_indicators`
Computes cumulative exposure indicators including concentration-time area under the curve (AUC), duration of critical exposure, time distribution by exposure level, and identification of the most critical pollutant.

### `stratify_life_rhythm`
Adds temporal strata describing periods of the day, day types, and user-defined life-rhythm segments.

### `compute_daily_exposure`
Aggregates exposure indicators at the daily scale while accounting for minimum data-coverage requirements. Outputs can include daily mean, maximum, AUC, critical-exposure duration, and coverage information.

### `identify_critical_locations`
Aggregates geolocated exposure data into spatial cells and identifies exposure hotspots according to configurable spatial criteria.

---

## 5. Visualisation

### `visualize_exposure`
Produces configurable pollutant time series, concentration distributions, hour/day heatmaps, and GPS-based exposure maps when coordinates are available.

### `calendar_heatmap`
Creates a calendar-style heatmap in which each cell represents a day and can be coloured according to an aggregated pollutant value or exposure level.

### `statistical_summary_visual`
Creates a multi-panel statistical dashboard summarising exposure indicators, exposure-level distributions, normalised temporal dynamics, and optional stratifications.

---

## 6. Reporting

### `statistical_summary_report`
Produces structured descriptive statistics at configurable temporal granularities: overall, hourly, daily, weekly, monthly, and stratified summaries.

### `generate_report`
Generates an automated PDF report from processed OEEIL data using ReportLab. The report can include campaign metadata, exposure indicators, pollutant distributions, figures, and stratified statistics.

---

# Example pipeline

```python
from oeeil import (
    standardize_db,
    convert_timezone,
    detect_extinction_periods,
    filter_pollutant_outliers,
    impute_missing_values,
    interpolate_gps_coordinates,
    compute_displacement_speed,
    classify_transport_mode,
    classify_exposure_level,
    compute_daily_exposure,
)

df = standardize_db(df)
df = convert_timezone(df)
df = detect_extinction_periods(df)
df = filter_pollutant_outliers(df)

df, imputation_metadata = impute_missing_values(df)

df = interpolate_gps_coordinates(df)
df = compute_displacement_speed(df)
df = classify_transport_mode(df)

df = classify_exposure_level(df)
daily_exposure = compute_daily_exposure(df)
```

The exact return structure varies between functions. Some functions return a DataFrame directly, while others return additional metadata or structured result objects.

---

# Validation

The initial package was developed and functionally tested using data from four OEEIL sensors collected during the MobiCard campaign in summer 2025:

| Sensor | Measurement period | Measurements |
|---|---:|---:|
| OEI0012 | 03/07–10/07/2025 | 36,844 |
| OEI0018 | 15/07–21/07/2025 | 30,015 |
| OEI0020 | 02/07–10/07/2025 | 37,853 |
| OEI0021 | 17/07–24/07/2025 | 32,075 |

The initial validation dataset contained **136,787 measurements** collected over approximately 7-9 days per sensor.

The package functions were tested for technical execution and output consistency. Functions that depend on external reference measurements require additional scientific or operational validation using real reference databases.

The thesis dataset did not include a suitable colocation campaign with a regulatory reference instrument for NO₂, O₃, and VOC conversion. The new calibration and gas-deconvolution functions therefore provide the software framework for these operations, but their coefficients must be established and validated using appropriate experimental reference data before absolute exposure interpretation.

---

# Project status

Version **0.1.0** is the first packaged release of the OEEIL processing framework.

---

# Authors

- **Hâjar Abdaoui**
- **Ines Yous**

University of Lille  
UFR Health and Sports Sciences - ILIS  
Master's degree in Health Engineering - Health Data Science   
Academic year 2025–2026

Master's thesis:  
*Development of a tool for the automated processing, visualisation and summarisation of data from an environmental air pollution sensor (OEEIL sensor)*

Supervision: **Dr Stephan Gabet**

---

## Acknowledgements

The development of this work was carried out within a multidisciplinary context involving the University of Lille, IMT Nord Europe, and contributors to the OEEIL working group.

The authors particularly acknowledge **Dr Stephan Gabet** for scientific supervision, **Nathalie Redon** for her expertise on the OEEIL sensor and air-quality sensing, and the members of the OEEIL working group for their contributions to the methodological discussions.

---

## Citation

If you use this package in academic work, please cite the associated Master's thesis until a dedicated software citation is provided:

> Abdaoui H., Yous I. (2026). *Development of a tool for the automated processing, visualisation and summarisation of data from an environmental air pollution sensor (OEEIL sensor).* Master's degree thesis, University of Lille, UFR3S–ILIS.

---

## License

OEEIL is distributed under the **Apache License 2.0**.

See the [LICENSE](LICENSE) file for the full license terms and the [NOTICE](NOTICE) file for attribution information.
