Skip to content

Commit

Permalink
use more straitforward code because otherwise error occurs with non-s…
Browse files Browse the repository at this point in the history
…tandard calendar
  • Loading branch information
lee1043 committed May 8, 2024
1 parent f2a4e11 commit 493076a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pcmdi_metrics/mjo/lib/mjo_metric_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,18 @@ def mjo_metric_ewr_calculation(
print("debug: check time")

time_key = get_time_key(ds)
first_time = ds.indexes[time_key].to_datetimeindex()[0].to_pydatetime()
last_time = ds.indexes[time_key].to_datetimeindex()[-1].to_pydatetime()

# Get first time step date
first_time_year = ds[time_key][0].item().year
first_time_month = ds[time_key][0].item().month
first_time_day = ds[time_key][0].item().day
first_time = datetime(first_time_year, first_time_month, first_time_day)

# Get last time step date
last_time_year = ds[time_key][-1].item().year
last_time_month = ds[time_key][-1].item().month
last_time_day = ds[time_key][-1].item().day
last_time = datetime(last_time_year, last_time_month, last_time_day)

if season == "NDJFMA":
# Adjust years to consider only when continuous NDJFMA is available
Expand Down

0 comments on commit 493076a

Please sign in to comment.