vtools.datastore.dss package¶
Submodules¶
vtools.datastore.dss.api module¶
vtools.datastore.dss.dss_catalog module¶
-
exception
DssCatalogError
(st='Error in cataloging dss file')¶ Bases:
exceptions.Exception
Exception tracking error happend in dss catalog operations
vtools.datastore.dss.dss_constants module¶
vtools.datastore.dss.dss_service module¶
-
exception
DssAccessError
¶ Bases:
exceptions.Exception
-
exception
DssCatalogServiceError
¶ Bases:
exceptions.Exception
-
class
DssService
¶ Bases:
vtools.datastore.service.Service
” Service to cataloging dss file, access and edit dss data
-
database_file_dir
= ''¶
-
db_file_use_number
= 0¶
-
dss_file_index_last
= 0¶
-
dss_file_index_used
= []¶
-
first_initialization
= True¶
-
has_dss_catalog_table
= False¶
-
identification
= 'vtools.datastore.dss.DssService'¶
-
load_record_property
(path, dparts, source)¶ This public sub should be only be called by dss catalog only, to load complete properties of a record.
path is in condenseded form and dparts is a tuple contain all the d parts of the record.
-
remove_dssfile_catalog
(dss_file_path)¶ remove all the catalog information about a dss file, this function can be used to reload catalog when it placed before a get_catalog function
-
static
serve
(source)¶
-
update_db
(dss_file_path)¶ update db record about dss file.
-
vtools.datastore.dss.utility module¶
Handy utility functions to read data from or save data to dss source.
-
dss_retrieve_ts
(dss_file, selector, time_window=None, unique=False, overlap=None)¶ Retrieve timeseries from a dss file based on the specified paths within a given time_window. usage: rt=retrieve_dss_data(dss_file,selector)
- input:
dss_file: path of dss file (relative or abs). selector: data record paths within dss file, might
be a single path, or a wildcard path.- time_window: time window of selection, can be string
- like “(10/1/1997 12:00, 2/14/2001 11:45)”, or tuple of datetime (start,end) or tuple of time string like (“10/1/1997 12:00”,”2/14/2001 11:45”). if not given, all data will be retrieved.
- overlap: a tuple, like (0,0),(0,1),(1,0),(1,1) or None
- This tuple set the option of retrieving a data just preceding or following time window early and late side for irregular timeseries (0,0): only retrieve data within time window (1,0): retrieve a data preceding time window early side in addition to data within (0,1): retrieve a data following time window late side in addition to data within (1,1): retrieve a data preceding and following in addition to data within If early or late sides exactly coincide with data point, the data preceding or following the earyl or late side will still be returned when the corresponding overlap is set. This behaviour is caused by HecDss interal API. dss service will raise ValueError if overlap is not None in reading regular timeseries.
- ouput:
- one or more time series if succeed.
-
dss_store_ts
(ts, dss_file, path)¶ - “
- Save a timeseris object into specficed path within a dss file.
- input:
- dss_file: path of dss file (relative or abs). path: a data record path within dss file. ts: a instance of timeseris class.
- ouput:
- None
-
dss_catalog
(dss_source, selection=None)¶ return catalog of a dss file.
-
visual_dss_format
(selection, write_times='all')¶ return a formatting string in dss style.
-
dss_delete_ts
(dssfile='', selection='')¶ delete selected time series from dss file.
-
is_valid_dss
(dss_file)¶ Decide if the string dss_file point to a valid dss file.
vtools.datastore.dss.vtime_dss_utility module¶
-
validate_rts_for_dss
(rt)¶ Validate the time and property of regualr time series for storage in dss.
-
string_to_dss_julian_date
(sdate)¶
-
dss_julian_date_to_string
(jdate, time_unit)¶ Jdate must be in minutes.
-
datetime_to_dss_julian_date
(dtime)¶ Convert a datetime to dss julian dates (start from 12/31/1899).
-
dss_rts_to_ts
(data, startdate, starttime, time_interval, iofset, prop=None, flags=None)¶ Convert dss file time seris into TimeSeries class. data: array of values startdate: start date of time windows desired as string conformed to dss style starttime: start time of time windows desired as string conformed to dss style time_interval: time interval of time windows desired as mintues conformed to dss style prop: dict save info get from dss func flags:list of data quality flag returned by zrrtx or zrrtsx
adjustment of startdatetime of regular time series with averaging aggreation setting: read from dss: starttime need to be move backward a interval store into dss: startime need to be move forward a interval
-
dss_its_to_ts
(data, jbdate, itimes, prop, flags)¶ Convert dss irregular time series into TimeSeries class. data: list of raw data returned by zrits or zritsx jbadte: integer dss base date returned by zrits or zritsx itimes: offset list in minutes from base date for each time point
it is also generated by zritx or zritsxprop: dict save info get from dss func flags: list of data quality flag returned by zritx or zritsx
-
validate_its_for_dss
(irrts)¶ Validate parameters and create input necessary for a its to store in dss.
-
discover_valid_rts_start
(data, start, interval)¶ given the rts data seq., which may contain empty data markers (e.g. -902) at begin or end, find out the datetime of first valid number and return. start, and interval must be datetime and timedelta respectively.
-
discover_valid_rts_end
(data, start, interval)¶ given the rts data seq., which may contain continous invalid dss number at begin or end of sequence, find out the datetime of last valid number and return. start, and interval must be datetime and timedelta respectively.
-
dss_julian2python
(jbdate, itime)¶
-
uncondensed_Dparts
(interval_str, start_str, end_str)¶ ” Generates list of uncondensed D parts according to star, end of block and interval
interval_str is Epart,start_str is a Dpart