Skip to content

Commit

Permalink
parse start_ and end_date even for fx freq if there is a time coordinate
Browse files Browse the repository at this point in the history
  • Loading branch information
dougiesquire committed Mar 1, 2024
1 parent bbd8b12 commit 1f613a7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/access_nri_intake/source/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ def _todate(t):
return cftime.num2date(t, time_var.units, calendar=time_var.calendar)

time_format = "%Y-%m-%d, %H:%M:%S"
start_date = "none"
end_date = "none"
ts = None
te = None
frequency = "fx"
has_time = time_dim in ds

Expand Down Expand Up @@ -137,7 +137,15 @@ def _todate(t):
if has_time & (frequency != "fx"):
if not has_bounds:
ts, te = _guess_start_end_dates(ts, te, frequency)

if ts is None:
start_date = "none"
else:
start_date = ts.strftime(time_format)

if te is None:
end_date = "none"
else:
end_date = te.strftime(time_format)

if frequency[0]:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_source_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,8 @@ def test_parse_access_filename(filename, expected):
"GMOM_JRA_WD_ww3_hi_XXXX_XX_XX_XXXXX",
"1900-01-02-00000",
"fx", # WW3 provides no time bounds
"none",
"none",
"1900-01-02, 00:00:00",
"1900-01-02, 00:00:00",
["EF", "mapsta"],
["1D spectral density", "map status"],
["", ""],
Expand Down

0 comments on commit 1f613a7

Please sign in to comment.