Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mortenwh committed May 14, 2024
1 parent cdb110d commit 03e579a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions nansat/mappers/mapper_meps_ncml.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import pytz
import netCDF4
import datetime

Expand All @@ -15,13 +16,14 @@ def __init__(self, ncml_url, gdal_dataset, gdal_metadata, netcdf_dim=None, *args
if not ncml_url.endswith(".ncml"):
raise WrongMapperError

dt = 0
dt = datetime.timedelta(0)
if netcdf_dim is not None and "time" in netcdf_dim.keys():
ds = netCDF4.Dataset(ncml_url)
time = netcdf_dim["time"]
dt = time - np.datetime64(
datetime.datetime.fromisoformat(ds.time_coverage_start.replace("Z", "+00:00")))
url = self._get_odap_url(ncml_url, np.round(dt))
time = netcdf_dim["time"].astype(datetime.datetime).replace(
tzinfo=pytz.timezone("utc"))
dt = time - datetime.datetime.fromisoformat(ds.time_coverage_start.replace(
"Z", "+00:00"))
url = self._get_odap_url(ncml_url, np.round(dt.total_seconds()/3600))

super(Mapper, self).__init__(url, gdal_dataset, gdal_metadata, *args, **kwargs)

Expand Down

0 comments on commit 03e579a

Please sign in to comment.