Skip to content

Commit

Permalink
fix for issue 15: units 'M' and 'Y' no longer supported
Browse files Browse the repository at this point in the history
  • Loading branch information
dwr-psandhu committed Feb 5, 2020
1 parent 076dbd5 commit 11d1f61
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyhecdss/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__author__ = """Nicky Sandhu"""
__email__ = '[email protected]'
__version__ = "0.2.9"
__version__ = "0.3.0"
from .pyhecdss import *
9 changes: 6 additions & 3 deletions pyhecdss/pyhecdss.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,11 @@ def m2ihm(self, minute):
def parse_pathname_epart(self, pathname):
return pathname.split('/')[1:7][4]

def _number_between(startDateStr, endDateStr, delta=pd.to_timedelta(1, 'Y')):
return (pd.to_datetime(endDateStr)-pd.to_datetime(startDateStr))/delta
def _number_between(startDateStr, endDateStr, delta=np.timedelta64(1, 'D')):
"""
This is just a guess at number of values to be read so going over is ok.
"""
return round((pd.to_datetime(endDateStr)-pd.to_datetime(startDateStr))/delta+1)

def _get_timedelta_unit(epart):
if 'YEAR' in epart:
Expand Down Expand Up @@ -441,7 +444,7 @@ def read_its(self, pathname, startDateStr=None, endDateStr=None, guess_vals_per_
ietime = istime = 0
# guess how many values to be read based on e part approximation
ktvals = DSSFile._number_between(startDateStr, endDateStr,
pd.to_timedelta(1, unit=DSSFile._get_timedelta_unit(epart)))
np.timedelta64(1, DSSFile._get_timedelta_unit(epart)))
ktvals = guess_vals_per_block*int(ktvals)
kdvals = ktvals
itimes = np.zeros(ktvals, 'i')
Expand Down

0 comments on commit 11d1f61

Please sign in to comment.