Skip to content

Commit b94dbc9

Browse files
Merge pull request #200 from nsidc/seki-method-temporal-interp
Support for seki method thresholding in daily temporal interpolation
2 parents 84348f5 + f612fb0 commit b94dbc9

3 files changed

Lines changed: 33 additions & 3 deletions

File tree

seaice_ecdr/nrt.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,10 @@ def temporally_interpolated_nrt_ecdr_dataset(
185185

186186
data_stack = xr.concat(init_datasets, dim="time").sortby("time")
187187

188+
target_platform = PLATFORM_CONFIG.get_platform_by_date(date)
188189
temporally_interpolated_ds = temporal_interpolation(
189190
date=date,
191+
platform=target_platform,
190192
hemisphere=hemisphere,
191193
resolution=NRT_RESOLUTION,
192194
data_stack=data_stack,

seaice_ecdr/temporal_composite_daily.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
from seaice_ecdr._types import ECDR_SUPPORTED_RESOLUTIONS
2020
from seaice_ecdr.ancillary import (
21+
get_cdr_conc_threshold,
2122
get_daily_climatology_mask,
2223
get_non_ocean_mask,
2324
nh_polehole_mask,
@@ -29,7 +30,7 @@
2930
from seaice_ecdr.initial_daily_ecdr import (
3031
read_or_create_and_read_idecdr_ds,
3132
)
32-
from seaice_ecdr.platforms import PLATFORM_CONFIG
33+
from seaice_ecdr.platforms import PLATFORM_CONFIG, Platform
3334
from seaice_ecdr.spillover import LAND_SPILL_ALGS
3435
from seaice_ecdr.util import (
3536
date_range,
@@ -203,6 +204,8 @@ def is_seaice_conc(
203204
def temporally_composite_dataarray(
204205
*,
205206
target_date: dt.date,
207+
platform: Platform,
208+
hemisphere: Hemisphere,
206209
da: xr.DataArray,
207210
interp_range: int = 5,
208211
one_sided_limit: int = 3,
@@ -362,8 +365,14 @@ def temporally_composite_dataarray(
362365
# temporal_flags[have_only_next] = pdist[have_only_next] # CDRv04r00 error
363366
temporal_flags[have_only_next] = ndist[have_only_next] # Correct
364367

365-
# Ensure that no conc values are between 0 and 10% after temporal interp
366-
is_conc_too_low = (temp_comp_2d > 0) & (temp_comp_2d < 0.1)
368+
# Ensure that no conc values are between 0 and the threshold
369+
conc_threshold_perc = get_cdr_conc_threshold(
370+
date=target_date,
371+
hemisphere=hemisphere,
372+
platform=platform,
373+
)
374+
conc_threshold_frac = conc_threshold_perc / 100.0
375+
is_conc_too_low = (temp_comp_2d > 0) & (temp_comp_2d < conc_threshold_frac)
367376
temp_comp_2d[is_conc_too_low] = 0
368377

369378
# Ensure flag values do not occur over land
@@ -557,6 +566,7 @@ def filter_field_via_bitmask(
557566
def temporal_interpolation(
558567
*,
559568
date: dt.date,
569+
platform: Platform,
560570
hemisphere: Hemisphere,
561571
resolution: ECDR_SUPPORTED_RESOLUTIONS,
562572
data_stack: xr.Dataset,
@@ -591,6 +601,8 @@ def temporal_interpolation(
591601
# Actually compute the cdr_conc temporal composite
592602
ti_var, ti_flags = temporally_composite_dataarray(
593603
target_date=date,
604+
hemisphere=hemisphere,
605+
platform=platform,
594606
da=data_stack.conc,
595607
interp_range=interp_range,
596608
non_ocean_mask=non_ocean_mask,
@@ -697,6 +709,8 @@ def temporal_interpolation(
697709
# NOTE: the bt_conc array does not have daily_climatology applied
698710
bt_conc, _ = temporally_composite_dataarray(
699711
target_date=date,
712+
hemisphere=hemisphere,
713+
platform=platform,
700714
da=data_stack.raw_bt_seaice_conc,
701715
interp_range=interp_range,
702716
non_ocean_mask=non_ocean_mask,
@@ -706,6 +720,8 @@ def temporal_interpolation(
706720
# NOTE: the nt_conc array does not have daily_climatology applied
707721
nt_conc, _ = temporally_composite_dataarray(
708722
target_date=date,
723+
hemisphere=hemisphere,
724+
platform=platform,
709725
da=data_stack.raw_nt_seaice_conc,
710726
interp_range=interp_range,
711727
non_ocean_mask=non_ocean_mask,
@@ -869,7 +885,10 @@ def temporally_interpolated_ecdr_dataset(
869885

870886
data_stack = xr.concat(init_datasets, dim="time").sortby("time")
871887

888+
target_platform = PLATFORM_CONFIG.get_platform_by_date(date)
889+
872890
tie_ds = temporal_interpolation(
891+
platform=target_platform,
873892
hemisphere=hemisphere,
874893
resolution=resolution,
875894
date=date,

seaice_ecdr/tests/unit/test_temporal_composite_daily.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from seaice_ecdr.constants import ECDR_PRODUCT_VERSION
1414
from seaice_ecdr.initial_daily_ecdr import get_idecdr_dir, get_idecdr_filepath
1515
from seaice_ecdr.platforms import SUPPORTED_PLATFORM_ID
16+
from seaice_ecdr.platforms.config import F17_PLATFORM
1617
from seaice_ecdr.temporal_composite_daily import (
1718
iter_dates_near_date,
1819
temporally_composite_dataarray,
@@ -109,6 +110,8 @@ def test_temporal_composite_max_interp_range_9():
109110
with pytest.raises(RuntimeError, match=r"interp_range"):
110111
temporally_composite_dataarray(
111112
target_date=dt.date(2020, 1, 1),
113+
hemisphere=NORTH,
114+
platform=F17_PLATFORM,
112115
da=xr.DataArray(coords=(range(2), range(3), range(4))),
113116
interp_range=10,
114117
non_ocean_mask=xr.DataArray([False, False, False]),
@@ -150,6 +153,8 @@ def test_temporal_composite_da_oneday():
150153
# then the output will equal the input
151154
temporal_composite, _ = temporally_composite_dataarray(
152155
target_date=mock_date,
156+
hemisphere=NORTH,
157+
platform=F17_PLATFORM,
153158
da=initial_data_array,
154159
interp_range=0,
155160
non_ocean_mask=xr.full_like(initial_data_array.isel(time=0), False, dtype=bool),
@@ -266,6 +271,8 @@ def test_temporal_composite_da_multiday():
266271

267272
temporal_composite, temporal_flags = temporally_composite_dataarray(
268273
target_date=mock_date,
274+
hemisphere=NORTH,
275+
platform=F17_PLATFORM,
269276
da=input_data_array,
270277
interp_range=time_spread,
271278
non_ocean_mask=xr.full_like(input_data_array.isel(time=0), False, dtype=bool),
@@ -351,6 +358,8 @@ def test_temporal_composite_da_multiday_nrt():
351358

352359
temporal_composite, temporal_flags = temporally_composite_dataarray(
353360
target_date=mock_date,
361+
hemisphere=NORTH,
362+
platform=F17_PLATFORM,
354363
da=input_data_array,
355364
interp_range=5,
356365
one_sided_limit=5,

0 commit comments

Comments
 (0)