Skip to content

Commit d1352a4

Browse files
authored
Merge pull request #3050 from pnuu/feature-viirs-edr-volcanic-ash
2 parents d8c4382 + da46066 commit d1352a4

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

satpy/etc/readers/viirs_edr.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ file_types:
6464
file_reader: !!python/name:satpy.readers.viirs_edr.VIIRSJRRFileHandler
6565
file_patterns:
6666
- 'JRR-IceAge_{version}_{platform_shortname}_s{start_time:%Y%m%d%H%M%S%f}_e{end_time:%Y%m%d%H%M%S%f}_c{creation_time}.nc'
67+
jrr_volcanicash:
68+
file_reader: !!python/name:satpy.readers.viirs_edr.VIIRSJRRFileHandler
69+
drop_variables:
70+
- Det_QF_Size
71+
file_patterns:
72+
- 'JRR-VolcanicAsh_{version}_{platform_shortname}_s{start_time:%Y%m%d%H%M%S%f}_e{end_time:%Y%m%d%H%M%S%f}_c{creation_time}.nc'
6773

6874

6975
datasets:

satpy/readers/viirs_edr.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,11 @@ def __init__(self, filename, filename_info, filetype_info, **kwargs):
9898
# use entire scans as chunks
9999
row_chunks_m = max(get_chunk_size_limit() // 4 // M_COLS, 1) # 32-bit floats
100100
row_chunks_i = row_chunks_m * 2
101+
drop_variables = filetype_info.get("drop_variables", None)
101102
self.nc = xr.open_dataset(self.filename,
102103
decode_cf=True,
103104
mask_and_scale=True,
105+
drop_variables=drop_variables,
104106
chunks={
105107
"Columns": -1,
106108
"Rows": row_chunks_m,

satpy/tests/reader_tests/test_viirs_edr.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,24 @@ def _create_lst_variables() -> dict[str, xr.DataArray]:
268268
return data_vars
269269

270270

271+
@pytest.fixture(scope="module")
272+
def volcanic_ash_file(tmp_path_factory: TempPathFactory) -> Path:
273+
"""Generate fake *partial* Volcanic Ash VIIRs EDR file."""
274+
fn = f"JRR-VolcanicAsh_v3r0_j01_s{START_TIME:%Y%m%d%H%M%S}0_e{END_TIME:%Y%m%d%H%M%S}0_c202307231023395.nc"
275+
data_vars = _create_continuous_variables(
276+
("AshBeta",),
277+
data_attrs={
278+
"units": "1",
279+
"_FillValue": -999.,
280+
}
281+
)
282+
# The 'Det_QF_Size' variable is actually a scalar, but the there's no way to check it is dropped other than
283+
# making it 2D
284+
data_vars["Det_QF_Size"] = xr.DataArray(np.array([[1, 2]], dtype=np.int32),
285+
attrs={"_FillValue": -999, "units": "1"})
286+
return _create_fake_file(tmp_path_factory, fn, data_vars)
287+
288+
271289
def _create_continuous_variables(
272290
var_names: Iterable[str],
273291
data_attrs: None | dict = None
@@ -481,6 +499,17 @@ def test_get_platformname(self, surface_reflectance_file, filename_platform, exp
481499
scn.load(["surf_refl_I01"])
482500
assert scn["surf_refl_I01"].attrs["platform_name"] == exp_shortname
483501

502+
def test_volcanic_ash_drop_variables(self, volcanic_ash_file):
503+
"""Test that Det_QF_Size variable is dropped when reading VolcanicAsh products.
504+
505+
The said variable is also used as a dimension in v3r0 files, so the reading fails
506+
if it is not dropped.
507+
"""
508+
from satpy import Scene
509+
scn = Scene(reader="viirs_edr", filenames=[volcanic_ash_file])
510+
available = scn.available_dataset_names()
511+
assert "Det_QF_Size" not in available
512+
484513

485514
def _check_surf_refl_qf_data_arr(data_arr: xr.DataArray, multiple_files: bool) -> None:
486515
_array_checks(data_arr, dtype=np.uint8, multiple_files=multiple_files)

0 commit comments

Comments
 (0)