Commit 1cd8d8dda376146828212f6ac928a1361b6f75c5

Authored by Alain Klotz
1 parent d401de67
Exists in dev

Ephem sun and Moon.

Showing 1 changed file with 29 additions and 29 deletions   Show diff stats
src/core/pyros_django/scheduling/A_Scheduler.py
@@ -120,37 +120,11 @@ class A_Scheduler(Agent): @@ -120,37 +120,11 @@ class A_Scheduler(Agent):
120 agent_alias = self.config.get_agent_real_name(self.name, hostname) 120 agent_alias = self.config.get_agent_real_name(self.name, hostname)
121 log.info(f"{agent_alias=}") 121 log.info(f"{agent_alias=}")
122 122
123 - # === Get self._home (str) of current unit  
124 - self._home = self.config.getHome()  
125 -  
126 - # === Get home (Home object) of current unit  
127 - home = guitastro.Home(self._home)  
128 -  
129 - # === Get and update all file contexts from pyros config 123 + # === Get all file contexts from pyros config
130 self._fn = self.config.fn 124 self._fn = self.config.fn
131 log.info(f"=== List of file name contexts available for the unit") 125 log.info(f"=== List of file name contexts available for the unit")
132 - for fcname in self._fn.fcontexts:  
133 - self._fn.fcontext = fcname  
134 - if self.is_in_test_mode():  
135 - self._fn.rootdir = os.path.abspath(self._fn.rootdir.replace("/PRODUCTS/","/PRODUCTS/TESTS/"))  
136 - os.makedirs(self._fn.rootdir, exist_ok=True)  
137 - log.info(self._fn.fcontexts_human())  
138 -  
139 - """  
140 - def config_check_contexts(self, modetest:bool, loginfo:bool):  
141 - for fcname in self.fn.fcontexts:  
142 - self.fn.fcontext = fcname  
143 - if self.is_in_test_mode():  
144 - self.fn.rootdir = os.path.abspath(self.fn.rootdir.replace("/PRODUCTS/","/PRODUCTS/TESTS/"))  
145 - os.makedirs(self._fn.rootdir, exist_ok=True)  
146 - if loginfo:  
147 - log.info(self.fn.fcontext_human())  
148 - """  
149 -  
150 - # === Set longitude to sequence file context to manage the night subdirectories  
151 - longitude = home.longitude  
152 - log.info(f"{longitude=}")  
153 - self._fn.longitude(longitude) 126 + self.check_contexts(True)
  127 + log.info(f"{self._fn.longitude=}")
154 128
155 # === Status of routine processing 129 # === Status of routine processing
156 self._routine_running = self.RUNNING_NOTHING 130 self._routine_running = self.RUNNING_NOTHING
@@ -560,6 +534,32 @@ class A_Scheduler(Agent): @@ -560,6 +534,32 @@ class A_Scheduler(Agent):
560 eph = guitastro.Ephemeris() 534 eph = guitastro.Ephemeris()
561 eph.set_home(self.config.getHome()) 535 eph.set_home(self.config.getHome())
562 536
  537 + """ A placer dans Agent
  538 + def ephem_target2night(target->str) -> dict:
  539 + fcontext0 = self._oc['config'].fn.fcontext
  540 + # --- Build the path and file name of the sun ephemeris
  541 + self._oc['config'].fn.fcontext = "pyros_eph"
  542 + night = self._oc['config'].fn.date2night("now")
  543 + fn_param = {
  544 + "period" : f"{info['period_id']}",
  545 + "date": night,
  546 + "version": "1",
  547 + "unit": self._oc['config'].unit_name,
  548 + "target": target
  549 + }
  550 + fname = self._fn.naming_set(fn_param)
  551 + eph_file = self._fn.joinabs(fname)
  552 + # --- Compute the sun ephemeris if needed. Save it as pickle.
  553 + if not os.path.exists(eph_file):
  554 + ephem_target = eph.target2night(target, night, None, None)
  555 + os.makedirs(os.path.dirname(eph_file), exist_ok=True)
  556 + pickle.dump(ephem_sun, open(eph_file,"wb"))
  557 + else:
  558 + ephem_target = pickle.load(open(eph_file,"rb"))
  559 + self._oc['config'].fn.fcontext = fcontext0
  560 + return ephem_target
  561 + """
  562 +
563 # --- Build the path and file name of the sun ephemeris 563 # --- Build the path and file name of the sun ephemeris
564 self._fn.fcontext = "pyros_eph" 564 self._fn.fcontext = "pyros_eph"
565 fn_param = { 565 fn_param = {