Skip to content

Commit

Permalink
Merge pull request #142 from nsidc/update-pm_icecon
Browse files Browse the repository at this point in the history
Update pm_icecon dep
  • Loading branch information
trey-stafford authored Sep 13, 2024
2 parents 995d210 + d71ad8e commit d52e1c7
Show file tree
Hide file tree
Showing 56 changed files with 3,923 additions and 888 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# v0.2.0

* Produce 25km CDR instead of 12.5km.
* Refactor how platforms are handled to support overriding platform start dates
via yaml configuration files.


# v0.1.0

* Initial version of the ECDR.
8 changes: 7 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ dependencies:
- pandas ~=1.4.4
- opencv ~=4.8.0
- pm_tb_data ~=0.4.0
- pm_icecon ~=0.3.1
- pm_icecon ~=0.4.0
- leafmap
- rioxarray
- hvplot
- jupyter_bokeh

#############################
# Non-imported dependencies #
Expand All @@ -33,6 +37,8 @@ dependencies:
- mypy ==1.7.0
- pyfakefs ~=5.2.4
- pytest-order ~=1.0.1
# required by leafmap
- localtileserver

# other utilities
- bump-my-version ~=0.10.0
Expand Down
20 changes: 20 additions & 0 deletions make_25km_ecdr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

set -exo pipefail

BT_NT_BASE_DIR="/share/apps/G02202_V5/25km/BT_NT_ss"
mkdir -p $BT_NT_BASE_DIR
NT2_BASE_DIR="/share/apps/G02202_V5/25km/NT2_ss"
mkdir -p $NT2_BASE_DIR

START_DATE="2018-04-01"
END_DATE="2018-12-31"
HEMISPHERE="north"

# NT method first
FORCE_PLATFORM=F17 ./scripts/cli.sh multiprocess-daily --start-date $START_DATE --end-date $END_DATE --hemisphere $HEMISPHERE --base-output-dir $BT_NT_BASE_DIR --land-spillover-alg BT_NT --resolution 25 --ancillary-source CDRv4
FORCE_PLATFORM=am2 ./scripts/cli.sh multiprocess-daily --start-date $START_DATE --end-date $END_DATE --hemisphere $HEMISPHERE --base-output-dir $BT_NT_BASE_DIR --land-spillover-alg BT_NT --resolution 25 --ancillary-source CDRv4

# NT2 method second
FORCE_PLATFORM=F17 ./scripts/cli.sh multiprocess-daily --start-date $START_DATE --end-date $END_DATE --hemisphere $HEMISPHERE --base-output-dir $NT2_BASE_DIR --land-spillover-alg NT2 --resolution 25 --ancillary-source CDRv4
FORCE_PLATFORM=am2 ./scripts/cli.sh multiprocess-daily --start-date $START_DATE --end-date $END_DATE --hemisphere $HEMISPHERE --base-output-dir $NT2_BASE_DIR --land-spillover-alg NT2 --resolution 25 --ancillary-source CDRv4
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[project]
name = "seaice_ecdr"
version = "0.1.0"
version = "0.2.0"

[tool.bumpversion]
current_version = "0.1.0"
current_version = "0.2.0"
commit = false
tag = false

Expand Down Expand Up @@ -87,5 +87,6 @@ module = [
"rasterio.*",
"yaml.*",
"cv2.*",
"ruamel.*",
]
ignore_missing_imports = true
17 changes: 8 additions & 9 deletions scripts/ancillary/adapt_cdrv5_anc.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@
ecdr_anc_fn = {
"psn12.5": "/share/apps/G02202_V5/v05r00_ancillary/ecdr-ancillary-psn12.5.nc",
"pss12.5": "/share/apps/G02202_V5/v05r00_ancillary/ecdr-ancillary-pss12.5.nc",
"psn25": "/share/apps/G02202_V5/v05r00_ancillary/ecdr-ancillary-psn25.nc",
"pss25": "/share/apps/G02202_V5/v05r00_ancillary/ecdr-ancillary-pss25.nc",
# "psn25": "/share/apps/G02202_V5/v05r00_ancillary/ecdr-ancillary-psn25.nc",
# "pss25": "/share/apps/G02202_V5/v05r00_ancillary/ecdr-ancillary-pss25.nc",
"psn25": "/share/apps/G02202_V5/v05r00_ancillary/ecdr-ancillary-psn25_new.nc",
"pss25": "/share/apps/G02202_V5/v05r00_ancillary/ecdr-ancillary-pss25_new.nc",
}

nsidc0771_fn = {
Expand Down Expand Up @@ -148,10 +150,8 @@ def calc_adj123_np(surftype_da, ocean_val=50, coast_val=200):
Output:
Numpy array with adjacency values of 1, 2, 3
"""
surftype = surftype_da.as_numpy()
surftype = surftype_da.to_numpy()
is_ocean = surftype == ocean_val
is_coast = surftype == coast_val
is_land = (~is_ocean) & (~is_coast)

kernel = [
[
Expand All @@ -167,7 +167,7 @@ def calc_adj123_np(surftype_da, ocean_val=50, coast_val=200):
],
]
adj123_arr = np.zeros(surftype.shape, dtype=np.uint8)
adj123_arr[is_land] = 255
adj123_arr[~is_ocean] = 255
for adj_val in range(1, 4):
is_unlabeled = adj123_arr == 0
is_labeled = (adj123_arr == 255) | ((~is_unlabeled) & (adj123_arr < adj_val))
Expand All @@ -182,7 +182,7 @@ def calc_adj123_np(surftype_da, ocean_val=50, coast_val=200):
adj123_arr[is_newly_labeled] = adj_val

# Remove the land grid cells from the adjacency matrix
adj123_arr[adj123_arr == 255] = 0
# adj123_arr[adj123_arr == 255] = 0

return adj123_arr

Expand Down Expand Up @@ -559,8 +559,7 @@ def generate_ecdr_anc_file(gridid):
ds_hires_anc.data_vars["polehole_bitmask"].attrs[
"flag_masks"
]
)
- 1,
),
)
),
),
Expand Down
Loading

0 comments on commit d52e1c7

Please sign in to comment.