Correcting DATE-OBS and adding MJDREF/MJDREFI keywords in spectra
Closed this issue · 3 comments
The pha spectra obtained when running batspectrum_analysis (and probably the event files before) lack some temporal information:
-the file header only has a TSTART and a TSTOP
-the DATE-OBS is a constant set to '2022-01-26T12:16:00'
example:
f=fits.open('4U_1630-47_survey_point_20212731133.pha')
f[1].header
Out[4]:
XTENSION= 'BINTABLE' / binary table extension
BITPIX = 8 / array data type
NAXIS = 2 / number of array dimensions
NAXIS1 = 20 / length of dimension 1
NAXIS2 = 8 / length of dimension 2
PCOUNT = 0 / number of group parameters
GCOUNT = 1 / number of groups
TFIELDS = 4 / number of table fields
TTYPE1 = 'CHANNEL '
TFORM1 = 'J '
TTYPE2 = 'RATE '
TFORM2 = 'E '
TUNIT2 = 'count/s '
TTYPE3 = 'STAT_ERR'
TFORM3 = 'E '
TUNIT3 = 'count/s '
TTYPE4 = 'SYS_ERR '
TFORM4 = 'D '
EXTNAME = 'SPECTRUM' / extension name
TELESCOP= 'SWIFT ' / Telescope (mission) name
INSTRUME= 'BAT ' / Instrument name
HDUCLASS= 'OGIP ' / Conforms to OGIP/GSFC standards
HDUCLAS1= 'SPECTRUM' / Contains spectrum
GAINAPP = 'T ' / Gain correction has been applied
GAINMETH= 'FIXEDDAC' / Cubic ground gain/offset correction using DAC-b
TELAPSE = 443.0 / [s] Total elapsed time from start to stop
ONTIME = 443.0 / [s] Accumulated on-time
LIVETIME= 443.0 / [s] ONTIME multiplied by DEADC
EXPOSURE= 443.0 / [s] Accumulated exposure
BAT_RA = 248.5019983058676 / [deg] Right ascension of source
BAT_DEC = -47.39400153565722 / [deg] Declination of source
TSTART = 654694420.0 / Start time
TSTOP = 654694863.0 / Stop time
AREASCAL= 1.0 / Nominal effective area
BACKSCAL= 1.0 / Background scale factor
CORRSCAL= 0.0 / Correction scale factor
BACKFILE= 'none ' / Background FITS file
CORRFILE= 'none ' / Correction FITS file
RESPFILE= '4U_1630-47_survey_point_20212731133.rsp' / Redistribution Matrix file
ANCRFILE= 'none ' / Effective Area file (ARF)
QUALITY = 0 / Data quality flag
GROUPING= 0 / Spectra are not grouped
POISSERR= 'F ' / Poisson errors do not apply
SYS_ERR = 0.0 / Systematic error value
DETCHANS= 8 / Total number of detector channels available
CHANTYPE= 'PI ' / Pulse height channel type
HDUCLAS2= 'NET ' / Spectrum is background subtracted
HDUCLAS3= 'RATE ' / Spectrum is count/s
PHAVERSN= '1992a ' / Version of spectrum format
HDUVERS = '1.2.0 ' / Version of spectrum header
FLUXMETH= 'WEIGHTED' / Flux extraction method
BAT_XOBJ= -0.2964718762975234 / [cm] Position of source in BAT_X
BAT_YOBJ= 0.2575742108354418 / [cm] Position of source in BAT_Y
BAT_ZOBJ= 0.9196520822991298 / [cm] Position of source in BAT_Z
COORTYPE= 'sky ' / Type of coordinates specified for weighting
FFAPP = 1 / Projection correction applied?
NFAPP = 'F ' / Near-field correction applied? ~(COS+RSQ)
PCODEAPP= 1 / Partial coding correction applied?
PCODEFR = 0.8671875 / Partial coding fraction of target
NGPIXAPP= 1 / Normalized by number of detectors?
NGOODPIX= 13813 / Number of enabled detectors
DATE-OBS= '2022-01-26T12:16:00' / fake date-obs on UTC
MSKWTSQF= 0.997248493515814 / Half-variance of mask weight map
The date-obs is signaled as fake, but it would be helpful to add MJDREF/MJDREFI keywords (from i.e. https://swift.gsfc.nasa.gov/analysis/suppl_uguide/time_guide.html) as well as leapseconds if they are necessary, and correct the DATE-OBS according to TSTART.
This is a good suggestion, as I know that astropy highlights this as a warning. With the way that the current implementation of the survey data analysis is, this change is non-trivial.
In the future, when we improve the survey analysis capability we will be sure to do this so I will keep this open for now.
The fact that you tell me this is non-trivial makes me wonder if I haven't made a mistake.
In order to retrieve the Time of the observations, what I do is manually add a fixed MJDREF+MJDREFI according to the page I gave you, then "simply" add the Tstart in seconds.
Is this good enough ?
Of course, I'm missing the leapseconds, but for my purposes (daily integrations or at least hour to hour comparisons) few seconds don't change much.
Hi @Parrazyte,
Apologies for my confusion, I thought that this was a mosaic spectrum. The change is relatively straightforward to do and I think that you have already done it? Your value for DATE-OBS is different from what I have coded up in the bat_survey.py file. In any case, you can also get the real UTC date for a pointing observation from the BatSurvey object. There is some additional information here: https://github.com/parsotat/BatAnalysis/blob/main/notebooks/BatAnalysis_objects_intro.ipynb