Skip to content

Commit

Permalink
Merge pull request #147 from NCAR/ksha
Browse files Browse the repository at this point in the history
Minor bugfix on `credit.data`
  • Loading branch information
yingkaisha authored Jan 9, 2025
2 parents 85d6810 + 403bacd commit 648c231
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions credit/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1320,12 +1320,12 @@ def find_start_stop_indices(self, index):
# ============================================================================ #
# subtrack shifted_hour form the 1st & last init times
# convert to datetime object
self.init_datetime[index][0] = datetime.strptime(
self.init_datetime[index][0] = datetime.datetime.strptime(
self.init_datetime[index][0], "%Y-%m-%d %H:%M:%S"
) - timedelta(hours=shifted_hours)
self.init_datetime[index][1] = datetime.strptime(
) - datetime.timedelta(hours=shifted_hours)
self.init_datetime[index][1] = datetime.datetime.strptime(
self.init_datetime[index][1], "%Y-%m-%d %H:%M:%S"
) - timedelta(hours=shifted_hours)
) - datetime.timedelta(hours=shifted_hours)

# convert the 1st & last init times to a list of init times
self.init_datetime[index] = generate_datetime(
Expand All @@ -1343,7 +1343,7 @@ def find_start_stop_indices(self, index):
# init_time_list_np[0]: the first initialization time
# init_time_list_np[t]: the forcasted time of the (t-1)th step; the initialization time of the t-th step
self.init_time_list_np = [
np.datetime64(str(dt_obj) + ".000000000").astype(datetime)
np.datetime64(str(dt_obj) + ".000000000").astype(datetime.datetime)
for dt_obj in init_time_list_dt
]

Expand All @@ -1361,7 +1361,7 @@ def find_start_stop_indices(self, index):
N_times = len(ds["time"])
# convert ds['time'] to a list of nanosecondes
ds_time_list = [
np.datetime64(ds_time.values).astype(datetime)
np.datetime64(ds_time.values).astype(datetime.datetime)
for ds_time in ds["time"]
]
ds_start_time = ds_time_list[0]
Expand Down

0 comments on commit 648c231

Please sign in to comment.