Commit 201f002700878720e3a99ab6bb3ffd8112c4ca26
1 parent
6bc582b5
Exists in
dev
Modifs config + progress of the A_ImgProcessor
Showing
2 changed files
with
68 additions
and
52 deletions
Show diff stats
config/pyros_observatory/general/schemas/schema_observatory-2.0.yml
... | ... | @@ -181,6 +181,20 @@ schema;schema_CHANNEL: |
181 | 181 | type: str |
182 | 182 | pathnaming: |
183 | 183 | type: str |
184 | + img_tmp: | |
185 | + type: map | |
186 | + required: False | |
187 | + mapping: | |
188 | + root_dir: | |
189 | + type: str | |
190 | + description: | |
191 | + type: str | |
192 | + extension: | |
193 | + type: str | |
194 | + naming: | |
195 | + type: str | |
196 | + pathnaming: | |
197 | + type: str | |
184 | 198 | pyros_seq: |
185 | 199 | type: map |
186 | 200 | required: False | ... | ... |
src/core/pyros_django/img_process/A_ImgProcessor.py
... | ... | @@ -52,11 +52,11 @@ class A_ImgProcessor(Agent): |
52 | 52 | # TODO: Redefine valid timeout |
53 | 53 | _AGENT_SPECIFIC_COMMANDS = { |
54 | 54 | # Format : “cmd_name” : (timeout, exec_mode) |
55 | - | |
55 | + | |
56 | 56 | "do_create_test_images_1" : (60, Agent.EXEC_MODE.SEQUENTIAL, ''), |
57 | 57 | "do_create_test_images_2" : (60, Agent.EXEC_MODE.SEQUENTIAL, ''), |
58 | 58 | "do_stop_current_processing" : (60, Agent.EXEC_MODE.SEQUENTIAL, ''), |
59 | - } | |
59 | + } | |
60 | 60 | |
61 | 61 | # Scenario to be executed |
62 | 62 | # "self do_stop_current_processing" |
... | ... | @@ -86,24 +86,25 @@ class A_ImgProcessor(Agent): |
86 | 86 | # === Get the config object |
87 | 87 | self.config = self._oc['config'] |
88 | 88 | self.pconfig = self._oc['pyros_config'] |
89 | - | |
89 | + | |
90 | 90 | # === Get agent_alias |
91 | 91 | hostname = socket.gethostname() |
92 | 92 | log.info(f"{hostname=}") |
93 | 93 | log.info(f"{self.name=}") |
94 | 94 | agent_alias = self.config.get_agent_real_name(self.name, hostname) |
95 | 95 | log.info(f"{agent_alias=}") |
96 | - | |
96 | + | |
97 | 97 | # === Get self._home (str) of current unit |
98 | 98 | self._home = self.config.getHome() |
99 | - | |
99 | + | |
100 | 100 | # === Get home (Home object) of current unit |
101 | 101 | home = guitastro.Home(self._home) |
102 | - | |
102 | + | |
103 | 103 | # === Get the channel of agent |
104 | 104 | channel = self.config.get_channel_of_agent(agent_alias) |
105 | 105 | if channel == None: |
106 | 106 | raise Exception(f"{agent_alias} has no channel file contexts {channel=}") |
107 | + #log.info(f"{channel=}") | |
107 | 108 | |
108 | 109 | # === Get all file contexts from the channel config |
109 | 110 | self._fn = channel['fn_contexts'] |
... | ... | @@ -118,19 +119,12 @@ class A_ImgProcessor(Agent): |
118 | 119 | |
119 | 120 | # === Copy the channel file context into the Ima object |
120 | 121 | # --- TODO make a Filenames function to do that |
121 | - for fcname in self._fn.fcontexts: | |
122 | - self._fn.fcontext = fcname | |
123 | - description = self._fn.fcontext_value('description') | |
124 | - self._ima.fcontext_create(fcname, description) | |
122 | + self._ima.fcontext_replace(self._fn) | |
123 | + log.info(f"=== List of file name contexts available for the channel {channel['name']} ({channel['symbol']})") | |
124 | + for fcname in self._ima.fcontexts: | |
125 | 125 | self._ima.fcontext = fcname |
126 | - self._ima.pathnaming = self._fn.pathnaming | |
127 | - self._ima.naming = self._fn.naming | |
128 | - self._ima.pathing = self._fn.pathing | |
129 | - self._ima.rootdir = self._fn.rootdir | |
130 | - self._ima.subdir = self._fn.subdir | |
131 | - self._ima.fname = self._fn.fname | |
132 | - self._ima.extension = self._fn.extension | |
133 | - | |
126 | + log.info(f"{fcname} : {self._ima.fdescription} {self._ima.rootdir}/[{self._ima.pathing()}]/[{self._ima.naming()}]{self._ima.extension}") | |
127 | + | |
134 | 128 | # === Status of routine processing |
135 | 129 | self._routine_running = self.RUNNING_NOTHING |
136 | 130 | log.info("Init done with success") |
... | ... | @@ -255,19 +249,22 @@ class A_ImgProcessor(Agent): |
255 | 249 | """ |
256 | 250 | |
257 | 251 | # - Get informations from the file name according the fcontext |
258 | - infos = self._ima.pathnaming_get(fitsfile) | |
259 | - print(f"{infos}") | |
260 | - | |
252 | + log.info(f"{self._ima.fcontext} : {self._ima.fdescription} {self._ima.rootdir}/[{self._ima.pathing()}]/[{self._ima.naming()}]{self._ima.extension}") | |
253 | + infos = self._ima.naming_get(fitsfile) | |
254 | + print(f"{infos=}") | |
255 | + | |
261 | 256 | # - Load file in memory |
262 | 257 | log.info("Load the file in memory") |
263 | - #self.set_infos("Load the file in memory") | |
264 | - f = self._ima.genename(self._ima.load(fitsfile)) | |
265 | - # log.info(f"f={f}") | |
258 | + infos = self._ima.load(fitsfile) | |
259 | + print(f"{infos=}") | |
260 | + #f = self._ima.genename(self._ima.load(fitsfile)) | |
261 | + #log.info(f"{f=}") | |
266 | 262 | |
267 | 263 | # - Save as tmp |
268 | - self._ima.path(self._paths['ima_tmp']) | |
264 | + self._ima.fcontext = "img_tmp" | |
265 | + f = self._ima.join("tmp.fit") | |
269 | 266 | log.info("Save the temporary file as tmp name") |
270 | - self._ima.save("tmp") | |
267 | + self._ima.save(f) | |
271 | 268 | |
272 | 269 | # - Load tmp and get infos |
273 | 270 | self._ima.load("tmp") |
... | ... | @@ -333,35 +330,40 @@ class A_ImgProcessor(Agent): |
333 | 330 | """ |
334 | 331 | |
335 | 332 | def _create_test_images_1(self): |
333 | + # === Define an image to test the processing and copy it in incoming directory | |
334 | + file_in = os.path.join(os.environ['PROJECT_ROOT_PATH'],"vendor","guitastro","tests","data","m57.fit") | |
336 | 335 | try: |
337 | - # === Define an image to test the processing and copy it in incoming directory | |
338 | - file_in = os.path.join(os.environ['PROJECT_ROOT_PATH'],"vendor","guitastro","tests","data","m57.fit") | |
339 | - try: | |
340 | - self._ima.fcontext = "img_L0" | |
341 | - except Exception as e: | |
342 | - raise Exception(f"_create_test_images_1: {e}") | |
343 | - file_out = self._ima.join(file_in) | |
344 | - print(f"{file_in=}") | |
345 | - print(f"{file_out=}") | |
346 | - shutil.copyfile(file_in, file_out) | |
336 | + self._ima.fcontext = "img_L0" | |
347 | 337 | except Exception as e: |
348 | - raise e | |
338 | + raise Exception(f"_create_test_images_1: {e}") | |
339 | + param = {} | |
340 | + param['ftype'] = "L0A" | |
341 | + param['date'] = "20000713" | |
342 | + param['time'] = "224045000000" | |
343 | + param['unit'] = "TNC" | |
344 | + param['version'] = 1 | |
345 | + param['channel'] = "CH1" | |
346 | + param['id_seq'] = 123456789 | |
347 | + param['plane'] = 1 | |
348 | + param['frame'] = 1 | |
349 | + fname = self._ima.naming_set(param) | |
350 | + file_out = self._ima.join(fname) | |
351 | + print(f"{file_in=}") | |
352 | + print(f"{file_out=}") | |
353 | + shutil.copyfile(file_in, file_out) | |
349 | 354 | |
350 | 355 | def _create_test_images_2(self): |
351 | - try: | |
352 | - self._ima.etc.camera("Kepler 4040") | |
353 | - self._ima.etc.optics("Takahashi_180ED") | |
354 | - self._ima.etc.params("msky",18) | |
355 | - ra = 132.84583 | |
356 | - dec = 11.81333 | |
357 | - at = self._ima.simulation("GAIA", "PHOTOM", shutter_mode="closed", t=50, ra=ra, dec=dec) | |
358 | - file_out = os.path.join(self._paths['ima_tmp'], "m67.ecsv") | |
359 | - print(f"STEP TOTO 1 = {at}") | |
360 | - at.t.write(file_out, format='astrotable', overwrite=True) | |
361 | - print(f"STEP TOTO 2") | |
362 | - date_obs = self.getkwd("DATE-OBS") | |
363 | - except: | |
364 | - raise | |
356 | + self._ima.etc.camera("Kepler 4040") | |
357 | + self._ima.etc.optics("Takahashi_180ED") | |
358 | + self._ima.etc.params("msky",18) | |
359 | + ra = 132.84583 | |
360 | + dec = 11.81333 | |
361 | + at = self._ima.simulation("GAIA", "PHOTOM", shutter_mode="closed", t=50, ra=ra, dec=dec) | |
362 | + file_out = os.path.join(self._paths['ima_tmp'], "m67.ecsv") | |
363 | + print(f"STEP TOTO 1 = {at}") | |
364 | + at.t.write(file_out, format='astrotable', overwrite=True) | |
365 | + print(f"STEP TOTO 2") | |
366 | + date_obs = self.getkwd("DATE-OBS") | |
365 | 367 | |
366 | 368 | def _plural(self, n: int) -> str: |
367 | 369 | """Return "s" if n>1 for plurals. |
... | ... | @@ -379,7 +381,7 @@ class A_ImgProcessor(Agent): |
379 | 381 | return s |
380 | 382 | |
381 | 383 | if __name__ == "__main__": |
382 | - args = parse_args(sys.argv[1:]) | |
384 | + args = parse_args(sys.argv[1:]) | |
383 | 385 | #args = vars(parser.parse_args()) |
384 | 386 | agent = build_agent(A_ImgProcessor, param_constr=args) |
385 | 387 | print(agent) | ... | ... |