Skip to content

Commit

Permalink
Merge pull request #2635 from mraspaud/fix-nwcsaf-start-time2
Browse files Browse the repository at this point in the history
Fix nwcsaf_geo start time to be nominal time
  • Loading branch information
mraspaud committed Nov 15, 2023
2 parents ce41239 + e43f3fa commit 35f9f96
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 4 additions & 1 deletion satpy/readers/nwcsaf_nc.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,10 @@ def __del__(self):
@property
def start_time(self):
"""Return the start time of the object."""
return read_nwcsaf_time(self.nc.attrs["time_coverage_start"])
try:
return read_nwcsaf_time(self.nc.attrs["nominal_product_time"])
except KeyError:
return read_nwcsaf_time(self.nc.attrs["time_coverage_start"])

@property
def end_time(self):
Expand Down
10 changes: 7 additions & 3 deletions satpy/tests/reader_tests/test_nwcsaf_nc.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"pal_rgb": 3}

NOMINAL_LONGITUDE = 0.0
NOMINAL_TIME = "2023-01-18T10:30:00Z"
START_TIME = "2023-01-18T10:39:17Z"
END_TIME = "2023-01-18T10:42:22Z"
START_TIME_PPS = "20230118T103917000Z"
Expand All @@ -57,6 +58,9 @@

global_attrs.update(PROJ)

global_attrs_geo = global_attrs.copy()
global_attrs_geo["nominal_product_time"] = NOMINAL_TIME

CTTH_PALETTE_MEANINGS = ("0 500 1000 1500")

COT_PALETTE_MEANINGS = ("0 2 5 8 10 13 16 19 23 26 29 33 36 40 43 47 51 55 59 63 68 72 77 81 86 91 96"
Expand Down Expand Up @@ -90,7 +94,7 @@ def nwcsaf_geo_ct_filename(tmp_path_factory):
return create_nwcsaf_geo_ct_file(tmp_path_factory.mktemp("data"))


def create_nwcsaf_geo_ct_file(directory, attrs=global_attrs):
def create_nwcsaf_geo_ct_file(directory, attrs=global_attrs_geo):
"""Create a CT file."""
filename = directory / "S_NWC_CT_MSG4_MSG-N-VISIR_20230118T103000Z_PLAX.nc"
with h5netcdf.File(filename, mode="w") as nc_file:
Expand Down Expand Up @@ -227,7 +231,7 @@ def nwcsaf_pps_cpp_filehandler(nwcsaf_pps_cpp_filename):
@pytest.fixture(scope="session")
def nwcsaf_old_geo_ct_filename(tmp_path_factory):
"""Create a CT file and return the filename."""
attrs = global_attrs.copy()
attrs = global_attrs_geo.copy()
attrs.update(PROJ_KM)
attrs["time_coverage_start"] = np.array(["2023-01-18T10:39:17Z"], dtype="S20")
return create_nwcsaf_geo_ct_file(tmp_path_factory.mktemp("data-old"), attrs=attrs)
Expand Down Expand Up @@ -343,7 +347,7 @@ def test_times_are_in_dataset_attributes(self, nwcsaf_geo_ct_filehandler):

def test_start_time(self, nwcsaf_geo_ct_filehandler):
"""Test the start time property."""
assert nwcsaf_geo_ct_filehandler.start_time == read_nwcsaf_time(START_TIME)
assert nwcsaf_geo_ct_filehandler.start_time == read_nwcsaf_time(NOMINAL_TIME)

def test_end_time(self, nwcsaf_geo_ct_filehandler):
"""Test the end time property."""
Expand Down

0 comments on commit 35f9f96

Please sign in to comment.