simonsobs / scheduler

Scheduler for SO
0 stars 1 forks source link

"Sun-safe parking spot not found." when only CMB scan. #111

Closed yoshinori-0778 closed 1 month ago

yoshinori-0778 commented 1 month ago

I got error "ValueError("Sun-safe parking spot not found.")" when I try to produce a schedule that includes only CMB scan. This looks to related observation gap that is written as below. This was an output if we avoid this error by doing comment out of "raise ValueError("Sun-safe parking spot not found.")".

run.wait_until('2024-10-03T14:02:36+00:00')
run.acu.move_to(az=180.0, el=60.0)
run.wait_until('2024-10-03T14:07:36+00:00')
run.acu.move_to(az=180.0, el=60.0)
run.wait_until('2024-10-03T17:07:59.980000+00:00')
run.acu.move_to(az=111.483, el=60.0)
run.wait_until('2024-10-03T17:12:59.980000+00:00')
run.acu.move_to(az=111.483, el=60.0)

The output above looks fine in terms of the sun-avoidance.

I used latest main branch for both scheduler and scheduler-scripts scheduler: a4173fee02f43316f3036d2aa9380e132ded3a73 scheduler-scripts: a2dd0047f688b76046be6b21d5ed3c47c2c44a02

Used yaml file:

platform: satp3

# yaml loads iso format automatically into datetimes
t0: 2024-10-02T20:00:00+00:00
t1: 2024-10-03T22:00:00+00:00
t0_state_file: None
#t0_state_file: satp3/state_files/state_2024-08-17T20:00:00+00:00.npy

elevation: 60
boresight: 0
az_speed: 0.5
az_accel: 0.25

# optional, only needed if running non-defaults
apply_boresight_rotation: False
disable_hwp: True
no_cmb: False
hwp_dir: True # True: forwards, False: backwards
home_at_end: True # Home: spin down HWP and go to (180,60)
run_relock: True # Relock detectors at the beginning of the schedule

# can comment out completely if only wanting CMB
# BE CAREFUL - scheduler does not spin down HWP for boresight rotations 
#              in cal targets. Probably best not to use them
#cal_targets:
  #- source: jupiter
  #  # boresight: # if not specified, use scan boresight
  #  elevation: 48
  #  focus: 'ws1'
  #  allow_partial: True
  #  az_branch: 270 ## maybe need to scan one side of jupiter
  #- source: 
  #  # boresight: # if not specified, use scan boresight
  #  elevation: 60
  #  focus: 'ws3,ws4'
  #  allow_partial: False

Output

(soconda_0.1.2.dev221) ysueno@compute22:~/workspace/script/scheduler-scripts/sat$ python3 gen_schedule.
py yamls/202410/1002_cmb.yaml
Not using state file None because it doesn't exist
2024-10-02 17:03:15,811 [WARNING] Boresight Override does nothing for SATp3
2024-10-02 17:03:19,319 [INFO] applying sun avoidance rule: {'min_angle': 49, 'min_sun_time': 1980}
2024-10-02 17:03:21,001 [INFO] planning calibration scans...
2024-10-02 17:03:21,257 [INFO] -> after calibration policy: []
2024-10-02 17:03:21,257 [INFO] applying min duration rule: {'min_duration': 600}
2024-10-02 17:03:21,257 [INFO] ================ pass 1 ================
2024-10-02 17:03:21,257 [INFO] step 1: planning pre-session ops
2024-10-02 17:03:21,258 [INFO] step 2: planning calibration scans
2024-10-02 17:03:21,415 [INFO] step 3: planning cmb ops
2024-10-02 17:03:21,494 [INFO] step 4: planning post-session ops
2024-10-02 17:03:21,494 [INFO] not enough time for post-session operations, trimming...
2024-10-02 17:03:21,495 [INFO] ================ pass 2 ================
2024-10-02 17:03:21,495 [INFO] step 1: planning pre-session ops
2024-10-02 17:03:21,495 [INFO] step 2: planning calibration scans
2024-10-02 17:03:21,561 [INFO] step 3: planning cmb ops
2024-10-02 17:03:21,635 [INFO] step 4: planning post-session ops
2024-10-02 17:03:21,635 [INFO] round_trip: converged in pass 2, lowering...
2024-10-02 17:03:21,635 [INFO] ================ lowering ================
2024-10-02 17:03:21,635 [INFO] step 1: planning pre-session ops
2024-10-02 17:03:21,635 [INFO] step 2: planning calibration scans
2024-10-02 17:03:21,700 [INFO] step 3: planning cmb ops
2024-10-02 17:03:21,775 [INFO] step 4: planning post-session ops
2024-10-02 17:03:21,775 [INFO] ================ solve moves ================
2024-10-02 17:03:21,775 [INFO] step 1: solve sun-safe moves
Traceback (most recent call last):
  File "/so/home/ysueno/workspace/script/scheduler-scripts/sat/gen_schedule.py", line 158, in <module>
    main(**cfgs)
  File "/so/home/ysueno/workspace/script/scheduler-scripts/sat/gen_schedule.py", line 128, in main
    cmds, state = policy.seq2cmd(seq, t0, t1, return_state=True)
  File "/so/home/ysueno/workspace/script/scheduler/src/schedlib/policies/sat.py", line 728, in seq2cmd
    ops, state = build_op.apply(seq, t0, t1, state, self.operations)
  File "/so/home/ysueno/workspace/script/scheduler/src/schedlib/policies/stages/build_op.py", line 131, in apply
    ir = PlanMoves(**self.plan_moves).apply(ir)
  File "/so/home/ysueno/workspace/script/scheduler/src/schedlib/policies/stages/build_op.py", line 705, in apply
    gaps = get_safe_gaps(seq[i-1], seq[i])
  File "/so/home/ysueno/workspace/script/scheduler/src/schedlib/policies/stages/build_op.py", line 672, in get_safe_gaps
    raise ValueError("Sun-safe parking spot not found.")
ValueError: Sun-safe parking spot not found.
ykyohei commented 1 month ago

I agree with Yoshi that sun-safe criteria are wrongly calculated for this. We have this error everyday recently, so this is relatively urgent. I guess sun-avoidance part is written by @mhasself, could you take a look?

mhasself commented 1 month ago

I do not agree that Sun Safety is incorrectly applied here. el=60, az=180 is not safe at local noon (and won't be, for the next few months).

The "sun safe parking" code does not currently permit a change in elevation, for safe parking. That can presumably be added, but we need rules about what el moves are acceptable.

image

mhasself commented 1 month ago

I also acknowledge that the error message could be more helpful -- and explain that the position is only safe until time X, or something ...

ykyohei commented 1 month ago

Thank you, we missed that.. For now, we will escape to el 50 manually, but we need "sun safe parking" to support the change of elevation.