Loading fix_fits_header.pro +75 −8 Original line number Diff line number Diff line pro fix_fits_header, filename compile_opt idl2 key_list = ['SIMPLE', 'XTENSION', 'BITPIX', 'NAXIS', 'NAXIS1', 'NAXIS2', 'PCOUNT', 'GCOUNT', 'EXTEND', 'EXTNAME', 'LONGSTRN', 'FILENAME', 'FILE_RAW', 'PARENT', 'APID', 'DATE', 'DATE-OBS', 'DATE-BEG', 'DATE-AVG', 'DATE-END', 'TIMESYS', 'TIMRDER', 'TIMSYER', 'OBT_BEG', 'OBT_END', 'LEVEL', 'ORIGIN', 'CREATOR', 'VERS_SW', 'VERS_CAL', 'VERSION', 'COMPLETE', 'OBSRVTRY', 'TELESCOP', 'INSTRUME', 'DETECTOR', 'OBJECT', 'OBS_MODE', 'OBS_TYPE', 'FILTER', 'WAVELNTH', 'WAVEMIN', 'WAVEMAX', 'WAVEBAND', 'XPOSURE', 'NSUMEXP', 'TELAPSE', 'SOOPNAME', 'SOOPTYPE', 'OBS_ID', 'TARGET', 'BSCALE', 'BZERO', 'BTYPE', 'BUNIT', 'DATAMIN', 'DATAMAX', 'PXBEG1', 'PXBEG2', 'PXEND1', 'PXEND2', 'NBIN1', 'NBIN2', 'NBIN', 'WCSNAME', 'CTYPE1', 'CTYPE2', 'CUNIT1', 'CUNIT2', 'PC1_1', 'PC1_2', 'PC2_1', 'PC2_2', 'CDELT1', 'CDELT2 ', 'CRVAL1', 'CRVAL2', 'CRPIX1', 'CRPIX2', 'CROTA', 'SUNPIX1', 'SUNPIX2', 'SUN_XCEN', 'SUN_YCEN', 'IOPIX1', 'IOPIX2', 'IO_XCEN', 'IO_YCEN', 'FSPIX1', 'FSPIX2', 'FS_XCEN', 'FS_YCEN', 'SCPIX1', 'SCPIX2', 'SC_XCEN', 'SC_YCEN', 'SC_YAW', 'SC_PITCH', 'SC_ROLL', 'INN_FOV', 'OUT_FOV', 'LONPOLE', 'RSUN_ARC', 'RSUN_REF', 'SOLAR_B0', 'SOLAR_P0 ', 'SOLAR_EP', 'CAR_ROT', 'HGLT_OBS', 'HGLN_OBS', 'CRLT_OBS', 'CRLN_OBS', 'DSUN_OBS', 'DSUN_AU', 'AU_REF', 'HEEX_OBS', 'HEEY_OBS', 'HEEZ_OBS', 'HCIX_OBS', 'HCIY_OBS', 'HCIZ_OBS', 'HCIX_VOB', 'HCIY_VOB', 'HCIZ_VOB', 'HAEX_OBS', 'HAEY_OBS', 'HAEZ_OBS', 'HEQX_OBS', 'HEQY_OBS', 'HEQZ_OBS', 'GSEX_OBS', 'GSEY_OBS', 'GSEZ_OBS', 'OBS_VR', 'EAR_TDEL', 'SUN_TIME', 'DATE_EAR', 'DATE_SUN', 'IDB_VERS', 'HDR_VERS', 'SESS_NUM', 'SEQ_NUM', 'DATATYPE', 'OBJ_CNT', 'CONF_ID', 'REF_HDR', 'REF_TYPE', 'REF_CNT', 'DIT', 'NDIT', 'NDIT1', 'NDIT2', 'CADENCE', 'CAD_BEG', 'CAD_END', 'MEASKIND', 'FRAMEMOD', 'VLFPFILT', 'REF_ROWS', 'PRESUM', 'CR_SEP', 'CR_SEP_A', 'CR_SEP_B', 'SUN_DISK', 'CME_OBS', 'SP_NOISE', 'SNRMIN', 'SNRMAX', 'COMPR', 'RADIAL', 'MASKING', 'MASKRMIN', 'MASKRMAX', 'BIN_TYPE', 'N_POL', 'POL_ID', 'DAC1POL1', 'DAC2POL1', 'DAC1POL2', 'DAC2POL2', 'DAC1POL3', 'DAC2POL3', 'DAC1POL4', 'DAC2POL4', 'HVU_SCR', 'HVU_MCP', 'HV_SCR_V', 'HV_MCP_V', 'HV_MCP_I', 'TSENSOR', 'PMPTEMP', 'PMPSTAB', 'HV_TEMP', 'NB_IMG', 'SN_MEAN1', 'SN_VAR1', 'SN_MEAN2', 'SN_VAR2', 'SN_MEAN3', 'SN_VAR3', 'SN_MEAN4', 'SN_VAR4', 'SN_MEAN5', 'SN_VAR5', 'N', 'COMPRESS', 'COMP_RAT', 'FIRSTROW', 'B0_BIN', 'B0_DQ', 'B0_STOP', 'B1_BIN', 'B1_DQ', 'B1_STOP', 'B2_BIN', 'B2_DQ', 'B2_STOP', 'INFO_URL', 'CHECKSUM', 'DATASUM', 'COMMENT', 'HISTORY'] low_list = ['MEASKIND', 'FRAMEMOD', 'VLFPFILT', 'REF_ROWS', 'PRESUM', 'CR_SEP', 'SUN_DISK', 'CME_OBS', 'SP_NOISE', 'COMPR', 'RADIAL', 'MASKING', 'PMPSTAB', 'COMPRESS'] fits_info, filename, n_ext = n_ext, /silent for ext = 0, n_ext do begin data = readfits(filename, header, exten_no = ext, /noscale, /silent) for k = 0, n_elements(header) - 1 do begin while header[k].matches('\/ +') do begin header[k] = header[k].replace('/ ', '/ ') endwhile endfor fits_add_checksum, header, data modfits, filename, 0, header, exten_no = ext new_header = !null foreach key, key_list do begin value = fxpar(header, key, comment = comment, /null) if isa(value) then begin if key eq 'SIMPLE' or key eq 'EXTEND' then value = 'T' if key eq 'HVU_SCR' or key eq 'HVU_MCP' then value = fix(value) if max(low_list.contains(key, /fold)) then value = value.tolower() if key eq 'OBJECT' then comment = 'type of object observed ' if key eq 'TELAPSE' then comment = '[s] total elapsed time of observation' if key eq 'IDB_VERS' then comment = 'version of Metis IDB' if key eq 'SEQ_NUM' then comment = 'polarimetric sequence ID' if key eq 'FIRSTROW' then comment = '[pixel] band 0 start row' if key eq 'B0_BIN' then comment = 'binning type for band 0' if key eq 'B0_DQ' then comment = 'delta quant. for band 0 lossy compression' if key eq 'B0_STOP' then comment = '[pixel] band 0 end row' if key eq 'B1_BIN' then comment = 'binning type for band 1' if key eq 'B1_DQ' then comment = 'delta quant. for band 1 lossy compression' if key eq 'B1_STOP' then comment = '[pixel] band 1 end row' if key eq 'B2_BIN' then comment = 'binning type for band 2' if key eq 'B2_DQ' then comment = 'delta quant. for band 2 lossy compression' if key eq 'B2_STOP' then comment = '[pixel] band 2 end row' if key eq 'HISTORY' then if value[0].startswith('data', /fold) then value = value[1 : *] for k = 0, n_elements(value) - 1 do $ fxaddpar, new_header, key, value[k], comment.trim() endif endforeach fxaddpar, new_header, $ 'COMMENT', ('=== General description ').insert('', 80, fill = '='), before = 'FILENAME' fxaddpar, new_header, $ 'COMMENT', ('=== Instrument and observation configuration ').insert('', 80, fill = '='), before = 'OBSRVTRY' fxaddpar, new_header, $ 'COMMENT', ('=== Campaign information ').insert('', 80, fill = '='), before = 'SOOPNAME' fxaddpar, new_header, $ 'COMMENT', ('=== Description of data content ').insert('', 80, fill = '='), before = 'BSCALE' fxaddpar, new_header, $ 'COMMENT', ('=== Image relative to detector and electronics ').insert('', 80, fill = '='), before = 'PXBEG1' fxaddpar, new_header, $ 'COMMENT', ('=== World Coordinate System attitude parameters ').insert('', 80, fill = '='), before = 'WCSNAME' fxaddpar, new_header, $ 'COMMENT', ('=== Solar ephemeris ').insert('', 80, fill = '='), before = 'RSUN_ARC' fxaddpar, new_header, $ 'COMMENT', ('=== Parameters identifyng the data ').insert('', 80, fill = '='), before = 'IDB_VERS' fxaddpar, new_header, $ 'COMMENT', ('=== Acquisition configuration ').insert('', 80, fill = '='), before = 'DIT' fxaddpar, new_header, $ 'COMMENT', ('=== Onboard processing configuration ').insert('', 80, fill = '='), after = 'CAD_END', before = 'MEASKIND' if (fxpar(header, 'FILTER')).contains('uv', /fold) then $ fxaddpar, new_header, $ 'COMMENT', ('=== HVU configuration ').insert('', 80, fill = '='), before = 'HVU_SCR' if (fxpar(header, 'FILTER')).contains('vl', /fold) then $ fxaddpar, new_header, $ 'COMMENT', ('=== Polarimeter configuration ').insert('', 80, fill = '='), after = 'BIN_TYPE', before = 'N_POL' fxaddpar, new_header, $ 'COMMENT', ('=== Temperatures ').insert('', 80, fill = '='), after = 'HV_MCP_I', before = 'TSENSOR' if (fxpar(header, 'SP_NOISE')).contains('enabled', /fold) then $ fxaddpar, new_header, $ 'COMMENT', ('=== Spatial noise statistics ').insert('', 80, fill = '='), before = 'SN_MEAN1' fxaddpar, new_header, $ 'COMMENT', ('=== Compression configuration ').insert('', 80, fill = '='), before = 'COMPRESS' fxaddpar, new_header, $ 'COMMENT', ('=== Closing parameters, comments, and history ').insert('', 80, fill = '='), before = 'INFO_URL' fits_add_checksum, new_header, data modfits, filename, 0, new_header, exten_no = ext endfor end Loading
fix_fits_header.pro +75 −8 Original line number Diff line number Diff line pro fix_fits_header, filename compile_opt idl2 key_list = ['SIMPLE', 'XTENSION', 'BITPIX', 'NAXIS', 'NAXIS1', 'NAXIS2', 'PCOUNT', 'GCOUNT', 'EXTEND', 'EXTNAME', 'LONGSTRN', 'FILENAME', 'FILE_RAW', 'PARENT', 'APID', 'DATE', 'DATE-OBS', 'DATE-BEG', 'DATE-AVG', 'DATE-END', 'TIMESYS', 'TIMRDER', 'TIMSYER', 'OBT_BEG', 'OBT_END', 'LEVEL', 'ORIGIN', 'CREATOR', 'VERS_SW', 'VERS_CAL', 'VERSION', 'COMPLETE', 'OBSRVTRY', 'TELESCOP', 'INSTRUME', 'DETECTOR', 'OBJECT', 'OBS_MODE', 'OBS_TYPE', 'FILTER', 'WAVELNTH', 'WAVEMIN', 'WAVEMAX', 'WAVEBAND', 'XPOSURE', 'NSUMEXP', 'TELAPSE', 'SOOPNAME', 'SOOPTYPE', 'OBS_ID', 'TARGET', 'BSCALE', 'BZERO', 'BTYPE', 'BUNIT', 'DATAMIN', 'DATAMAX', 'PXBEG1', 'PXBEG2', 'PXEND1', 'PXEND2', 'NBIN1', 'NBIN2', 'NBIN', 'WCSNAME', 'CTYPE1', 'CTYPE2', 'CUNIT1', 'CUNIT2', 'PC1_1', 'PC1_2', 'PC2_1', 'PC2_2', 'CDELT1', 'CDELT2 ', 'CRVAL1', 'CRVAL2', 'CRPIX1', 'CRPIX2', 'CROTA', 'SUNPIX1', 'SUNPIX2', 'SUN_XCEN', 'SUN_YCEN', 'IOPIX1', 'IOPIX2', 'IO_XCEN', 'IO_YCEN', 'FSPIX1', 'FSPIX2', 'FS_XCEN', 'FS_YCEN', 'SCPIX1', 'SCPIX2', 'SC_XCEN', 'SC_YCEN', 'SC_YAW', 'SC_PITCH', 'SC_ROLL', 'INN_FOV', 'OUT_FOV', 'LONPOLE', 'RSUN_ARC', 'RSUN_REF', 'SOLAR_B0', 'SOLAR_P0 ', 'SOLAR_EP', 'CAR_ROT', 'HGLT_OBS', 'HGLN_OBS', 'CRLT_OBS', 'CRLN_OBS', 'DSUN_OBS', 'DSUN_AU', 'AU_REF', 'HEEX_OBS', 'HEEY_OBS', 'HEEZ_OBS', 'HCIX_OBS', 'HCIY_OBS', 'HCIZ_OBS', 'HCIX_VOB', 'HCIY_VOB', 'HCIZ_VOB', 'HAEX_OBS', 'HAEY_OBS', 'HAEZ_OBS', 'HEQX_OBS', 'HEQY_OBS', 'HEQZ_OBS', 'GSEX_OBS', 'GSEY_OBS', 'GSEZ_OBS', 'OBS_VR', 'EAR_TDEL', 'SUN_TIME', 'DATE_EAR', 'DATE_SUN', 'IDB_VERS', 'HDR_VERS', 'SESS_NUM', 'SEQ_NUM', 'DATATYPE', 'OBJ_CNT', 'CONF_ID', 'REF_HDR', 'REF_TYPE', 'REF_CNT', 'DIT', 'NDIT', 'NDIT1', 'NDIT2', 'CADENCE', 'CAD_BEG', 'CAD_END', 'MEASKIND', 'FRAMEMOD', 'VLFPFILT', 'REF_ROWS', 'PRESUM', 'CR_SEP', 'CR_SEP_A', 'CR_SEP_B', 'SUN_DISK', 'CME_OBS', 'SP_NOISE', 'SNRMIN', 'SNRMAX', 'COMPR', 'RADIAL', 'MASKING', 'MASKRMIN', 'MASKRMAX', 'BIN_TYPE', 'N_POL', 'POL_ID', 'DAC1POL1', 'DAC2POL1', 'DAC1POL2', 'DAC2POL2', 'DAC1POL3', 'DAC2POL3', 'DAC1POL4', 'DAC2POL4', 'HVU_SCR', 'HVU_MCP', 'HV_SCR_V', 'HV_MCP_V', 'HV_MCP_I', 'TSENSOR', 'PMPTEMP', 'PMPSTAB', 'HV_TEMP', 'NB_IMG', 'SN_MEAN1', 'SN_VAR1', 'SN_MEAN2', 'SN_VAR2', 'SN_MEAN3', 'SN_VAR3', 'SN_MEAN4', 'SN_VAR4', 'SN_MEAN5', 'SN_VAR5', 'N', 'COMPRESS', 'COMP_RAT', 'FIRSTROW', 'B0_BIN', 'B0_DQ', 'B0_STOP', 'B1_BIN', 'B1_DQ', 'B1_STOP', 'B2_BIN', 'B2_DQ', 'B2_STOP', 'INFO_URL', 'CHECKSUM', 'DATASUM', 'COMMENT', 'HISTORY'] low_list = ['MEASKIND', 'FRAMEMOD', 'VLFPFILT', 'REF_ROWS', 'PRESUM', 'CR_SEP', 'SUN_DISK', 'CME_OBS', 'SP_NOISE', 'COMPR', 'RADIAL', 'MASKING', 'PMPSTAB', 'COMPRESS'] fits_info, filename, n_ext = n_ext, /silent for ext = 0, n_ext do begin data = readfits(filename, header, exten_no = ext, /noscale, /silent) for k = 0, n_elements(header) - 1 do begin while header[k].matches('\/ +') do begin header[k] = header[k].replace('/ ', '/ ') endwhile endfor fits_add_checksum, header, data modfits, filename, 0, header, exten_no = ext new_header = !null foreach key, key_list do begin value = fxpar(header, key, comment = comment, /null) if isa(value) then begin if key eq 'SIMPLE' or key eq 'EXTEND' then value = 'T' if key eq 'HVU_SCR' or key eq 'HVU_MCP' then value = fix(value) if max(low_list.contains(key, /fold)) then value = value.tolower() if key eq 'OBJECT' then comment = 'type of object observed ' if key eq 'TELAPSE' then comment = '[s] total elapsed time of observation' if key eq 'IDB_VERS' then comment = 'version of Metis IDB' if key eq 'SEQ_NUM' then comment = 'polarimetric sequence ID' if key eq 'FIRSTROW' then comment = '[pixel] band 0 start row' if key eq 'B0_BIN' then comment = 'binning type for band 0' if key eq 'B0_DQ' then comment = 'delta quant. for band 0 lossy compression' if key eq 'B0_STOP' then comment = '[pixel] band 0 end row' if key eq 'B1_BIN' then comment = 'binning type for band 1' if key eq 'B1_DQ' then comment = 'delta quant. for band 1 lossy compression' if key eq 'B1_STOP' then comment = '[pixel] band 1 end row' if key eq 'B2_BIN' then comment = 'binning type for band 2' if key eq 'B2_DQ' then comment = 'delta quant. for band 2 lossy compression' if key eq 'B2_STOP' then comment = '[pixel] band 2 end row' if key eq 'HISTORY' then if value[0].startswith('data', /fold) then value = value[1 : *] for k = 0, n_elements(value) - 1 do $ fxaddpar, new_header, key, value[k], comment.trim() endif endforeach fxaddpar, new_header, $ 'COMMENT', ('=== General description ').insert('', 80, fill = '='), before = 'FILENAME' fxaddpar, new_header, $ 'COMMENT', ('=== Instrument and observation configuration ').insert('', 80, fill = '='), before = 'OBSRVTRY' fxaddpar, new_header, $ 'COMMENT', ('=== Campaign information ').insert('', 80, fill = '='), before = 'SOOPNAME' fxaddpar, new_header, $ 'COMMENT', ('=== Description of data content ').insert('', 80, fill = '='), before = 'BSCALE' fxaddpar, new_header, $ 'COMMENT', ('=== Image relative to detector and electronics ').insert('', 80, fill = '='), before = 'PXBEG1' fxaddpar, new_header, $ 'COMMENT', ('=== World Coordinate System attitude parameters ').insert('', 80, fill = '='), before = 'WCSNAME' fxaddpar, new_header, $ 'COMMENT', ('=== Solar ephemeris ').insert('', 80, fill = '='), before = 'RSUN_ARC' fxaddpar, new_header, $ 'COMMENT', ('=== Parameters identifyng the data ').insert('', 80, fill = '='), before = 'IDB_VERS' fxaddpar, new_header, $ 'COMMENT', ('=== Acquisition configuration ').insert('', 80, fill = '='), before = 'DIT' fxaddpar, new_header, $ 'COMMENT', ('=== Onboard processing configuration ').insert('', 80, fill = '='), after = 'CAD_END', before = 'MEASKIND' if (fxpar(header, 'FILTER')).contains('uv', /fold) then $ fxaddpar, new_header, $ 'COMMENT', ('=== HVU configuration ').insert('', 80, fill = '='), before = 'HVU_SCR' if (fxpar(header, 'FILTER')).contains('vl', /fold) then $ fxaddpar, new_header, $ 'COMMENT', ('=== Polarimeter configuration ').insert('', 80, fill = '='), after = 'BIN_TYPE', before = 'N_POL' fxaddpar, new_header, $ 'COMMENT', ('=== Temperatures ').insert('', 80, fill = '='), after = 'HV_MCP_I', before = 'TSENSOR' if (fxpar(header, 'SP_NOISE')).contains('enabled', /fold) then $ fxaddpar, new_header, $ 'COMMENT', ('=== Spatial noise statistics ').insert('', 80, fill = '='), before = 'SN_MEAN1' fxaddpar, new_header, $ 'COMMENT', ('=== Compression configuration ').insert('', 80, fill = '='), before = 'COMPRESS' fxaddpar, new_header, $ 'COMMENT', ('=== Closing parameters, comments, and history ').insert('', 80, fill = '='), before = 'INFO_URL' fits_add_checksum, new_header, data modfits, filename, 0, new_header, exten_no = ext endfor end