def test_read_obspack_flask_2021(): '''Test inputs from "obspack_multi-species_1_CCGGSurfaceFlask_v2.0_2021-02-09"''' filepath = get_datapath(filename="ch4_spf_surface-flask_1_ccgg_Event.nc", data_type="NOAA") data = parse_noaa(data_filepath=filepath, site="SPF", inlet="flask", measurement_type="flask", network="NOAA") ch4_data = data["ch4"]["data"] assert ch4_data.time[0] == Timestamp("1995-01-28T19:20:00") assert ch4_data.time[-1] == Timestamp("2015-12-12T20:15:00") assert ch4_data["ch4"][0] == pytest.approx(1673.89) assert ch4_data["ch4"][-1] == pytest.approx(1785.86) assert ch4_data["ch4_variability"][0] == pytest.approx(2.71) assert ch4_data["ch4_variability"][-1] == pytest.approx(0.91) attributes = ch4_data.attrs assert "sampling_period" in attributes assert attributes["sampling_period"] == "NOT_SET" assert "sampling_period_estimate" in attributes assert float(attributes["sampling_period_estimate"]) > 0.0 ch4_metadata = data["ch4"]["metadata"] assert "sampling_period" in ch4_metadata assert "sampling_period_estimate" in ch4_metadata parsed_surface_metachecker(data=data)
def test_read_file_thd(): thd_path = get_datapath(filename="trinidadhead.01.C", data_type="GC") thd_prec_path = get_datapath(filename="trinidadhead.01.precisions.C", data_type="GC") gas_data = parse_gcwerks( data_filepath=thd_path, precision_filepath=thd_prec_path, site="thd", network="agage", instrument="gcmd", ) parsed_surface_metachecker(data=gas_data) expected_keys = [ "ccl4_10m", "cfc113_10m", "cfc11_10m", "cfc12_10m", "ch3ccl3_10m", "ch4_10m", "chcl3_10m", "n2o_10m", ] assert sorted(list(gas_data.keys())) == expected_keys meas_data = gas_data["ch3ccl3_10m"]["data"] assert meas_data.time[0] == pd.Timestamp("2001-01-01T01:05:22.5") assert meas_data.time[-1] == pd.Timestamp("2001-12-31T23:18:22.5") assert meas_data["ch3ccl3"][0] == 41.537 assert meas_data["ch3ccl3"][-1] == 34.649
def test_read_raw_file(): filepath = get_datapath( filename="co_pocn25_surface-flask_1_ccgg_event.txt", data_type="NOAA") data = parse_noaa(data_filepath=filepath, inlet="flask", site="pocn25", measurement_type="flask", sampling_period=1200) parsed_surface_metachecker(data=data) co_data = data["co"]["data"] assert co_data.time[0] == Timestamp("1990-06-29T05:00:00") assert co_data["co"][0] == pytest.approx(94.9) assert co_data["co_repeatability"][0] == pytest.approx(-999.99) assert co_data["co_selection_flag"][0] == 0 assert co_data.time[-1] == Timestamp("2017-07-15T04:15:00") assert co_data["co"][-1] == pytest.approx(73.16) assert co_data["co_repeatability"][-1] == pytest.approx(-999.99) assert co_data["co_selection_flag"][-1] == 0 attrs = co_data.attrs assert attributes_checker_obssurface(attrs=attrs, species="co")
def test_read_file(btt_data): parsed_surface_metachecker(data=btt_data) co2_data = btt_data["CO2"]["data"] ch4_data = btt_data["CH4"]["data"] assert co2_data.time[0] == pd.Timestamp("2019-01-14T09:30:00.00") assert co2_data["co2"][0] == pytest.approx(420.4700671) assert co2_data.time[-1] == pd.Timestamp("2019-01-14T14:00:00") assert co2_data["co2"][-1] == pytest.approx(413.45942912) assert ch4_data.time[0] == pd.Timestamp("2019-01-14T09:30:00.00") assert ch4_data["ch4"][0] == pytest.approx(1957.23980459) assert ch4_data.time[-1] == pd.Timestamp("2019-01-14T14:00:00") assert ch4_data["ch4"][-1] == pytest.approx(1961.72216725)
def test_read_thd_window_inlet(): data_path = get_datapath(filename="trinidadhead.01.window-inlet.C", data_type="GC") prec_path = get_datapath(filename="trinidadhead.01.precisions.C", data_type="GC") res = parse_gcwerks( data_filepath=data_path, precision_filepath=prec_path, site="thd", instrument="gcmd", network="agage" ) parsed_surface_metachecker(data=res) data = res["ch4_10m"]["data"] assert data.time[0] == pd.Timestamp("2001-01-01T01:05:22.5") assert data.time[-1] == pd.Timestamp("2001-01-01T10:25:22.5") assert data["ch4"][0] == pytest.approx(1818.62) assert data["ch4"][-1] == pytest.approx(1840.432)
def test_read_file(npl_data): parsed_surface_metachecker(data=npl_data) co2_data = npl_data["CO2"]["data"] ch4_data = npl_data["CH4"]["data"] assert check_cf_compliance(dataset=co2_data) assert co2_data.time[0] == pd.Timestamp("2020-06-12") assert co2_data["co2"][0] == pytest.approx(424.1672774) assert co2_data.time[-1] == pd.Timestamp("2020-07-01T00:24:00") assert co2_data["co2"][-1] == pytest.approx(419.9544809) assert ch4_data.time[0] == pd.Timestamp("2020-06-12") assert ch4_data["ch4"][0] == pytest.approx(2004.462127) assert ch4_data.time[-1] == pd.Timestamp("2020-07-01T00:24:00") assert ch4_data["ch4"][-1] == pytest.approx(1910.546256)
def test_read_file(tmb_data): parsed_surface_metachecker(data=tmb_data) ch4_data = tmb_data["CH4"]["data"] co2_data = tmb_data["CO2"]["data"] co_data = tmb_data["CO"]["data"] assert ch4_data.time[0] == pd.Timestamp("2019-07-01T00:39:55.000000000") assert ch4_data["ch4"][0] == pytest.approx(1960.835716) assert ch4_data["ch4_variability"][0] == 0 assert co2_data.time[0] == pd.Timestamp("2019-07-01T00:39:55.000000000") assert co2_data["co2"][0] == pytest.approx(417.973447) assert co2_data["co2_variability"][0] == 0 assert co_data.time[0] == pd.Timestamp("2019-07-01T00:39:55.000000000") assert co_data["co"][0] == pytest.approx(0.08788712) assert co_data["co_variability"][0] == 0
def test_read_file(crds_data): ch4_data = crds_data["ch4"]["data"] co2_data = crds_data["co2"]["data"] co_data = crds_data["co"]["data"] assert ch4_data["ch4"][0].values == pytest.approx(1993.83) assert ch4_data["ch4_variability"][0].values == pytest.approx(1.555) assert ch4_data["ch4_number_of_observations"][0].values == pytest.approx( 19.0) assert co2_data["co2"][0] == pytest.approx(414.21) assert co2_data["co2_variability"][0] == pytest.approx(0.109) assert co2_data["co2_number_of_observations"][0] == pytest.approx(19.0) assert co_data["co"][0] == pytest.approx(214.28) assert co_data["co_variability"][0] == pytest.approx(4.081) assert co_data["co_number_of_observations"][0] == pytest.approx(19.0) parsed_surface_metachecker(data=crds_data)
def test_read_shangdianzi_ASM_inlet(): data_path = get_datapath(filename="shangdianzi-medusa.18.C", data_type="GC") prec_path = get_datapath(filename="shangdianzi-medusa.18.precisions.C", data_type="GC") res = parse_gcwerks( data_filepath=data_path, precision_filepath=prec_path, site="sdz", instrument="medusa", network="agage", ) parsed_surface_metachecker(data=res) data = res["nf3_80m"]["data"] data.time[0] == pd.Timestamp("2018-01-16T09:10:00") data.time[-1] == pd.Timestamp("2018-01-16T20:00:00") data["nf3"][0] == pytest.approx(2.172) data["nf3"][-1] == pytest.approx(2.061)
def test_read_file_site_filename_read(scsn06_data): ch4_data = scsn06_data["ch4"]["data"] assert ch4_data.time[0] == Timestamp("1991-07-05T17:00:00") assert ch4_data["ch4"][0] == pytest.approx(1713.21) assert ch4_data["ch4_repeatability"][0] == pytest.approx(2.4) assert ch4_data["ch4_selection_flag"][0] == 0 metadata = scsn06_data["ch4"]["metadata"] parsed_surface_metachecker(data=scsn06_data) expected_attrs = { "station_longitude": 107.0, "station_latitude": 6.0, "station_long_name": "South China Sea (6 N), N/A", "station_height_masl": 15.0, } for key, value in expected_attrs.items(): assert ch4_data.attrs[key] == value
def test_read_file_capegrim(cgo_data): parsed_surface_metachecker(data=cgo_data) # 30/11/2021: Species labels were updated to be standardised in line with variable naming # This list of expected labels was updated. expected_eight = [ "c2cl4_70m", "c2f6_70m", "c2h2_70m", "c2h6_70m", "c2hcl3_70m", "c3f8_70m", "c3h8_70m", "c4f10_70m", ] sorted_keys = sorted(list(cgo_data.keys())) assert sorted_keys[:8] == expected_eight assert len(sorted_keys) == 56
def test_read_file(): filepath = get_datapath(filename="THB_hourly_means_test.csv", data_type="Cranfield_CRDS") data = parse_cranfield(data_filepath=filepath, sampling_period="1200") assert sorted(list(data.keys())) == sorted(["co2", "co", "ch4"]) ch4_data = data["ch4"]["data"] co2_data = data["co2"]["data"] co_data = data["co"]["data"] assert check_cf_compliance(dataset=co2_data) assert ch4_data["ch4"][0] == pytest.approx(2585.6510) assert ch4_data["ch4 variability"][0] == pytest.approx(75.502187065) assert co_data["co"][0] == pytest.approx(289.697545) assert co_data["co variability"][0] == pytest.approx(6.999084) assert co2_data["co2"][0] == pytest.approx(460.573223) assert co2_data["co2 variability"][0] == pytest.approx(0.226956417) parsed_surface_metachecker(data=data)