Commit 34c17f58a30c2045962736803f1daf3dabf20c18
1 parent
6438ef81
Exists in
dev
Last small changes for image processing.
Showing
2 changed files
with
34 additions
and
44 deletions
Show diff stats
config/pyros_observatory/general/schemas/schema_observatory-2.0.yml
... | ... | @@ -303,6 +303,20 @@ schema;schema_FN_CONTEXTS: |
303 | 303 | type: str |
304 | 304 | pathnaming: |
305 | 305 | type: str |
306 | + pyros_skd: | |
307 | + type: map | |
308 | + required: False | |
309 | + mapping: | |
310 | + root_dir: | |
311 | + type: str | |
312 | + description: | |
313 | + type: str | |
314 | + extension: | |
315 | + type: str | |
316 | + naming: | |
317 | + type: str | |
318 | + pathnaming: | |
319 | + type: str | |
306 | 320 | |
307 | 321 | |
308 | 322 | schema;schema_CHANNEL: | ... | ... |
src/core/pyros_django/img_process/A_ImgProcessor.py
... | ... | @@ -174,14 +174,14 @@ class A_ImgProcessor(Agent): |
174 | 174 | """ |
175 | 175 | |
176 | 176 | def glob_images_to_process(self): |
177 | - """Get the list of L0A (and L1A or L1B) files compatibles with the unit and the channel. | |
177 | + """Get the list of ftypes L0A or L1A or L1B files compatibles with the unit and the channel. | |
178 | 178 | |
179 | 179 | The list is sorted to have the oldest file at the first place. |
180 | 180 | Files are FITS format. |
181 | 181 | The context file is 'img_L0' |
182 | 182 | |
183 | 183 | Returns: |
184 | - The list of files sorted from the oldest to the earlier. If L1A or L1B files exist the only the list of these files is returned. | |
184 | + The list of files sorted from the oldest to the earliest. If L1B files exist only the list of these files is returned, then L1A, than L0A. | |
185 | 185 | """ |
186 | 186 | |
187 | 187 | # - select the incoming directory file context |
... | ... | @@ -190,28 +190,19 @@ class A_ImgProcessor(Agent): |
190 | 190 | self._ima.fcontext = fcontext |
191 | 191 | except Exception as e: |
192 | 192 | raise Exception(f"glob_images_to_process: {e}") |
193 | - # - Get the fcontext naming wildcard | |
194 | - wildcard = self._ima.naming_wildcard() | |
195 | - # - Get param dict from the fcontext naming wildcard | |
196 | - param = self._ima.naming_get(wildcard) | |
197 | - # - Set the constraints of the wildcard | |
198 | - param['unit'] = self.config.unit_name | |
199 | - param['channel'] = self._channel['symbol'] | |
200 | - wildcard = self._ima.naming_set(param) | |
201 | - wildcard = self._ima.join(wildcard) | |
202 | - # - glob the incoming directory contents: | |
193 | + ftypes = ['L1B', 'L1A', 'L0A'] | |
194 | + for ftype in ftypes: | |
195 | + # - Get the naming wildcard with the constraints on unit and channel | |
196 | + wildcard = self._ima.naming_wildcard(ftype=ftype, unit=self.config.unit_name, channel=self._channel['symbol']) | |
197 | + # - Get the wildcard with the path and extension | |
198 | + wildcard = self._ima.join(wildcard) | |
199 | + # - glob the incoming directory contents: | |
200 | + fitsfiles = glob.glob(wildcard) | |
201 | + if len(fitsfiles) > 0: | |
202 | + break | |
203 | 203 | log.debug(f"glob_images_to_process: {wildcard=}") |
204 | - fitsfiles = glob.glob(wildcard) | |
205 | - # - Please sort list of files in increasing dates (TODO) | |
204 | + # - Sort list of files in increasing dates | |
206 | 205 | fitsfiles.sort() |
207 | - # - Get only L1? file types if exist | |
208 | - fics = [] | |
209 | - for fitsfile in fitsfiles: | |
210 | - param = self._ima.naming_get(fitsfile) | |
211 | - if param['ftype'][:1] == "L1": | |
212 | - fics.append(fitsfile) | |
213 | - if len(fics): | |
214 | - fitsfiles = fics | |
215 | 206 | return fitsfiles |
216 | 207 | |
217 | 208 | def bias_correction(self): |
... | ... | @@ -255,15 +246,9 @@ class A_ImgProcessor(Agent): |
255 | 246 | if not os.path.exists(fdark_out): |
256 | 247 | # - The night dark does not exists in tmp |
257 | 248 | self._ima.fcontext = "cal_L1" |
258 | - # - Get the fcontext naming wildcard | |
259 | - wildcard = self._ima.naming_wildcard() | |
260 | - # - Get param dict from the fcontext naming wildcard | |
261 | - param_dark = self._ima.naming_get(wildcard) | |
262 | - # - Set the constraints of the wildcard | |
263 | - param_dark['ftype'] = 'DA1' | |
264 | - param_dark['unit'] = self.config.unit_name | |
265 | - param_dark['channel'] = self._channel['symbol'] | |
266 | - wildcard = self._ima.naming_set(param_dark) | |
249 | + # - Get the naming wildcard with the constraints on unit and channel | |
250 | + wildcard = self._ima.naming_wildcard(ftype='DA1', unit=self.config.unit_name, channel=self._channel['symbol']) | |
251 | + # - Get the wildcard with the path and extension | |
267 | 252 | wildcard = os.path.join( self._ima.rootdir, self._datedict['night'], wildcard + self._ima.extension) |
268 | 253 | # - glob the incoming directory contents: |
269 | 254 | #log.info(f"dark glob : {wildcard=}") |
... | ... | @@ -326,16 +311,9 @@ class A_ImgProcessor(Agent): |
326 | 311 | if not os.path.exists(fflat_out): |
327 | 312 | # - The night flat does not exists in tmp |
328 | 313 | self._ima.fcontext = "cal_L1" |
329 | - # - Get the fcontext naming wildcard | |
330 | - wildcard = self._ima.naming_wildcard() | |
331 | - # - Get param dict from the fcontext naming wildcard | |
332 | - param_flat = self._ima.naming_get(wildcard) | |
333 | - # - Set the constraints of the wildcard | |
334 | - param_flat['ftype'] = 'FL1' | |
335 | - param_flat['unit'] = self.config.unit_name | |
336 | - param_flat['channel'] = self._channel['symbol'] | |
337 | - param_flat['filter'] = self._filter_symbol | |
338 | - wildcard = self._ima.naming_set(param_flat) | |
314 | + # - Get the naming wildcard with the constraints on unit and channel | |
315 | + wildcard = self._ima.naming_wildcard(ftype='FL1', unit=self.config.unit_name, channel=self._channel['symbol'], filter=self._filter_symbol) | |
316 | + # - Get the wildcard with the path and extension | |
339 | 317 | wildcard = os.path.join( self._ima.rootdir, self._datedict['night'], wildcard + self._ima.extension) |
340 | 318 | # - glob the incoming directory contents: |
341 | 319 | #log.info(f"flat glob : {wildcard=}") |
... | ... | @@ -344,8 +322,6 @@ class A_ImgProcessor(Agent): |
344 | 322 | if len(fitsfiles) > 0: |
345 | 323 | fflat_in = fitsfiles[0] |
346 | 324 | # - Copy the night flat into tmp |
347 | - #log.info(f"{fflat_in=}") | |
348 | - #log.info(f"{fflat_out=}") | |
349 | 325 | shutil.copyfile(fflat_in, fflat_out) |
350 | 326 | |
351 | 327 | # - Flat correction if flat exists |
... | ... | @@ -628,7 +604,7 @@ class A_ImgProcessor(Agent): |
628 | 604 | A filter C is assumed. |
629 | 605 | Create bias, dark and flat calibration images. |
630 | 606 | |
631 | - This method needs external internal call. | |
607 | + This method needs external internal call (GAIA catalog via astroquery). | |
632 | 608 | """ |
633 | 609 | |
634 | 610 | # --- Configure the simulator | ... | ... |