Skip to content
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
10 changes: 10 additions & 0 deletions polar2grid/etc/enhancements/generic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -333,54 +333,64 @@ enhancements:
# Polar2Grid - CLAVR-x products
clavrx_cloud_type:
name: cloud_type
reader: clavrx
operations: {}
clavrx_cld_temp_acha:
name: cld_temp_acha
reader: clavrx
operations:
- name: linear_stretch
method: !!python/name:satpy.enhancements.contrast.stretch
kwargs: {stretch: 'crude', min_stretch: 160, max_stretch: 320.}
clavrx_cld_height_acha:
name: cld_height_acha
reader: clavrx
operations:
- name: linear_stretch
method: !!python/name:satpy.enhancements.contrast.stretch
kwargs: {stretch: 'crude', min_stretch: 0, max_stretch: 20000.}
clavrx_cloud_phase:
name: cloud_phase
reader: clavrx
operations: {}
clavrx_cld_opd_dcomp:
name: cld_opd_dcomp
reader: clavrx
operations:
- name: linear_stretch
method: !!python/name:satpy.enhancements.contrast.stretch
kwargs: {stretch: 'crude', min_stretch: -0.2, max_stretch: 160.}
clavrx_cld_opd_nlcomp:
name: cld_opd_nlcomp
reader: clavrx
operations:
- name: linear_stretch
method: !!python/name:satpy.enhancements.contrast.stretch
kwargs: {stretch: 'crude', min_stretch: -0.2, max_stretch: 160.}
clavrx_cld_reff_dcomp:
name: cld_reff_dcomp
reader: clavrx
operations:
- name: linear_stretch
method: !!python/name:satpy.enhancements.contrast.stretch
kwargs: {stretch: 'crude', min_stretch: 0, max_stretch: 160.}
clavrx_cld_reff_nlcomp:
name: cld_reff_nlcomp
reader: clavrx
operations:
- name: linear_stretch
method: !!python/name:satpy.enhancements.contrast.stretch
kwargs: {stretch: 'crude', min_stretch: 0, max_stretch: 160.}
clavrx_cld_emiss_acha:
name: cld_emiss_acha
reader: clavrx
operations:
- name: linear_stretch
method: !!python/name:satpy.enhancements.contrast.stretch
kwargs: {stretch: 'crude', min_stretch: 0, max_stretch: 1.}
clavrx_refl_lunar_dnb_nom:
name: refl_lunar_dnb_nom
reader: clavrx
operations:
- name: linear_stretch
method: !!python/name:satpy.enhancements.contrast.stretch
Expand Down
34 changes: 18 additions & 16 deletions polar2grid/glue.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,21 @@


def _write_scene(
scn: Scene, writers: list[str], writer_args: dict[str, dict], data_ids: list[DataID], to_save: Optional[list] = None
scn: Scene,
writers: list[str],
writer_args: dict[str, dict],
data_ids: list[DataID],
):
if to_save is None:
to_save = []
to_save = []
if not data_ids:
# no datasets to save
return to_save

_assign_default_native_area_id(scn, data_ids)
for writer_name in writers:
wargs = writer_args.get(writer_name, {})
_write_scene_with_writer(scn, writer_name, data_ids, wargs, to_save)
res = _write_scene_with_writer(scn, writer_name, data_ids, wargs)
to_save.append(res)

Check notice on line 137 in polar2grid/glue.py

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ No longer an issue: Excess Number of Function Arguments

_write_scene is no longer above the threshold for number of arguments. This function has too many arguments, indicating a lack of encapsulation. Avoid adding more arguments.
return to_save


Expand All @@ -143,20 +146,15 @@
scn[data_id].attrs["area"].area_id = "native"


def _write_scene_with_writer(scn: Scene, writer_name: str, data_ids: list[DataID], wargs: dict, to_save: list) -> None:
def _write_scene_with_writer(scn: Scene, writer_name: str, data_ids: list[DataID], wargs: dict) -> list | tuple:
try:
res = scn.save_datasets(writer=writer_name, compute=False, datasets=data_ids, **wargs)
except ValueError as err:
err_msg = str(err)
if "Unknown writer" in err_msg:
LOG.error(err_msg)
raise
if res and isinstance(res[0], (tuple, list)):
# list of (dask-array, file-obj) tuples
to_save.extend(zip(*res, strict=True))
else:
# list of delayed objects
to_save.extend(res)
return res

Check notice on line 157 in polar2grid/glue.py

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ No longer an issue: Excess Number of Function Arguments

_write_scene_with_writer is no longer above the threshold for number of arguments. This function has too many arguments, indicating a lack of encapsulation. Avoid adding more arguments.


def _print_list_products(reader_info, is_polar2grid: bool, p2g_only: bool):
Expand Down Expand Up @@ -229,19 +227,19 @@


def _save_scenes(scenes_to_save: list[tuple], reader_info, writer_args) -> list:
to_save = []
all_to_save = []
for scene_to_save, products_to_save in scenes_to_save:
_overwrite_platform_name_with_aliases(scene_to_save)
_overwrite_sensor_with_aliases(scene_to_save)
reader_info.apply_p2g_name_to_scene(scene_to_save)
to_save = _write_scene(
this_scene_to_save = _write_scene(
scene_to_save,
writer_args["writers"],
writer_args,
products_to_save,
to_save=to_save,
)
return to_save
all_to_save.extend(this_scene_to_save)
return all_to_save


def _get_glue_name(args):
Expand Down Expand Up @@ -419,7 +417,11 @@
rename_log = True
args.log_fn = glue_name + "_fail.log"
levels = [logging.ERROR, logging.WARN, logging.INFO, logging.DEBUG]
setup_logging(console_level=levels[min(3, args.verbosity)], log_filename=args.log_fn)
if os.getenv("P2G_ALLOW_TRACE"):
from satpy.utils import TRACE_LEVEL

levels.append(TRACE_LEVEL)
setup_logging(console_level=levels[min(len(levels) - 1, args.verbosity)], log_filename=args.log_fn)
logging.getLogger("rasterio").setLevel(levels[min(1, args.verbosity)])
logging.getLogger("fsspec").setLevel(levels[min(2, args.verbosity)])
logging.getLogger("s3fs").setLevel(levels[min(2, args.verbosity)])
Expand Down
27 changes: 23 additions & 4 deletions polar2grid/readers/abi_l1b.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@
+---------------------------+-----------------------------------------------------+
| night_microphysics | Night Microphysics RGB |
+---------------------------+-----------------------------------------------------+
| day_cloud_type | Day Cloud Type RGB |
+---------------------------+-----------------------------------------------------+
| day_severe_storms | Day Severe Storms RGB (aka. Day Convection) |
+---------------------------+-----------------------------------------------------+
| volcanic_emissions | Volcanic Emissions (SO2 and Ash) (aka. SO2) |
+---------------------------+-----------------------------------------------------+
| day_blowing_snow | Day Blowing Snow RGB |
+---------------------------+-----------------------------------------------------+

"""

Expand All @@ -108,12 +116,23 @@
READER_PRODUCTS = ["C{:02d}".format(x) for x in range(1, 17)]
COMPOSITE_PRODUCTS = [
"true_color",
"natural_color",
"natural_color", # <-- considered legacy RGB Workshop 2025
"airmass",
"ash",
"dust",
"fog",
"ash", # <-- deprecated name as of RGB Workshop 2025 (preferred: 24h_microphysics_ash)
"dust", # <-- deprecated name as of RGB Workshop 2025 (preferred: 24h_microphysics_dust)
"fog", # <-- deprecated name as of RGB Workshop 2025 (preferred: night_microphysics)?
"night_microphysics",
# 2025 new
"day_cloud_type",
"day_severe_storms",
"volcanic_emissions", # old name: so2
"day_blowing_snow",
# "day_cloud_type_distinction", # aka: day cloud phase distinction
# "cira_fire_temperature",
# "snow_fog", # day snow fog - considered legacy RGB Workshop 2025
# "land_cloud", # day land cloud - considered legacy RGB Workshop 2025
# "water_vapors2", # differential water vapor - considered legacy RGB Workshop 2025
# "simple_water_vapor", # aka: water_vapors1 (deprecated in Satpy)
]


Expand Down
4 changes: 2 additions & 2 deletions polar2grid/writers/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ def save_image(self, img, filename=None, compute=True, dtype=None, fill_value=No
dst = np.memmap(filename, shape=img.data.shape, dtype=dtype, mode="w+")
if compute:
da.store(data, dst)
return
return [[data], [dst]]
return filename
return [data], [dst]

def _prep_data(self, data: xr.DataArray, dtype: np.dtype, fill_value) -> da.Array:
fill = data.attrs.get("_FillValue", np.nan)
Expand Down
Loading