Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pandas-based avoidance for non-nanosecond datetime value conversion t… #152

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions ecco_v4_py/ecco_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from __future__ import division, print_function
import numpy as np
import pandas as pd
import xarray as xr
import datetime
import dateutil
Expand Down Expand Up @@ -303,7 +304,7 @@ def make_time_bounds_and_center_times_from_ecco_dataset(ecco_dataset, \
time_bnds = time_bnds.T

# make time bounds dataset
if 'time' not in ecco_dataset.dims.keys():
if 'time' not in ecco_dataset.dims:
ecco_dataset = ecco_dataset.expand_dims(dim='time')

#print ('-- tb shape ', time_bnds.shape)
Expand Down Expand Up @@ -388,7 +389,7 @@ def make_time_bounds_from_ds64(rec_avg_end, output_freq_code):
def extract_yyyy_mm_dd_hh_mm_ss_from_datetime64(dt64):
"""

Extract separate fields for year, monday, day, hour, min, sec from
Extract separate fields for year, month, day, hour, min, sec from
a datetime64 object, or an array-like object of datetime64 objects

Parameters
Expand Down Expand Up @@ -420,7 +421,7 @@ def extract_yyyy_mm_dd_hh_mm_ss_from_datetime64(dt64):
xdates = extract_yyyy_mm_dd_hh_mm_ss_from_datetime64(xr.DataArray(dt64))
return tuple([x.values for x in xdates])
elif isinstance(dt64,np.datetime64):
xdates = extract_yyyy_mm_dd_hh_mm_ss_from_datetime64(xr.DataArray(np.array([dt64])))
xdates = extract_yyyy_mm_dd_hh_mm_ss_from_datetime64(xr.DataArray(pd.to_datetime(dt64)))
return tuple([int(x.values) for x in xdates])

#%%
Expand Down