sunpy icon indicating copy to clipboard operation
sunpy copied to clipboard

Add a way for the JP2 get_header function to get the comments

Open nabobalis opened this issue 3 years ago • 1 comments

Example XML for EUI FSI:

            <meta>
                <fits>
                    <XTENSION comment="binary table extension">BINTABLE</XTENSION>
                    <BITPIX comment="array data type">8</BITPIX>
                    <NAXIS comment="number of array dimensions">2</NAXIS>
                    <NAXIS1 comment="width of table in bytes">3040</NAXIS1>
                    <NAXIS2 comment="number of rows in table">3072</NAXIS2>
                    <PCOUNT comment="number of group parameters">5367484</PCOUNT>
                    <GCOUNT comment="number of groups">1</GCOUNT>
                    <TFIELDS comment="number of fields in each row">4</TFIELDS>
                    <TTYPE1 comment="label for field 1">COMPRESSED_DATA</TTYPE1>
                    <TFORM1 comment="data format of field: variable length array">1PB(2874)</TFORM1>
                    <TTYPE2 comment="label for field 2">GZIP_COMPRESSED_DATA</TTYPE2>
                    <TFORM2 comment="data format of field: variable length array">1PB(0)</TFORM2>
                    <TTYPE3 comment="label for field 3">ZSCALE</TTYPE3>
                    <TFORM3 comment="data format of field: 8-byte DOUBLE">1D</TFORM3>
                    <TTYPE4 comment="label for field 4">ZZERO</TTYPE4>
                    <TFORM4 comment="data format of field: 8-byte DOUBLE">1D</TFORM4>
                    <ZIMAGE comment="extension contains compressed image">T</ZIMAGE>
                    <ZSIMPLE comment="file conforms to basic FITS standards">T</ZSIMPLE>
                    <ZTENSION comment="binary table extension">IMAGE</ZTENSION>
                    <ZBITPIX comment="number of bits per data pixel, rounded up">-32</ZBITPIX>
                    <ZNAXIS comment="number of axes in data cube">2</ZNAXIS>
                    <ZNAXIS1 comment="length of data axis 1">3040</ZNAXIS1>
                    <ZNAXIS2 comment="length of data axis 2">3072</ZNAXIS2>
                    <ZPCOUNT comment="number of group parameters">0</ZPCOUNT>
                    <ZGCOUNT comment="number of groups">1</ZGCOUNT>
                    <ZTILE1 comment="size of tiles to be compressed">3040</ZTILE1>
                    <ZTILE2 comment="size of tiles to be compressed">1</ZTILE2>
                    <ZCMPTYPE comment="compression algorithm">RICE_1</ZCMPTYPE>
                    <ZNAME1 comment="compression block size">BLOCKSIZE</ZNAME1>
                    <ZVAL1 comment="pixels per block">32</ZVAL1>
                    <ZNAME2 comment="bytes per pixel (1, 2, 4, or 8)">BYTEPIX</ZNAME2>
                    <ZVAL2 comment="bytes per pixel (1, 2, 4, or 8)">4</ZVAL2>
                    <ZNAME3 comment="floating point quantization level">NOISEBIT</ZNAME3>
                    <ZVAL3 comment="floating point quantization level">-0.04736711829900742</ZVAL3>
                    <ZQUANTIZ comment="No dithering during quantization">NO_DITHER</ZQUANTIZ>
                    <EXTNAME comment="name of this binary table extension">COMPRESSED_IMAGE</EXTNAME>
                    <LONGSTRN comment="The OGIP long string convention may be used">OGIP 1.0</LONGSTRN>
                    <COMMENT comment="--------- Instrument and Observation Configuration: --------------------"/>
                    <FILENAME comment="FITS filename">solo_L2_eui-fsi174-image_20220401T000045248_V01.fits</FILENAME>
                    <DATE comment="[UTC] FITS file creation date">2022-04-19T17:46:08.331</DATE>
                    <FILE_RAW>BatchRequest.PktTmRaw.SOL.0.2022.102.09.57.02.645.npUR@2022.102.09.57.03.231.1.xml</FILE_RAW>
                    <PARENT comment="source file">solo_L1_eui-fsi174-image_20220401T000045248_V01.fits</PARENT>
                    <APID comment="APID number of associated TM">940</APID>
                    <DATE-OBS comment="[UTC] deprecated, same as DATE-BEG.">2022-04-01T00:00:45.248</DATE-OBS>
                    <DATE-BEG comment="[UTC] start time of observation">2022-04-01T00:00:45.248</DATE-BEG>
                    <DATE-AVG comment="[UTC] average time of observation">2022-04-01T00:00:50.248</DATE-AVG>
                    <TIMESYS comment="system used for time keywords">UTC</TIMESYS>
                    <OBT_BEG comment="start acquisition time in OBT">702086332.1543732</OBT_BEG>
                    <LEVEL comment="data processing level">L2</LEVEL>
                    <ORIGIN comment="file generation location">Royal Observatory of Belgium</ORIGIN>
                    <CREATOR comment="See HISTORY">euiprep.py</CREATOR>
                    <VERS_SW comment="(L1) version of SW that provided FITS file">933</VERS_SW>
                    <VERS_CAL comment="cal version (euiprep git short SHA-1)">9fd92712</VERS_CAL>
                    <VERSION comment="incremental version number">01</VERSION>
                    <IMGTYPE comment="type of image; solar, calib., engineering">solar image</IMGTYPE>
                    <JOBID comment="unique pipeline job ID">20220419T161929.109Z_01f</JOBID>
                    <COMPLETE comment="C or I for complete/incomplete">C</COMPLETE>
                    <COMMENT comment="--------- Description of Data Content: ---------------------------------"/>
                    <OBSRVTRY comment="satellite name">Solar Orbiter</OBSRVTRY>
                    <TELESCOP comment="telescope/Sensor name">SOLO/EUI/FSI</TELESCOP>
                    <INSTRUME comment="instrument name">EUI</INSTRUME>
                    <DETECTOR comment="instrument subunit or sensor">FSI</DETECTOR>
                    <DOORINT comment="internal door position">open</DOORINT>
                    <DOOREXT comment="external HS Door 2 FSI @-292.32 s">open</DOOREXT>
                    <XPOSURE comment="[s] total effective exposure time">10.0</XPOSURE>
                    <FILTER comment="physical filter during acquisition">Zirconium_174_n25</FILTER>
                    <FILTPOS comment="(0-199) filter wheel position service5">50</FILTPOS>
                    <WAVELNTH comment="[Angstrom] characteristic wavelength observatio">174</WAVELNTH>
                    <WAVEMIN comment="[Angstrom] min wavelength resp. &gt; 0.05 of max">171</WAVEMIN>
                    <WAVEMAX comment="[Angstrom] max wavelength resp. &gt; 0.05 of max">185</WAVEMAX>
                    <SOOPNAME comment="name of the SOOP Campaign that the">R_SMALL_MRES_MCAD_AR-Long-Term</SOOPNAME>
                    <SOOPTYPE comment="campaign ID(s) that the data belong to">RS0</SOOPTYPE>
                    <OBS_MODE comment="observation mode">FSI_GENERIC_S_B</OBS_MODE>
                    <OBS_TYPE comment="encoded version of OBS_MODE">u7FA</OBS_TYPE>
                    <OBS_ID comment="unique ID of the individual observation">SEUI_060A_RS0_111_u7FA_11D</OBS_ID>
                    <TARGET comment="type of target from planning">not defined</TARGET>
                    <COMMENT comment="--------- Image Relative to Detector and Electronics: ------------------"/>
                    <BTYPE comment="type of data">Flux</BTYPE>
                    <BUNIT comment="units of physical value, after BSCALE, BZERO">DN/s</BUNIT>
                    <UCD comment="Unified Content Descriptor">phot.count;em.UV.10-50nm</UCD>
                    <COMMENT comment="--------- World Coordinate System Attitude: ----------------------------"/>
                    <PXBEG1 comment="first read-out pixel in dimension 1">1</PXBEG1>
                    <PXEND1 comment="last read-out pixel in dimension 1">3040</PXEND1>
                    <PXBEG2 comment="first read-out pixel in dimension 2">1</PXBEG2>
                    <PXEND2 comment="last read-out pixel in dimension 2">3072</PXEND2>
                    <NBIN1 comment="on-board binning factor in dim 1">1</NBIN1>
                    <NBIN2 comment="on-board binning factor in dim 1">1</NBIN2>
                    <NBIN comment="total binning factor">1</NBIN>
                    <COMMENT comment="--------- Front End Electronics: ---------------------------------------"/>
                    <WCSNAME comment="name of coordinate system">Helioprojective-cartesian</WCSNAME>
                    <CTYPE1 comment="helioprojective longitude (Solar X)">HPLN-TAN</CTYPE1>
                    <CTYPE2 comment="helioprojective latitude (Solar Y)">HPLT-TAN</CTYPE2>
                    <CUNIT1 comment="units along axis 1">arcsec</CUNIT1>
                    <CUNIT2 comment="units along axis 2">arcsec</CUNIT2>
                    <PC1_1 comment="WCS coordinate transformation matrix">0.9972313171841322</PC1_1>
                    <PC1_2 comment="WCS coordinate transformation matrix">-0.07436195281997848</PC1_2>
                    <PC2_1 comment="WCS coordinate transformation matrix">0.07436195281997848</PC2_1>
                    <PC2_2 comment="WCS coordinate transformation matrix">0.9972313171841322</PC2_2>
                    <CDELT1 comment="[arcsec] pixel scale along axis 1">4.44012445</CDELT1>
                    <CDELT2 comment="[arcsec] pixel scale along axis 2">4.44012445</CDELT2>
                    <CROTA comment="[deg] rotation angle">4.264562520191733</CROTA>
                    <CRVAL1 comment="[arcsec] value of reference pixel along axis 1">-2333.62487204408</CRVAL1>
                    <CRVAL2 comment="[arcsec] value of reference pixel along axis 2">835.8842416903123</CRVAL2>
                    <CRPIX1 comment="[pixel] reference pixel location along axis 1">1536.5</CRPIX1>
                    <CRPIX2 comment="[pixel] reference pixel location along axis 2">1536.5</CRPIX2>
                    <LONPOLE comment="[deg] native longitude of the celestial pole">180.0</LONPOLE>
                    <ATT_SKD comment="attitude SKD version, +flown/+predicted">v107_20220418_001+flown</ATT_SKD>
                    <COMMENT comment="--------- Temperature: -------------------------------------------------"/>
                    <DETGAINL comment="commanded low gain value">0.875</DETGAINL>
                    <DETGAINH comment="commanded high-gain value">3.0</DETGAINH>
                    <GAINCOMB comment="commanded low/high gain combination">combined</GAINCOMB>
                    <READOUTM comment="commanded FEE readout mode">4</READOUTM>
                    <DOWNLOAM comment="commanded FEE download mode">0</DOWNLOAM>
                    <GAINTHRE comment="commanded threshold value for H/L gain">15600</GAINTHRE>
                    <LEDSTATE comment="LED control for current telescope">all off</LEDSTATE>
                    <COMMENT comment="--------- Telemetry Header: --------------------------------------------"/>
                    <TEMPINT comment="[K] internal APS detector temperature">212.8559377945334</TEMPINT>
                    <TEMP1DET comment="[K] last measured APS det. T before date-avg">212.8559377945334</TEMP1DET>
                    <TEMP2DET comment="[K] earliest measured APS det. T after date-avg">212.8559377945334</TEMP2DET>
                    <TTEMP1 comment="[UTC] time TEMP1DET measurement">2022-04-01T00:00:27.654647</TTEMP1>
                    <TTEMP2 comment="[UTC] time TEMP2DET measurement">2022-04-01T00:01:27.653899</TTEMP2>
                    <COMMENT comment="--------- CEB Pixel Preprocessing: -------------------------------------"/>
                    <ALU comment="CEB ALU register">21155</ALU>
                    <ALU2 comment="CEB ALU2 register">0</ALU2>
                    <DETREG20 comment="REG20_VDAC_CLIPP">85</DETREG20>
                    <DETREG21 comment="REG21_VDAC_OFFSETP">87</DETREG21>
                    <DETREG22 comment="REG22_VDAC_CMREF">63</DETREG22>
                    <DETREG23 comment="REG23_VDAC_OFFSETN">39</DETREG23>
                    <DETREG24 comment="REG24_VDAC_CLIPN">41</DETREG24>
                    <DETREG25 comment="REG25_VDAC_CMREF_LV">35</DETREG25>
                    <DETREG26 comment="REG26_IDAC_CDSSTAGE2_3">137</DETREG26>
                    <DETREG27 comment="REG27_IDAC_CDSSTAGE1_COMPA">136</DETREG27>
                    <DETREG28 comment="REG28_IDAC_INVBUFFER_REFBU">136</DETREG28>
                    <DETREG29 comment="REG29_IDAC_COLBUFFER_COLBU">136</DETREG29>
                    <DETREG2A comment="REG2A_IDAC_COLPC_COLGAINST">8</DETREG2A>
                    <DETREG2B comment="REG2B_IDAC_OUTPUTDRIVER_CO">136</DETREG2B>
                    <DETREG2C comment="REG2C_VDAC_BLACKSUN_EVEN">0</DETREG2C>
                    <DETREG2D comment="REG2D_IDAC_ABS_REBUFF_TEMP">136</DETREG2D>
                    <DETREG2E comment="REG2E_COLGAIN_EVEN_FF_MID">255</DETREG2E>
                    <DETREG2F comment="REG2F_COLGAIN_EVEN_FF_LOW">240</DETREG2F>
                    <DETREG30 comment="REG30_COLGAIN_EVEN_FB_MID">0</DETREG30>
                    <DETREG31 comment="REG31_COLGAIN_EVEN_FB_LOW">15</DETREG31>
                    <DETREG32 comment="REG32_COLGAIN_EVEN_FB_HIGH">0</DETREG32>
                    <DETREG33 comment="REG33_COLGAIN_ODD_FF_MID">127</DETREG33>
                    <DETREG34 comment="REG34_COLGAIN_ODD_FF_LOW">0</DETREG34>
                    <DETREG35 comment="REG35_COLGAIN_ODD_FB_MID">0</DETREG35>
                    <DETREG36 comment="REG36_COLGAIN_ODD_FB_LOW">255</DETREG36>
                    <DETREG37 comment="REG37_COLGAIN_VDAC_SIGCLAM">0</DETREG37>
                    <DETREG38 comment="REG38_CDS_EN_SAMPLE_CLOCK_">61</DETREG38>
                    <DETREG39 comment="REG39_MBS_PIXCOL_ADDR_LOW">0</DETREG39>
                    <DETREG3A comment="REG3A_MBS_PIXCOL_ADDR_HIGH">0</DETREG3A>
                    <DETREG3B comment="REG3B_MBS_MUXBUS_SR_EOSX_S">0</DETREG3B>
                    <DETREG3C comment="REG3C_VDAC_SIGC_LAMP_BLACK">0</DETREG3C>
                    <DETREG3D comment="REG3D_XWIN_ADDRESS">0</DETREG3D>
                    <DETREG3E comment="REG3E_VDAC_BUSCLAMPHIGH">65</DETREG3E>
                    <DETREG3F comment="REG3F_VDAC_BUSCLAMPLOW">65</DETREG3F>
                    <DOORPOS comment="Door position (raw) = open">34</DOORPOS>
                    <FILCPOS comment="filter wheel commanded position">2</FILCPOS>
                    <COMMENT comment="--------- Data Routing: ------------------------------------------------"/>
                    <GAOFSTAT comment="status of the CEB gain and offset correction">both</GAOFSTAT>
                    <BADPXREM comment="commanded bad pixel removal on or off">off</BADPXREM>
                    <BADPXDEF comment="commanded bad pixel default @-25.59 s">50</BADPXDEF>
                    <CRREM comment="cosmic ray removal on or off">off</CRREM>
                    <CRREMLIM comment="[1 G. sigma DN] cosmic ray limit @-25.59 s">1024</CRREMLIM>
                    <GAINHG comment="global gain corr. high gain @PT-39.7 d">86</GAINHG>
                    <GAINLG comment="global gain corr. low gain  @PT-39.7 d">2240</GAINLG>
                    <OFFSETHG comment="[DN] global offset corr. high gain @PT-39.7 d">9</OFFSETHG>
                    <OFFSETLG comment="[DN] global offset corr. low gain @PT-39.7 d">210</OFFSETLG>
                    <COMMENT comment="--------- Onboard Processing: ------------------------------------------"/>
                    <PRIORITY comment="priority # of image/histogram when downloaded">50</PRIORITY>
                    <SCITABID comment="exposure identifier in sec. science table">12545</SCITABID>
                    <SCITABNR comment="sequential number of SCITABID">0</SCITABNR>
                    <COMMENT comment="--------- Derived Image Properties: ------------------------------------"/>
                    <RECSTATE comment="recoding on or off">on</RECSTATE>
                    <RECNRBIT comment="bit depth recoding output (sqrt)">8</RECNRBIT>
                    <RECLOW comment="rec. threshold low (clipped 0)">0</RECLOW>
                    <RECHIGH comment="rec. threshold high(clipped 2^RECNRBIT-1)">32767</RECHIGH>
                    <COMBITPP comment="WICOM compression bpp ( COMBITPP*0.04=bpp)">14</COMBITPP>
                    <COMSPLMD comment="WICOM compression splitb3 mode">provided by user</COMSPLMD>
                    <COMSPLVL comment="WICOM compression splitb3 value">5</COMSPLVL>
                    <COMWEIMD comment="WICOM compression weighting mode">off</COMWEIMD>
                    <COMWEIVL comment="WICOM sub-band coefficient">128,128,128,128,128,128,128,128,128,128</COMWEIVL>
                    <COMSIZE comment="number of bytes onboard compressed image">660944</COMSIZE>
                    <COMSTRIP comment="compression type: off=whole image; on=strip">off</COMSTRIP>
                    <COMPRESS comment="data compression quality (None/Lossless/Lossy)">Lossy-high quality</COMPRESS>
                    <COMP_RAT comment="compression ratio: uncompressed/compressed size">26.77188990292672</COMP_RAT>
                    <COMMENT comment="--------- Solar Ephemeris: ---------------------------------------------"/>
                    <EUXCEN comment="[pixel] axis 1 location of solar center in L1">2047.139752723288</EUXCEN>
                    <EUYCEN comment="[pixel] axis 2 location of solar center in L1">1307.990989573304</EUYCEN>
                    <DATAMIN comment="minimum valid physical value">0.0</DATAMIN>
                    <DATAMAX comment="maximum valid physical value">3104.25146484375</DATAMAX>
                    <DATAMEAN comment="[DN/s]average pixel value across image">41.61718368530273</DATAMEAN>
                    <COMMENT comment="--------- Parameters Closing Metadata: ---------------------------------"/>
                    <RSUN_ARC comment="[arcsec] apparent photospheric solar radius">2790.410945714562</RSUN_ARC>
                    <RSUN_OBS comment="[arcsec] apparent photospheric solar radius">2790.410945714562</RSUN_OBS>
                    <RSUN_REF comment="[m] assumed physical solar radius">695700000</RSUN_REF>
                    <SOLAR_B0 comment="[deg] s/c tilt of solar North pole">2.147124950229911</SOLAR_B0>
                    <SOLAR_P0 comment="[deg] s/c celestial North to solar North angle">3.992220102191558</SOLAR_P0>
                    <SOLAR_EP comment="[deg] s/c ecliptic North to solar North angle">-5.773255074322562</SOLAR_EP>
                    <CAR_ROT comment="carrington rotation number">2255.614484746929</CAR_ROT>
                    <HGLT_OBS comment="[deg] s/c Heliographic latitude (B0 angle)">2.147124950229911</HGLT_OBS>
                    <HGLN_OBS comment="[deg] s/c Heliographic longitude">101.8661943423178</HGLN_OBS>
                    <CRLT_OBS comment="[deg] s/c Carrington latitude (B0 angle)">2.147124950229911</CRLT_OBS>
                    <CRLN_OBS comment="[deg] s/c Carrington longitude (L0 angle)">138.785491105656</CRLN_OBS>
                    <DSUN_OBS comment="[m] s/c distance from Sun">51427121540.8056</DSUN_OBS>
                    <DSUN_AU comment="[AU] s/c distance from Sun">0.3437690743870032</DSUN_AU>
                    <HEEX_OBS comment="[m] s/c Heliocentric Earth Ecliptic X">-10718284325.66252</HEEX_OBS>
                    <HEEY_OBS comment="[m] s/c Heliocentric Earth Ecliptic Y">50257504175.96361</HEEY_OBS>
                    <HEEZ_OBS comment="[m] s/c Heliocentric Earth Ecliptic Z">-2012581697.732553</HEEZ_OBS>
                    <HCIX_OBS comment="[m] s/c Heliocentric Inertial X">-40922164730.45497</HCIX_OBS>
                    <HCIY_OBS comment="[m] s/c Heliocentric Inertial Y">-31087182249.36421</HCIY_OBS>
                    <HCIZ_OBS comment="[m] s/c Heliocentric Inertial Z">1926749475.440923</HCIZ_OBS>
                    <HCIX_VOB comment="[m/s] s/c Heliocentric Inertial X Velocity">26666.95038676039</HCIX_VOB>
                    <HCIY_VOB comment="[m/s] s/c Heliocentric Inertial Y Velocity">-55712.33307072568</HCIY_VOB>
                    <HCIZ_VOB comment="[m/s] s/c Heliocentric Inertial Z Velocity">4450.461071764702</HCIZ_VOB>
                    <HAEX_OBS comment="[m] s/c Heliocentric Aries Ecliptic X">20065312320.27745</HAEX_OBS>
                    <HAEY_OBS comment="[m] s/c Heliocentric Aries Ecliptic Y">-47308359305.94632</HAEY_OBS>
                    <HAEZ_OBS comment="[m] s/c Heliocentric Aries Ecliptic Z">-2012762092.745572</HAEZ_OBS>
                    <HEQX_OBS comment="[m] s/c Heliocentric Earth Equatorial X">-10567370545.77384</HEQX_OBS>
                    <HEQY_OBS comment="[m] s/c Heliocentric Earth Equatorial Y">50292814061.05637</HEQY_OBS>
                    <HEQZ_OBS comment="[m] s/c Heliocentric Earth Equatorial Z">1926749475.440923</HEQZ_OBS>
                    <GSEX_OBS comment="[m] s/c Geocentric Solar Ecliptic X">160182554838.6424</GSEX_OBS>
                    <GSEY_OBS comment="[m] s/c Geocentric Solar Ecliptic Y">-50257504175.96361</GSEY_OBS>
                    <GSEZ_OBS comment="[m] s/c Geocentric Solar Ecliptic Z">-2012581697.732556</GSEZ_OBS>
                    <OBS_VR comment="[m/s] Radial velocity of S/C relative to Sun">61924.88255268854</OBS_VR>
                    <EAR_TDEL comment="[s] Time(Sun to Earth) - Time(Sun to S/C)">327.0167289270976</EAR_TDEL>
                    <SUN_TIME comment="[s] Time(Sun to S/C)">171.5424126540421</SUN_TIME>
                    <DATE_EAR comment="[UTC] start time of observation Earth">2022-04-01T00:06:17.265</DATE_EAR>
                    <DATE_SUN comment="[UTC] start time of observation Sun">2022-03-31T23:57:58.706</DATE_SUN>
                    <COMMENT comment="--------- General Description: -----------------------------------------"/>
                    <INFO_URL comment="Link to additional information">http://sidc.be/EUI/data</INFO_URL>
                    <CHECKSUM comment="HDU checksum updated 2022-04-19T17:46:09">g9TFh6QEg6QEg6QE</CHECKSUM>
                    <DATASUM comment="data unit checksum updated 2022-04-19T17:46:09">1384228763</DATASUM>
                    <ZEXTEND comment="F = no extensions T = extension(s)">F</ZEXTEND>
                    <ZHECKSUM comment="HDU checksum updated 2022-04-19T17:46:08">4f5B7f594f5A4f57</ZHECKSUM>
                    <ZDATASUM comment="data unit checksum updated 2022-04-19T17:46:08">3134201577</ZDATASUM>
                    <HISTORY comment="orkingDirectory /tmp/telemetry_parser --configFile /home/eui/config/conf"/>
                    <HISTORY comment="ig.ini --outputDirectory /data/solo-eui/internal/L0/ --atROB"/>
                    <HISTORY comment="created by /home/eui/pipeline/level0_to_level1_release.py --inputL0 /hom"/>
                    <HISTORY comment="e/eui/pipeline/new_release/release5/append/xag_append.txt --outputReleas"/>
                    <HISTORY comment="eList /home/eui/pipeline/new_release/release5/append/output_xag.txt --co"/>
                    <HISTORY comment="nfigFile /home/eui/config/config.ini -od /data/solo-eui/internal/release"/>
                    <HISTORY comment="s/202204_release_5.0/L1/"/>
                    <HISTORY comment="euiprep.py (L1 to L2), UTC time: 2022-04-19T17:45:52"/>
                    <HISTORY comment="S/W git version: 9fd9271230a2c6e432290e383a816032ea7d600a"/>
                    <HISTORY comment="Pointing updated with: CRVAL1=-2333.624872, CRVAL2=835.884242, EUXCEN=20"/>
                    <HISTORY comment="47.139753, EUYCEN=1307.990990, attempt=1, tolerance=0.000030"/>
                    <HISTORY comment="Image normalized by integration time."/>
                    <HISTORY comment="Image rectified using: order 1, optical."/>
                    <HISTORY comment="Last 32 columns removed."/>
                    <HISTORY comment="created by /home/eui/pipeline/telemetry_parser.py --databaseExternal --w"/>
                </fits>
                <helioviewer>
                    <HV_COMMENT>
 Title         : solo_L2_eui-fsi174-image_20220401T000045248_V01.fits
 Contact       : [email protected]
 Copyright     : Public Domain
 Creation Time : 2022-06-09T08:23:01.344Z
 Software      : fits2img
 Source        : bogdan-dongle.oma.be
</HV_COMMENT>
                </helioviewer>
            </meta>

Originally posted by @bogdanni in https://github.com/sunpy/sunpy/issues/6198#issuecomment-1150841143

We want to update https://github.com/sunpy/sunpy/blob/main/sunpy/io/jp2.py#L40 to parse these comments into the returned header.

What is unclear is, how best to do that and how best to store those comments in the FileHeader.

nabobalis avatar Jun 09 '22 20:06 nabobalis

Heavily compressed test file at http://swhv.oma.be/test/metadata/2022_04_01__00_00_45__SOLO-EUI-FSI_EUI_FSI_174.jp2

bogdanni avatar Jun 10 '22 05:06 bogdanni

@nabobalis I am on this issue.

aritrasinha108 avatar Mar 09 '23 20:03 aritrasinha108

``

Heavily compressed test file at http://swhv.oma.be/test/metadata/2022_04_01__00_00_45__SOLO-EUI-FSI_EUI_FSI_174.jp2

@nabobalis So I tried to run a test script that uses this test file and tries to fetch the header for it.

In the get_header function inside sunpy/io/jp2.py

from glymur import Jp2k
jp2 = Jp2k(filepath)
xml_box = [box for box in jp2.box if box.box_id == 'xml ']
xmlstring = ET.tostring(xml_box[0].xml.find('fits'))
pydict = xml_to_dict(xmlstring)["fits"]
....
....
return [FileHeader(pydict)]

I tried to log the string xmlstring and pydict dictionary that is being passed into the FileHeader object. It looks something like this:

xmlstring

<fits>
    <XTENSION comment="binary table extension">
         BINTABLE
    </XTENSION>
    <BITPIX comment="array data type">
        8
    </BITPIX>
    ....
</fits>

Pydict

{'XTENSION': 'BINTABLE', 'BITPIX': '8', 'NAXIS': '2', 'NAXIS1': '3040', 'NAXIS2': '3072', 'PCOUNT': '5367484', 'GCOUNT': '1', 'TFIELDS': '4', 'TTYPE1': 'COMPRESSED_DATA', .... }

The comments are lost while converting it into a dictionary. This can be fixed by changing the function node_to_dict where we recusrively convert each node into an XML format sunpy/io/xml.py

Am I in the right direction?

Also, will there be a lot of changes or refactoring involved if we change the way the FileHeader object stores these properties? Probably in form of a nested dictionary like

{'XTENSION': {'COMMENT:' 'binary table extension', 'VALUE': 'BINTABLE' }, ... } 

Or in form of a tuple like

{'XTENSION':  ('binary table extension', 'BINTABLE' ), ... } 

aritrasinha108 avatar Mar 11 '23 20:03 aritrasinha108

Am I in the right direction?

I don't know, I have not spent any time looking into how we would do this inside IO. We want to get the comments, the question is where do we change our IO code.

Also, will there be a lot of changes or refactoring involved if we change the way the FileHeader object stores these properties?

Does it not handle comments for other file types? Or how do we handle them, if at all?

nabobalis avatar Mar 11 '23 20:03 nabobalis

I think for FITS files an extra dictionary KEYCOMMENTS is stored (keyword,comment).

bogdanni avatar Mar 11 '23 20:03 bogdanni

I think for FITS files an extra dictionary KEYCOMMENTS is stored (keyword,comment).

Oh, I just saw that. I'll follow that only in that case. Thanks a lot

aritrasinha108 avatar Mar 11 '23 20:03 aritrasinha108

Am I in the right direction?

I don't know, I have not spent any time looking into how we would do this inside IO. We want to get the comments, the question is where do we change our IO code.

@nabobalis @bogdanni I think we can then write a separate function altogether inside sunpy/utli/xml.py to fetch a dictionary where each keyword would map to the comment on passing the XML string. And we can use that and add the comments dictionary to the FileHeader object with the keyword KEYCOMMENTS here similar to what we're doing for FITS files.

aritrasinha108 avatar Mar 11 '23 21:03 aritrasinha108

Sounds good

nabobalis avatar Mar 11 '23 21:03 nabobalis