Skip to content

Commit

Permalink
Merge pull request #627 from metno/fix_o3max
Browse files Browse the repository at this point in the history
Fix o3max
  • Loading branch information
dulte authored Apr 28, 2022
2 parents 5c6334b + 668a3b0 commit 42d2acf
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 2 deletions.
1 change: 1 addition & 0 deletions pyaerocom/aeroval/glob_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@
concnh4=["NH4", "3D", "Gas concentrations"],
concno3=["NO3", "3D", "Gas concentrations"],
vmro3=["O3", "3D", "Volume mixing ratios"],
vmro3max=["O3Max", "3D", "Volume mixing ratios"],
concNtno3=["tNO3", "3D", "Concentration"],
concNtnh=["tNH", "3D", "Concentration"],
concNnh3=["NH3", "3D", "Concentration"],
Expand Down
23 changes: 23 additions & 0 deletions pyaerocom/aux_var_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,3 +667,26 @@ def concx_to_vmrx(data, p_pascal, T_kelvin, conc_unit, mmol_var, mmol_air=None,
if not np.isclose(conversion_fac, 1, rtol=1e-7):
vmr *= conversion_fac
return vmr


def calc_vmro3max(data):

var_name = "vmro3"
new_var_name = "vmro3max"

flags = data.data_flagged[var_name]

o3max = data[var_name]

units = data.var_info[var_name]["units"]
# data.var_info[new_var_name]["units"] = units

if not new_var_name in data.var_info:
data.var_info[new_var_name] = {}

data.var_info[new_var_name] = data.var_info[var_name]

data.data_flagged[new_var_name] = flags
# print(data.var_info)
# exit()
return o3max
4 changes: 4 additions & 0 deletions pyaerocom/data/ebas_config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ matrix=air
component=ozone
matrix=air

[vmro3max]
component=ozone
matrix=air

[vmrco]
component=carbon_monoxide
matrix=air
Expand Down
3 changes: 3 additions & 0 deletions pyaerocom/io/read_ebas.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from pyaerocom import const
from pyaerocom._lowlevel_helpers import BrowseDict
from pyaerocom.aux_var_helpers import (
calc_vmro3max,
compute_ac550dryaer,
compute_ang4470dryaer_from_dry_scat,
compute_sc440dryaer,
Expand Down Expand Up @@ -231,6 +232,7 @@ class ReadEbas(ReadUngriddedBase):
"wetoxs": ["concprcpoxs", "pr"],
"wetoxn": ["concprcpoxn", "pr"],
"wetrdn": ["concprcprdn", "pr"],
"vmro3max": ["vmro3"],
}

#: Meta information supposed to be migrated to computed variables
Expand All @@ -250,6 +252,7 @@ class ReadEbas(ReadUngriddedBase):
"wetoxs": compute_wetoxs_from_concprcpoxs,
"wetoxn": compute_wetoxn_from_concprcpoxn,
"wetrdn": compute_wetrdn_from_concprcprdn,
"vmro3max": calc_vmro3max,
}

#: Custom reading options for individual variables. Keys need to be valid
Expand Down
9 changes: 8 additions & 1 deletion pyaerocom/io/read_eea_aqerep_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class ReadEEAAQEREPBase(ReadUngriddedBase):
VAR_NAMES_FILE["concpm10"] = "concentration"
VAR_NAMES_FILE["concpm25"] = "concentration"
VAR_NAMES_FILE["vmro3"] = "concentration"
VAR_NAMES_FILE["vmro3max"] = "concentration"
VAR_NAMES_FILE["vmrno2"] = "concentration"

#: units of variables in files (needs to be defined for each variable supported)
Expand All @@ -85,6 +86,7 @@ class ReadEEAAQEREPBase(ReadUngriddedBase):
concpm10="**/??_5_*_timeseries.csv*",
conco3="**/??_7_*_timeseries.csv*",
vmro3="**/??_7_*_timeseries.csv*",
vmro3max="**/??_7_*_timeseries.csv*",
concno2="**/??_8_*_timeseries.csv*",
vmrno2="**/??_8_*_timeseries.csv*",
concco="**/??_10_*_timeseries.csv*",
Expand All @@ -97,13 +99,17 @@ class ReadEEAAQEREPBase(ReadUngriddedBase):
CONV_FACTOR["vmro3"] = np.float_(
0.493
) # retrieved using STD atmosphere from geonum and pya.mathutils.concx_to_vmrx
CONV_FACTOR["vmro3max"] = np.float_(
0.493
) # retrieved using STD atmosphere from geonum and pya.mathutils.concx_to_vmrx
CONV_FACTOR["vmrno2"] = np.float_(
0.514
) # retrieved using STD atmosphere from geonum and pya.mathutils.concx_to_vmrx

# unit of the converted property after the conversion
CONV_UNIT = {}
CONV_UNIT["vmro3"] = "ppb"
CONV_UNIT["vmro3max"] = "ppb"
CONV_UNIT["vmrno2"] = "ppb"

#: field name of the start time of the measurement (in lower case)
Expand Down Expand Up @@ -165,10 +171,11 @@ class ReadEEAAQEREPBase(ReadUngriddedBase):
# and this constant, it can also read the E1a data set
DATA_PRODUCT = ""

AUX_REQUIRES = {"vmro3": ["conco3"], "vmrno2": ["concno2"]}
AUX_REQUIRES = {"vmro3max": ["conco3"], "vmro3": ["conco3"], "vmrno2": ["concno2"]}

AUX_FUNS = {
"vmro3": NotImplementedError(),
"vmro3max": NotImplementedError(),
"vmrno2": NotImplementedError(),
}

Expand Down
2 changes: 1 addition & 1 deletion pyaerocom/io/read_mscw_ctm.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
calc_concNtnh,
calc_concsspm25,
calc_conNtno3,
calc_vmrox,
calc_vmrno2,
calc_vmrox,
subtract_dataarrays,
update_EC_units,
)
Expand Down
1 change: 1 addition & 0 deletions tests/io/test_read_ebas.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ def test_PROVIDES_VARIABLES(reader: ReadEbas):
"conco3",
"concco",
"vmro3",
"vmro3max",
"vmrco",
"vmrno2",
"vmrno",
Expand Down

0 comments on commit 42d2acf

Please sign in to comment.