Skip to content

Commit

Permalink
Update mersi_l1b.py
Browse files Browse the repository at this point in the history
  • Loading branch information
yukaribbba committed May 13, 2024
1 parent 9e24223 commit e9aa4ad
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions satpy/readers/mersi_l1b.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,9 @@ def get_dataset(self, dataset_id, ds_info):
file_key = ds_info.get("file_key", dataset_id["name"])
band_index = ds_info.get("band_index")
data = self[file_key]
if band_index is not None:
data = data[band_index]
if data.ndim >= 2:
data = data.rename({data.dims[-2]: "y", data.dims[-1]: "x"})
data = data[band_index] if band_index is not None else data
data = data.rename({data.dims[-2]: "y", data.dims[-1]: "x"}) if data.ndim >= 2 else data

attrs = data.attrs.copy() # avoid contaminating other band loading
attrs.update(ds_info)
if "rows_per_scan" in self.filetype_info:
Expand Down Expand Up @@ -267,12 +266,10 @@ def _get_bt_dataset(self, data, calibration_index, wave_number):
"""
# pass the dask array
bt_data = rad2temp(wave_number, data.data * 1e-5) # brightness temperature
if isinstance(bt_data, np.ndarray):
# old versions of pyspectral produce numpy arrays
data.data = da.from_array(bt_data, chunks=data.data.chunks)
else:
# new versions of pyspectral can do dask arrays
data.data = bt_data

# old versions of pyspectral produce numpy arrays
# new versions of pyspectral can do dask arrays
data.data = da.from_array(bt_data, chunks=data.data.chunks) if isinstance(bt_data, np.ndarray) else bt_data

# Some BT bands seem to have 0 in the first 10 columns
# and it is an invalid measurement, so let's mask
Expand Down

0 comments on commit e9aa4ad

Please sign in to comment.