Skip to content

Commit

Permalink
Merge pull request #123 from ACCESS-NRI/missing_attrs
Browse files Browse the repository at this point in the history
Enter missing attrs in datastores as "", rather than None
  • Loading branch information
dougiesquire authored Sep 29, 2023
2 parents 635d10f + 5532fc3 commit 3e72ae0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions src/access_nri_intake/source/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
38 changes: 19 additions & 19 deletions tests/test_source_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
),
Expand All @@ -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"],
),
),
Expand All @@ -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"],
),
),
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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"],
),
),
Expand All @@ -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"],
),
),
Expand Down Expand Up @@ -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",
Expand All @@ -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"],
),
),
Expand All @@ -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"],
),
),
Expand Down

0 comments on commit 3e72ae0

Please sign in to comment.