Created
September 11, 2020 19:29
-
-
Save zonca/568eda8286109688790fe34465dd3e64 to your computer and use it in GitHub Desktop.
fix IRIS simulator FITS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"from astropy.io import fits\n", | |
"import sys\n", | |
"\n", | |
"filename = \"example_field/iris_sim_gc_filterKN3.fits\"" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"good_file = fits.open(\"/home/zonca/p/software/iris_pipeline/iris_pipeline/tests/data/raw_science_frame_sci.fits\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"SIMPLE = T / Written by IDL: Wed Aug 21 16:20:21 2019 \n", | |
"BITPIX = 8 / array data type \n", | |
"NAXIS = 0 / \n", | |
"EXTEND = T / \n", | |
"SIMPLE = T /conforms to FITS standard \n", | |
"DATE = '2019-08-21T23:20:21.00002914666817Z' /[yyyy-mm-ddThh:mm:ss.ss] UTC da\n", | |
"FILENAME= '/raw_science_frame_sci.fitsfits' /Name of the file \n", | |
"DATAMODL= 'IRISImageModel' /Type of data model \n", | |
"TELESCOP= 'TMT ' /Telescope used to acquire the data \n", | |
"DATE-OBS= '2019-08-21' /[yyyy-mm-dd] UTC date at start of exposure \n", | |
"TIME-OBS= '23:20:21.000' /[hh:mm:ss.sss] UTC time at start of exposure \n", | |
"INSTRUME= 'IRIS ' /Instrument used to acquire the data \n", | |
"DETECTOR= 'IRIS1 ' /Name of detector used to acquire the data \n", | |
"FILTER = 'K ' /Name of the filter element used \n", | |
"PUPIL = 'CLEAR ' /Name of the pupil element used \n", | |
"EXP_TYPE= 'IRIS_IMAGE' /Type of data in the exposure \n", | |
"SUBARRAY= 'FULL ' /Subarray used \n", | |
"SUBSTRT1= 1 / Starting pixel in axis 1 direction \n", | |
"SUBSTRT2= 1 / Starting pixel in axis 2 direction \n", | |
"SUBSIZE1= 4096 /Number of pixels in axis 1 direction \n", | |
"SUBSIZE2= 4096 /Number of pixels in axis 2 direction " | |
] | |
}, | |
"execution_count": 3, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"good_file[0].header" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"hdulist = fits.open(filename, mode=\"readonly\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"hdulist[0].header[\"INSTRUME\"] = hdulist[0].header[\"INSTR\"]\n", | |
"del hdulist[0].header[\"INSTR\"]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"hdulist[0].header[\"DATAMODL\"] = \"IRISImageModel\"\n", | |
"hdulist[0].header[\"TELESCOP\"] = \"TMT\"" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"hdulist[0].header[\"NFRAMES\"] = int(hdulist[0].header[\"NFRAMES\"])" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"for i in [1,2]:\n", | |
" hdulist[0].header[f\"CTYPE{i}\"] = hdulist[0].header[f\"CTYPE{i}\"].replace(\"LINEAR\", \"TAN\")\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 9, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"copy_keys = [\"DATE-OBS\", \"TIME-OBS\"]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 10, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"for key in copy_keys:\n", | |
" hdulist[0].header[key] = good_file[0].header[key]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 11, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"hdulist.append(fits.ImageHDU(data=hdulist[0].data, name=\"SCI\"))\n", | |
"\n", | |
"del hdulist[0].data\n", | |
"\n", | |
"out_filename = filename.replace(\".fits\", \"_fix.fits\")\n", | |
"hdulist.writeto(out_filename, overwrite=True)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 12, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"WARNING: FITSFixedWarning: RADECSYS= 'FK5 ' / \n", | |
"the RADECSYS keyword is deprecated, use RADESYSa. [astropy.wcs.wcs]\n", | |
"WARNING: FITSFixedWarning: EPOCH = '2019-12-17T00:40:46.48107737302794Z' / \n", | |
"a floating-point value was expected. [astropy.wcs.wcs]\n" | |
] | |
} | |
], | |
"source": [ | |
"from astropy.wcs import WCS\n", | |
"wcs = WCS(hdulist[0].header)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 13, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"SIMPLE = T / Written by IDL: Mon Dec 16 16:40:46 2019 \n", | |
"BITPIX = -64 / IEEE double precision floating point \n", | |
"NAXIS = 2 / \n", | |
"NAXIS1 = 4096 / \n", | |
"NAXIS2 = 4096 / \n", | |
"EXTEND = T \n", | |
"SCALE = 0.00400000 / pixel scale (arcsec) \n", | |
"UNITS = 'electrons' / \n", | |
"COORD_SY= 'C ' / \n", | |
"RADECSYS= 'FK5 ' / \n", | |
"CTYPE1 = 'RA--TAN ' \n", | |
"CTYPE2 = 'DEC-TAN ' \n", | |
"CUNIT1 = 'deg ' / \n", | |
"CUNIT2 = 'deg ' / \n", | |
"CRPIX1 = 2048.12 / \n", | |
"CRPIX2 = 2048.12 / \n", | |
"CRVAL1 = 265.197723389 / \n", | |
"CRVAL2 = -28.9921894073 / \n", | |
"CDELT1 = 1.11111013731E-06 /0.00400000 pixel scale \n", | |
"CDELT2 = 1.11111013731E-06 /0.00400000 pixel scale \n", | |
"CROTA1 = 0 / \n", | |
"CROTA2 = 0 / \n", | |
"EPOCH = '2019-12-17T00:40:46.48107737302794Z' / \n", | |
"EQUINOX = 2000 / \n", | |
"READNOIS= 11.3636 / \n", | |
"DARKCURR= 0.00200000 / \n", | |
"ITIME = 2.20000 / \n", | |
"NFRAMES = 1 \n", | |
"FILTER = 'KN3 ' / \n", | |
"CENWAVE = 2.17660 / \n", | |
"TELALT = ' ' /Telescope altitude. \n", | |
"LGS1ALT = ' ' /LGS 1 altitude (m). \n", | |
"PARANGE = 0 / \n", | |
"DATE_OBS= '2019-12-17T00:40:46.48131877183928Z' / \n", | |
"MJD_OBS = ' ' /Modified Julian Date. \n", | |
"GUIDCOL1= ' ' /Guidestar 1 color. \n", | |
"GUIDCOL2= ' ' /Guidestar 2 color. \n", | |
"GUIDCOL3= ' ' /Guidestar 3 color. \n", | |
"GUIDDEC1= ' ' /Guidestar 1 Dec. \n", | |
"GUIDDEC2= ' ' /Guidestar 2 Dec. \n", | |
"GUIDDEC3= ' ' /Guidestar 3 Dec. \n", | |
"GUIDNAM1= ' ' /Guidestar 1 name. \n", | |
"GUIDNAM2= ' ' /Guidestar 2 name. \n", | |
"GUIDNAM3= ' ' /Guidestar 3 name. \n", | |
"GUIDPM1 = ' ' /Guidestar 1 proper motion. \n", | |
"GUIDPM2 = ' ' /Guidestar 2 proper motion. \n", | |
"GUIDPM3 = ' ' /Guidestar 3 proper motion. \n", | |
"GUIDRA1 = ' ' /Guidestar 1 RA. \n", | |
"GUIDRA2 = ' ' /Guidestar 2 RA. \n", | |
"GUIDRA3 = ' ' /Guidestar 3 RA. \n", | |
"GUIDWAV1= ' ' /Guidestar 1 wavelength (microns). \n", | |
"GUIDWAV2= ' ' /Guidestar 2 wavelength (microns). \n", | |
"GUIDWAV3= ' ' /Guidestar 3 wavelength (microns). \n", | |
"AOTTFGUI= ' ' /Name of OIWFS performing TTF (OIWFS1, OIWFS2, OI\n", | |
"AOTTGUID= ' ' /Name of OIWFS performing TT (OIWFS1, OIWFS2, OIW\n", | |
"GUID_X1 = ' ' /Guidestar 1 probe arm positions X. \n", | |
"GUID_X2 = ' ' /Guidestar 2 probe arm positions X. \n", | |
"GUID_X3 = ' ' /Guidestar 3 probe arm positions X. \n", | |
"GUID_Y1 = ' ' /Guidestar 1 probe arm positions Y. \n", | |
"GUID_Y2 = ' ' /Guidestar 2 probe arm positions Y. \n", | |
"GUID_Y3 = ' ' /Guidestar 3 probe arm positions Y. \n", | |
"GUID_Z1 = ' ' /Guidestar 1 probe arm positions Z. \n", | |
"GUID_Z2 = ' ' /Guidestar 2 probe arm positions Z. \n", | |
"GUID_Z3 = ' ' /Guidestar 3 probe arm positions Z. \n", | |
"AOTT1CLK= ' ' /AO TT camera clock. \n", | |
"AOTT1CTS= ' ' /AO TT counts. \n", | |
"AOTT1FR = ' ' /AO TT frame-rate. \n", | |
"AOTT1GAI= ' ' /AO TT loop gain. \n", | |
"AOTT1STA= ' ' /AO TT loop state. \n", | |
"AOTT2CLK= ' ' /AO TT camera clock. \n", | |
"AOTT2CTS= ' ' /AO TT counts. \n", | |
"AOTT2FR = ' ' /AO TT frame-rate. \n", | |
"AOTT2GAI= ' ' /AO TT loop gain. \n", | |
"AOTT2STA= ' ' /AO TT loop state. \n", | |
"AOTTFCLK= ' ' /AO TTF camera clock. \n", | |
"AOTTFCTS= ' ' /AO TTF counts. \n", | |
"AOTTFFR = ' ' /AO TTF frame-rate. \n", | |
"AOTTFGAI= ' ' /AO TTF loop gain. \n", | |
"AOTTFSTA= ' ' /AO TTF loop state. \n", | |
"GUIDSEE1= ' ' /Guidestar 1 seeing. \n", | |
"GUIDSEE2= ' ' /Guidestar 2 seeing. \n", | |
"GUIDSEE3= ' ' /Guidestar 3 seeing. \n", | |
"GUID_CTS= ' ' /Guidestar 3 counts. \n", | |
"GUID_GAI= ' ' /Guider 3 gain. \n", | |
"CS_THETA= ' ' /* theta: Position of the coldstop in theta. \n", | |
"CS_XPOS = ' ' /* x_pos: Position of the cold stop in x. \n", | |
"CS_YPOS = ' ' /* y_pos: Position of the coldstop in y. \n", | |
"IMGTEMP = ' ' /* Temperature of the imager detector. \n", | |
"IFSTEMP = ' ' /* Temperature of the ifs detector. \n", | |
"DETNAME = ' ' /* detectorName: Imager detector name (serial num\n", | |
"RNOISE = ' ' /* readNoise: Nominal readout noise of each detec\n", | |
"GAIN = ' ' /* gain: Imager detector gains. \n", | |
"PXLTIME = ' ' /* pixelClockingTime: Time to clock out a pixel i\n", | |
"DSPVER = ' ' /* versionDSP: Version number of downloaded DSP c\n", | |
"DRVVER = ' ' /* versionDriver: Version number of Linux driver \n", | |
"ARCVER = ' ' /* versionAPI: Version number of ARC API. \n", | |
"EXPTIME = ' ' /* totalTime: Total integration time for exposure\n", | |
"RAMPTIME= ' ' /* rampIntegrationTime: Time exposing for a ramp.\n", | |
"RAMPS = ' ' /* ramps: Total number of ramps in this exposure.\n", | |
"READS = ' ' /* reads: Total number of readouts in this ramp. \n", | |
"SPICKPOS= ' ' /Atrribute <position>: Status of the IFS slicer p\n", | |
"SPERIPOS= ' ' /Atrribute <position>: Status of the IFS slicer p\n", | |
"IFSMODE = ' ' /Attribute <mode>: lenslet or slicer. \n", | |
"IFSSCALE= ' ' /Attribute <current>: IFS scale. \n", | |
"DLSTOFF1= ' ' /Offset from last dither pos-axis 1. \n", | |
"DLSTOFF2= ' ' /Offset from last dither pos-axis 2. \n", | |
"DTOTOFF1= ' ' /Offset from start of dither-axis 1. \n", | |
"DTOTOFF2= ' ' /Offset from start of dither-axis 2. \n", | |
"AODM1GAI= ' ' /AO deformable mirror 1 loop gain. \n", | |
"AODM1STA= ' ' /AO deformable mirror 1 loop state. \n", | |
"AODM2GAI= ' ' /AO deformable mirror 2 loop gain. \n", | |
"AODM2STA= ' ' /AO deformable mirror 2 loop state. \n", | |
"AOMODE = ' ' /AO observing mode: LGS, NGS. \n", | |
"DM1RFN = ' ' /Name of DM1 reconstructor file. \n", | |
"DMRFN2 = ' ' /Name of DM2 reconstructor file. \n", | |
"LGS1PARM= ' ' /LGS 1 parameters. \n", | |
"LGS1RMSW= ' ' /LGSAO 1 RMS WF Residual. \n", | |
"LGS1SPOT= ' ' /LGS 1 spot size. \n", | |
"LGS1STAT= ' ' /LGS 1 status. \n", | |
"LGS2ALT = ' ' /LGS 2 altitude (m). \n", | |
"LGS2PARM= ' ' /LGS 2 parameters. \n", | |
"LGS2RMSW= ' ' /LGSAO 2 RMS WF Residual. \n", | |
"LGS2SPOT= ' ' /LGS 2 spot size. \n", | |
"LGS2STAT= ' ' /LGS 2 status. \n", | |
"LGS3ALT = ' ' /LGS 3 altitude (m). \n", | |
"LGS3PARM= ' ' /LGS 3 parameters. \n", | |
"LGS3RMSW= ' ' /LGSAO 3 RMS WF Residual. \n", | |
"LGS3SPOT= ' ' /LGS 3 spot size. \n", | |
"LGS3STAT= ' ' /LGS 3 status. \n", | |
"LGS4ALT = ' ' /LGS 4 altitude (m). \n", | |
"LGS4PARM= ' ' /LGS 4 parameters. \n", | |
"LGS4RMSW= ' ' /LGSAO 4 RMS WF Residual. \n", | |
"LGS4SPOT= ' ' /LGS 4 spot size. \n", | |
"LGS4STAT= ' ' /LGS 4 status. \n", | |
"LGS5ALT = ' ' /LGS 5 altitude (m). \n", | |
"LGS5PARM= ' ' /LGS 5 parameters. \n", | |
"LGS5RMSW= ' ' /LGSAO 5 RMS WF Residual. \n", | |
"LGS5SPOT= ' ' /LGS 5 spot size. \n", | |
"LGS5STAT= ' ' /LGS 5 status. \n", | |
"LGS6ALT = ' ' /LGS 6 altitude (m). \n", | |
"LGS6PARM= ' ' /LGS 6 parameters. \n", | |
"LGS6RMSW= ' ' /LGSAO 6 RMS WF Residual. \n", | |
"LGS6SPOT= ' ' /LGS 6 spot size. \n", | |
"LGS6STAT= ' ' /LGS 6 status. \n", | |
"WFS1CLK = ' ' /WFS 1 camera clock. \n", | |
"WFS1CTS = ' ' /WFS 1 counts. \n", | |
"WFS1FR = ' ' /WFS 1 frame-rate. \n", | |
"WFS1GAIN= ' ' /WFS 1 gain. \n", | |
"WFS2CLK = ' ' /WFS 2 camera clock. \n", | |
"WFS2CTS = ' ' /WFS 2 counts. \n", | |
"WFS2FR = ' ' /WFS 2 frame-rate. \n", | |
"WFS2GAIN= ' ' /WFS 2 gain. \n", | |
"WFS3CLK = ' ' /WFS 3 camera clock. \n", | |
"WFS3CTS = ' ' /WFS 3 counts. \n", | |
"WFS3FR = ' ' /WFS 3 frame-rate. \n", | |
"WFS3GAIN= ' ' /WFS 3 gain. \n", | |
"WFS4CLK = ' ' /WFS 4 camera clock. \n", | |
"WFS4CTS = ' ' /WFS 4 counts. \n", | |
"WFS4FR = ' ' /WFS 4 frame-rate. \n", | |
"WFS4GAIN= ' ' /WFS 4 gain. \n", | |
"WFS5CLK = ' ' /WFS 5 camera clock. \n", | |
"WFS5CTS = ' ' /WFS 5 counts. \n", | |
"WFS5FR = ' ' /WFS 5 frame-rate. \n", | |
"WFS5GAIN= ' ' /WFS 5 gain. \n", | |
"WFS6CLK = ' ' /WFS 6 camera clock. \n", | |
"WFS6CTS = ' ' /WFS 6 counts. \n", | |
"WFS6FR = ' ' /WFS 6 frame-rate. \n", | |
"WFS6GAIN= ' ' /WFS 6 gain. \n", | |
"CALPOS = ' ' /Calibration unit position (in/out). \n", | |
"FIBRBRT = ' ' /Calibration fiber brightness. \n", | |
"FIBRNAME= ' ' /Calibration fiber. \n", | |
"FIBRSTAT= ' ' /Calibration fiber status (on/off). \n", | |
"FLATBRT = ' ' /Calibration flat brightness. \n", | |
"FLATNAME= ' ' /Calibration flat. \n", | |
"FLATSTAT= ' ' /Calibration flat status (on/off). \n", | |
"LAMPBRT = ' ' /Calibration arc lamp brightness. \n", | |
"LAMPNAME= ' ' /Calibration arc lamp. \n", | |
"LAMPSTAT= ' ' /Calibration arc lamp status (on/off). \n", | |
"PINHOLE = ' ' /Pinhole mask (in/out). \n", | |
"PICK_PV = ' ' /Status of the pickoff mirror for PV optics. \n", | |
"FILTER1 = ' ' /* position: current filter name. \n", | |
"FILTPOS1= ' ' /* angle: current filter position. \n", | |
"FILTER2 = ' ' /* position: current filter name. \n", | |
"FILTPOS2= ' ' /* angle: current filter position. \n", | |
"FILTER3 = ' ' /* position: current filter name. \n", | |
"FILTPOS3= ' ' /* angle: current filter position. \n", | |
"FILTER4 = ' ' /* position: current filter name. \n", | |
"FILTPOS4= ' ' /* angle: current filter position. \n", | |
"FILTER5 = ' ' /* position: current filter name. \n", | |
"FILTPOS5= ' ' /* angle: current filter position. \n", | |
"IFSNAME = ' ' /Attribute <current>: IFS grating position. \n", | |
"LMASKPOS= ' ' /Attribute <position>: IFS lenslet mask position.\n", | |
"SMASKPOS= ' ' /Attribute <position>: IFS slicer mask position. \n", | |
"DPRES = ' ' /Dome pressure. \n", | |
"DTEMP = ' ' /Dome temperature. \n", | |
"EXTDTEMP= ' ' /Outside the dome temperature/pressure. \n", | |
"M1_PRES1= ' ' /Primary mirror pressure (front side). \n", | |
"M1_PRES2= ' ' /Primary mirror pressure (backside). \n", | |
"M1_TEMP1= ' ' /Primary mirror temperature (front side). \n", | |
"M1_TEMP2= ' ' /Primary mirror temperature (backside). \n", | |
"M1_X = ' ' /Primary mirror position in X. \n", | |
"M1_Y = ' ' /Primary mirror position in Y. \n", | |
"M1_Z = ' ' /Primary mirror position in Z. \n", | |
"M2_PRES = ' ' /Secondary mirror pressure. \n", | |
"M2_TEMP = ' ' /Secondary mirror temperature. \n", | |
"M2_X = ' ' /Secondary mirror position in X. \n", | |
"M2_Y = ' ' /Secondary mirror position in Y. \n", | |
"M2_Z = ' ' /Secondary mirror position in Z. \n", | |
"M3_PRES = ' ' /Tertiary mirror pressure. \n", | |
"M3_TEMP = ' ' /Tertiary mirror temperature. \n", | |
"M3_X = ' ' /Tertiary mirror position in X. \n", | |
"M3_Y = ' ' /Tertiary mirror position in Y. \n", | |
"M3_Z = ' ' /Tertiary mirror position in Z. \n", | |
"PARANG = ' ' /Parallactic Angle. \n", | |
"PA_IFS = ' ' /Position Angle of spectrograph on sky. \n", | |
"PA_IMAG = ' ' /Position Angle of imager on sky. \n", | |
"RATEL = ' ' /RA of telescope. \n", | |
"SITEDWPT= ' ' /Site dewpoint. \n", | |
"SITEHUM = ' ' /Site humidity. \n", | |
"SITEPRES= ' ' /Site pressure. \n", | |
"SITETEMP= ' ' /Site temperature. \n", | |
"TELAZ = ' ' /Telescope azimuth. \n", | |
"TELFOCUS= ' ' /Telescope focus. \n", | |
"UT = ' ' /Universal Time. \n", | |
"ADCORIEN= ' ' /* orientation: Current ADC orientation. \n", | |
"ADCSEP = ' ' /* power : Current ADC separation. \n", | |
"INSTRUME= 'IRIS ' \n", | |
"DATAMODL= 'IRISImageModel' \n", | |
"TELESCOP= 'TMT ' \n", | |
"DATE-OBS= '2019-08-21' \n", | |
"TIME-OBS= '23:20:21.000' " | |
] | |
}, | |
"execution_count": 13, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"hdulist[0].header" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "IRIS", | |
"language": "python", | |
"name": "iris" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.7.0" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 4 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment