Package invocations :: Package cu8 :: Module cu8 :: Class Cu8
[hide private]

Class Cu8

source code


Updates the photometric zero-point values in FITS files and in the database, from the values provided in the CASU-supplied calibration table file if specified with -m/--manual option otherwise a global solution to all data is applied (not implemented yet!).

Nested Classes [hide private]
    Nested Errors and Exceptions

Inherited from wsatools.DbConnect.CuSession.CuSession: CuError

Instance Methods [hide private]
 
_onRun(self)
Run CU8
source code
 
_onException(self)
Report warning count if CU8 is interrupted.
source code
bool
_calibrateZeroPoint(self)
Calculates new zero-point values that can be used by CU8 to recalibrate data in the database.
source code
 
_determineVersionNumber(self)
Looks in table PhotCalVers for the previous recalibration version number and increments.
source code
 
_oldZPDict(self, intStkZPs, multiframeID)
?
source code
 
_parseSchemas(self)
Parses WSA_MultiframeSchema.sql to determine MultiframeDetector and PreviousMFDZP table attributes.
source code
 
_propagateChanges(self, mfID, newZPDict, oldZPInfo) source code
 
_updatePhotCalVers(self)
Updates end date of last recalibration version entry in table PhotCalVers and inserts details for new recalibration version.
source code
list(tuple(str, dict)) INCORRECT!
_parseCalibTableFile(self, tablePathName)
Convert calibration table file to a dictionary of useful entities.
source code
 
_getDict(self, fitsName, infoArray)
Produces dictionary of FITS updates from table.
source code
 
_addHistory(self, historyPhrase, header, numSpareKeys)
Update the FITS header to consolidate previous CASU HISTORY cards, and to add in a new HISTORY card with supplied details.
source code
 
_deprecateKeywords(self, pHeader)
Remove misplaced keys from the primary header and update HISTORY card.
source code
 
_getAttr(self, kywrd, infoArray, row) source code
 
_requiresUpdate(self, header)
Tests whether a FITS header has already been updated with the latest recalibration values.
source code
int
_shrinkHistory(self, header)
Consolidates previous CASU HISTORY cards into a smaller amount of header space, to help prevent the creation of new header blocks.
source code
 
_updateArchive(self, mfID, extNums, tables, zpValues)
Updates the database multiframe entry for the new zero-point values, copying the old values into the PreviousMFDZP table.
source code
 
_updateSynopticSource(self, photTable, deltaZP, shortName, mfID, extNum)
?
source code
 
_updateFiles(self, calibList)
WRITE SOMETHING HERE
source code
 
_updateCatalogueFile(self, catPathName, zpValues)
WRITE SOMETHING HERE
source code
 
_updateImageFile(self, imgPathName, zpValues)
WRITE SOMETHING HERE
source code
 
_updateKeywords(self, header, extNum, zpValues)
Update keywords for latest recalibration values and update HISTORY card.
source code

Inherited from wsatools.DbConnect.CuSession.CuSession: __del__, __init__, logBrokenFile, run

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods [hide private]

Inherited from wsatools.DbConnect.CuSession.CuSession: logException

Class Variables [hide private]
  cuNum = 8
Curation task number.
  calibKeys = [('MAGZPT', 'Photometric ZP (mags) for default ext...
  maxDeltaZP = 0.05
  zpComment = 'Photometric ZP (mags) for default extinction'
  zpErrComment = 'Photometric ZP error (mags)'
  numZPComment = ' Number of standards used'
  nightZPComment = 'Average photometric ZP (mags) for night'
  nightZPErrComment = 'Photometric ZP sigma for night (mags)'
  nightNumComment = 'Number of ZP used in band for night'
List of MultiframeDetector attributes to update together with their calibration FITS keywords and descriptions.
  highDeltaZP = 0.5
Warn if change in zero-point is greater than this value.
  minimumDeltaZP = 0.0005
Only recalibrate detection table if change in zero-point is greater than this value.
  misplacedKeys = ['MAGZPT', 'MAGZRR']
List of keys that should be removed from primary header.
  paddingLine = 'WFAU added block padding'
Comment line to pad out excess space in FITS headers.
  testDir = 'cu8_test_rsc'
Name of testing directory to store FITS file copies.
  copyFits = False
Update copies of the FITS files instead of originals?
  dateRange = DateRange(begin=<mx.DateTime.DateTime object for '...
Include data observed between these nights only when doing the automatic calibration of multi-epoch data.
  fromMf = None
Continue recalibrations from this multiframe ID and catalogue file onwards in the list (format tuple(int, str)).
  releaseNum = None
Current release number of products to be automatically calibrated.
  reqProdRange = None
Only apply the automatic calibration of multi-epoch data to this product ID range.
  tablePathName = ''
Path to the file containing the table of new calibration values.
  _fitsThread = None
A separate thread to run the FITS file updater.
  _mfdAttrKeys = None
List of MultiframeDetector attributes to update, and corresponding FITS keys.
  _newVersNum = 0
Current recalibration version number.
  _numErrors = 0
Counter for number of run-time errors raised.
  _numWarnings = 0
Counter for number of run-time warnings raised.
  _prevMDZPattrs = ''
Comma-separated string of MultiframeDetector attributes to copy into the PreviousMDZP table.
  _recalSchema = None
Dictionary of lists of columns for recalibration attributes referenced by the detection table for every programme that is to be recalibrated.
  _timeStamp = ''
Time stamp to place into HISTORY card, denoting time of FITS update.

Inherited from wsatools.DbConnect.CuSession.CuSession: archive, comment, cuEventID, curator, eTypes, isDayStampedLog, onlyNonSurveys, onlySurveys, programme, programmeID, resultsFilePathName, shareFileID, sysc

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

_onRun(self)

source code 

Run CU8

Overrides: wsatools.DbConnect.CuSession.CuSession._onRun

_onException(self)

source code 

Report warning count if CU8 is interrupted.

Overrides: wsatools.DbConnect.CuSession.CuSession._onException

_calibrateZeroPoint(self)

source code 

Calculates new zero-point values that can be used by CU8 to recalibrate data in the database. Compares the photometry in multi-epoch products to single epoch observations to find the zero-point offsets for the single epoch frames.

Returns: bool
True, if new calibrations need to be applied.

_determineVersionNumber(self)

source code 

Looks in table PhotCalVers for the previous recalibration version number and increments. If this is a re-run or we are just updating FITS files the previous version number is used.

_parseSchemas(self)

source code 

Parses WSA_MultiframeSchema.sql to determine MultiframeDetector and PreviousMFDZP table attributes. Also, the programme schemas for every programme to be recalibrated to determine the photometry attributes to be recalibrated.

Warning: This function must be called after the new version number is set.

_updatePhotCalVers(self)

source code 

Updates end date of last recalibration version entry in table PhotCalVers and inserts details for new recalibration version. An additional entry is added for re-runs, with an alternative start date. This is to record the complete set of cuEventID for a recalibration version number.

_parseCalibTableFile(self, tablePathName)

source code 

Convert calibration table file to a dictionary of useful entities.

Parameters:
  • tablePathName (str) - Path to the file containing the table of new calibration values.
Returns: list(tuple(str, dict)) INCORRECT!
A list of pairs: FITS file name, and dictionary of FITS header keyword/value pairs.

To Do: This should be a self-contained function, abolishing need for curInfo + helper func, would optimised parsing.

_addHistory(self, historyPhrase, header, numSpareKeys)

source code 

Update the FITS header to consolidate previous CASU HISTORY cards, and to add in a new HISTORY card with supplied details. If the number of header keys are reduced such that the few header block are required, then additional padding lines are inserted to maintain the number of header blocks, hence the file update will not require the entire FITS file to be written (just the header).

Parameters:
  • historyPhrase (str) - New HISTORY card.
  • header (pyfits.Header) - FITS file header to update.
  • numSpareKeys (int) - Number of spare keywords available in current header block.

_deprecateKeywords(self, pHeader)

source code 

Remove misplaced keys from the primary header and update HISTORY card.

Parameters:
  • pHeader (pyfits.Header) - FITS file primary header.

_requiresUpdate(self, header)

source code 

Tests whether a FITS header has already been updated with the latest recalibration values.

Parameters:
  • header ()
Returns:
True if update required.

_shrinkHistory(self, header)

source code 

Consolidates previous CASU HISTORY cards into a smaller amount of header space, to help prevent the creation of new header blocks.

Parameters:
  • header (pyfits.Header) - FITS file header to update.
Returns: int
Number of header keys freed up.

_updateArchive(self, mfID, extNums, tables, zpValues)

source code 

Updates the database multiframe entry for the new zero-point values, copying the old values into the PreviousMFDZP table. Then applies zero-point change to detections from that multiframe as a photometric magnitude recalibration.

Parameters:
  • mfID (int) - Multiframe ID to update.
  • extNums (list(int)) - List of extensions to be updated for this multiframe.
  • tables (set(str)) - Set of detection tables containing detections from this multiframe.
  • zpValues (dict(str:float)) - The new zero-point values referenced by FITS keywords.

_updateKeywords(self, header, extNum, zpValues)

source code 

Update keywords for latest recalibration values and update HISTORY card.

Parameters:
  • header (pyfits.Header) - FITS file header to update.
  • extNum (int) - Extension number of given header.

Class Variable Details [hide private]

calibKeys

Value:
[('MAGZPT', 'Photometric ZP (mags) for default extinction'),
 ('MAGZRR', 'Photometric ZP error (mags)'),
 ('NUMZPT', 'Number of standards used'),
 ('NIGHTZPT', 'Average photometric ZP (mags) for night'),
 ('NIGHTZRR', 'Photometric ZP sigma for night (mags)'),
 ('NIGHTNUM', 'Number of ZP used in band for night')]

nightNumComment

List of MultiframeDetector attributes to update together with their calibration FITS keywords and descriptions. Order determines the sequence that the old values are listed in new HISTORY card.

Value:
'Number of ZP used in band for night'

dateRange

Include data observed between these nights only when doing the automatic calibration of multi-epoch data.

Value:
DateRange(begin=<mx.DateTime.DateTime object for '1753-01-01 00:00:00.\
00' at 3197b70>, end=<mx.DateTime.DateTime object for '9999-12-31 00:0\
0:00.00' at 3197e88>)

fromMf

Continue recalibrations from this multiframe ID and catalogue file onwards in the list (format tuple(int, str)). If no catalogue given, then not FITS updates will occur. If mfID=0 then all multiframes in the list are updated.

Value:
None

_mfdAttrKeys

List of MultiframeDetector attributes to update, and corresponding FITS keys. Created by parsing the schema.

Value:
None

_prevMDZPattrs

Comma-separated string of MultiframeDetector attributes to copy into the PreviousMDZP table. Created by parsing the schema for PreviousMDZP, and setting versNum to the current version.

Value:
''