gwsumm.state package¶
Submodules¶
Module contents¶
A SummaryState defines a sub-set of time over which a ~gwsumm.tabs.Tab should be processed. Each SummaryState is normally tied to one or more data-quality flags marking times during which each of the LIGO instruments was operating in a certain configuration, or was subject to a known noise interference.
The state registry¶
GWSumm defines a state ‘registry’, simply a record of all SummaryState objects that have been defined (and registered) so far in a given program. The registry just makes remembering states in complicated programs a little easier.
Any SummaryState can be registered with an arbitrary name as follows:
>>> from gwsumm.state.registry import register_state
>>> register_state(mystate, 'my state')
and can be recovered later:
>>> from gwsumm.state.registry import get_state
>>> mystate = get_state('my state')
API reference¶
|
An operating state over which to process a ~gwsumm.tabs.DataTab. |
|
Query the registry for the SummaryState registered to the given key |
|
Query the registry for a list of states (defaults to all) |
|
Register a new SummaryState to the given |
- class gwsumm.state.SummaryState(name, known=[], active=[], description=None, definition=None, hours=None, key=None, filename=None, url=None)[source]¶
Bases:
DataQualityFlag
An operating state over which to process a ~gwsumm.tabs.DataTab.
- Parameters:
- namestr
name for this state
- known~gwpy.segments.SegmentList, optional
list of known segments
- active~gwpy.segments.SegmentList, optional
list of active segments
- descriptionstr, optional
text describing what this state means
- definitionstr, optional
logical combination of flags that define known and active segments for this state (see :attr:`documentation <SummaryState.definition>` for details)
- keystr, optional
registry key for this state, defaults to :attr:`~SummaryState.name`
- MATH_DEFINITION = re.compile('(<|<=|=|>=|>|==|!=)')¶
- copy()[source]¶
Build an exact copy of this flag.
- Returns:
- flag2DataQualityFlag
a copy of the original flag, but with a fresh memory address.
- property definition¶
The combination of data-quality flags that define this SummaryState
For example:
>>> state = SummaryState(definition='L1:DMT-SCIENCE:1')
would define a SummaryState based on the validity and activity of the single flag
'L1:DMT-SCIENCE:1'
(the science-mode flag for the LIGO Livingston Observatory interferometer). Similarly:>>> state = SummaryState( definition='L1:DMT-SCIENCE:1&!L1:DMT-LIGHTDIP_10_PERCENT:1')
would define a SummaryState as active when the
'L1:DMT-SCIENCE:1'
flag was active and the'L1:DMT-LIGHTDIP_10_PERCENT:1'
flag was not active.The following logical identifiers are acceptable:
&
Union (i.e. flag1 and flag2 must be active)
|
Intersection (i.e. flag1 or flag2 must be active)
&!
One-sided difference (i.e. flag1 is active and flag2 is notactive)
!=
Two-sided difference (i.e. flag1 is active and flag2 is not ORflag2 is active and flag2 is not)
- Type:
- property end¶
GPS end time of this state’s validity
- fetch(config=<GWSummConfigParser()>, segmentcache=None, segdb_error='raise', datacache=None, datafind_error='raise', nproc=1, nds=None, **kwargs)[source]¶
Finalise this state by fetching its defining segments, either from global memory, or from the segment database
- classmethod from_ini(config, section)[source]¶
Create a new SummaryState from a section in a ConfigParser.
- Parameters:
- config:class:`~gwsumm.config.GWConfigParser`
customised configuration parser containing given section
- sectionstr
name of section to parse
- Returns:
- SummaryState
a new state, with attributes set from the options in the configuration
- property key¶
The registry key for this SummaryState.
- Type:
str
- property name¶
Name of this state
- property start¶
GPS start time of this state’s validity.
- property tag¶
File tag for images generated using this state
- gwsumm.state.generate_all_state(start, end, register=True, **kwargs)[source]¶
Build a new SummaryState for the given [start, end) interval.
- Parameters:
- start~gwpy.time.LIGOTimeGPS, float
the GPS start time of the current analysis
- end~gwpy.time.LIGOTimeGPS, float
the GPS end time of the current analysis
- registerbool, optional
should the new SummaryState be registered, default True
- **kwargs
other keyword arguments passed to the SummaryState constructor
- Returns:
- allstateSummaryState
the newly created ‘All’ SummaryState
- gwsumm.state.get_state(key)[source]¶
Query the registry for the SummaryState registered to the given key
- Parameters:
- keystr
registered key of desired SummaryState. This may not match the ~SummaryState.name attribute` if the state was registered with a different key.
- Returns:
- stateSummaryState
the SummaryState registered with the given key
- Raises:
- ValueError:
if the
key
doesn’t map to a registered SummaryState
- gwsumm.state.get_states(keys={})[source]¶
Query the registry for a list of states (defaults to all)
- Parameters:
- keysset of str
the set of state keys to query in the registry
- Returns:
- statesdict
a dict of (
key
, SummaryState) pairs
- Raises:
- ValueError:
if any of the
keys
doesn’t map to a registered SummaryState
- gwsumm.state.register_state(state, key=None, force=False)[source]¶
Register a new SummaryState to the given
key
- Parameters:
- stateSummaryState
defining Class for this state type.
- keystr, optional
unique descriptive name for the SummaryState to be registered. If
key=None
, the :attr:`~SummaryState.key` attribute of the given state will be used.- forcebool
overwrite existing registration for this key
- Raises:
- ValueError
if key is already registered and
force
not given as True