Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

li2_nc reader daskified #2985

Merged
merged 4 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
mraspaud marked this conversation as resolved.
Show resolved Hide resolved
# 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
Loading