Commit d3e716774b820997154e799b185af4575a381041
1 parent
14733cc6
Exists in
dev
Put seq & eph fn_context in obsconfig file
Showing
10 changed files
with
159 additions
and
106 deletions
Show diff stats
CHANGELOG
@@ -2,7 +2,8 @@ | @@ -2,7 +2,8 @@ | ||
2 | - Add install-dependecies command | 2 | - Add install-dependecies command |
3 | - Move obsconfig/config folder into obsconfig | 3 | - Move obsconfig/config folder into obsconfig |
4 | - Rename default obsconfig file | 4 | - Rename default obsconfig file |
5 | - | 5 | + - Put seq & eph fn_context in obsconfig file |
6 | + | ||
6 | 01-09-2023 (AKo): V0.6.29.0 | 7 | 01-09-2023 (AKo): V0.6.29.0 |
7 | - Add fn context to channels in obsconfig class | 8 | - Add fn context to channels in obsconfig class |
8 | - Add makedirs in fn_context definition | 9 | - Add makedirs in fn_context definition |
config/config_pyros_default.yml
@@ -3,12 +3,6 @@ general: | @@ -3,12 +3,6 @@ general: | ||
3 | logo: logo_pyros_default.png | 3 | logo: logo_pyros_default.png |
4 | color_theme: sienna | 4 | color_theme: sienna |
5 | nb_element_per_page: 20 | 5 | nb_element_per_page: 20 |
6 | - fn_contexts: | ||
7 | - pyros_seq: | ||
8 | - root_dir: "data/sequence/" | ||
9 | - description: "pyros_seq" | ||
10 | - extension: ".p" | ||
11 | - pathnaming: "PyROS.seq.1" | ||
12 | USR: | 6 | USR: |
13 | nb_element_per_page: 10 | 7 | nb_element_per_page: 10 |
14 | SCP: ~ | 8 | SCP: ~ |
config/pyros_observatory/general/schemas/schema_observatory-2.0.yml
@@ -130,6 +130,83 @@ schema;schema_MOUNT: | @@ -130,6 +130,83 @@ schema;schema_MOUNT: | ||
130 | sequence: | 130 | sequence: |
131 | - type: any | 131 | - type: any |
132 | 132 | ||
133 | +schema;schema_FN_CONTEXTS: | ||
134 | + | ||
135 | + type: map | ||
136 | + required: False | ||
137 | + mapping: | ||
138 | + img_L0: | ||
139 | + type: map | ||
140 | + required: False | ||
141 | + mapping: | ||
142 | + root_dir: | ||
143 | + type: str | ||
144 | + description: | ||
145 | + type: str | ||
146 | + extension: | ||
147 | + type: str | ||
148 | + naming: | ||
149 | + type: str | ||
150 | + pathnaming: | ||
151 | + type: str | ||
152 | + img_L1: | ||
153 | + type: map | ||
154 | + required: False | ||
155 | + mapping: | ||
156 | + root_dir: | ||
157 | + type: str | ||
158 | + description: | ||
159 | + type: str | ||
160 | + extension: | ||
161 | + type: str | ||
162 | + naming: | ||
163 | + type: str | ||
164 | + pathnaming: | ||
165 | + type: str | ||
166 | + img_tmp: | ||
167 | + type: map | ||
168 | + required: False | ||
169 | + mapping: | ||
170 | + root_dir: | ||
171 | + type: str | ||
172 | + description: | ||
173 | + type: str | ||
174 | + extension: | ||
175 | + type: str | ||
176 | + naming: | ||
177 | + type: str | ||
178 | + pathnaming: | ||
179 | + type: str | ||
180 | + pyros_seq: | ||
181 | + type: map | ||
182 | + required: False | ||
183 | + mapping: | ||
184 | + root_dir: | ||
185 | + type: str | ||
186 | + description: | ||
187 | + type: str | ||
188 | + extension: | ||
189 | + type: str | ||
190 | + naming: | ||
191 | + type: str | ||
192 | + pathnaming: | ||
193 | + type: str | ||
194 | + pyros_eph: | ||
195 | + type: map | ||
196 | + required: False | ||
197 | + mapping: | ||
198 | + root_dir: | ||
199 | + type: str | ||
200 | + description: | ||
201 | + type: str | ||
202 | + extension: | ||
203 | + type: str | ||
204 | + naming: | ||
205 | + type: str | ||
206 | + pathnaming: | ||
207 | + type: str | ||
208 | + | ||
209 | + | ||
133 | schema;schema_CHANNEL: | 210 | schema;schema_CHANNEL: |
134 | type: map | 211 | type: map |
135 | mapping: | 212 | mapping: |
@@ -150,66 +227,8 @@ schema;schema_CHANNEL: | @@ -150,66 +227,8 @@ schema;schema_CHANNEL: | ||
150 | sequence: | 227 | sequence: |
151 | - type: any | 228 | - type: any |
152 | fn_contexts: | 229 | fn_contexts: |
153 | - type: map | ||
154 | - required: False | ||
155 | - mapping: | ||
156 | - img_L0: | ||
157 | - type: map | ||
158 | - required: False | ||
159 | - mapping: | ||
160 | - root_dir: | ||
161 | - type: str | ||
162 | - description: | ||
163 | - type: str | ||
164 | - extension: | ||
165 | - type: str | ||
166 | - naming: | ||
167 | - type: str | ||
168 | - pathnaming: | ||
169 | - type: str | ||
170 | - img_L1: | ||
171 | - type: map | ||
172 | - required: False | ||
173 | - mapping: | ||
174 | - root_dir: | ||
175 | - type: str | ||
176 | - description: | ||
177 | - type: str | ||
178 | - extension: | ||
179 | - type: str | ||
180 | - naming: | ||
181 | - type: str | ||
182 | - pathnaming: | ||
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 | ||
198 | - pyros_seq: | ||
199 | - type: map | ||
200 | - required: False | ||
201 | - mapping: | ||
202 | - root_dir: | ||
203 | - type: str | ||
204 | - description: | ||
205 | - type: str | ||
206 | - extension: | ||
207 | - type: str | ||
208 | - naming: | ||
209 | - type: str | ||
210 | - pathnaming: | ||
211 | - type: str | ||
212 | - | 230 | + include: schema_FN_CONTEXTS |
231 | + | ||
213 | schema;schema_IMAGE_CALIBRATIONS: | 232 | schema;schema_IMAGE_CALIBRATIONS: |
214 | type: map | 233 | type: map |
215 | mapping: | 234 | mapping: |
@@ -400,6 +419,11 @@ schema;schema_UNIT: | @@ -400,6 +419,11 @@ schema;schema_UNIT: | ||
400 | - type: str | 419 | - type: str |
401 | DATABASE: | 420 | DATABASE: |
402 | include: schema_DATABASE | 421 | include: schema_DATABASE |
422 | + SEQUENCE_MANAGEMENT: | ||
423 | + type: map | ||
424 | + mapping: | ||
425 | + fn_contexts: | ||
426 | + include: schema_FN_CONTEXTS | ||
403 | AGENTS: | 427 | AGENTS: |
404 | include: schema_AGENTS | 428 | include: schema_AGENTS |
405 | TOPOLOGY: | 429 | TOPOLOGY: |
config/pyros_observatory/pyros_observatory_default/observatory.yml
@@ -68,6 +68,20 @@ OBSERVATORY: | @@ -68,6 +68,20 @@ OBSERVATORY: | ||
68 | computer: MainComputer | 68 | computer: MainComputer |
69 | file: .database.env | 69 | file: .database.env |
70 | 70 | ||
71 | + SEQUENCE_MANAGEMENT: | ||
72 | + fn_contexts: | ||
73 | + pyros_seq: | ||
74 | + root_dir: "data/sequences/" | ||
75 | + description: "pyros_seq" | ||
76 | + extension: ".p" | ||
77 | + pathnaming: "PyROS.seq.1" | ||
78 | + | ||
79 | + pyros_eph: | ||
80 | + root_dir : "/tmp/eph" | ||
81 | + description: "Ephemeris PyROS" | ||
82 | + extension : ".f" | ||
83 | + pathnaming : "PyROS.eph.1" | ||
84 | + | ||
71 | AGENTS: | 85 | AGENTS: |
72 | 86 | ||
73 | - AGENT_DEVICE: | 87 | - AGENT_DEVICE: |
@@ -138,6 +152,22 @@ OBSERVATORY: | @@ -138,6 +152,22 @@ OBSERVATORY: | ||
138 | AGENTS: | 152 | AGENTS: |
139 | - optic | 153 | - optic |
140 | - camera | 154 | - camera |
155 | + fn_contexts: | ||
156 | + img_L0: | ||
157 | + root_dir: "data/product/images/science/incoming" | ||
158 | + description: "PyROS images L0" | ||
159 | + extension: ".fit" | ||
160 | + naming: "PyROS.img.1" | ||
161 | + img_L1: | ||
162 | + root_dir: "data/product/images/science/processed" | ||
163 | + description: "PyROS images L1" | ||
164 | + extension: ".fit" | ||
165 | + pathnaming: "PyROS.img.1" | ||
166 | + img_tmp: | ||
167 | + root_dir: "data/product/images/tmp" | ||
168 | + description: "PyROS temporary files during processings" | ||
169 | + extension: ".fit" | ||
170 | + pathnaming: "" | ||
141 | 171 | ||
142 | ALBUMS: | 172 | ALBUMS: |
143 | 173 |
config/schema_pyros_config.yml
@@ -16,24 +16,6 @@ mapping: | @@ -16,24 +16,6 @@ mapping: | ||
16 | nb_element_per_page: | 16 | nb_element_per_page: |
17 | type: int | 17 | type: int |
18 | required: True | 18 | required: True |
19 | - fn_contexts: | ||
20 | - type: map | ||
21 | - required: True | ||
22 | - mapping: | ||
23 | - pyros_seq: | ||
24 | - type: map | ||
25 | - required: True | ||
26 | - mapping: | ||
27 | - root_dir: | ||
28 | - type: str | ||
29 | - description: | ||
30 | - type: str | ||
31 | - extension: | ||
32 | - type: str | ||
33 | - naming: | ||
34 | - type: str | ||
35 | - pathnaming: | ||
36 | - type: str | ||
37 | USR: | 19 | USR: |
38 | type: any | 20 | type: any |
39 | SCP: | 21 | SCP: |
src/core/pyros_django/dashboard/config_pyros.py
@@ -88,19 +88,7 @@ class ConfigPyros: | @@ -88,19 +88,7 @@ class ConfigPyros: | ||
88 | if pyros_config_file is None: | 88 | if pyros_config_file is None: |
89 | pyros_config_file = "config_pyros_default.yml" | 89 | pyros_config_file = "config_pyros_default.yml" |
90 | self.pyros_config = self.read_and_check_config_file(pyros_config_file) | 90 | self.pyros_config = self.read_and_check_config_file(pyros_config_file) |
91 | - fn = FileNames() | ||
92 | - contexts = self.pyros_config["general"]["fn_contexts"] | ||
93 | - for context, values in contexts.items(): | ||
94 | - fn.fcontext_create(context, values["description"]) | ||
95 | - fn.fcontext = context | ||
96 | - if values.get("naming"): | ||
97 | - fn.naming(values["naming"]) | ||
98 | - elif values.get("pathnaming"): | ||
99 | - fn.pathnaming(values["pathnaming"]) | ||
100 | - root_project_path = os.environ.get("PROJECT_ROOT_PATH") | ||
101 | - fn.rootdir = os.path.join(root_project_path, values["root_dir"]) | ||
102 | - fn.extension = values["extension"] | ||
103 | - self.fn = fn | 91 | + |
104 | def main(): | 92 | def main(): |
105 | os.environ["DJANGO_PATH"] = "../../src/core/pyros_django" | 93 | os.environ["DJANGO_PATH"] = "../../src/core/pyros_django" |
106 | os.environ["PROJECT_ROOT_PATH"] = "../../../../" | 94 | os.environ["PROJECT_ROOT_PATH"] = "../../../../" |
src/core/pyros_django/obs_config/obsconfig_class.py
@@ -606,6 +606,20 @@ class OBSConfig: | @@ -606,6 +606,20 @@ class OBSConfig: | ||
606 | self.unit_name = unit_name | 606 | self.unit_name = unit_name |
607 | # call get_agents so the class will check if mandatory agents are in the obsconfig | 607 | # call get_agents so the class will check if mandatory agents are in the obsconfig |
608 | self.get_agents(self.unit_name) | 608 | self.get_agents(self.unit_name) |
609 | + fn = FileNames() | ||
610 | + contexts = self.get_unit_by_name(self.unit_name)["SEQUENCE_MANAGEMENT"]["fn_contexts"] | ||
611 | + for context, values in contexts.items(): | ||
612 | + fn.fcontext_create(context, values["description"]) | ||
613 | + fn.fcontext = context | ||
614 | + if values.get("naming"): | ||
615 | + fn.naming(values["naming"]) | ||
616 | + elif values.get("pathnaming"): | ||
617 | + fn.pathnaming(values["pathnaming"]) | ||
618 | + root_project_path = os.environ.get("PROJECT_ROOT_PATH") | ||
619 | + fn.rootdir = os.path.join(root_project_path, values["root_dir"]) | ||
620 | + fn.extension = values["extension"] | ||
621 | + self.fn = fn | ||
622 | + | ||
609 | 623 | ||
610 | def get_obs_name(self) -> str: | 624 | def get_obs_name(self) -> str: |
611 | """ | 625 | """ |
src/core/pyros_django/scheduling/A_Scheduler.py
@@ -127,7 +127,7 @@ class A_Scheduler(Agent): | @@ -127,7 +127,7 @@ class A_Scheduler(Agent): | ||
127 | home = guitastro.Home(self._home) | 127 | home = guitastro.Home(self._home) |
128 | 128 | ||
129 | # === Get all file contexts from pyros config | 129 | # === Get all file contexts from pyros config |
130 | - self._fn = self.pconfig.fn | 130 | + self._fn = self.config.fn |
131 | 131 | ||
132 | # === Select the file contextof sequence files | 132 | # === Select the file contextof sequence files |
133 | self._fn.pathnaming("PyROS.seq.1") | 133 | self._fn.pathnaming("PyROS.seq.1") |
src/core/pyros_django/scp_mgmt/A_SCP_Manager.py
@@ -59,7 +59,7 @@ class A_SCP_Manager(Agent): | @@ -59,7 +59,7 @@ class A_SCP_Manager(Agent): | ||
59 | next_period = Period.objects.next_period() | 59 | next_period = Period.objects.next_period() |
60 | period = next_period | 60 | period = next_period |
61 | self.pconfig = self._oc['pyros_config'] | 61 | self.pconfig = self._oc['pyros_config'] |
62 | - self._fn = self.pconfig.fn | 62 | + self._fn = self.config.fn |
63 | self.config = self._oc['config'] | 63 | self.config = self._oc['config'] |
64 | self._fn.pathnaming("PyROS.seq.1") | 64 | self._fn.pathnaming("PyROS.seq.1") |
65 | 65 | ||
@@ -271,14 +271,34 @@ class A_SCP_Manager(Agent): | @@ -271,14 +271,34 @@ class A_SCP_Manager(Agent): | ||
271 | eph = guitastro.Ephemeris() | 271 | eph = guitastro.Ephemeris() |
272 | target_sun = "sun" | 272 | target_sun = "sun" |
273 | ephem_sun = eph.target2night(target_sun, current_date, None, None) | 273 | ephem_sun = eph.target2night(target_sun, current_date, None, None) |
274 | - file_name_sun = f"ephem_sun_{current_date}" | ||
275 | - file_name_moon = f"ephem_moon_{current_date}" | 274 | + |
275 | + self._fn.fcontext_create("pyros_eph", "Ephemeris PyROS") | ||
276 | + self._fn.fcontext = "pyros_eph" | ||
277 | + self._fn.pathnaming("PyROS.eph.1") | ||
278 | + self._fn.rootdir = "/tmp/eph" | ||
279 | + self._fn.extension = ".f" | ||
280 | + param = {} | ||
281 | + param['period'] = period_id | ||
282 | + param['date'] = current_date | ||
283 | + param['unit'] = self.pconfig.unit_name | ||
284 | + param['version'] = 1 | ||
285 | + param['target'] = "sun" | ||
286 | + fname = self._fn.naming_set(param) | ||
287 | + file_name_sun = self._fn.join(fname) | ||
288 | + | ||
289 | + # moon parameters | ||
290 | + param['target'] = "moon" | ||
291 | + fname = self._fn.naming_set(param) | ||
292 | + file_name_moon = self._fn.join(fname) | ||
276 | os.chdir(ephem_data_night_folder) | 293 | os.chdir(ephem_data_night_folder) |
277 | pickle.dump(ephem_sun, open(f"{file_name_sun}.f","wb")) | 294 | pickle.dump(ephem_sun, open(f"{file_name_sun}.f","wb")) |
278 | target_moon = "moon" | 295 | target_moon = "moon" |
279 | ephem_moon = eph.target2night(target_moon, current_date, None, None) | 296 | ephem_moon = eph.target2night(target_moon, current_date, None, None) |
280 | pickle.dump(ephem_moon, open(f"{file_name_moon}.f","wb")) | 297 | pickle.dump(ephem_moon, open(f"{file_name_moon}.f","wb")) |
281 | 298 | ||
299 | + | ||
300 | + | ||
301 | + | ||
282 | # lire tous les fichiers sun de la period et appliquer le sky_elev pour déterminer le quota total de période | 302 | # lire tous les fichiers sun de la period et appliquer le sky_elev pour déterminer le quota total de période |
283 | # prendre le champ alt & | 303 | # prendre le champ alt & |
284 | # -> prendre tous les éléments en dessous de duskelev (cf l412 d'A_Sheduler, exemple 14 des éphémérides pour trier ces éléménts) et faire un sum | 304 | # -> prendre tous les éléments en dessous de duskelev (cf l412 d'A_Sheduler, exemple 14 des éphémérides pour trier ces éléménts) et faire un sum |
src/core/pyros_django/seq_submit/functions.py
@@ -441,9 +441,9 @@ def create_sequence_pickle(sequence): | @@ -441,9 +441,9 @@ def create_sequence_pickle(sequence): | ||
441 | unit_name = os.environ["unit_name"] | 441 | unit_name = os.environ["unit_name"] |
442 | config = OBSConfig(os.environ["PATH_TO_OBSCONF_FILE"], unit_name) | 442 | config = OBSConfig(os.environ["PATH_TO_OBSCONF_FILE"], unit_name) |
443 | pyros_config = ConfigPyros(os.environ["pyros_config_file"]) | 443 | pyros_config = ConfigPyros(os.environ["pyros_config_file"]) |
444 | - pyros_config.fn.fcontext = "pyros_seq" | 444 | + config.fn.fcontext = "pyros_seq" |
445 | home = guitastro.Home(config.getHome()) | 445 | home = guitastro.Home(config.getHome()) |
446 | - pyros_config.fn.longitude(home.longitude) | 446 | + config.fn.longitude(home.longitude) |
447 | period_id = str(period.id) | 447 | period_id = str(period.id) |
448 | if len(str(period.id)) < 3: | 448 | if len(str(period.id)) < 3: |
449 | while len(period_id) < 3: | 449 | while len(period_id) < 3: |
@@ -455,8 +455,8 @@ def create_sequence_pickle(sequence): | @@ -455,8 +455,8 @@ def create_sequence_pickle(sequence): | ||
455 | "date": sequence.night_id, | 455 | "date": sequence.night_id, |
456 | "id_seq": sequence.id | 456 | "id_seq": sequence.id |
457 | } | 457 | } |
458 | - pyros_config.fn.fname = pyros_config.fn.naming_set(fn_param) | ||
459 | - fpath_name = pyros_config.fn.join(pyros_config.fn.fname) | 458 | + config.fn.fname = config.fn.naming_set(fn_param) |
459 | + fpath_name = config.fn.join(config.fn.fname) | ||
460 | # create dirs if they don't exist | 460 | # create dirs if they don't exist |
461 | os.makedirs(os.path.dirname(fpath_name), exist_ok=True) | 461 | os.makedirs(os.path.dirname(fpath_name), exist_ok=True) |
462 | print(fpath_name) | 462 | print(fpath_name) |