diff --git a/config/pyros_observatory/general/schemas/schema_observatory-2.0.yml b/config/pyros_observatory/general/schemas/schema_observatory-2.0.yml index b550575..3f82a9d 100644 --- a/config/pyros_observatory/general/schemas/schema_observatory-2.0.yml +++ b/config/pyros_observatory/general/schemas/schema_observatory-2.0.yml @@ -303,6 +303,20 @@ schema;schema_FN_CONTEXTS: type: str pathnaming: type: str + pyros_skd: + type: map + required: False + mapping: + root_dir: + type: str + description: + type: str + extension: + type: str + naming: + type: str + pathnaming: + type: str schema;schema_CHANNEL: diff --git a/src/core/pyros_django/img_process/A_ImgProcessor.py b/src/core/pyros_django/img_process/A_ImgProcessor.py index 92d9906..ef9c27a 100755 --- a/src/core/pyros_django/img_process/A_ImgProcessor.py +++ b/src/core/pyros_django/img_process/A_ImgProcessor.py @@ -174,14 +174,14 @@ class A_ImgProcessor(Agent): """ def glob_images_to_process(self): - """Get the list of L0A (and L1A or L1B) files compatibles with the unit and the channel. + """Get the list of ftypes L0A or L1A or L1B files compatibles with the unit and the channel. The list is sorted to have the oldest file at the first place. Files are FITS format. The context file is 'img_L0' Returns: - 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. + 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. """ # - select the incoming directory file context @@ -190,28 +190,19 @@ class A_ImgProcessor(Agent): self._ima.fcontext = fcontext except Exception as e: raise Exception(f"glob_images_to_process: {e}") - # - Get the fcontext naming wildcard - wildcard = self._ima.naming_wildcard() - # - Get param dict from the fcontext naming wildcard - param = self._ima.naming_get(wildcard) - # - Set the constraints of the wildcard - param['unit'] = self.config.unit_name - param['channel'] = self._channel['symbol'] - wildcard = self._ima.naming_set(param) - wildcard = self._ima.join(wildcard) - # - glob the incoming directory contents: + ftypes = ['L1B', 'L1A', 'L0A'] + for ftype in ftypes: + # - Get the naming wildcard with the constraints on unit and channel + wildcard = self._ima.naming_wildcard(ftype=ftype, unit=self.config.unit_name, channel=self._channel['symbol']) + # - Get the wildcard with the path and extension + wildcard = self._ima.join(wildcard) + # - glob the incoming directory contents: + fitsfiles = glob.glob(wildcard) + if len(fitsfiles) > 0: + break log.debug(f"glob_images_to_process: {wildcard=}") - fitsfiles = glob.glob(wildcard) - # - Please sort list of files in increasing dates (TODO) + # - Sort list of files in increasing dates fitsfiles.sort() - # - Get only L1? file types if exist - fics = [] - for fitsfile in fitsfiles: - param = self._ima.naming_get(fitsfile) - if param['ftype'][:1] == "L1": - fics.append(fitsfile) - if len(fics): - fitsfiles = fics return fitsfiles def bias_correction(self): @@ -255,15 +246,9 @@ class A_ImgProcessor(Agent): if not os.path.exists(fdark_out): # - The night dark does not exists in tmp self._ima.fcontext = "cal_L1" - # - Get the fcontext naming wildcard - wildcard = self._ima.naming_wildcard() - # - Get param dict from the fcontext naming wildcard - param_dark = self._ima.naming_get(wildcard) - # - Set the constraints of the wildcard - param_dark['ftype'] = 'DA1' - param_dark['unit'] = self.config.unit_name - param_dark['channel'] = self._channel['symbol'] - wildcard = self._ima.naming_set(param_dark) + # - Get the naming wildcard with the constraints on unit and channel + wildcard = self._ima.naming_wildcard(ftype='DA1', unit=self.config.unit_name, channel=self._channel['symbol']) + # - Get the wildcard with the path and extension wildcard = os.path.join( self._ima.rootdir, self._datedict['night'], wildcard + self._ima.extension) # - glob the incoming directory contents: #log.info(f"dark glob : {wildcard=}") @@ -326,16 +311,9 @@ class A_ImgProcessor(Agent): if not os.path.exists(fflat_out): # - The night flat does not exists in tmp self._ima.fcontext = "cal_L1" - # - Get the fcontext naming wildcard - wildcard = self._ima.naming_wildcard() - # - Get param dict from the fcontext naming wildcard - param_flat = self._ima.naming_get(wildcard) - # - Set the constraints of the wildcard - param_flat['ftype'] = 'FL1' - param_flat['unit'] = self.config.unit_name - param_flat['channel'] = self._channel['symbol'] - param_flat['filter'] = self._filter_symbol - wildcard = self._ima.naming_set(param_flat) + # - Get the naming wildcard with the constraints on unit and channel + wildcard = self._ima.naming_wildcard(ftype='FL1', unit=self.config.unit_name, channel=self._channel['symbol'], filter=self._filter_symbol) + # - Get the wildcard with the path and extension wildcard = os.path.join( self._ima.rootdir, self._datedict['night'], wildcard + self._ima.extension) # - glob the incoming directory contents: #log.info(f"flat glob : {wildcard=}") @@ -344,8 +322,6 @@ class A_ImgProcessor(Agent): if len(fitsfiles) > 0: fflat_in = fitsfiles[0] # - Copy the night flat into tmp - #log.info(f"{fflat_in=}") - #log.info(f"{fflat_out=}") shutil.copyfile(fflat_in, fflat_out) # - Flat correction if flat exists @@ -628,7 +604,7 @@ class A_ImgProcessor(Agent): A filter C is assumed. Create bias, dark and flat calibration images. - This method needs external internal call. + This method needs external internal call (GAIA catalog via astroquery). """ # --- Configure the simulator -- libgit2 0.21.2