Convert dark_id (YYYYDOY) to the corresponding DateTime ‘date’ format.
| Parameters: | date – dark id (YYYYDOY) |
|---|---|
| Returns: | str in DateTime ‘date’ format |
Return the multiplicative scale factor to convert a CCD dark map from the actual temperature t_ccd to the reference temperature t_ccd_ref.
Based on best global fit for dark current model in plot_predicted_warmpix.py. Previous value was 0.62 instead of 0.70. This represents the change in dark current for each 4 degC decrease:
>>> from mica.archive.aca_dark import temp_scalefac
>>> print temp_scalefac(t_ccd=-15, t_ccd_ref=-19)
0.7
| Parameters: |
|
|---|---|
| Returns: | scale factor |
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: | astropy Table or list 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 |
Routines related to the dark current model and guide / acq success prediction.
Calculate probability of acquisition success for a star with mag magnitude and a CCD warm fraction warm_frac. Uses the empirical relation:
P_acq_success = offset(mag) + scale(mag) * warm_frac
In ../guide_acq_success/plot_acq_success.py we find the best fit relation:
log10(scale) = 0.185 + 0.990 * (mag - 10) + -0.491 * (mag - 10)**2 log10(offset) = -1.489 + 0.888 * (mag - 10) + 0.280 * (mag - 10)**2
Return probability of acquisition success for given date, temperature and mag.
Any of the inputs can be scalars or arrays, with the output being the result of the broadcasted dimension of the inputs.
This is based on the dark model and acquisition success fitting presented in the State of the ACA 2013 (sot/state_of_aca/guide_acq_stats)
| Parameters: |
|
|---|---|
| Returns: | Acquisition success probability(s) |
Return the dark current histogram corresponding to date and t_ccd.
| Parameters: |
|
|---|---|
| Returns: | bin_centers, bins, darkhist |
Return the dark current model corresponding to date and t_ccd.
| Parameters: |
|
|---|---|
| Returns: | TBD |
Return probability of guide (bad_trak) success for given date, temperature and mag.
Any of the inputs can be scalars or arrays, with the output being the result of the broadcasted dimension of the inputs.
This is based on the dark model and guide success fitting presented in the State of the ACA 2013 (sot/state_of_aca/guide_acq_stats)
| Parameters: |
|
|---|---|
| Returns: | Guide success probability(s) |
Return smooth broken powerlaw parameters at date. This is based on the sbp fits for the darkhist_peaknorm histograms, with parameters derived from by-hand inspection of fit trending. See NOTES.
Smoothed broken power-law. Pars are same as bpl1d (NOT + gaussian sigma): 1: gamma1 2: gamma2 3: x_b (break point) 4: x_r (normalization reference point) 5: ampl1 # NOT 6: sigma (bins)
Return the multiplicative scale factor to convert a CCD dark map from the nominal -19C temperature to the temperature T. Based on best global fit for dark current model in plot_predicted_warmpix.py. Previous value was 0.62 instead of 0.70.
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 |
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 |