diff --git a/src/core/pyros_django/scheduling/A_Scheduler.py b/src/core/pyros_django/scheduling/A_Scheduler.py index c549421..5d524c2 100755 --- a/src/core/pyros_django/scheduling/A_Scheduler.py +++ b/src/core/pyros_django/scheduling/A_Scheduler.py @@ -120,37 +120,11 @@ class A_Scheduler(Agent): agent_alias = self.config.get_agent_real_name(self.name, hostname) log.info(f"{agent_alias=}") - # === Get self._home (str) of current unit - self._home = self.config.getHome() - - # === Get home (Home object) of current unit - home = guitastro.Home(self._home) - - # === Get and update all file contexts from pyros config + # === Get all file contexts from pyros config self._fn = self.config.fn log.info(f"=== List of file name contexts available for the unit") - for fcname in self._fn.fcontexts: - self._fn.fcontext = fcname - if self.is_in_test_mode(): - self._fn.rootdir = os.path.abspath(self._fn.rootdir.replace("/PRODUCTS/","/PRODUCTS/TESTS/")) - os.makedirs(self._fn.rootdir, exist_ok=True) - log.info(self._fn.fcontexts_human()) - - """ - def config_check_contexts(self, modetest:bool, loginfo:bool): - for fcname in self.fn.fcontexts: - self.fn.fcontext = fcname - if self.is_in_test_mode(): - self.fn.rootdir = os.path.abspath(self.fn.rootdir.replace("/PRODUCTS/","/PRODUCTS/TESTS/")) - os.makedirs(self._fn.rootdir, exist_ok=True) - if loginfo: - log.info(self.fn.fcontext_human()) - """ - - # === Set longitude to sequence file context to manage the night subdirectories - longitude = home.longitude - log.info(f"{longitude=}") - self._fn.longitude(longitude) + self.check_contexts(True) + log.info(f"{self._fn.longitude=}") # === Status of routine processing self._routine_running = self.RUNNING_NOTHING @@ -560,6 +534,32 @@ class A_Scheduler(Agent): eph = guitastro.Ephemeris() eph.set_home(self.config.getHome()) + """ A placer dans Agent + def ephem_target2night(target->str) -> dict: + fcontext0 = self._oc['config'].fn.fcontext + # --- Build the path and file name of the sun ephemeris + self._oc['config'].fn.fcontext = "pyros_eph" + night = self._oc['config'].fn.date2night("now") + fn_param = { + "period" : f"{info['period_id']}", + "date": night, + "version": "1", + "unit": self._oc['config'].unit_name, + "target": target + } + fname = self._fn.naming_set(fn_param) + eph_file = self._fn.joinabs(fname) + # --- Compute the sun ephemeris if needed. Save it as pickle. + if not os.path.exists(eph_file): + ephem_target = eph.target2night(target, night, None, None) + os.makedirs(os.path.dirname(eph_file), exist_ok=True) + pickle.dump(ephem_sun, open(eph_file,"wb")) + else: + ephem_target = pickle.load(open(eph_file,"rb")) + self._oc['config'].fn.fcontext = fcontext0 + return ephem_target + """ + # --- Build the path and file name of the sun ephemeris self._fn.fcontext = "pyros_eph" fn_param = { -- libgit2 0.21.2