diff --git a/satpy/etc/readers/viirs_edr.yaml b/satpy/etc/readers/viirs_edr.yaml index e53a27d072..aaada95036 100644 --- a/satpy/etc/readers/viirs_edr.yaml +++ b/satpy/etc/readers/viirs_edr.yaml @@ -64,6 +64,12 @@ file_types: file_reader: !!python/name:satpy.readers.viirs_edr.VIIRSJRRFileHandler file_patterns: - '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' + jrr_volcanicash: + file_reader: !!python/name:satpy.readers.viirs_edr.VIIRSJRRFileHandler + drop_variables: + - Det_QF_Size + file_patterns: + - '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' datasets: diff --git a/satpy/readers/viirs_edr.py b/satpy/readers/viirs_edr.py index 43f7d06032..baa6803418 100644 --- a/satpy/readers/viirs_edr.py +++ b/satpy/readers/viirs_edr.py @@ -98,9 +98,11 @@ def __init__(self, filename, filename_info, filetype_info, **kwargs): # use entire scans as chunks row_chunks_m = max(get_chunk_size_limit() // 4 // M_COLS, 1) # 32-bit floats row_chunks_i = row_chunks_m * 2 + drop_variables = filetype_info.get("drop_variables", None) self.nc = xr.open_dataset(self.filename, decode_cf=True, mask_and_scale=True, + drop_variables=drop_variables, chunks={ "Columns": -1, "Rows": row_chunks_m, diff --git a/satpy/tests/reader_tests/test_viirs_edr.py b/satpy/tests/reader_tests/test_viirs_edr.py index 447d43938d..095bf5a199 100644 --- a/satpy/tests/reader_tests/test_viirs_edr.py +++ b/satpy/tests/reader_tests/test_viirs_edr.py @@ -268,6 +268,24 @@ def _create_lst_variables() -> dict[str, xr.DataArray]: return data_vars +@pytest.fixture(scope="module") +def volcanic_ash_file(tmp_path_factory: TempPathFactory) -> Path: + """Generate fake *partial* Volcanic Ash VIIRs EDR file.""" + 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" + data_vars = _create_continuous_variables( + ("AshBeta",), + data_attrs={ + "units": "1", + "_FillValue": -999., + } + ) + # The 'Det_QF_Size' variable is actually a scalar, but the there's no way to check it is dropped other than + # making it 2D + data_vars["Det_QF_Size"] = xr.DataArray(np.array([[1, 2]], dtype=np.int32), + attrs={"_FillValue": -999, "units": "1"}) + return _create_fake_file(tmp_path_factory, fn, data_vars) + + def _create_continuous_variables( var_names: Iterable[str], data_attrs: None | dict = None @@ -481,6 +499,17 @@ def test_get_platformname(self, surface_reflectance_file, filename_platform, exp scn.load(["surf_refl_I01"]) assert scn["surf_refl_I01"].attrs["platform_name"] == exp_shortname + def test_volcanic_ash_drop_variables(self, volcanic_ash_file): + """Test that Det_QF_Size variable is dropped when reading VolcanicAsh products. + + The said variable is also used as a dimension in v3r0 files, so the reading fails + if it is not dropped. + """ + from satpy import Scene + scn = Scene(reader="viirs_edr", filenames=[volcanic_ash_file]) + available = scn.available_dataset_names() + assert "Det_QF_Size" not in available + def _check_surf_refl_qf_data_arr(data_arr: xr.DataArray, multiple_files: bool) -> None: _array_checks(data_arr, dtype=np.uint8, multiple_files=multiple_files)