lair.air.background#

Calculate background concentrations.

Functions

get_well_mixed(data[, hours])

Subset the data to the well-mixed hours of the day.

phase_shift_corrected_baseline(data[, n, q])

Derive a baseline concentration using a low quantile approach to minimize phase shift effects.

rolling_baseline(data[, window, q, ...])

Calculate the baseline concentration as the {q} quantile of a rolling window of size {window} hours.

thoning(data[, smooth_time])

Thoning curve fitting.

thoning_filter(data, **kwargs)

Create a Thoning filter object from a time series of data.

lair.air.background.get_well_mixed(data: Series | DataFrame, hours: list[int] = [12, 13, 14, 15, 16]) Series | DataFrame[source]#

Subset the data to the well-mixed hours of the day.

Parameters:
datapd.Series | pd.DataFrame

Time series data to subset. Must have a datetime index.

hourslist[int], optional

Hours of the day to subset. Default is LST afternoon hours.

Returns:
pd.Series | pd.DataFrame

Subset of the data for the well-mixed hours.

lair.air.background.rolling_baseline(data: Series, window: Any = '24h', q: float = 0.01, min_periods: int = 1, center: bool = True) Series[source]#

Calculate the baseline concentration as the {q} quantile of a rolling window of size {window} hours.

Parameters:
datapd.Series

Time series of data to calculate the baseline from.

windowAny, optional

Window size for the rolling calculation. Must be passable to pd.Timedelta. Default is ‘24h’.

qfloat, optional

Quantile to calculate the baseline from. Default is 0.01.

min_periodsint, optional

Minimum number of periods within each window required to have a value. Default is 1.

centerbool, optional

Center the window on the timestamp. Default is True.

Returns:
pd.Series

Baseline concentration

lair.air.background.phase_shift_corrected_baseline(data: Series, n: int = 3600, q: float = 0.01) Series[source]#

Derive a baseline concentration using a low quantile approach to minimize phase shift effects. This method uses forward-looking and backward-looking windows to better represent the lowest observed concentrations during periods of rapid change.

Note

Original developed by Ben Fasoli for the Google Street View project. See supplementary material in: https://doi.org/10.1016/j.atmosenv.2023.119995

Parameters:
datapd.Series

Signal time series with local datetime index.

nint

Window size in seconds.

qfloat

Quantile to extract from signal.

timezonestr, optional

Timezone to convert the datetime index to.

Returns:
pd.Series

Baseline concentration

lair.air.background.thoning_filter(data: Series, **kwargs) ccgFilter[source]#

Create a Thoning filter object from a time series of data.

Parameters:
datapd.Series

Time series of data to be smoothed. Must have a datetime index.

**kwargs

Additional keyword arguments to pass to the ccgFilter class.

Returns:
ccgFilter

Thoning filter object.

lair.air.background.thoning(data: Series, smooth_time: list[datetime] | None = None, **kwargs) Series[source]#

Thoning curve fitting.

Wraps code published by NOAA GML: https://gml.noaa.gov/ccgg/mbl/crvfit/crvfit.html

Thoning, K.W., P.P. Tans, and W.D. Komhyr, 1989,

Atmospheric carbon dioxide at Mauna Loa Observatory, 2. Analysis of the NOAA/GMCC data, 1974 1985., J. Geophys. Res. ,94, 8549 8565.

Parameters:
datapd.Series

Time series of data to be smoothed. Must have a datetime index.

**kwargs

Additional keyword arguments to pass to the ccgFilter class.

Returns:
pd.Series

Smoothed data.