Skip to content

Commit

Permalink
Add geolocation to IASISND02 reader
Browse files Browse the repository at this point in the history
  • Loading branch information
gerritholl committed Jul 21, 2023
1 parent 3bdb524 commit 369ea33
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
11 changes: 7 additions & 4 deletions satpy/readers/iasi_l2_eps.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ def get_dataset(self, dataid, dataset_info):
"""Get dataset."""
if self._nc is None:
self._nc = self._get_netcdf_dataset()

Check warning on line 63 in satpy/readers/iasi_l2_eps.py

View check run for this annotation

Codecov / codecov/patch

satpy/readers/iasi_l2_eps.py#L63

Added line #L63 was not covered by tests
da = self._nc[dataid["name"]]
da = da * da.attrs.pop("scale_factor", 1)
return da
data = self._nc[dataid["name"]]
with xr.set_options(keep_attrs=True):
data = xr.where(data != np.iinfo(data.dtype).max, data, np.nan)
data = data * data.attrs.pop("scale_factor", 1)
return data

def _get_netcdf_dataset(self):
"""Get full NetCDF dataset."""
Expand All @@ -84,7 +86,8 @@ def available_datasets(self, configured_datasets):
"""Get available datasets."""
# FIXME: do this without converting/reading the file — maybe hardcode
# still?
common = {"file_type": "iasi_l2_eps", "resolution": 12000}
common = {"file_type": "iasi_l2_eps", "resolution": 12000,
"coordinates": ["lon", "lat"]}
if self._nc is None:
self._nc = self._get_netcdf_dataset()
for var in self._nc.data_vars:
Expand Down
14 changes: 13 additions & 1 deletion satpy/tests/reader_tests/test_iasisnd02.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import dask
import numpy as np
import pandas as pd
import pyresample
import pytest

from ..utils import CustomScheduler
Expand Down Expand Up @@ -201,7 +202,8 @@ def test_load(iasisndl2_file, tmp_path):
from satpy import Scene
with dask.config.set(scheduler=CustomScheduler(max_computes=0)):
sc = Scene(filenames=[iasisndl2_file], reader=["iasi_l2_eps"])
sc.load(["surface_temperature"])
sc.load(["surface_temperature", "atmospheric_temperature",
"atmospheric_water_vapour"])
assert sc["surface_temperature"].dims == ("y", "x")
np.testing.assert_allclose(
sc["surface_temperature"][0, 100:104],
Expand All @@ -212,5 +214,15 @@ def test_load(iasisndl2_file, tmp_path):
np.testing.assert_allclose(
sc["surface_temperature"][30, 60:66],
np.array([282.27, 283.18, 285.67, 282.98, 282.81, 282.9]))
np.testing.assert_array_equal(
sc["surface_temperature"][30, :5],
[np.nan]*5)
np.testing.assert_array_equal(
sc["atmospheric_water_vapour"][0, 0, :5],
[np.nan]*5)

assert isinstance(sc["surface_temperature"].data, dask.array.Array)
assert isinstance(sc["surface_temperature"].attrs["area"],
pyresample.SwathDefinition)
assert sc["surface_temperature"].attrs["standard_name"] == "surface_temperature"
assert sc["surface_temperature"].attrs["units"] == "K"

0 comments on commit 369ea33

Please sign in to comment.