pyhecdss package¶
Submodules¶
pyhecdss.pyhecdss module¶
- class pyhecdss.pyhecdss.DSSData(data, units, period_type)¶
Bases:
tuple
- property data¶
Alias for field number 0
- property period_type¶
Alias for field number 2
- property units¶
Alias for field number 1
- class pyhecdss.pyhecdss.DSSFile(fname, create_new=False)[source]¶
Bases:
object
Opens a HEC-DSS file for operations of read and write. The correct way of using is “with” statement:
``` with DSSFile(‘myfile.dss’) as dh:
dfcat=dh.read_catalog()
- Raises:
FileNotFoundError: If the path to the file is not found. Usually silently creats an empty file if missing
- Returns:
DSSFile: an open DSS file handle
- EPART_PATTERN = re.compile('(?P<n>\\d+)(?P<interval>M[O|I]N|YEAR|HOUR|DAY|WEEK)')¶
vectorized version of timedelta
- FREQ_NAME_MAP = {'A-DEC': 'YEAR', 'D': 'DAY', 'H': 'HOUR', 'M': 'MON', 'T': 'MIN', 'W': 'WEEK'}¶
- MISSING_RECORD = -902.0¶
- MISSING_VALUE = -901.0¶
- NAME_FREQ_MAP = {'DAY': 'D', 'HOUR': 'H', 'MIN': 'T', 'MON': 'M', 'WEEK': 'W', 'YEAR': 'A-DEC'}¶
- get_pathnames(catalog_dataframe=None)[source]¶
converts a catalog data frame into pathnames If catalog_dataframe is None then reads catalog to populate it
returns a list of pathnames (condensed version, i.e. D part is time window) /A PART/B PART/C PART/DPART (START DATE “-” END DATE)/E PART/F PART/
- get_version()[source]¶
Get version of DSS File returns a tuple of string version of 4 characters and integer version
- num_values_in_interval(edstr, istr)[source]¶
Get number of values in interval istr, using the start date and end date string
- read_catalog()[source]¶
Reads .dsd (condensed catalog) for the given dss file. Will run catalog if it doesn’t exist or is out of date
- read_its(pathname, startDateStr=None, endDateStr=None, guess_vals_per_block=10000)[source]¶
reads the entire irregular time series record. The timewindow is derived from the D-PART of the pathname so make sure to read that from the catalog before calling this function
- read_rts(pathname, startDateStr=None, endDateStr=None)[source]¶
read regular time series for pathname. if pathname D part contains a time window (START DATE “-” END DATE) and either start or end date is None it uses that to define start and end date
- timedelta_minutes = <numpy.vectorize object>¶
- write_its(pathname, df, cunits, ctype, interval=None)[source]¶
write irregular time series to the pathname.
The timewindow part of the pathname (D PART) is used to establish the base julian date for storage of the time values (minutes relative to that base julian date)
The interval is the block size to store irregular time series for efficient access interval values should be “IR-YEAR”, “IR-MONTH” or “IR-DAY”
Uses the provided pandas.DataFrame df index (time) and values and also stores the units (cunits) and type (ctype)
- pyhecdss.pyhecdss.get_matching_ts(filename, pathname=None, path_parts=None)[source]¶
Opens the DSS file and reads matching pathname or path parts
Args:
- Parameters
filename – DSS filename containing data
pathname – The DSS pathname A-F parts like string /A/B/C/D/E/F/ where A-F is either blank implying match all or a regular expression to be matched
or :param pathparts: if A-F regular expression contains the “/” character use the path_parts array instead
One of pathname or pathparts must be specified
- Returns
an generator of named tuples of DSSData ( data as dataframe, units as string, type as string one of INST-VAL, PER-VAL)
- pyhecdss.pyhecdss.get_start_end_dates(twstr, sep='-')[source]¶
Get the start and end date (as strings of format ddMMMyyyy,e.g. 01JAN1991) from timewindow string The start and end times must be separated by sep (default = ‘-’) and can be in any format that works with pandas to_datetime (see link below)
The returned start and end date are rounded down and up (respectively) to the day
- Args:
twstr (str): timewindow as string of the form that can be parsed by pd.to_datetime [https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.to_datetime.html]
- pyhecdss.pyhecdss.get_ts(filename, pathname)[source]¶
Gets regular time series matching the pathname from the filename. Opens and reads pathname from filename and then closes it (slightly inefficient)
filename: a path to DSS file pathname: a string of the form /A/B/C/D/E/F that is parsed to match all parts except D which if not blank is used to determine the time window to retrieve D should be specified in the format of ddMMMYYYY HHmm - ddMMMYYYY HHmm
a generator of named tuples DSSData(data=pandas DataFrame, units=units, period_type=period type) for timeseries found or an empty list
Assumes that all matching are Regular time series ( as opposed to Irregular, See DSS terminolog)
Get time series based on a part of pathname, e.g.
>>> pyhecdss.get_rts('test1.dss', '//SIN/////') [(rts,units,type),...]
- pyhecdss.pyhecdss.get_version(fname)[source]¶
Get version of DSS File returns a tuple of string version of 4 characters and integer version
pyhecdss.pyheclib module¶
- class pyhecdss.pyheclib.doubleArray(nelements: size_t)[source]¶
Bases:
object
- property thisown¶
The membership flag
- pyhecdss.pyheclib.fortranopen_(INPUT: int *, filename: char *, _filename_len: slen_t) → int[source]¶
- pyhecdss.pyheclib.hec_zgintl(intl: int *, chintl: char *, _chintl_len: slen_t, istat: int *) → int *, int *, int *[source]¶
- pyhecdss.pyheclib.hec_zinqir(ifltab: int *, cflg: char *, calpha: char *, inumb: int *) → char *[source]¶
- pyhecdss.pyheclib.hec_zritsxd(ifltab: int *, cpath: char *, juls: int *, istime: int *, jule: int *, ietime: int *, itimes: int *, dvalues: double *, inflag: int *) → int *, int *, char *, char *, int *[source]¶
- pyhecdss.pyheclib.hec_zrrtsxd(ifltab: int *, cpath: char *, cdate: char *, ctime: char *, numpyvalues: double *) → char *, char *, int *, int *[source]¶
- pyhecdss.pyheclib.hec_zsitsxd(ifltab: int *, cpath: char *, itimes: int *, dvalues: double *, ibdate: int *, cunits: char *, ctype: char *, inflag: int *) → int *[source]¶
- pyhecdss.pyheclib.hec_zsrtsxd(ifltab: int *, cpath: char *, cdate: char *, ctime: char *, numpyvalues: double *, cunits: char *, ctype: char *) → int *[source]¶
- class pyhecdss.pyheclib.intArray(nelements: size_t)[source]¶
Bases:
object
- property thisown¶
The membership flag