Commit 2d1bc05bc83b1c7e8bf7b761606d2639bc05514f
1 parent
dfbe4770
Exists in
dev
Add duskelev in obsconfig & fix update_sun_moon_ephems
Showing
3 changed files
with
21 additions
and
6 deletions
Show diff stats
config/pyros_observatory/general/schemas/schema_observatory-2.0.yml
@@ -525,6 +525,9 @@ schema;schema_UNIT: | @@ -525,6 +525,9 @@ schema;schema_UNIT: | ||
525 | home: | 525 | home: |
526 | type: str | 526 | type: str |
527 | required: True | 527 | required: True |
528 | + duskelev: | ||
529 | + type: str | ||
530 | + required: True | ||
528 | horizon: | 531 | horizon: |
529 | type: map | 532 | type: map |
530 | required: True | 533 | required: True |
src/core/pyros_django/majordome/agent/Agent.py
@@ -154,7 +154,8 @@ import config.old_config as config_old | @@ -154,7 +154,8 @@ import config.old_config as config_old | ||
154 | #from config import * | 154 | #from config import * |
155 | 155 | ||
156 | from majordome.models import AgentSurvey, AgentCmd, AgentLogs | 156 | from majordome.models import AgentSurvey, AgentCmd, AgentLogs |
157 | -from user_mgmt.models import Period, Quota | 157 | +from user_mgmt.models import Period |
158 | +from scp_mgmt.models import Quota | ||
158 | 159 | ||
159 | from vendor.guitastro.src.guitastro import Ephemeris | 160 | from vendor.guitastro.src.guitastro import Ephemeris |
160 | import pickle | 161 | import pickle |
@@ -3551,21 +3552,21 @@ class Agent: | @@ -3551,21 +3552,21 @@ class Agent: | ||
3551 | # --- Check if durations.pickle file exists | 3552 | # --- Check if durations.pickle file exists |
3552 | rootdir = self._oc['config'].fn.rootdir | 3553 | rootdir = self._oc['config'].fn.rootdir |
3553 | filename = os.path.join(rootdir, period_id, "durations.pickle") | 3554 | filename = os.path.join(rootdir, period_id, "durations.pickle") |
3554 | - self.dprint(f"Read {filename=}") | 3555 | + log.info(f"Read {filename=}") |
3555 | if os.path.exists(filename): | 3556 | if os.path.exists(filename): |
3556 | self._oc['config'].fn.fcontext = fcontext0 | 3557 | self._oc['config'].fn.fcontext = fcontext0 |
3557 | return pickle.load(open(filename, "wb")) | 3558 | return pickle.load(open(filename, "wb")) |
3558 | 3559 | ||
3559 | # --- Get the period limit dates jd1, jd2 | 3560 | # --- Get the period limit dates jd1, jd2 |
3560 | - self.dprint(f"{dir(operiod)=}") | 3561 | + log.info(f"{dir(operiod)=}") |
3561 | d = operiod.start_date.isoformat() | 3562 | d = operiod.start_date.isoformat() |
3562 | night_start = d[0:4]+d[5:7]+d[8:10] | 3563 | night_start = d[0:4]+d[5:7]+d[8:10] |
3563 | jd1, _ = self.config.fn.night2date(night_start) | 3564 | jd1, _ = self.config.fn.night2date(night_start) |
3564 | d = operiod.end_date.isoformat() | 3565 | d = operiod.end_date.isoformat() |
3565 | night_end = d[0:4]+d[5:7]+d[8:10] | 3566 | night_end = d[0:4]+d[5:7]+d[8:10] |
3566 | jd2, _ = self.config.fn.night2date(night_end) | 3567 | jd2, _ = self.config.fn.night2date(night_end) |
3567 | - self.dprint(f"{night_start=} {night_end=}") | ||
3568 | - self.dprint(f"{jd1=} {jd2=}") | 3568 | + log.info(f"{night_start=} {night_end=}") |
3569 | + log.info(f"{jd1=} {jd2=}") | ||
3569 | 3570 | ||
3570 | # --- Loop over dates of the period to create ephems | 3571 | # --- Loop over dates of the period to create ephems |
3571 | targets = ['sun', 'moon'] | 3572 | targets = ['sun', 'moon'] |
@@ -3576,10 +3577,11 @@ class Agent: | @@ -3576,10 +3577,11 @@ class Agent: | ||
3576 | d_cur = 0 | 3577 | d_cur = 0 |
3577 | d_total = 0 | 3578 | d_total = 0 |
3578 | night_info = {} | 3579 | night_info = {} |
3580 | + self._duskelev = self.config.getDuskElev() | ||
3579 | while jd < jd2: | 3581 | while jd < jd2: |
3580 | night = self._oc['config'].fn.date2night(jd) | 3582 | night = self._oc['config'].fn.date2night(jd) |
3581 | for target in targets: | 3583 | for target in targets: |
3582 | - self.dprint(f"{night=} {target=}") | 3584 | + log.info(f"{night=} {target=}") |
3583 | ephem = self.ephem_target2night(target, jd) | 3585 | ephem = self.ephem_target2night(target, jd) |
3584 | if target == "sun": | 3586 | if target == "sun": |
3585 | ks = np.where(ephem['alt'] < self._duskelev) | 3587 | ks = np.where(ephem['alt'] < self._duskelev) |
src/core/pyros_django/obs_config/obsconfig_class.py
@@ -1239,6 +1239,16 @@ class OBSConfig: | @@ -1239,6 +1239,16 @@ class OBSConfig: | ||
1239 | """ | 1239 | """ |
1240 | home = self.get_unit_by_name(self.unit_name).get("home") | 1240 | home = self.get_unit_by_name(self.unit_name).get("home") |
1241 | return home | 1241 | return home |
1242 | + | ||
1243 | + def getDuskElev(self)->float: | ||
1244 | + """ | ||
1245 | + Return duskelev of current unit | ||
1246 | + | ||
1247 | + Returns: | ||
1248 | + float: string reprensenting duskelev of unit | ||
1249 | + """ | ||
1250 | + duskelev = float(self.get_unit_by_name(self.unit_name).get("duskelev")) | ||
1251 | + return duskelev | ||
1242 | 1252 | ||
1243 | def get_agent_path_data_root(self, agent_name:str, computer_hostname=None) -> str: | 1253 | def get_agent_path_data_root(self, agent_name:str, computer_hostname=None) -> str: |
1244 | """ | 1254 | """ |