@@ -55,3 +55,106 @@ def bit_start_find_and_fix(
5555 special_start_bit_list [- 1 ] = 16
5656 return True , special_start_bit_list
5757 return False , None
58+
59+
60+ def uvs_rdr_start_byte (name , hdul ):
61+ """
62+ Sometimes, the start byte is incorrectly recorded in the PDS3 labels (It
63+ is always wrong in the PDS4 labels. We do not have a "check" for that yet,
64+ so I recommend using the PDS3 labels). Here we use the FITS index
65+ defined by the mission for each object to look up the correct start_byte in
66+ the HDU fileinfo.
67+
68+ This won't work if HDUs are missing etc, but I have not encountered that.
69+
70+ HITS
71+ * juno_uvs
72+ * RDR
73+ """
74+ import warnings
75+ # indices are in online PDS docs and comments in the labels
76+ index_dict = {'CALIBRATED_SPECTRAL_HEADER' : 0 ,
77+ 'CALIBRATED_SPECTRAL_IMAGE' : 0 ,
78+ 'ACQUISITION_LIST_HEADER' : 1 ,
79+ 'ACQUISITION_LIST_TABLE' : 1 ,
80+ 'CALIBRATED_PHOTON_LIST_HEADER' : 2 ,
81+ 'CALIBRATED_PHOTON_LIST_TABLE' : 2 ,
82+ 'ANCILLARY_DATA_HEADER' : 3 ,
83+ 'ANCILLARY_DATA_TABLE' : 3 ,
84+ 'CALIBRATED_ANALOG_COUNT_RATE_HEADER' : 4 ,
85+ 'CALIBRATED_ANALOG_COUNT_RATE_TABLE' : 4 ,
86+ 'CALIBRATED_DIGITAL_COUNT_RATE_HEADER' : 5 ,
87+ 'CALIBRATED_DIGITAL_COUNT_RATE_TABLE' : 5 ,
88+ 'HOUSEKEEPING_HEADER' : 6 ,
89+ 'HOUSEKEEPING_TABLE' : 6 ,
90+ 'WAVELENGTH_LOOKUP_HEADER' : 7 ,
91+ 'WAVELENGTH_LOOKUP_IMAGE' : 7 ,
92+ 'MASK_INFORMATION_HEADER' : 8 ,
93+ 'MASK_INFORMATION_TABLE' : 8 ,
94+ }
95+ try :
96+ correct_index = index_dict [name ]
97+ hdu = hdul [correct_index ]
98+ hinfo = hdu .fileinfo ()
99+ if 'HEADER' in name :
100+ return hinfo ['hdrLoc' ]
101+ else :
102+ return hinfo ['datLoc' ]
103+ except Exception as e :
104+ warnings .warn ("This key doesn't appear to be in the FITS file." )
105+ return None
106+
107+
108+ def uvs_edr_start_byte (name , hdul ):
109+ """
110+ Sometimes, the start byte is incorrectly recorded in the PDS3 labels (It
111+ is always wrong in the PDS4 labels. We do not have a "check" for that yet,
112+ so I recommend using the PDS3 labels). Here we use the FITS index
113+ defined by the mission for each object to look up the correct start_byte in
114+ the HDU fileinfo.
115+
116+ This won't work if HDUs are missing etc, but I have not encountered that.
117+
118+ HITS
119+ * juno_uvs
120+ * EDR
121+ """
122+ import warnings
123+ # indices are in online PDS docs and comments in the labels
124+ index_dict = {'SPECTRAL_VS_SPATIAL_HEADER' : 0 ,
125+ 'SPECTRAL_VS_SPATIAL_IMAGE' : 0 ,
126+ 'SPATIAL_VS_TIME_HEADER' : 1 ,
127+ 'SPATIAL_VS_TIME_QUBE' : 1 ,
128+ 'FRAME_LIST_HEADER' : 2 ,
129+ 'FRAME_LIST_TABLE' : 2 ,
130+ 'SCAN_MIRROR_POSITIONS_HEADER' : 3 ,
131+ 'SCAN_MIRROR_POSITIONS_TABLE' : 3 ,
132+ 'RAW_FRAME_HEADER' : 4 ,
133+ 'RAW_FRAME_TABLE' : 4 ,
134+ 'ANALOG_COUNT_RATE_HEADER' : 5 ,
135+ 'ANALOG_COUNT_RATE_TABLE' : 5 ,
136+ 'DIGITAL_COUNT_RATE_HEADER' : 6 ,
137+ 'DIGITAL_COUNT_RATE_TABLE' : 6 ,
138+ 'PULSE_HEIGHT_DISTRIBUTION_LA_HEADER' : 7 ,
139+ 'PULSE_HEIGHT_DISTRIBUTION_LA_QUBE' : 7 ,
140+ 'PULSE_HEIGHT_DISTRIBUTION_STELLAR_HEADER' : 8 ,
141+ 'PULSE_HEIGHT_DISTRIBUTION_STELLAR_QUBE' : 8 ,
142+ 'PULSE_HEIGHT_DISTRIBUTION_STIM_HEADER' : 9 ,
143+ 'PULSE_HEIGHT_DISTRIBUTION_STIM_QUBE' : 9 ,
144+ 'HOUSEKEEPING_HEADER' : 10 ,
145+ 'HOUSEKEEPING_TABLE' : 10 ,
146+ 'PARAMETER_LIST_HEADER' : 11 ,
147+ 'PARAMETER_LIST_TABLE' : 11 ,
148+ }
149+
150+ try :
151+ correct_index = index_dict [name ]
152+ hdu = hdul [correct_index ]
153+ hinfo = hdu .fileinfo ()
154+ if 'HEADER' in name :
155+ return hinfo ['hdrLoc' ]
156+ else :
157+ return hinfo ['datLoc' ]
158+ except Exception as e :
159+ warnings .warn ("This key doesn't appear to be in the FITS file." )
160+ return None
0 commit comments