From b69009f5810850dc210016b5fae6d273a4052ffa Mon Sep 17 00:00:00 2001 From: dougiesquire Date: Fri, 29 Sep 2023 16:10:21 +1000 Subject: [PATCH] enter missing attrs in datastores as "", rather than None --- src/access_nri_intake/source/utils.py | 6 ++--- tests/test_source_utils.py | 38 +++++++++++++-------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/access_nri_intake/source/utils.py b/src/access_nri_intake/source/utils.py index c46b8afb..37c53bbf 100644 --- a/src/access_nri_intake/source/utils.py +++ b/src/access_nri_intake/source/utils.py @@ -257,15 +257,15 @@ def parse_access_ncfile(file, time_dim="time"): if "standard_name" in attrs: variable_standard_name_list.append(attrs["standard_name"]) else: - variable_standard_name_list.append(None) + variable_standard_name_list.append("") if "cell_methods" in attrs: variable_cell_methods_list.append(attrs["cell_methods"]) else: - variable_cell_methods_list.append(None) + variable_cell_methods_list.append("") if "units" in attrs: variable_units_list.append(attrs["units"]) else: - variable_units_list.append(None) + variable_units_list.append("") start_date, end_date, frequency = get_timeinfo(ds, filename_frequency, time_dim) diff --git a/tests/test_source_utils.py b/tests/test_source_utils.py index 777446c3..06e68da2 100644 --- a/tests/test_source_utils.py +++ b/tests/test_source_utils.py @@ -95,7 +95,7 @@ def test_parse_access_filename(filename, expected): "none", ["geolat_t", "geolon_t"], ["tracer latitude", "tracer longitude"], - [None, None], + ["", ""], ["time: point", "time: point"], ["degrees_N", "degrees_E"], ), @@ -111,8 +111,8 @@ def test_parse_access_filename(filename, expected): "1910-01-01, 00:00:00", ["temp", "time_bounds"], ["Conservative temperature", "time axis boundaries"], - ["sea_water_conservative_temperature", None], - ["time: mean", None], + ["sea_water_conservative_temperature", ""], + ["time: mean", ""], ["K", "days"], ), ), @@ -130,8 +130,8 @@ def test_parse_access_filename(filename, expected): "mixed layer depth determined by density criteria", "time axis boundaries", ], - ["ocean_mixed_layer_thickness_defined_by_sigma_t", None], - ["time: mean", None], + ["ocean_mixed_layer_thickness_defined_by_sigma_t", ""], + ["time: mean", ""], ["m", "days"], ), ), @@ -168,8 +168,8 @@ def test_parse_access_filename(filename, expected): "area of T grid cells", "boundaries for time-averaging interval", ], - [None, None, None, None, None], - [None, None, "time: mean", None, None], + ["", "", "", "", ""], + ["", "", "time: mean", "", ""], [ "degrees_north", "degrees_east", @@ -212,8 +212,8 @@ def test_parse_access_filename(filename, expected): "area of T grid cells", "boundaries for time-averaging interval", ], - [None, None, None, None, None], - [None, None, "time: mean", None, None], + ["", "", "", "", ""], + ["", "", "time: mean", "", ""], [ "degrees_north", "degrees_east", @@ -234,8 +234,8 @@ def test_parse_access_filename(filename, expected): "2015-07-01, 00:00:00", ["sst", "time_bounds"], ["Potential temperature", "time axis boundaries"], - ["sea_surface_temperature", None], - ["time: mean", None], + ["sea_surface_temperature", ""], + ["time: mean", ""], ["K", "days"], ), ), @@ -250,8 +250,8 @@ def test_parse_access_filename(filename, expected): "2015-07-01, 00:00:00", ["temp_global_ave", "time_bounds"], ["Global mean temp in liquid seawater", "time axis boundaries"], - ["sea_water_potential_temperature", None], - ["time: mean", None], + ["sea_water_potential_temperature", ""], + ["time: mean", ""], ["deg_C", "days"], ), ), @@ -288,8 +288,8 @@ def test_parse_access_filename(filename, expected): "area of T grid cells", "boundaries for time-averaging interval", ], - [None, None, None, None, None], - [None, None, "time: mean", None, None], + ["", "", "", "", ""], + ["", "", "time: mean", "", ""], [ "degrees_north", "degrees_east", @@ -310,8 +310,8 @@ def test_parse_access_filename(filename, expected): "1850-12-30, 00:00:00", ["fgco2_raw", "time_bounds"], ["Flux into ocean - DIC, inc. anth.", "time axis boundaries"], - [None, None], - ["time: mean", None], + ["", ""], + ["time: mean", ""], ["mmol/m^2/s", "days"], ), ), @@ -326,8 +326,8 @@ def test_parse_access_filename(filename, expected): "1850-12-30, 00:00:00", ["o2", "time_bounds"], ["o2", "time axis boundaries"], - [None, None], - ["time: mean", None], + ["", ""], + ["time: mean", ""], ["mmol/m^3", "days"], ), ),