From d3e716774b820997154e799b185af4575a381041 Mon Sep 17 00:00:00 2001 From: Alexis Koralewski Date: Wed, 13 Sep 2023 17:37:42 +0200 Subject: [PATCH] Put seq & eph fn_context in obsconfig file --- CHANGELOG | 3 ++- config/config_pyros_default.yml | 6 ------ config/pyros_observatory/general/schemas/schema_observatory-2.0.yml | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------ config/pyros_observatory/pyros_observatory_default/observatory.yml | 30 ++++++++++++++++++++++++++++++ config/schema_pyros_config.yml | 18 ------------------ src/core/pyros_django/dashboard/config_pyros.py | 14 +------------- src/core/pyros_django/obs_config/obsconfig_class.py | 14 ++++++++++++++ src/core/pyros_django/scheduling/A_Scheduler.py | 2 +- src/core/pyros_django/scp_mgmt/A_SCP_Manager.py | 26 +++++++++++++++++++++++--- src/core/pyros_django/seq_submit/functions.py | 8 ++++---- 10 files changed, 159 insertions(+), 106 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 9f86ddb..788c335 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,7 +2,8 @@ - Add install-dependecies command - Move obsconfig/config folder into obsconfig - Rename default obsconfig file - + - Put seq & eph fn_context in obsconfig file + 01-09-2023 (AKo): V0.6.29.0 - Add fn context to channels in obsconfig class - Add makedirs in fn_context definition diff --git a/config/config_pyros_default.yml b/config/config_pyros_default.yml index 8635f81..54c5428 100644 --- a/config/config_pyros_default.yml +++ b/config/config_pyros_default.yml @@ -3,12 +3,6 @@ general: logo: logo_pyros_default.png color_theme: sienna nb_element_per_page: 20 - fn_contexts: - pyros_seq: - root_dir: "data/sequence/" - description: "pyros_seq" - extension: ".p" - pathnaming: "PyROS.seq.1" USR: nb_element_per_page: 10 SCP: ~ 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 8aa4ad8..4d724ad 100644 --- a/config/pyros_observatory/general/schemas/schema_observatory-2.0.yml +++ b/config/pyros_observatory/general/schemas/schema_observatory-2.0.yml @@ -130,6 +130,83 @@ schema;schema_MOUNT: sequence: - type: any +schema;schema_FN_CONTEXTS: + + type: map + required: False + mapping: + img_L0: + type: map + required: False + mapping: + root_dir: + type: str + description: + type: str + extension: + type: str + naming: + type: str + pathnaming: + type: str + img_L1: + type: map + required: False + mapping: + root_dir: + type: str + description: + type: str + extension: + type: str + naming: + type: str + pathnaming: + type: str + img_tmp: + type: map + required: False + mapping: + root_dir: + type: str + description: + type: str + extension: + type: str + naming: + type: str + pathnaming: + type: str + pyros_seq: + type: map + required: False + mapping: + root_dir: + type: str + description: + type: str + extension: + type: str + naming: + type: str + pathnaming: + type: str + pyros_eph: + type: map + required: False + mapping: + root_dir: + type: str + description: + type: str + extension: + type: str + naming: + type: str + pathnaming: + type: str + + schema;schema_CHANNEL: type: map mapping: @@ -150,66 +227,8 @@ schema;schema_CHANNEL: sequence: - type: any fn_contexts: - type: map - required: False - mapping: - img_L0: - type: map - required: False - mapping: - root_dir: - type: str - description: - type: str - extension: - type: str - naming: - type: str - pathnaming: - type: str - img_L1: - type: map - required: False - mapping: - root_dir: - type: str - description: - type: str - extension: - type: str - naming: - type: str - pathnaming: - type: str - img_tmp: - type: map - required: False - mapping: - root_dir: - type: str - description: - type: str - extension: - type: str - naming: - type: str - pathnaming: - type: str - pyros_seq: - type: map - required: False - mapping: - root_dir: - type: str - description: - type: str - extension: - type: str - naming: - type: str - pathnaming: - type: str - + include: schema_FN_CONTEXTS + schema;schema_IMAGE_CALIBRATIONS: type: map mapping: @@ -400,6 +419,11 @@ schema;schema_UNIT: - type: str DATABASE: include: schema_DATABASE + SEQUENCE_MANAGEMENT: + type: map + mapping: + fn_contexts: + include: schema_FN_CONTEXTS AGENTS: include: schema_AGENTS TOPOLOGY: diff --git a/config/pyros_observatory/pyros_observatory_default/observatory.yml b/config/pyros_observatory/pyros_observatory_default/observatory.yml index 59a4e11..eccd21c 100644 --- a/config/pyros_observatory/pyros_observatory_default/observatory.yml +++ b/config/pyros_observatory/pyros_observatory_default/observatory.yml @@ -68,6 +68,20 @@ OBSERVATORY: computer: MainComputer file: .database.env + SEQUENCE_MANAGEMENT: + fn_contexts: + pyros_seq: + root_dir: "data/sequences/" + description: "pyros_seq" + extension: ".p" + pathnaming: "PyROS.seq.1" + + pyros_eph: + root_dir : "/tmp/eph" + description: "Ephemeris PyROS" + extension : ".f" + pathnaming : "PyROS.eph.1" + AGENTS: - AGENT_DEVICE: @@ -138,6 +152,22 @@ OBSERVATORY: AGENTS: - optic - camera + fn_contexts: + img_L0: + root_dir: "data/product/images/science/incoming" + description: "PyROS images L0" + extension: ".fit" + naming: "PyROS.img.1" + img_L1: + root_dir: "data/product/images/science/processed" + description: "PyROS images L1" + extension: ".fit" + pathnaming: "PyROS.img.1" + img_tmp: + root_dir: "data/product/images/tmp" + description: "PyROS temporary files during processings" + extension: ".fit" + pathnaming: "" ALBUMS: diff --git a/config/schema_pyros_config.yml b/config/schema_pyros_config.yml index 20f9ee3..5a95434 100644 --- a/config/schema_pyros_config.yml +++ b/config/schema_pyros_config.yml @@ -16,24 +16,6 @@ mapping: nb_element_per_page: type: int required: True - fn_contexts: - type: map - required: True - mapping: - pyros_seq: - type: map - required: True - mapping: - root_dir: - type: str - description: - type: str - extension: - type: str - naming: - type: str - pathnaming: - type: str USR: type: any SCP: diff --git a/src/core/pyros_django/dashboard/config_pyros.py b/src/core/pyros_django/dashboard/config_pyros.py index 47b181d..5d74343 100644 --- a/src/core/pyros_django/dashboard/config_pyros.py +++ b/src/core/pyros_django/dashboard/config_pyros.py @@ -88,19 +88,7 @@ class ConfigPyros: if pyros_config_file is None: pyros_config_file = "config_pyros_default.yml" self.pyros_config = self.read_and_check_config_file(pyros_config_file) - fn = FileNames() - contexts = self.pyros_config["general"]["fn_contexts"] - for context, values in contexts.items(): - fn.fcontext_create(context, values["description"]) - fn.fcontext = context - if values.get("naming"): - fn.naming(values["naming"]) - elif values.get("pathnaming"): - fn.pathnaming(values["pathnaming"]) - root_project_path = os.environ.get("PROJECT_ROOT_PATH") - fn.rootdir = os.path.join(root_project_path, values["root_dir"]) - fn.extension = values["extension"] - self.fn = fn + def main(): os.environ["DJANGO_PATH"] = "../../src/core/pyros_django" os.environ["PROJECT_ROOT_PATH"] = "../../../../" diff --git a/src/core/pyros_django/obs_config/obsconfig_class.py b/src/core/pyros_django/obs_config/obsconfig_class.py index 7bc7a61..14b7823 100644 --- a/src/core/pyros_django/obs_config/obsconfig_class.py +++ b/src/core/pyros_django/obs_config/obsconfig_class.py @@ -606,6 +606,20 @@ class OBSConfig: self.unit_name = unit_name # call get_agents so the class will check if mandatory agents are in the obsconfig self.get_agents(self.unit_name) + fn = FileNames() + contexts = self.get_unit_by_name(self.unit_name)["SEQUENCE_MANAGEMENT"]["fn_contexts"] + for context, values in contexts.items(): + fn.fcontext_create(context, values["description"]) + fn.fcontext = context + if values.get("naming"): + fn.naming(values["naming"]) + elif values.get("pathnaming"): + fn.pathnaming(values["pathnaming"]) + root_project_path = os.environ.get("PROJECT_ROOT_PATH") + fn.rootdir = os.path.join(root_project_path, values["root_dir"]) + fn.extension = values["extension"] + self.fn = fn + def get_obs_name(self) -> str: """ diff --git a/src/core/pyros_django/scheduling/A_Scheduler.py b/src/core/pyros_django/scheduling/A_Scheduler.py index dbd3ae0..5f3cb48 100755 --- a/src/core/pyros_django/scheduling/A_Scheduler.py +++ b/src/core/pyros_django/scheduling/A_Scheduler.py @@ -127,7 +127,7 @@ class A_Scheduler(Agent): home = guitastro.Home(self._home) # === Get all file contexts from pyros config - self._fn = self.pconfig.fn + self._fn = self.config.fn # === Select the file contextof sequence files self._fn.pathnaming("PyROS.seq.1") diff --git a/src/core/pyros_django/scp_mgmt/A_SCP_Manager.py b/src/core/pyros_django/scp_mgmt/A_SCP_Manager.py index b678d63..9fec0dd 100644 --- a/src/core/pyros_django/scp_mgmt/A_SCP_Manager.py +++ b/src/core/pyros_django/scp_mgmt/A_SCP_Manager.py @@ -59,7 +59,7 @@ class A_SCP_Manager(Agent): next_period = Period.objects.next_period() period = next_period self.pconfig = self._oc['pyros_config'] - self._fn = self.pconfig.fn + self._fn = self.config.fn self.config = self._oc['config'] self._fn.pathnaming("PyROS.seq.1") @@ -271,14 +271,34 @@ class A_SCP_Manager(Agent): eph = guitastro.Ephemeris() target_sun = "sun" ephem_sun = eph.target2night(target_sun, current_date, None, None) - file_name_sun = f"ephem_sun_{current_date}" - file_name_moon = f"ephem_moon_{current_date}" + + self._fn.fcontext_create("pyros_eph", "Ephemeris PyROS") + self._fn.fcontext = "pyros_eph" + self._fn.pathnaming("PyROS.eph.1") + self._fn.rootdir = "/tmp/eph" + self._fn.extension = ".f" + param = {} + param['period'] = period_id + param['date'] = current_date + param['unit'] = self.pconfig.unit_name + param['version'] = 1 + param['target'] = "sun" + fname = self._fn.naming_set(param) + file_name_sun = self._fn.join(fname) + + # moon parameters + param['target'] = "moon" + fname = self._fn.naming_set(param) + file_name_moon = self._fn.join(fname) os.chdir(ephem_data_night_folder) pickle.dump(ephem_sun, open(f"{file_name_sun}.f","wb")) target_moon = "moon" ephem_moon = eph.target2night(target_moon, current_date, None, None) pickle.dump(ephem_moon, open(f"{file_name_moon}.f","wb")) + + + # lire tous les fichiers sun de la period et appliquer le sky_elev pour déterminer le quota total de période # prendre le champ alt & # -> 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 diff --git a/src/core/pyros_django/seq_submit/functions.py b/src/core/pyros_django/seq_submit/functions.py index 03a1034..a775399 100644 --- a/src/core/pyros_django/seq_submit/functions.py +++ b/src/core/pyros_django/seq_submit/functions.py @@ -441,9 +441,9 @@ def create_sequence_pickle(sequence): unit_name = os.environ["unit_name"] config = OBSConfig(os.environ["PATH_TO_OBSCONF_FILE"], unit_name) pyros_config = ConfigPyros(os.environ["pyros_config_file"]) - pyros_config.fn.fcontext = "pyros_seq" + config.fn.fcontext = "pyros_seq" home = guitastro.Home(config.getHome()) - pyros_config.fn.longitude(home.longitude) + config.fn.longitude(home.longitude) period_id = str(period.id) if len(str(period.id)) < 3: while len(period_id) < 3: @@ -455,8 +455,8 @@ def create_sequence_pickle(sequence): "date": sequence.night_id, "id_seq": sequence.id } - pyros_config.fn.fname = pyros_config.fn.naming_set(fn_param) - fpath_name = pyros_config.fn.join(pyros_config.fn.fname) + config.fn.fname = config.fn.naming_set(fn_param) + fpath_name = config.fn.join(config.fn.fname) # create dirs if they don't exist os.makedirs(os.path.dirname(fpath_name), exist_ok=True) print(fpath_name) -- libgit2 0.21.2