Skip to content

Commit

Permalink
Increase accuracy by using ns
Browse files Browse the repository at this point in the history
  • Loading branch information
Nina.Hakansson committed Mar 5, 2024
1 parent ad3d2e4 commit c09787c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions satpy/readers/viirs_vgac_l1c_nc.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ def extract_time_data(self, data, nc):
"days since %d/%m/%YT%H:%M:%S"))
delta_part_of_day, delta_full_days = np.modf(nc["proj_time0"].values)
delta_full_days = np.timedelta64(int(delta_full_days), "D")
delta_part_of_day = delta_part_of_day * np.timedelta64(1, "D").astype("timedelta64[us]")
delta_hours = data.values * np.timedelta64(1, "h").astype("timedelta64[us]")
delta_part_of_day = delta_part_of_day * np.timedelta64(1, "D").astype("timedelta64[ns]")
delta_hours = data.values * np.timedelta64(1, "h").astype("timedelta64[ns]")
time_data = xr.DataArray(reference_time + delta_full_days + delta_part_of_day + delta_hours,
coords=data.coords, attrs={"long_name": "Scanline time"})
self._start_time = self.dt64_to_datetime(time_data[0].values)
Expand Down
6 changes: 4 additions & 2 deletions satpy/tests/reader_tests/test_viirs_vgac_l1c_nc.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ def test_read_vgac(self, nc_filename):
diff_s = (scn_["scanline_timestamps"][0] - np.datetime64("2023-03-28T09:08:07")
- np.timedelta64(123, "ms"))
diff_e = np.datetime64("2023-03-28T10:11:12") - scn_["scanline_timestamps"][-1]
assert (np.abs(diff_e) < np.timedelta64(5000, "ns"))
assert (np.abs(diff_s) < np.timedelta64(5000, "ns"))
assert (diff_e < np.timedelta64(5000, "ns"))
assert (diff_s < np.timedelta64(5000, "ns"))
assert (diff_e > np.timedelta64(-5000, "ns"))
assert (diff_s > np.timedelta64(-5000, "ns"))
assert (scn_["M05"][0, 0] == 100)
assert (scn_["M15"][0, 0] == 400)
assert scn_.start_time == datetime.datetime(year=2023, month=3, day=28,
Expand Down

0 comments on commit c09787c

Please sign in to comment.