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'}
catalog()[source]

Catalog DSS Files

close()[source]

Close DSS File

get_epart_from_freq()[source]
get_freq_from_epart()[source]
get_number_and_frequency_from_epart()[source]
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

julian_day(date)[source]

get julian day for the date. (count of days since beginning of year)

m2ihm(minute)[source]

24 hour style from mins

num_values_in_interval(edstr, istr)[source]

Get number of values in interval istr, using the start date and end date string

open()[source]

Open DSS file

parse_pathname_epart(pathname)[source]
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)

write_rts(pathname, df, cunits, ctype)[source]

write time series to this DSS file with the given pathname. The time series is passed in as a pandas DataFrame and associated units and types of length no greater than 8.

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.pyhecdss.set_message_level(level)[source]

set the verbosity level of the HEC-DSS library level ranges from “bort” only (level 0) to “internal” (level >10)

pyhecdss.pyhecdss.set_program_name(program_name)[source]

sets the name of the program (upto 6 chars long) to store with data

pyhecdss.pyheclib module

pyhecdss.pyheclib.copy_doublep(value: double)double *[source]
pyhecdss.pyheclib.copy_intp(value: int)int *[source]
pyhecdss.pyheclib.delete_doublep(obj: double *)void[source]
pyhecdss.pyheclib.delete_intp(obj: int *)void[source]
class pyhecdss.pyheclib.doubleArray(nelements: size_t)[source]

Bases: object

cast()double *[source]
static frompointer(t: double *)doubleArray *[source]
property thisown

The membership flag

pyhecdss.pyheclib.doubleArray_frompointer(t: double *)doubleArray *[source]
pyhecdss.pyheclib.doublep_assign(obj: double *, value: double)void[source]
pyhecdss.pyheclib.doublep_value(obj: double *)double[source]
pyhecdss.pyheclib.fortranclose_(INPUT: int *)int[source]
pyhecdss.pyheclib.fortranflush_(INPUT: int *)void[source]
pyhecdss.pyheclib.fortranopen_(INPUT: int *, filename: char *, _filename_len: slen_t)int[source]
pyhecdss.pyheclib.hec_datjul(cdate: char *)int *, int *[source]
pyhecdss.pyheclib.hec_zfver(cfname: char *)char *, 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_zopen(ifltab: int *, cfname: char *)int *[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_zset(cflg: char *, cstr: char *, numb: int *)void[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

cast()int *[source]
static frompointer(t: int *)intArray *[source]
property thisown

The membership flag

pyhecdss.pyheclib.intArray_frompointer(t: int *)intArray *[source]
pyhecdss.pyheclib.intp_assign(obj: int *, value: int)void[source]
pyhecdss.pyheclib.intp_value(obj: int *)int[source]
pyhecdss.pyheclib.new_doublep()double *[source]
pyhecdss.pyheclib.new_intp()int *[source]
pyhecdss.pyheclib.zcat_(ifltab: int *, icunit: int *, icdunt: int *, inunit: int *, cinstr: char *, labrev: int *, ldosrt: int *, lcdcat: int *, norecs: int *, _cinstr_len: slen_t)void[source]
pyhecdss.pyheclib.zclose_(ifltab: int *)void[source]

Module contents