diff --git a/CHANGELOG b/CHANGELOG index 55a8183..4aee4d6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,12 @@ -21-07-2023 (AKo): V0.6.27.0 +28-07-2023 (AKo): V0.6.28.0 + - Add command in A_SCP_Manager to generate ephemeris files of sun & moon for a period + - Fix config_pyros paths + - Fix JS of agent_detail + +26-07-2023 (AKo): V0.6.27.0 + - Remove private & privatedev folder + +24-07-2023 (AKo): V0.6.27.0 - install_observatory now copy default observatory if repository doesn't exists - fix error on update due to package version for doc generation - update dockerfile (can't copy outside build context) 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 2cabf51..b678d63 100644 --- a/src/core/pyros_django/scp_mgmt/A_SCP_Manager.py +++ b/src/core/pyros_django/scp_mgmt/A_SCP_Manager.py @@ -16,10 +16,9 @@ for short_path in short_paths: sys.path.insert(0, path) # Project imports -from src.core.pyros_django.user_mgmt.models import PyrosUser -from seq_submit.models import Period, SP_Period, SP_Period_Guest, SP_PeriodWorkflow, ScientificProgram,SP_Period_User, ScienceTheme -from src.core.pyros_django.majordome.agent.Agent import Agent, build_agent -from vendor.guitastro.src.guitastro import guitastro +from majordome.agent.Agent import Agent, build_agent +from user_mgmt.models import PyrosUser, SP_Period, Period, SP_Period, SP_Period_Guest, SP_PeriodWorkflow +import vendor.guitastro.src.guitastro as guitastro # Django imports from django.shortcuts import reverse @@ -47,7 +46,7 @@ class A_SCP_Manager(Agent): _AGENT_SPECIFIC_COMMANDS = { # Format : “cmd_name” : (timeout, exec_mode, tooltip) - "generate_ephem_moon_and_sun_for_period": (3, Agent.EXEC_MODE.SEQUENTIAL, 'generate ephem of moon & sun for a period'), + "do_generate_ephem_moon_and_sun_for_period": (3, Agent.EXEC_MODE.SEQUENTIAL, 'generate ephem of moon & sun for a period'), } # new init with obsconfig @@ -59,6 +58,10 @@ class A_SCP_Manager(Agent): super().__init__() next_period = Period.objects.next_period() period = next_period + self.pconfig = self._oc['pyros_config'] + self._fn = self.pconfig.fn + self.config = self._oc['config'] + self._fn.pathnaming("PyROS.seq.1") # @override def _init(self): @@ -240,19 +243,26 @@ class A_SCP_Manager(Agent): for n in range(int((end_date - start_date).days)): yield start_date + timedelta(n) - def generate_ephem_moon_and_sun_for_period(self,period): + def do_generate_ephem_moon_and_sun_for_period(self, period_id:int): + period = Period.objects.get(id=period_id) period_start_date = period.start_date period_end_date = period.end_date + root_path = os.environ.get("PROJECT_ROOT_PATH") os.chdir(root_path) - ephem_data_night_folder = os.path.join(root_path, "data") + + home = guitastro.Home(self._oc["config"].getHome()) + self._fn.longitude(home.longitude) + + ephem_data_night_folder = self._fn.rootdir if os.path.exists(ephem_data_night_folder): period_id = str(period.id) # form correct period string if len(str(period.id)) < 3: while len(period_id) < 3: period_id = "0" + period_id - ephem_data_night_folder = os.path.join(root_path, "data", period_id) + period_id = "P" + period_id + ephem_data_night_folder = os.path.join(ephem_data_night_folder, period_id) if not os.path.exists(ephem_data_night_folder): os.makedirs(ephem_data_night_folder, exist_ok=True) for single_date in self.daterange(period_start_date, period_end_date): @@ -261,15 +271,18 @@ 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}.p" - file_name_moon = f"ephem_moon_{current_date}.p" + file_name_sun = f"ephem_sun_{current_date}" + file_name_moon = f"ephem_moon_{current_date}" 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 + if __name__ == "__main__": # with thread -- libgit2 0.21.2