Skip to content

Commit

Permalink
Merge pull request #2985 from ClementLaplace/li_reader_daskified
Browse files Browse the repository at this point in the history
li2_nc reader daskified
  • Loading branch information
mraspaud authored Nov 20, 2024
2 parents b00303e + fa56be5 commit 12c05dc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 0 additions & 1 deletion satpy/readers/li_base_nc.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,6 @@ def get_dataset(self, dataset_id, ds_info=None):
# Retrieve default infos if missing:
if ds_info is None:
ds_info = self.get_dataset_infos(dataset_id["name"])

# check for potential error:
if ds_info is None:
raise KeyError(f"No dataset registered for {dataset_id}")
Expand Down
5 changes: 5 additions & 0 deletions satpy/readers/li_l2_nc.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ def get_dataset(self, dataset_id, ds_info=None):
var_with_swath_coord = self.is_var_with_swath_coord(dataset_id)
if var_with_swath_coord and self.with_area_def:
data_array = self.get_array_on_fci_grid(data_array)
else :
if data_array is not None:
if not isinstance(data_array.data, da.Array):
data_array.data = da.from_array(data_array.data)
return data_array

def get_area_def(self, dsid):
Expand Down Expand Up @@ -161,6 +165,7 @@ def get_array_on_fci_grid(self, data_array: xr.DataArray):
data_2d = da.where(data_2d > 0, data_2d, np.nan)

xarr = xr.DataArray(da.asarray(data_2d, CHUNK_SIZE), dims=("y", "x"))

xarr.attrs = attrs

return xarr
Expand Down
2 changes: 2 additions & 0 deletions satpy/tests/reader_tests/test_li_l2_nc.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import os
from unittest import mock

import dask.array as da
import numpy as np
import pytest
import xarray as xr
Expand Down Expand Up @@ -128,6 +129,7 @@ def _test_dataset_variable(self, var_params, sname=""):
res = self.get_variable_dataset(dataset_info, dname, handler)
assert res.shape == shape
assert res.dims[0] == "y"
assert isinstance(res.data,da.Array)
# Should retrieve content with fullname key:
full_name = self.create_fullname_key(desc, var_path, dname, sname=sname)
# Note: 'content' is not recognized as a valid member of the class below
Expand Down

0 comments on commit 12c05dc

Please sign in to comment.