Commit 1c875d781e95113af614e09158ee5b901ac71753
1 parent
6d8ef54d
Exists in
dev
Add command in A_SCP_Manager to generate ephemeris files of sun & moon for a period
Showing
2 changed files
with
33 additions
and
12 deletions
Show diff stats
CHANGELOG
1 | -21-07-2023 (AKo): V0.6.27.0 | |
1 | +28-07-2023 (AKo): V0.6.28.0 | |
2 | + - Add command in A_SCP_Manager to generate ephemeris files of sun & moon for a period | |
3 | + - Fix config_pyros paths | |
4 | + - Fix JS of agent_detail | |
5 | + | |
6 | +26-07-2023 (AKo): V0.6.27.0 | |
7 | + - Remove private & privatedev folder | |
8 | + | |
9 | +24-07-2023 (AKo): V0.6.27.0 | |
2 | 10 | - install_observatory now copy default observatory if repository doesn't exists |
3 | 11 | - fix error on update due to package version for doc generation |
4 | 12 | - update dockerfile (can't copy outside build context) | ... | ... |
src/core/pyros_django/scp_mgmt/A_SCP_Manager.py
... | ... | @@ -16,10 +16,9 @@ for short_path in short_paths: |
16 | 16 | sys.path.insert(0, path) |
17 | 17 | |
18 | 18 | # Project imports |
19 | -from src.core.pyros_django.user_mgmt.models import PyrosUser | |
20 | -from seq_submit.models import Period, SP_Period, SP_Period_Guest, SP_PeriodWorkflow, ScientificProgram,SP_Period_User, ScienceTheme | |
21 | -from src.core.pyros_django.majordome.agent.Agent import Agent, build_agent | |
22 | -from vendor.guitastro.src.guitastro import guitastro | |
19 | +from majordome.agent.Agent import Agent, build_agent | |
20 | +from user_mgmt.models import PyrosUser, SP_Period, Period, SP_Period, SP_Period_Guest, SP_PeriodWorkflow | |
21 | +import vendor.guitastro.src.guitastro as guitastro | |
23 | 22 | |
24 | 23 | # Django imports |
25 | 24 | from django.shortcuts import reverse |
... | ... | @@ -47,7 +46,7 @@ class A_SCP_Manager(Agent): |
47 | 46 | _AGENT_SPECIFIC_COMMANDS = { |
48 | 47 | # Format : “cmd_name” : (timeout, exec_mode, tooltip) |
49 | 48 | |
50 | - "generate_ephem_moon_and_sun_for_period": (3, Agent.EXEC_MODE.SEQUENTIAL, 'generate ephem of moon & sun for a period'), | |
49 | + "do_generate_ephem_moon_and_sun_for_period": (3, Agent.EXEC_MODE.SEQUENTIAL, 'generate ephem of moon & sun for a period'), | |
51 | 50 | } |
52 | 51 | |
53 | 52 | # new init with obsconfig |
... | ... | @@ -59,6 +58,10 @@ class A_SCP_Manager(Agent): |
59 | 58 | super().__init__() |
60 | 59 | next_period = Period.objects.next_period() |
61 | 60 | period = next_period |
61 | + self.pconfig = self._oc['pyros_config'] | |
62 | + self._fn = self.pconfig.fn | |
63 | + self.config = self._oc['config'] | |
64 | + self._fn.pathnaming("PyROS.seq.1") | |
62 | 65 | |
63 | 66 | # @override |
64 | 67 | def _init(self): |
... | ... | @@ -240,19 +243,26 @@ class A_SCP_Manager(Agent): |
240 | 243 | for n in range(int((end_date - start_date).days)): |
241 | 244 | yield start_date + timedelta(n) |
242 | 245 | |
243 | - def generate_ephem_moon_and_sun_for_period(self,period): | |
246 | + def do_generate_ephem_moon_and_sun_for_period(self, period_id:int): | |
247 | + period = Period.objects.get(id=period_id) | |
244 | 248 | period_start_date = period.start_date |
245 | 249 | period_end_date = period.end_date |
250 | + | |
246 | 251 | root_path = os.environ.get("PROJECT_ROOT_PATH") |
247 | 252 | os.chdir(root_path) |
248 | - ephem_data_night_folder = os.path.join(root_path, "data") | |
253 | + | |
254 | + home = guitastro.Home(self._oc["config"].getHome()) | |
255 | + self._fn.longitude(home.longitude) | |
256 | + | |
257 | + ephem_data_night_folder = self._fn.rootdir | |
249 | 258 | if os.path.exists(ephem_data_night_folder): |
250 | 259 | period_id = str(period.id) |
251 | 260 | # form correct period string |
252 | 261 | if len(str(period.id)) < 3: |
253 | 262 | while len(period_id) < 3: |
254 | 263 | period_id = "0" + period_id |
255 | - ephem_data_night_folder = os.path.join(root_path, "data", period_id) | |
264 | + period_id = "P" + period_id | |
265 | + ephem_data_night_folder = os.path.join(ephem_data_night_folder, period_id) | |
256 | 266 | if not os.path.exists(ephem_data_night_folder): |
257 | 267 | os.makedirs(ephem_data_night_folder, exist_ok=True) |
258 | 268 | for single_date in self.daterange(period_start_date, period_end_date): |
... | ... | @@ -261,15 +271,18 @@ class A_SCP_Manager(Agent): |
261 | 271 | eph = guitastro.Ephemeris() |
262 | 272 | target_sun = "sun" |
263 | 273 | ephem_sun = eph.target2night(target_sun, current_date, None, None) |
264 | - file_name_sun = f"ephem_sun_{current_date}.p" | |
265 | - file_name_moon = f"ephem_moon_{current_date}.p" | |
274 | + file_name_sun = f"ephem_sun_{current_date}" | |
275 | + file_name_moon = f"ephem_moon_{current_date}" | |
266 | 276 | os.chdir(ephem_data_night_folder) |
267 | 277 | pickle.dump(ephem_sun, open(f"{file_name_sun}.f","wb")) |
268 | 278 | target_moon = "moon" |
269 | 279 | ephem_moon = eph.target2night(target_moon, current_date, None, None) |
270 | 280 | pickle.dump(ephem_moon, open(f"{file_name_moon}.f","wb")) |
271 | 281 | |
272 | - | |
282 | + # 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 & | |
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 | |
285 | + | |
273 | 286 | if __name__ == "__main__": |
274 | 287 | |
275 | 288 | # with thread | ... | ... |