Utilities for the engineering archive.
Estimate the memory size required to fetch the msids between start and stop. This is generally intended for limiting queries to be less than ~100 Mb and allows for making some assumptions for improved performance (see below).
Returns a tuple of the estimated megabytes of memory for the raw fetch and megabytes for the final output (which is different only in the case of interpolating). This is done by fetching 3 days of telemetry (2010:001 to 2010:004) and scaling appropriately.
If fast is True (default) then if either of the conditions below apply a result of (-1, -1) is returned, indicating that the fetch will probably be less than ~100 Mb and should be OK. (This does not account for the number of MSIDs passed in msids).
- Fetch duration (stop - start) is less than 30 days
- Fetch stat is ‘5min’ or ‘daily’
Parameters: |
|
---|---|
Returns: | fetch_Mb, interpolated_Mb |
Determine contiguous intervals during which bools is True.
If complete_intervals is True (default) then the intervals are guaranteed to be complete so that the all reported intervals had a transition before and after within the telemetry interval.
If max_gap is specified then any time gaps longer than max_gap are filled with a fictitious False value to create an artificial interval boundary at max_gap / 2 seconds from the nearest data value.
Returns an astropy Table with a row for each interval. Columns are:
Example (find SCS107 runs via telemetry):
>>> from Ska.engarchive import utils, fetch
>>> dat = fetch.Msidset(['3tscmove', 'aorwbias', 'coradmen'], '2012:190', '2012:205')
>>> dat.interpolate(32.8) # Sample MSIDs onto 32.8 second intervals (like 3TSCMOVE)
>>> scs107 = ((dat['3tscmove'].vals == 'T')
& (dat['aorwbias'].vals == 'DISA')
& (dat['coradmen'].vals == 'DISA'))
>>> scs107s = utils.logical_intervals(dat.times, scs107)
>>> print scs107s['datestart', 'datestop', 'duration']
datestart datestop duration
--------------------- --------------------- -------------
2012:194:20:00:31.652 2012:194:20:04:21.252 229.600000083
2012:196:21:07:36.452 2012:196:21:11:26.052 229.600000083
2012:201:11:45:46.852 2012:201:11:49:36.452 229.600000083
Parameters: |
|
---|---|
Returns: | Table of intervals |
Calculate vector to Earth, Sun, or Moon in Chandra body coordinates between start and stop dates at 5 minute (328 sec) intervals.
The return value in a NumPy structured array table (see below) which contains the distance in km from Chandra to the the solar system object along with the corresponding direction vectors in Chandra body coordinates and in the ECI frame. For convenience the attitude quaternion components are also provided.
Output table columns:
Example:
from Ska.engarchive.utils import ss_vector
from Ska.Matplotlib import plot_cxctime
vec = ss_vector('2010:001', '2010:030', obj='Sun')
figure(1)
clf()
subplot(2, 1, 1)
plot_cxctime(vec['times'], vec['body_x'], '-b')
plot_cxctime(vec['times'], vec['body_y'], '-r')
plot_cxctime(vec['times'], vec['body_z'], '-g')
subplot(2, 1, 2)
plot_cxctime(vec['times'], vec['distance'])
Parameters: |
|
---|---|
Returns: | table of vector values |
Determine contiguous intervals during which the vals is unchanged.
Returns an Astropy Table with a row for each interval. Columns are:
Example:
>>> from Ska.engarchive import fetch, utils
>>> dat = fetch.Msid('cobsrqid', '2010:003', '2010:004')
>>> obsids = utils.state_intervals(dat.times, dat.vals)
>>> print obsids['datestart', 'datestop', 'val']
datestart datestop val
--------------------- --------------------- -------
2010:003:12:00:00.976 2010:004:09:07:44.180 11011.0
2010:004:09:07:44.180 2010:004:09:40:52.680 56548.0
2010:004:09:40:52.680 2010:004:12:00:00.280 12068.0
Parameters: |
|
---|---|
Returns: | structured array table of intervals |