calibpipe.atmosphere package#

Sub-package containing classes responsible for the atmosphere calibration.

Subpackages#

Submodules#

calibpipe.atmosphere.atmosphere_containers module#

Containers to keep atmospheric data and metadata.

class calibpipe.atmosphere.atmosphere_containers.AtmosphericModelContainer(prefix=None, **fields)[source]#

Bases: Container

Container for the atmospheric models.

Attributes:
startField(default=None)

Start of use timestamp

stopField(default=None)

End of use timestamp

versionField(default=None, allow_none=False)

Atmospheric model version

currentField(default=True)

Boolean flag showing whether a given model is currently in use

seasonField(default=None)

Season alias

name_ObservatoryField(default=None)

Reference observatory name

version_ObservatoryField(default=None)

Reference observatory configuration version

metadict

dict of attached metadata

prefixstr

Prefix attached to column names when saved to a table or file

start#
stop#
version#
current#
season#
name_Observatory#
version_Observatory#
meta#
prefix#
default_prefix = 'atmosphericmodel'#
fields = {'current': Field(default=True), 'name_Observatory': Field(default=None), 'season': Field(default=None), 'start': Field(default=None), 'stop': Field(default=None), 'version': Field(default=None, allow_none=False), 'version_Observatory': Field(default=None)}#
class calibpipe.atmosphere.atmosphere_containers.MacobacContainer(prefix=None, **fields)[source]#

Bases: Container

Container for 12 months average CO2 background concentration.

Attributes:
co2_concentrationField(default=nan ppm, unit=ppm)

12 months average CO2 background concentration

estimation_dateField(default=None, type=date, allow_none=False)

Date of MACOBAC estimation

versionField(default=0.0.0)

Atmospheric model version

metadict

dict of attached metadata

prefixstr

Prefix attached to column names when saved to a table or file

co2_concentration#
estimation_date#
version#
meta#
prefix#
default_prefix = 'macobac'#
fields = {'co2_concentration': Field(default=nan ppm, unit=ppm), 'estimation_date': Field(default=None, type=date, allow_none=False), 'version': Field(default=0.0.0)}#
class calibpipe.atmosphere.atmosphere_containers.MolecularAtmosphericProfileMetaContainer(prefix=None, **fields)[source]#

Bases: Container

Container for molecular atmospheric metadata.

Container that stores the metadata associated to the molecular atmospheric part of the model.

Attributes:
data_assimilation_systemField(default=)

Data assimilation system

datasetField(default=)

Dataset of the given data assimilation system

descriptionField(default=)

Optional description field

versionField(default=None, allow_none=False)

Atmospheric model version

metadict

dict of attached metadata

prefixstr

Prefix attached to column names when saved to a table or file

data_assimilation_system#
dataset#
description#
version#
meta#
prefix#
default_prefix = 'molecularatmosphericprofilemeta'#
fields = {'data_assimilation_system': Field(default=), 'dataset': Field(default=), 'description': Field(default=), 'version': Field(default=None, allow_none=False)}#
class calibpipe.atmosphere.atmosphere_containers.MolecularAtmosphericProfileContainer(prefix=None, **fields)[source]#

Bases: Container

Container for molecular atmospheric profile.

Attributes:
altitudeField(default=None, unit=km, ndim=1)

Altitude

pressureField(default=None, unit=hPa, ndim=1)

Pressure

temperatureField(default=None, unit=K, ndim=1)

Temperature

partial_water_pressureField(default=None, ndim=1)

Partial water vapor pressure, expressed as a fraction of the total pressure

refractive_index_m_1Field(default=None, ndim=1)

Refractive index N-1

atmospheric_densityField(default=None, unit=g / cm3, ndim=1)

Atmospheric density

atmospheric_thicknessField(default=None, unit=g / cm2, ndim=1)

Atmospheric thickness

versionField(default=None, allow_none=False)

Atmospheric model version

metadict

dict of attached metadata

prefixstr

Prefix attached to column names when saved to a table or file

altitude#
pressure#
temperature#
partial_water_pressure#
refractive_index_m_1#
atmospheric_density#
atmospheric_thickness#
version#
meta#
prefix#
default_prefix = 'molecularatmosphericprofile'#
fields = {'altitude': Field(default=None, unit=km, ndim=1), 'atmospheric_density': Field(default=None, unit=g / cm3, ndim=1), 'atmospheric_thickness': Field(default=None, unit=g / cm2, ndim=1), 'partial_water_pressure': Field(default=None, ndim=1), 'pressure': Field(default=None, unit=hPa, ndim=1), 'refractive_index_m_1': Field(default=None, ndim=1), 'temperature': Field(default=None, unit=K, ndim=1), 'version': Field(default=None, allow_none=False)}#
class calibpipe.atmosphere.atmosphere_containers.MolecularDensityContainer(prefix=None, **fields)[source]#

Bases: Container

Container for molecular density profile.

Attributes:
seasonField(default=None, ndim=1)

Atmospheric model season alias.

densityField(default=None, unit=1 / cm3)

Molecular number density

versionField(default=None, allow_none=False)

Atmospheric model version

metadict

dict of attached metadata

prefixstr

Prefix attached to column names when saved to a table or file

season#
density#
version#
meta#
prefix#
default_prefix = 'moleculardensity'#
fields = {'density': Field(default=None, unit=1 / cm3), 'season': Field(default=None, ndim=1), 'version': Field(default=None, allow_none=False)}#
class calibpipe.atmosphere.atmosphere_containers.RayleighExtinctionContainer(prefix=None, **fields)[source]#

Bases: Container

Container for Rayleigh extinction profile.

Attributes:
wavelengthField(default=None, unit=nm, ndim=1, allow_none=False)

Wavelength

altitudeField(default=None, unit=km, ndim=2, allow_none=False)

Altitude

AODField(default=None, ndim=2, allow_none=False)

Absolute Optical Depth (AOD)

versionField(default=None, allow_none=False)

Atmospheric model version

metadict

dict of attached metadata

prefixstr

Prefix attached to column names when saved to a table or file

wavelength#
altitude#
AOD#
version#
meta#
prefix#
default_prefix = 'rayleighextinction'#
fields = {'AOD': Field(default=None, ndim=2, allow_none=False), 'altitude': Field(default=None, unit=km, ndim=2, allow_none=False), 'version': Field(default=None, allow_none=False), 'wavelength': Field(default=None, unit=nm, ndim=1, allow_none=False)}#
class calibpipe.atmosphere.atmosphere_containers.SelectedAtmosphericModelContainer(prefix=None, **fields)[source]#

Bases: Container

Container for atmosphere model selection.

Attributes:
dateField(default=None, type=date, allow_none=False)

Date of reference model selection.

versionField(default=None, allow_none=False)

Atmospheric model version

seasonField(default=None, ndim=1)

Atmospheric model season alias.

siteField(default=None, type=str, allow_none=False)

Observation site name

provenanceField(default=None, type=str, allow_none=False)

Model data provenance. Can be timestamp, GDAS or ECMWF.

metadict

dict of attached metadata

prefixstr

Prefix attached to column names when saved to a table or file

date#
version#
season#
site#
provenance#
meta#
prefix#
default_prefix = 'selectedatmosphericmodel'#
fields = {'date': Field(default=None, type=date, allow_none=False), 'provenance': Field(default=None, type=str, allow_none=False), 'season': Field(default=None, ndim=1), 'site': Field(default=None, type=str, allow_none=False), 'version': Field(default=None, allow_none=False)}#

calibpipe.atmosphere.meteo_data_handlers module#

Meteorological data handling module.

class calibpipe.atmosphere.meteo_data_handlers.MeteoDataHandler(**kwargs: Any)[source]#

Bases: Component

Abstract class for meteo data handling.

dataset#

Meteorological dataset name

gridstep#

Meteo data grid step in degrees

update_frequency#

Frequency at which new meteorological data is available in hours

update_tzinfo#

IANA-compliant time zone base for the meteo data updates

data_path#

Path where the meteorological data shall be stored

timeout#

Request timeout limit in seconds

__init__(config=None, parent=None, das=None, **kwargs)[source]#
Parameters:
configtraitlets.loader.Config

Configuration specified by config file or cmdline arguments. Used to set traitlet values.

parent: Tool or Component

If a Component is created by another Component or Tool, you need to pass the creating Component as parent, e.g. parent=self. This makes sure the config is correctly handed down to the child components. Do not pass config in this case.

kwargs

Traitlets to be overridden. TraitError is raised if kwargs contains a key that does not correspond to a traitlet.

time_rounder(timestamp, up=None)[source]#

Round a given timestamp to the nearest DAS update timestamp.

This function rounds the given timestamp to the nearest multiple of the DAS update frequency. The rounding is done with respect to a fixed epoch (2000-01-01 00:00:00 UTC).

Parameters:
timestampdatetime.datetime

The timestamp to be rounded.

upbool, optional

If True, round up to the next nearest DAS update timestamp. If False, round down to the previous nearest DAS update timestamp.

Returns:
datetime.datetime

The rounded timestamp.

get_near_gridpoints(latitude, longitude)[source]#

Get closest meteorological data point and a grid box, surrounding the observatory.

The interpolation grids of the meteorological systems is assumed to start at (0,0) and be defined w.r.t. WGS84.

Parameters:
latitudeastropy.coordinates.Latitude

Latitude of the observatory location.

longitudeastropy.coordinates.Longitude

Longitude of the observatory location.

Returns:
nearest_grid_pointtuple(float, float)

Longitude and latitude of the nearest grid point.

box_coordinateslist(tuple(float, float))

List of coordinates (longitude, latitude) of four grid points forming a box around the observatory location.

create_request(start, stop, latitude, longitude, nearest_point=True)[source]#

To be implemented in the child classes.

request_data()[source]#

To be implemented in the child classes.

merge_data()[source]#

Merge meteo data.

Creates an ecsv file that contains an astropy.core.Table with the meteorological data from grib files, downloaded from DAS.

cleanup()[source]#

Remove temporary files.

class calibpipe.atmosphere.meteo_data_handlers.GDASDataHandler(**kwargs: Any)[source]#

Bases: MeteoDataHandler

GDAS/NCAR meteorological data handler.

dataset#

A trait for unicode strings.

gridstep#

A float trait.

update_frequency#

An int trait.

__init__(config=None, parent=None, **kwargs)[source]#
Parameters:
configtraitlets.loader.Config

Configuration specified by config file or cmdline arguments. Used to set traitlet values.

parent: Tool or Component

If a Component is created by another Component or Tool, you need to pass the creating Component as parent, e.g. parent=self. This makes sure the config is correctly handed down to the child components. Do not pass config in this case.

kwargs

Traitlets to be overridden. TraitError is raised if kwargs contains a key that does not correspond to a traitlet.

create_request(start, stop, latitude, longitude, nearest_point=True)[source]#

Create a request for GDAS data.

Parameters:
startdatetime.datetime

The start time for the data request.

stopdatetime.datetime

The stop time for the data request.

latitudeastropy.coordinates.Latitude

Latitude of the location for which data is requested.

longitudeastropy.coordinates.Longitude

Longitude of the location for which data is requested.

nearest_pointbool, optional

If True, request data for the nearest grid point. If False, request data for a grid box surrounding the location. Default is True.

request_data()[source]#

Request GDAS data.

class calibpipe.atmosphere.meteo_data_handlers.ECMWFDataHandler(**kwargs: Any)[source]#

Bases: MeteoDataHandler

ECMWF/Copernicus meteorological data handler.

dataset#

A trait for unicode strings.

gridstep#

A float trait.

update_frequency#

An int trait.

__init__(config=None, parent=None, **kwargs)[source]#
Parameters:
configtraitlets.loader.Config

Configuration specified by config file or cmdline arguments. Used to set traitlet values.

parent: Tool or Component

If a Component is created by another Component or Tool, you need to pass the creating Component as parent, e.g. parent=self. This makes sure the config is correctly handed down to the child components. Do not pass config in this case.

kwargs

Traitlets to be overridden. TraitError is raised if kwargs contains a key that does not correspond to a traitlet.

create_request(start, stop, latitude, longitude, nearest_point=False)[source]#

Create a request for ECMWF/Copernicus meteorological data.

This method prepares a request for meteorological data from the ECMWF/Copernicus dataset for a specified time range and location. The request can be for the nearest grid point or a grid box surrounding the specified location.

Parameters:
startdatetime.datetime

The start time for the data request.

stopdatetime.datetime

The stop time for the data request.

latitudeastropy.coordinates.Latitude

Latitude of the location for which data is requested.

longitudeastropy.coordinates.Longitude

Longitude of the location for which data is requested.

nearest_pointbool, optional

If True, request data for the nearest grid point. If False, request data for a grid box surrounding the location. Default is False.

Returns:
None
request_data()[source]#

Request ECMWF data.

The data is requested from the ECMWF/Copernicus server using the cdsapi library.

class calibpipe.atmosphere.meteo_data_handlers.CO2DataHandler(**kwargs: Any)[source]#

Bases: MeteoDataHandler

Mauna Loa CO2 data handler.

dataset#

A trait for unicode strings.

__init__(config=None, parent=None, **kwargs)[source]#
Parameters:
configtraitlets.loader.Config

Configuration specified by config file or cmdline arguments. Used to set traitlet values.

parent: Tool or Component

If a Component is created by another Component or Tool, you need to pass the creating Component as parent, e.g. parent=self. This makes sure the config is correctly handed down to the child components. Do not pass config in this case.

kwargs

Traitlets to be overridden. TraitError is raised if kwargs contains a key that does not correspond to a traitlet.

request_data()[source]#

Request CO2 data from the Mauna Loa Observatory.

Returns:
int

Returns 0 on successful data retrieval.

Raises:
IntermittentError

If the request to the dataset URL times out.