CADWRDeltaModeling/pyhecdss

handle non-zero iofset value

dwr-psandhu opened this issue · 5 comments

A time series can be stored with a certain timestamp or period value and could have a constant offset within that period (or from that timestamp? check)

This ability is available in HEC-DSS, but the ifoset is ignored with a warning for now.

Pandas period type does not support offsets. One complicated solution could be to return a datetimeindex with offsets which works but may cause confusion as the dataframe could be datetimeindex or periodindex for the same time series depending upon the index.
A simplification is needed...

kjnam commented

I think what you are looking for is related to this: pandas-dev/pandas#6779. For example, let's say if you want to add two days to a period value:

p = pd.Period('2019-10-01')
p
Period('2019-10-01', 'D')
p + 2 * pd.tseries.frequencies.to_offset('D')
Period('2019-10-03', 'D')

In HEC-DSS case they allow a monthly period value and then a offset of minutes into that period. Look at ZOFSET and IOFSET documentation in https://www.hec.usace.army.mil/publications/ComputerProgramDocumentation/CPD-57.pdf

So trying the above example,

p=pd.Period('2019-10-31','M')
p-pd.tseries.frequencies.to_offset('D') # this fails

If I change to

p=pd.Timestamp('2019-10-31')
p-pd.tseries.frequencies.to_offset('D') # this works as expected.

Thinking about it, offsets into periods seem devoid of meaning to me. Hence my suggestion that perhaps to keep things simple and consistent return all HECDSS timeseries with Timestamp index and the letting the end user deal with if they want to convert to period may be a better solution

kjnam commented

Agreed. Offsetting in a smaller interval than the time period is somewhat confusing too.

Closing as already supported for timestamped values. Will not work for periods