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

Add VolcanicAsh product to VIIRS EDR reader #3050

Merged
merged 1 commit into from
Feb 7, 2025
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
6 changes: 6 additions & 0 deletions satpy/etc/readers/viirs_edr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions satpy/readers/viirs_edr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
29 changes: 29 additions & 0 deletions satpy/tests/reader_tests/test_viirs_edr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Loading