Skip to content

Commit

Permalink
tests fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
garciampred committed Jul 26, 2024
1 parent 8927e29 commit 278e568
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 77 deletions.
2 changes: 1 addition & 1 deletion cdsobs/cdm/lite.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"quasisystematic_uncertainty",
"positive_quasisystematic_uncertainty",
"negative_quasisystematic_uncertainty",
"flag",
"quality_flag",
]
cdm_lite_variables = dict(
mandatory=variable_names,
Expand Down
16 changes: 0 additions & 16 deletions cdsobs/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,3 @@
"EPN": ["precipitable_water_column"],
},
}
AUX_FIELDS = [
"total_uncertainty",
"positive_total_uncertainty",
"negative_total_uncertainty",
"max_positive_total_uncertainty",
"max_negative_total_uncertainty",
"min_positive_total_uncertainty",
"min_negative_total_uncertainty",
"random_uncertainty",
"positive_systematic_uncertainty",
"negative_systematic_uncertainty",
"quasisystematic_uncertainty",
"positive_quasisystematic_uncertainty",
"negative_quasisystematic_uncertainty",
"flag",
]
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,10 @@ sources:
solarad_min_flag: minimum_solar_irradiance_quality_flag
sur_temp: soil_temperature
sur_temp_flag: soil_temperature_quality_flag
sur_temp_max: hourly_maximum_soil_temperature
sur_temp_max_flag: hourly_maximum_soil_temperature_flag
sur_temp_min: hourly_minimum_soil_temperature
sur_temp_min_flag: hourly_minimum_soil_temperature_quality_flag
sur_temp_max: maximum_soil_temperature
sur_temp_max_flag: maximum_soil_temperature_flag
sur_temp_min: minimum_soil_temperature
sur_temp_min_flag: minimum_soil_temperature_quality_flag
sur_temp_type: soil_temperature_processing_level
sys_m: air_temperature_negative_systematic_uncertainty
sys_p: air_temperature_positive_systematic_uncertainty
Expand Down Expand Up @@ -608,13 +608,13 @@ sources:
dtype: float32
long_name: tmaxerr_p
units: K
hourly_maximum_soil_temperature:
maximum_soil_temperature:
description: From measurements of "soil temperature" (described in this list), this parameter provides the highest value measured during the aggregation period.
dtype: float32
long_name: sur_temp_max
quality_flag: sur_temp_max_flag
units: K
hourly_maximum_soil_temperature_quality_flag:
maximum_soil_temperature_quality_flag:
description: This parameter indicates if the "Maximum soil temperature" (described in this list) may be used because it is based on good data (value of 0) or if it should be treated with suspicion because erroneous data were detected (value of 3). denotes good data and 3 denotes erroneous data.
dtype: float32
long_name: sur_temp_max_flag
Expand All @@ -635,13 +635,13 @@ sources:
dtype: float32
long_name: tminerr_p
units: K
hourly_minimum_soil_temperature:
minimum_soil_temperature:
description: From measurements of "soil temperature" (described in this list), this parameter provides the lowest value measured during the aggregation period.
dtype: float32
long_name: sur_temp_min
quality_flag: sur_temp_min_flag
units: K
hourly_minimum_soil_temperature_quality_flag:
minimum_soil_temperature_quality_flag:
description: This parameter indicates if the "Minimum soil temperature" (described in this list) may be used because it is based on good data (value of 0) or if it should be treated with suspicion because erroneous data were detected (value of 3).
dtype: float32
long_name: sur_temp_min_flag
Expand Down Expand Up @@ -827,8 +827,8 @@ sources:
sitename: alternative_name
solrad_monthly_avg: monthly_global_solar_radiation
sur_temp_monthly_avg: soil_temperature
sur_temp_monthly_max: monthly_maximum_soil_temperature
sur_temp_monthly_min: monthly_minimum_soil_temperature
sur_temp_monthly_max: maximum_soil_temperature
sur_temp_monthly_min: minimum_soil_temperature
sur_temp_monthly_type: soil_temperature_processing_level
sys_m: air_temperature_negative_systematic_uncertainty
sys_p: air_temperature_positive_systematic_uncertainty
Expand Down Expand Up @@ -944,7 +944,7 @@ sources:
dtype: float32
long_name: tmaxerr_p
units: K
monthly_maximum_soil_temperature:
maximum_soil_temperature:
description: From measurements of "soil temperature" (described in this list), this parameter provides the highest value measured during the aggregation period.
dtype: float32
long_name: sur_temp_monthly_max
Expand All @@ -971,7 +971,7 @@ sources:
dtype: float32
long_name: tminerr_p
units: K
monthly_minimum_soil_temperature:
minimum_soil_temperature:
description: From measurements of "soil temperature" (described in this list), this parameter provides the lowest value measured during the aggregation period.
dtype: float32
long_name: sur_temp_monthly_min
Expand Down
79 changes: 37 additions & 42 deletions tests/test_cdm_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,51 +82,50 @@ def test_get_aux_fields_mapping_from_service_definition():
],
"daily_maximum_air_temperature": [],
"daily_minimum_air_temperature": [],
"downward_shortwave_irradiance_at_earth_surface": [
{
"auxvar": "downward_shortwave_irradiance_at_earth_surface_quality_flag",
"metadata_name": "flag",
}
"maximum_soil_temperature": [
{"auxvar": "maximum_soil_temperature_flag", "metadata_name": "quality_flag"}
],
"hourly_maximum_downward_shortwave_irradiance_at_earth_surface": [
"maximum_solar_irradiance": [
{
"auxvar": "hourly_maximum_downward_shortwave_irradiance_at_earth_surface_quality_flag",
"metadata_name": "flag",
"auxvar": "maximum_solar_irradiance_quality_flag",
"metadata_name": "quality_flag",
}
],
"hourly_maximum_soil_temperature": [
{"auxvar": "hourly_maximum_soil_temperature_flag", "metadata_name": "flag"}
],
"hourly_minimum_downward_shortwave_irradiance_at_earth_surface": [
"minimum_soil_temperature": [
{
"auxvar": "hourly_minimum_downward_shortwave_irradiance_at_earth_surface_quality_flag",
"metadata_name": "flag",
"auxvar": "minimum_soil_temperature_quality_flag",
"metadata_name": "quality_flag",
}
],
"hourly_minimum_soil_temperature": [
"minimum_solar_irradiance": [
{
"auxvar": "hourly_minimum_soil_temperature_quality_flag",
"metadata_name": "flag",
"auxvar": "minimum_solar_irradiance_quality_flag",
"metadata_name": "quality_flag",
}
],
"relative_humidity": [
{"auxvar": "relative_humidity_quality_flag", "metadata_name": "flag"}
{
"auxvar": "relative_humidity_quality_flag",
"metadata_name": "quality_flag",
}
],
"soil_moisture_100cm_from_earth_surface": [],
"soil_moisture_10cm_from_earth_surface": [],
"soil_moisture_20cm_from_earth_surface": [],
"soil_moisture_50cm_from_earth_surface": [],
"soil_moisture_5cm_from_earth_surface": [],
"soil_temperature": [
{"auxvar": "soil_temperature_quality_flag", "metadata_name": "flag"}
{"auxvar": "soil_temperature_quality_flag", "metadata_name": "quality_flag"}
],
"soil_temperature_100cm_from_earth_surface": [],
"soil_temperature_10cm_from_earth_surface": [],
"soil_temperature_20cm_from_earth_surface": [],
"soil_temperature_50cm_from_earth_surface": [],
"soil_temperature_5cm_from_earth_surface": [],
"solar_irradiance": [
{"auxvar": "solar_irradiance_quality_flag", "metadata_name": "quality_flag"}
],
}

service_definition = get_service_definition(dataset_name)
source_definition = service_definition.sources[source]
variables = get_variables_from_service_definition(service_definition, source)
Expand All @@ -142,44 +141,40 @@ def test_get_aux_fields_mapping_from_service_definition():
"air_temperature_negative_systematic_uncertainty",
"air_temperature_positive_quasisystematic_uncertainty",
"air_temperature_negative_quasisystematic_uncertainty",
"downward_shortwave_irradiance_at_earth_surface_quality_flag",
"hourly_maximum_downward_shortwave_irradiance_at_earth_surface_quality_flag",
"hourly_maximum_soil_temperature_flag",
"hourly_minimum_downward_shortwave_irradiance_at_earth_surface_quality_flag",
"hourly_minimum_soil_temperature_quality_flag",
"maximum_soil_temperature_flag",
"maximum_solar_irradiance_quality_flag",
"minimum_soil_temperature_quality_flag",
"minimum_solar_irradiance_quality_flag",
"relative_humidity_quality_flag",
"soil_temperature_quality_flag",
"solar_irradiance_quality_flag",
]
assert not actual.var_has_uncertainty_field("accumulated_precipitation")
assert actual.var_has_uncertainty_field("air_temperature")
assert actual.vars_with_uncertainty_field == ["air_temperature"]
assert actual.quality_flag_fields == [
"downward_shortwave_irradiance_at_earth_surface_quality_flag",
"hourly_maximum_downward_shortwave_irradiance_at_earth_surface_quality_flag",
"hourly_maximum_soil_temperature_flag",
"hourly_minimum_downward_shortwave_irradiance_at_earth_surface_quality_flag",
"hourly_minimum_soil_temperature_quality_flag",
"maximum_soil_temperature_flag",
"maximum_solar_irradiance_quality_flag",
"minimum_soil_temperature_quality_flag",
"minimum_solar_irradiance_quality_flag",
"relative_humidity_quality_flag",
"soil_temperature_quality_flag",
"solar_irradiance_quality_flag",
]
assert not actual.var_has_quality_field("air_temperature")
assert actual.var_has_quality_field(
"downward_shortwave_irradiance_at_earth_surface"
)
assert actual.var_has_quality_field("maximum_soil_temperature")
assert actual.vars_with_quality_field == [
"downward_shortwave_irradiance_at_earth_surface",
"hourly_maximum_downward_shortwave_irradiance_at_earth_surface",
"hourly_maximum_soil_temperature",
"hourly_minimum_downward_shortwave_irradiance_at_earth_surface",
"hourly_minimum_soil_temperature",
"maximum_soil_temperature",
"maximum_solar_irradiance",
"minimum_soil_temperature",
"minimum_solar_irradiance",
"relative_humidity",
"soil_temperature",
"solar_irradiance",
]
assert (
actual.get_var_quality_flag_field_name(
"downward_shortwave_irradiance_at_earth_surface"
)
== "downward_shortwave_irradiance_at_earth_surface_quality_flag"
actual.get_var_quality_flag_field_name("maximum_soil_temperature")
== "maximum_soil_temperature_flag"
)
assert actual.get_var_uncertainty_field_names("air_temperature") == [
"air_temperature_positive_total_uncertainty",
Expand Down
41 changes: 35 additions & 6 deletions tests/test_http_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,36 +90,65 @@ def test_get_dataset_auxiliary_variables_mapping():
"accumulated_precipitation": [],
"air_temperature": [
{
"auxvar": "air_temperature_mean_positive_total_uncertainty",
"auxvar": "air_temperature_positive_total_uncertainty",
"metadata_name": "positive_total_uncertainty",
},
{
"auxvar": "air_temperature_mean_negative_total_uncertainty",
"auxvar": "air_temperature_negative_total_uncertainty",
"metadata_name": "negative_total_uncertainty",
},
{
"auxvar": "air_temperature_positive_random_uncertainty",
"metadata_name": "positive_random_uncertainty",
},
{
"auxvar": "air_temperature_negative_random_uncertainty",
"metadata_name": "negative_random_uncertainty",
},
{
"auxvar": "air_temperature_positive_systematic_uncertainty",
"metadata_name": "positive_systematic_uncertainty",
},
{
"auxvar": "air_temperature_negative_systematic_uncertainty",
"metadata_name": "negative_systematic_uncertainty",
},
],
"daily_global_solar_radiation": [],
"daily_maximum_air_temperature": [
{
"auxvar": "air_temperature_max_positive_total_uncertainty",
"auxvar": "daily_maximum_air_temperature_positive_total_uncertainty",
"metadata_name": "positive_total_uncertainty",
},
{
"auxvar": "air_temperature_max_negative_total_uncertainty",
"auxvar": "daily_maximum_air_temperature_negative_total_uncertainty",
"metadata_name": "negative_total_uncertainty",
},
],
"daily_maximum_relative_humidity": [],
"daily_mean_air_temperature": [
{
"auxvar": "mean_air_temperature_positive_total_uncertainty",
"metadata_name": "positive_total_uncertainty",
},
{
"auxvar": "mean_air_temperature_negative_total_uncertainty",
"metadata_name": "negative_total_uncertainty",
},
],
"daily_minimum_air_temperature": [
{
"auxvar": "air_temperature_min_positive_total_uncertainty",
"auxvar": "daily_minimum_air_temperature_positive_total_uncertainty",
"metadata_name": "positive_total_uncertainty",
},
{
"auxvar": "air_temperature_min_negative_total_uncertainty",
"auxvar": "daily_minimum_air_temperature_negative_total_uncertainty",
"metadata_name": "negative_total_uncertainty",
},
],
"daily_minimum_relative_humidity": [],
"maximum_soil_temperature": [],
"minimum_soil_temperature": [],
"relative_humidity": [],
"soil_moisture_100cm_from_earth_surface": [],
"soil_moisture_10cm_from_earth_surface": [],
Expand Down

0 comments on commit 278e568

Please sign in to comment.