From 43d36fcde0d9daebf07d8976876b98f90016844c Mon Sep 17 00:00:00 2001 From: Scott Stewart Date: Thu, 19 Sep 2024 10:05:10 -0600 Subject: [PATCH 1/3] add combined bt and nt2 spillover --- seaice_ecdr/cli/daily.py | 3 +- seaice_ecdr/spillover.py | 84 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 85 insertions(+), 2 deletions(-) diff --git a/seaice_ecdr/cli/daily.py b/seaice_ecdr/cli/daily.py index 85066582..e7dc23c0 100644 --- a/seaice_ecdr/cli/daily.py +++ b/seaice_ecdr/cli/daily.py @@ -33,7 +33,8 @@ def make_25km_ecdr( ): # TODO: consider extracting these to CLI options that default to these values. RESOLUTION: Final = "25" - LAND_SPILLOVER_ALG: Final = "BT_NT" + LAND_SPILLOVER_ALG: Final = "NT2_BT" + ANCILLARY_SOURCE: Final = "CDRv4" # TODO: the amsr2 start date should ideally be read from the platform start # date config. diff --git a/seaice_ecdr/spillover.py b/seaice_ecdr/spillover.py index b9c14a58..60d6e375 100644 --- a/seaice_ecdr/spillover.py +++ b/seaice_ecdr/spillover.py @@ -23,7 +23,7 @@ from seaice_ecdr.util import get_ecdr_grid_shape NT_MAPS_DIR = Path("/share/apps/G02202_V5/cdr_testdata/nt_datafiles/data36/maps") -LAND_SPILL_ALGS = Literal["BT_NT", "NT2", "ILS", "ILSb"] +LAND_SPILL_ALGS = Literal["BT_NT", "NT2", "ILS", "ILSb", "BT_NT2", "NT2_BT"] def convert_nonocean_to_shoremap(*, is_nonocean: npt.NDArray): @@ -266,6 +266,88 @@ def land_spillover( affect_dist3=False, ) spillover_applied = spillover_applied_nt2 + elif algorithm == "NT2_BT": + # Apply the NT2 land spillover_algorithm to the cdr_conc_field + # and then apply the BT land spillover algorithm + + l90c = get_land90_conc_field( + hemisphere=hemisphere, + resolution=tb_data.resolution, + ancillary_source=ancillary_source, + ) + adj123 = get_adj123_field( + hemisphere=hemisphere, + resolution=tb_data.resolution, + ancillary_source=ancillary_source, + ) + spillover_applied_nt2 = apply_nt2_land_spillover( + conc=cdr_conc, + adj123=adj123.data, + l90c=l90c.data, + # anchoring_siconc=50.0, + # affect_dist3=True, + anchoring_siconc=0.0, + affect_dist3=False, + ) + + # Apply the BT land spillover algorithm to the cdr_conc field + non_ocean_mask = get_non_ocean_mask( + hemisphere=hemisphere, + resolution=tb_data.resolution, + ancillary_source=ancillary_source, + ) + + spillover_applied_nt2_bt = coastal_fix( + conc=spillover_applied_nt2, + missing_flag_value=np.nan, + land_mask=land_mask, + minic=10, + fix_goddard_bt_error=fix_goddard_bt_error, + ) + + spillover_applied = spillover_applied_nt2_bt + + elif algorithm == "BT_NT2": + # Apply the BT land spillover algorithm to the cdr_conc field + non_ocean_mask = get_non_ocean_mask( + hemisphere=hemisphere, + resolution=tb_data.resolution, + ancillary_source=ancillary_source, + ) + + spillover_applied_bt = coastal_fix( + # conc=bt_conc, + conc=cdr_conc, + missing_flag_value=np.nan, + land_mask=land_mask, + minic=10, + fix_goddard_bt_error=fix_goddard_bt_error, + ) + + # Apply the NT2 land spillover_algorithm to the cdr_conc_field + # after the BT algorithm has been applied to it + l90c = get_land90_conc_field( + hemisphere=hemisphere, + resolution=tb_data.resolution, + ancillary_source=ancillary_source, + ) + adj123 = get_adj123_field( + hemisphere=hemisphere, + resolution=tb_data.resolution, + ancillary_source=ancillary_source, + ) + spillover_applied_bt_nt2 = apply_nt2_land_spillover( + # conc=cdr_conc, + conc=spillover_applied_bt, + adj123=adj123.data, + l90c=l90c.data, + # anchoring_siconc=50.0, + # affect_dist3=True, + anchoring_siconc=0.0, + affect_dist3=False, + ) + spillover_applied = spillover_applied_bt_nt2 + elif algorithm == "BT_NT": non_ocean_mask = get_non_ocean_mask( hemisphere=hemisphere, From 7b383a44a350079031e89d70712fdafa55a19401 Mon Sep 17 00:00:00 2001 From: Scott Stewart Date: Thu, 19 Sep 2024 10:13:27 -0600 Subject: [PATCH 2/3] remove BT_NT2 (keep NT2_BT) land spillover --- seaice_ecdr/spillover.py | 43 +--------------------------------------- 1 file changed, 1 insertion(+), 42 deletions(-) diff --git a/seaice_ecdr/spillover.py b/seaice_ecdr/spillover.py index 60d6e375..5323f4c0 100644 --- a/seaice_ecdr/spillover.py +++ b/seaice_ecdr/spillover.py @@ -23,7 +23,7 @@ from seaice_ecdr.util import get_ecdr_grid_shape NT_MAPS_DIR = Path("/share/apps/G02202_V5/cdr_testdata/nt_datafiles/data36/maps") -LAND_SPILL_ALGS = Literal["BT_NT", "NT2", "ILS", "ILSb", "BT_NT2", "NT2_BT"] +LAND_SPILL_ALGS = Literal["BT_NT", "NT2", "ILS", "ILSb", "NT2_BT"] def convert_nonocean_to_shoremap(*, is_nonocean: npt.NDArray): @@ -307,47 +307,6 @@ def land_spillover( spillover_applied = spillover_applied_nt2_bt - elif algorithm == "BT_NT2": - # Apply the BT land spillover algorithm to the cdr_conc field - non_ocean_mask = get_non_ocean_mask( - hemisphere=hemisphere, - resolution=tb_data.resolution, - ancillary_source=ancillary_source, - ) - - spillover_applied_bt = coastal_fix( - # conc=bt_conc, - conc=cdr_conc, - missing_flag_value=np.nan, - land_mask=land_mask, - minic=10, - fix_goddard_bt_error=fix_goddard_bt_error, - ) - - # Apply the NT2 land spillover_algorithm to the cdr_conc_field - # after the BT algorithm has been applied to it - l90c = get_land90_conc_field( - hemisphere=hemisphere, - resolution=tb_data.resolution, - ancillary_source=ancillary_source, - ) - adj123 = get_adj123_field( - hemisphere=hemisphere, - resolution=tb_data.resolution, - ancillary_source=ancillary_source, - ) - spillover_applied_bt_nt2 = apply_nt2_land_spillover( - # conc=cdr_conc, - conc=spillover_applied_bt, - adj123=adj123.data, - l90c=l90c.data, - # anchoring_siconc=50.0, - # affect_dist3=True, - anchoring_siconc=0.0, - affect_dist3=False, - ) - spillover_applied = spillover_applied_bt_nt2 - elif algorithm == "BT_NT": non_ocean_mask = get_non_ocean_mask( hemisphere=hemisphere, From c790f829791a4c44f0bd5fd0561301b405281eab Mon Sep 17 00:00:00 2001 From: Scott Stewart Date: Thu, 19 Sep 2024 11:30:49 -0600 Subject: [PATCH 3/3] remove unused kwargs; fix typo --- seaice_ecdr/spillover.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/seaice_ecdr/spillover.py b/seaice_ecdr/spillover.py index 5323f4c0..e90edb16 100644 --- a/seaice_ecdr/spillover.py +++ b/seaice_ecdr/spillover.py @@ -110,7 +110,7 @@ def improved_land_spillover( siconc is less than a threshold [sie_min] The ils_arr is encoded as: - 0: missing information: siconc cannot be used to anchor/disanchore + 0: missing information: siconc cannot be used to anchor/disanchor 1: non-ocean (ie land or other grid cells without siconc (~lake)) 2: ocean that may be removed by land spillover, if dilated sie low 3: ocean whose concentration may anchor/disanchor coastal siconc @@ -260,8 +260,6 @@ def land_spillover( conc=cdr_conc, adj123=adj123.data, l90c=l90c.data, - # anchoring_siconc=50.0, - # affect_dist3=True, anchoring_siconc=0.0, affect_dist3=False, ) @@ -284,8 +282,6 @@ def land_spillover( conc=cdr_conc, adj123=adj123.data, l90c=l90c.data, - # anchoring_siconc=50.0, - # affect_dist3=True, anchoring_siconc=0.0, affect_dist3=False, )