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

Rename prototype_amsr2 -> prototype_am2 #152

Merged
merged 1 commit into from
Sep 18, 2024
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# v0.3.0

* Add new `daily` cli that produces daily NC files ready for publication. During
the AMSR2 period, a `prototype_amsr2` group is added to the final output files
the AMSR2 period, a `prototype_am2` group is added to the final output files
with AMSR2-derived fields.

# match-cdrv4 (commit 87271ec)
Expand Down
29 changes: 20 additions & 9 deletions seaice_ecdr/daily_aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,28 @@ def _update_ncrcat_daily_ds(
if k != "number_of_missing_pixels"
}

# TODO: ideally this is more generic (e.g., we get the prototype platform ID
# from config)
if "/prototype_amsr2" in ds.groups:
ds["prototype_amsr2"]["am2_seaice_conc"].attrs = {
k: v
for k, v in ds["prototype_amsr2"]["am2_seaice_conc"].attrs.items()
if k != "number_of_missing_pixels"
}
# Remove "number_of_missing_pixels" attr from seaice conc var in any
# prototype subgroups
prototype_groups = [
group_name for group_name in ds.groups if "/prototype_" in group_name
]
if len(prototype_groups) > 0:
for prototype_group in prototype_groups:
# We expect prototype group name to have the form
# `prototype_{platform_id}`
platform_id = prototype_group.split("_")[1]
prototype_group_name = f"prototype_{platform_id}"
prototype_seaice_conc_name = f"{platform_id}_seaice_conc"
ds[prototype_group_name][prototype_seaice_conc_name].attrs = {
k: v
for k, v in ds[prototype_group_name][
prototype_seaice_conc_name
].attrs.items()
if k != "number_of_missing_pixels"
}

# Set global attributes. Only updates to the root group are necessary. The
# `prototype_amsr2` and `cdr_supplementary` groups will keep its attrs unchanged.
# `prototype_{platform_id}` and `cdr_supplementary` groups will keep its attrs unchanged.
daily_aggregate_ds_global_attrs = get_global_attrs(
time=ds.time,
temporality="daily",
Expand Down
2 changes: 1 addition & 1 deletion seaice_ecdr/publish_daily.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def publish_daily_nc(
# TODO: consider extracting to config or a kwarg of this function for more
# flexible use with other platforms in the future.
PROTOTYPE_PLATFORM_ID: SUPPORTED_PLATFORM_ID = "am2"
PROTOTYPE_PLATFORM_DATA_GROUP_NAME = "prototype_amsr2"
PROTOTYPE_PLATFORM_DATA_GROUP_NAME = f"prototype_{PROTOTYPE_PLATFORM_ID}"

intermediate_output_dir = get_intermediate_output_dir(
base_output_dir=base_output_dir,
Expand Down
4 changes: 2 additions & 2 deletions seaice_ecdr/tests/integration/test_publish_daily.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def test_publish_daily_nc(base_output_dir_test_path): # noqa

# TODO: we would expect this date to contain the amsr2 prototype group,
# but the integration tests do not currently run with the AMSR2 platform
# config, so the `prototype_amsr2` group is not present.
# assert "prototype_amsr2" in ds.groups
# config, so the `prototype_am2` group is not present.
# assert "prototype_am2" in ds.groups
assert "/cdr_supplementary" in ds.groups

assert "valid_range" not in ds.time.attrs.keys()
Expand Down
4 changes: 2 additions & 2 deletions seaice_ecdr/tests/regression/test_daily_aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ def test_daily_aggregate_matches_daily_data(tmpdir):
agg_cdr_supplementary_ds = xr.open_dataset(
aggregate_filepath, group="cdr_supplementary"
)
# TODO: prototype_amsr2 does not currently exist in this regression test
# TODO: prototype_am2 does not currently exist in this regression test
# because only data for the default platforms are being generated
# agg_prototype_amsr2_ds = xr.open_dataset(aggregate_filepath, group="prototype_amsr2")
# agg_prototype_am2_ds = xr.open_dataset(aggregate_filepath, group="prototype_am2")

checksum_filepath = (
complete_output_dir
Expand Down