EfdClient¶
-
class
lsst_efd_client.
EfdClient
(efd_name, db_name='efd', port='443', internal_scale='tai', path_to_creds='~/.lsst/notebook_auth.yaml')¶ Bases:
object
Class to handle connections and basic queries
Parameters: - efd_name :
str
Name of the EFD instance for which to retrieve credentials.
- db_name :
str
, optional Name of the database within influxDB to query (‘efd’ by default).
- port :
str
, optional Port to use when querying the database (‘443’ by default).
- internal_scale :
str
, optional Time scale to use when converting times to internal formats (‘tai’ by default).
- path_to_creds :
str
, optional Absolute path to use when reading credentials from disk (‘~/.lsst/notebook_auth.yaml’ by default).
Attributes Summary
deployment
influx_client
The aioinflux.client.InfluxDBClient
used for queries.subclasses
Methods Summary
build_time_range_query
(topic_name, fields, …)Build a query based on a time range. from_name
(efd_name, *args, **kwargs)Construct a client for the specific named subclass. get_fields
(topic_name)Query the list of field names for a topic. get_topics
()Query the list of possible topics. select_packed_time_series
(topic_name, …[, …])Select fields that are time samples and unpack them into a dataframe. select_time_series
(topic_name, fields, …)Select a time series for a set of topics in a single subsystem select_top_n
(topic_name, fields, num[, index])Select the most recent N samples from a set of topics in a single subsystem. Attributes Documentation
-
deployment
= ''¶
-
influx_client
= None¶ The
aioinflux.client.InfluxDBClient
used for queries.This should be used to execute queries not wrapped by this class.
-
subclasses
= {}¶
Methods Documentation
-
build_time_range_query
(topic_name, fields, start, end, is_window=False, index=None)¶ Build a query based on a time range.
Parameters: - topic_name :
str
Name of topic for which to build a query.
- fields :
str
orlist
Name of field(s) to query.
- start :
astropy.time.Time
Start time of the time range, if
is_window
is specified, this will be the midpoint of the range.- end :
astropy.time.Time
orastropy.time.TimeDelta
End time of the range either as an absolute time or a time offset from the start time.
- is_window :
bool
, optional If set and the end time is specified as a
TimeDelta
, compute a range centered on the start time (default isFalse
).- index :
int
, optional For indexed topics set this to the index of the topic to query (default is
None
).
Returns: - query :
str
A string containing the constructed query statement.
- topic_name :
-
from_name
(efd_name, *args, **kwargs)¶ Construct a client for the specific named subclass.
Parameters: - efd_name :
str
Name of the EFD instance for which to construct a client.
- *args
Extra arguments to pass to the subclass constructor.
- **kwargs
Extra keyword arguments to pass to the subclass constructor.
Raises: - NotImpementedError
Raised if there is no subclass corresponding to the name.
- efd_name :
-
get_fields
(topic_name)¶ Query the list of field names for a topic.
Parameters: - topic_name :
str
Name of topic to query for field names.
Returns: - results :
list
List of field names in specified topic.
- topic_name :
-
get_topics
()¶ Query the list of possible topics.
Returns: - results :
list
List of valid topics in the database.
- results :
-
select_packed_time_series
(topic_name, base_fields, start, end, is_window=False, index=None, ref_timestamp_col='cRIO_timestamp')¶ Select fields that are time samples and unpack them into a dataframe.
Parameters: - topic_name :
str
Name of topic to query.
- base_fields :
str
orlist
Base field name(s) that will be expanded to query all vector entries.
- start :
astropy.time.Time
Start time of the time range, if
is_window
is specified, this will be the midpoint of the range.- end :
astropy.time.Time
orastropy.time.TimeDelta
End time of the range either as an absolute time or a time offset from the start time.
- is_window :
bool
, optional If set and the end time is specified as a
TimeDelta
, compute a range centered on the start time (default isFalse
).- index :
int
, optional For indexed topics set this to the index of the topic to query (default is
False
).- ref_timestamp_col :
str
, optional Name of the field name to use to assign timestamps to unpacked vector fields (default is ‘cRIO_timestamp’).
Returns: - result :
pandas.DataFrame
A
pandas.DataFrame
containing the results of the query.
- topic_name :
-
select_time_series
(topic_name, fields, start, end, is_window=False, index=None)¶ Select a time series for a set of topics in a single subsystem
Parameters: - topic_name :
str
Name of topic to query.
- fields :
str
orlist
Name of field(s) to query.
- start :
astropy.time.Time
Start time of the time range, if
is_window
is specified, this will be the midpoint of the range.- end :
astropy.time.Time
orastropy.time.TimeDelta
End time of the range either as an absolute time or a time offset from the start time.
- is_window :
bool
, optional If set and the end time is specified as a
TimeDelta
, compute a range centered on the start time (default isFalse
).- index :
int
, optional For indexed topics set this to the index of the topic to query (default is
None
).
Returns: - result :
pandas.DataFrame
A
pandas.DataFrame
containing the results of the query.
- topic_name :
-
select_top_n
(topic_name, fields, num, index=None)¶ Select the most recent N samples from a set of topics in a single subsystem. This method does not guarantee sort direction of the returned rows.
Parameters: Returns: - result :
pandas.DataFrame
A
pandas.DataFrame
containing teh results of the query.
- result :
- efd_name :