Convert dark_id (YYYYDOY) to the corresponding DateTime ‘date’ format.
Parameters: | date – dark id (YYYYDOY) |
---|---|
Returns: | str in DateTime ‘date’ format |
Convert date to the corresponding YYYYDOY format for a dark cal identifiers.
Parameters: | date – any DateTime compatible format |
---|---|
Returns: | dark id (YYYYDOY) |
Get an ordered dict of directory paths containing dark current calibration files, where the key is the dark cal identifier (YYYYDOY) and the value is the path.
Parameters: | source – source of dark cal directories (‘mica’|’ska’) |
---|---|
Returns: | ordered dict of absolute directory paths |
Return the dark calibration id corresponding to date.
If select is 'before' (default) then use the first calibration which occurs before date. Other valid options are 'after' and 'nearest'.
Parameters: |
|
---|---|
Returns: | dark cal id string (YYYYDOY) |
Return the dark calibration image (e-/s) nearest to date.
If select is 'before' (default) then use the first calibration which occurs before date. Other valid options are 'after' and 'nearest'.
Parameters: |
|
---|---|
Returns: | 1024 x 1024 ndarray with dark cal image in e-/s |
Return a dark calibration properties structure for date
If select is 'before' (default) then use the first calibration which occurs before date. Other valid options are 'after' and 'nearest'.
If include_image is True then an additional column or key image is defined which contains the corresponding 1024x1024 dark cal image.
Parameters: |
|
---|---|
Returns: | dict of dark calibration properties |
Return a table of dark calibration properties between start and stop.
If include_image is True then an additional column or key image is defined which contains the corresponding 1024x1024 dark cal image.
If as_table is True (default) then the result is an astropy Table object. If False then a list of dicts is returned. In this case the full contents of the properties file including replica properties is available.
Parameters: |
|
---|---|
Returns: | astropy Table or list of dark calibration properties |
Get the best estimate of CCD temperature between tstart and tstop
Parameters: |
|
---|
Get the dark cal ID in the Ska dark current files corresponding to date. It is assumed the dark cal dirs are labeled by YYYYDOY within root.
This routine allows for plus/minus one day of slop.
Parameters: | date – Date of dark cal |
---|---|
Returns: | str in yeardoy format |
Experimental/alpha code to work with ACA L0 Header 3 data
ACA header 3 data object to work with header 3 data from available 8x8 ACA L0 telemetry:
>>> from mica.archive import aca_hdr3
>>> ccd_temp = aca_hdr3.MSID('ccd_temp', '2012:001', '2012:020')
>>> type(ccd_temp.vals)
'numpy.ma.core.MaskedArray'
When given an msid and start and stop range, the object will query the ACA L0 archive to populate the object, which includes the MSID values (vals) at the given times (times).
The parameter msid_data is used to create an MSID object from the data of another MSID object.
When filter_bad is supplied then only valid data values are stored and the vals and times attributes are np.ndarray instead of ma.MaskedArray.
Parameters: |
|
---|
ACA header 3 data object to work with header 3 data from available 8x8 ACA L0 telemetry. An MSIDset works with multiple MSIDs simultaneously.
>>> from mica.archive import aca_hdr3
>>> perigee_data = aca_hdr3.MSIDset(['ccd_temp', 'aca_temp', 'dac'],
... '2012:001', '2012:030')
Parameters: |
|
---|
For a the given parameters, retrieve telemetry and construct a masked array of the MSIDs available in that telemetry.
>>> from mica.archive import aca_l0
>>> slot_data = aca_l0.get_slot_data('2012:001', '2012:002', slot=7)
>>> temp_ccd_8x8 = aca_l0.get_slot_data('2005:001', '2005:010',
... slot=6, imgsize=[8],
... columns=['TIME', 'TEMPCCD'])
Parameters: |
|
---|---|
Returns: | data structure for slot |
Return type: | numpy masked recarray |
Retrieve list of files from ACA0 archive lookup table that match arguments. The database query returns files with
tstart < stop and tstop > start
which returns all files that contain any part of the interval between start and stop. If the obsid argument is provided, the archived obspar tstart/tstop (sybase aca.obspar table) are used.
>>> from mica.archive import aca_l0
>>> obsid_files = aca_l0.get_files(obsid=5438)
>>> time_files = aca_l0.get_files(start='2012:001', stop='2012:002')
>>> time_8x8 = aca_l0.get_files(start='2011:001', stop='2011:010',
... imgsize=[8])
Parameters: |
|
---|---|
Returns: | interval files |
Return type: | list |
Get ACA L0 images for the given start and stop times and the given slot. Optionally filter on image size via imgsize or change the default image metadata via columns.
>>> from mica.archive import aca_l0
>>> imgs = aca_l0.get_l0_images('2012:001', '2012:002', slot=7)
>>> imgs = aca_l0.get_l0_images('2005:001', '2005:002', slot=6, imgsize=[8])
The default columns are: [‘TIME’, ‘IMGROW0’, ‘IMGCOL0’, ‘BGDAVG’, ‘IMGSTAT’, ‘IMGFUNC1’, ‘IMGSIZE’, ‘INTEG’]
The image pixel values are given in units of DN. One can convert to e-/sec by multiplying by (5 / INTEG).
Parameters: |
|
---|---|
Returns: | list of ACAImage objects |
Script to update Ska file archive aspect L1 products. Module also provides methods to retrieve the directory (or directories) for an obsid.
This uses the obsid_archive module with a configuration specific to the aspect L1 products.
List asp_l1 files for an obsid or a time range.
>>> from mica.archive import asp_l1
>>> obs_files = asp_l1.get_files(6000)
>>> obs_gspr = asp_l1.get_files(6000, content=['GSPROPS'])
>>> range_fidpr = asp_l1.get_files(start='2012:001',
... stop='2012:030',
... content=['FIDPROPS'])
Parameters: |
|
---|---|
Returns: | full path of files matching query |
Get ASP L1 directory for default/released products for an obsid.
>>> from mica.archive import asp_l1
>>> asp_l1.get_dir(2121)
'/data/aca/archive/asp1/02/02121'
Parameters: | obsid – obsid |
---|---|
Returns: | directory |
Return type: | string |
Get all ASP L1 directories for an obsid in the Ska file archive.
>>> from mica.archive import asp_l1
>>> obsdirs = asp_l1.get_obs_dirs(6000)
obsdirs will look something like:
{'default': '/data/aca/archive/asp1/06/06000',
2: '/data/aca/archive/asp1/06/06000_v02',
3: '/data/aca/archive/asp1/06/06000_v03',
'last': '/data/aca/archive/asp1/06/06000',
'revisions': [2, 3]}
Parameters: | obsid – obsid |
---|---|
Returns: | map of obsid version to directories |
Return type: | dictionary |
Base Class used in mica.archive.asp_l1 and mica.archive.obspar
Generalized module for fetching and archiving obsid-organized telemetry such as asp_l1 and obspar products.
Object to store configuration, logging, and processing tasks to fetch obsid telemetry from the CXC archive and store in a Ska file archive, while logging the archive files to a file lookup database.
The configuration dictionary config may have these key/values:
(example /data/aca/archive/asp1)
telemetry
ignored when in regular update mode
cols: headers that will be included in file lookup table
sql_def: sql file to build file lookup archfiles table
new processing (by id)
processing id
label: label of product type for log messages
(example asp1{fidprops}). This will be retrieved with “get %s” % config[‘small’] and the retrieved files will be used to determine product version.
“get %s” % config[small] (example ‘fidpr‘)
retrieved files (example ‘pacdfd+N(d{3})_’)
full: arc5gl keyword for products (example ‘asp1’)
from obsid 1.
Parameters: | config – configuration dictionary |
---|---|
Returns: | ObsArchive instance |
Read obspar and add ‘obsid’ and ‘filename’ keys to the dictionary i and archfiles are just passed to make the logging prettier.
Retrieve telemetry for an observation from the CXC archive and store in the Ska file archive.
Parameters: |
|
---|---|
Returns: | obsid directory in Ska file archive |
Return type: | directory string |
Get information for a file for the file lookup table/database. For obspars, call the get_obspar_info() method. For FITS files, call get_fits_info() method.
Return the latest released directory for an obsid Return None if there are no ‘default’ / released products.
Determine the version/revision of a set of archived files from their file names.
Parameters: |
|
---|---|
Returns: | version number |
Return type: | integer |
Read FITS file f with index i (position within list of filenames archfiles) and get dictionary of values to store in file lookup database. This values include all header key/value pairs with keys in config[cols] plus the header checksum, the filename, the year, and day-of-year.
Parameters: |
|
---|---|
Returns: | info for a file |
Return type: | dictionary |
Return a dictionary of the directories available for an obsid. This is just done with a glob in the data directories.
Wrap get_all_obspar_info() and just include columns in config[‘cols’]
Return a list of all of the *_last directories in the file archive (and specify revision=default to attempt to get new released products for them).
Determine the version number associated with the current released products or with the products referenced by “version=last”.
Parameters: |
|
---|---|
Returns: | version |
Return type: | integer |
Set environment included an arc5gl handle and and a handle to the axafapstat database
Set environment included an arc5gl handle and and a handle to the axafapstat database
Create links in the obsid data directories to make it easy to find the current ‘default’/released data, all versions that have been archived, and the ‘last’/unreleased/provisional data if available.
This is designed so that if obsid 5 has released data in version 1 and provisional data in version 2, that the directories and links will look like:
directory 00005_v01 directory 00005_v02 link 00005 -> 00005_v01 link 00005_last -> 00005_v02
Script to update Ska file archive obspars. Module also provides methods to retrieve the directory (or directories) for an obsid.
This uses the obsid_archive module with a configuration specific to the obspar products.
Get obspar directory for default/released products for an obsid.
>>> from mica.archive import obspar
>>> obspar.get_dir(2121)
'/data/aca/archive/obspar/02/02121'
Parameters: | obsid – obsid |
---|---|
Returns: | directory |
Return type: | string |
Get all obspar directories for an obsid in the Ska file archive.
>>> from mica.archive import obspar
>>> obsdirs = obspar.get_obs_dirs(6000)
obsdirs will look something like:
{'default': '/data/aca/archive/obspar/06/06000',
2: '/data/aca/archive/obspar/06/06000_v02',
3: '/data/aca/archive/obspar/06/06000_v03',
'last': '/data/aca/archive/obspar/06/06000',
'revisions': [2, 3]}
Parameters: | obsid – obsid |
---|---|
Returns: | map of obsid version to directories |
Return type: | dictionary |
Retrieve V&V data for an obsid/version. This reads the saved JSON and returns the previously- calculated V&V data.
Parameters: |
|
---|---|
Returns: | dict of V&V data |
Get directory containing V&V products for a requested obsid/version, including plots and json.
Parameters: |
|
---|---|
Returns: | directory name for obsid/version |
Get list of V&V files available for a requested obsid/version.
Parameters: |
|
---|---|
Returns: | list of files |
Retrieve/return all data from RMS trending H5 archive
Returns: | numpy array of RMS data for each star/obsid/version |
---|
Given obsid and version, find archived ASP1 and obspar products and run V&V. Effort is made to find the obspar that was actually used during creation of the ASP1 products.
Parameters: |
|
---|---|
Returns: | mica.vv.Obi V&V object |
Return timeline that contains a given date. The ‘timeline_loads’ query is used to give the mp_dir as well as datestart and datestop for the timeline.
Parameters: |
|
---|---|
Returns: | dictionary of appropriate record from timeline_loads table |
For a given obsid, return a dictionary describing the starcheck catalog that should apply. The content of that dictionary is from the database tables of that parsed the starcheck report and has keys:
Status:
Parameters: |
|
---|---|
Returns: | dictionary with starcheck content described above |
For a given date, return a dictionary describing the starcheck catalog that should apply. The content of that dictionary is from the database tables that parsed the starcheck report. A catalog is defined as applying, in this function, to any time from the end of the previous dwell through the end of the dwell in which the catalog was used.
Star catalog dictionary with keys:
Status:
Parameters: |
|
---|---|
Returns: | dictionary with starcheck content described above |
Get the mission planning directory for an obsid and some status information. If the obsid catalog was used more than once (multi-obi or rescheduled after being used in a vehicle-only interval), return the directory and details of the last one used on the spacecraft.
The returned directory describes the directory that was used for the products with this star catalog. The returned status has possible values:
The return ‘date’ is the date/time of the MP_STARCAT time.
Parameters: |
|
---|---|
Returns: | directory, status, date . Described above. |
Use the database of starcheck products to get a list of monitor windows This list is filtered by timelines content to only include catalogs that should have or will run.
Parameters: |
|
---|---|
Returns: | astropy Table of monitor windows. See get_starcheck_catalog_at_date for description of the values of the ‘status’ column. The ‘catalog’ column contains the get_starcheck_catalog_at_date returned dictionary. |