Skip to content

Commit

Permalink
Use MELT_SEASON_LAST_DOY constant in monthly melt field creation
Browse files Browse the repository at this point in the history
  • Loading branch information
trey-stafford committed Nov 7, 2024
1 parent 44b47bc commit 782689e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions seaice_ecdr/intermediate_monthly.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
from seaice_ecdr.constants import DEFAULT_BASE_OUTPUT_DIR
from seaice_ecdr.days_treated_differently import months_of_cdr_missing_data
from seaice_ecdr.intermediate_daily import get_ecdr_filepath
from seaice_ecdr.melt import MELT_SEASON_LAST_DOY
from seaice_ecdr.nc_attrs import get_global_attrs
from seaice_ecdr.platforms import PLATFORM_CONFIG, SUPPORTED_PLATFORM_ID
from seaice_ecdr.tb_data import get_hemisphere_from_crs_da
Expand Down Expand Up @@ -479,11 +480,12 @@ def calc_cdr_melt_onset_day_monthly(
# Create `cdr_melt_onset_day_monthly`. This is the value from
# the last day of the month unless the month is incomplete.
# xarray uses np.datetime64[ns] for time
doy_str_list = [
date.strftime("%j") for date in daily_melt_onset_for_month.time.dt.date.values
doy_list: list[int] = [
int(date.strftime("%j"))
for date in daily_melt_onset_for_month.time.dt.date.values
]
if "244" in doy_str_list:
day_244_idx = doy_str_list.index("244")
if MELT_SEASON_LAST_DOY in doy_list:
day_244_idx = doy_list.index(MELT_SEASON_LAST_DOY)
max_date = daily_melt_onset_for_month.time[day_244_idx].values
logger.info(f"Found non-max date with melt: {max_date}")
else:
Expand Down
4 changes: 2 additions & 2 deletions seaice_ecdr/melt.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
import numpy.typing as npt

# Start and end DOYs for the melt season (inclusive)
MELT_SEASON_FIRST_DOY = 60
MELT_SEASON_LAST_DOY = 244
MELT_SEASON_FIRST_DOY: int = 60
MELT_SEASON_LAST_DOY: int = 244

# Flag value for grid cells before melting is detected or if no melt is ever
# detected.
Expand Down

0 comments on commit 782689e

Please sign in to comment.