Closed thusser closed 3 years ago
Thanks @thusser.
It looks like it might be an issue with the time_resolution
parameter that is passed to a scheduler, which has a default of 20 seconds. If you change that, to e.g. one second, it still schedules outside of your time block but it's within about one half second of that (see below).
This is probably an indexing error somewhere in there. I don't have a ton of time right not to try to fix it but that point you in the right direction.
I changed time resolution here. Note that it does take a lot longer to process.
# create scheduler with fine time resolution
scheduler = PriorityScheduler(constraints, observer, transitioner=transitioner, time_resolution=1*u.second)
which gives:
HIP 24565
Window: 2021-02-26T17:49:50.294 - 2021-02-26T21:49:50.294
Scheduled: 2021-02-26T18:09:27.919 - 2021-02-26T18:11:30.919
---
M42
Window: 2021-02-26T08:09:50.000 - 2021-02-27T08:09:50.000
Scheduled: 2021-02-26T18:27:47.913 - 2021-02-26T18:30:18.913
---
TOI 1676.01
Window: 2021-02-26T19:23:33.700 - 2021-02-26T20:24:39.181
Scheduled: 2021-02-26T19:23:33.895 - 2021-02-26T20:14:30.895
---
TOI 959.01
Window: 2021-02-26T21:28:55.708 - 2021-02-26T22:57:13.764
Scheduled: 2021-02-26T21:28:55.854 - 2021-02-26T22:47:05.854
---
TOI 1274.01
Window: 2021-02-27T01:11:39.252 - 2021-02-27T01:46:50.182
Scheduled: 2021-02-27T01:21:48.778 - 2021-02-27T01:46:50.778
SCHEDULED OUTSIDE REQUESTED WINDOW!
---
TOI 2138.01
Window: 2021-02-27T02:05:12.480 - 2021-02-27T02:38:50.308
Scheduled: 2021-02-27T02:15:21.761 - 2021-02-27T02:38:50.761
SCHEDULED OUTSIDE REQUESTED WINDOW!
---
TOI 1829.01
Window: 2021-02-27T03:06:53.686 - 2021-02-27T03:48:25.220
Scheduled: 2021-02-27T03:17:02.741 - 2021-02-27T03:48:25.741
SCHEDULED OUTSIDE REQUESTED WINDOW!
---
TOI 1252.01
Window: 2021-02-27T04:16:14.102 - 2021-02-27T04:49:17.384
Scheduled: 2021-02-27T04:26:22.718 - 2021-02-27T04:49:17.718
SCHEDULED OUTSIDE REQUESTED WINDOW!
---
Thanks both!
Some follow-up questions for @thusser based on @wtgee's post:
time_resolution
parameter even smaller (0.1*u.s
) and then you'll get precision on that order, but the runtime will scale with the time resolution. If you're running this once per day then perhaps speed doesn't matter too much, but of course I would understand if you needed to run it on the fly (in response to weather, for example) and you'd like it to be fastInvestigating a bit, I wonder if this is related to these lines: by taking the np.ceil
, are we rounding up when we should be rounding down?
Switching that ceil
to a floor
produces the following (without changing the time_resolution
parameter), with passing tests:
HIP 24565
Window: 2021-02-26T17:49:50.294 - 2021-02-26T21:49:50.294
Scheduled: 2021-02-26T18:09:20.009 - 2021-02-26T18:11:20.009
---
M42
Window: 2021-02-26T08:09:50.000 - 2021-02-27T08:09:50.000
Scheduled: 2021-02-26T18:28:00.010 - 2021-02-26T18:30:20.010
---
TOI 1676.01
Window: 2021-02-26T19:23:33.700 - 2021-02-26T20:24:39.181
Scheduled: 2021-02-26T19:23:40.012 - 2021-02-26T20:14:20.012
---
TOI 959.01
Window: 2021-02-26T21:28:55.708 - 2021-02-26T22:57:13.764
Scheduled: 2021-02-26T21:29:00.016 - 2021-02-26T22:47:00.016
---
TOI 1274.01
Window: 2021-02-27T01:11:39.252 - 2021-02-27T01:46:50.182
Scheduled: 2021-02-27T01:21:40.025 - 2021-02-27T01:46:40.025
---
TOI 2138.01
Window: 2021-02-27T02:05:12.480 - 2021-02-27T02:38:50.308
Scheduled: 2021-02-27T02:15:20.027 - 2021-02-27T02:38:40.027
---
TOI 1829.01
Window: 2021-02-27T03:06:53.686 - 2021-02-27T03:48:25.220
Scheduled: 2021-02-27T03:17:00.029 - 2021-02-27T03:48:20.029
---
TOI 1252.01
Window: 2021-02-27T04:16:14.102 - 2021-02-27T04:49:17.384
Scheduled: 2021-02-27T04:26:20.032 - 2021-02-27T04:49:00.032
---
It looks like it might be an issue with the time_resolution parameter that is passed to a scheduler, which has a default of 20 seconds.
Ah, interesting, so at least I know how much smaller I have to make the observing windows for my workaround to work. This is clearly a bug and it would be great if someone would fix it, but that would work for me.
how quickly do you need this to run? You could make the time_resolution parameter even smaller (0.1*u.s) and then you'll get precision on that order, but the runtime will scale with the time resolution. If you're running this once per day then perhaps speed doesn't matter too much, but of course I would understand if you needed to run it on the fly (in response to weather, for example) and you'd like it to be fast
I'm rescheduling quite often: blocks are added during the night, maybe we have to reschedule during the night after we opened late due to clouds, etc. In the future I'd even like to add seeing as a scheduling parameter, in order to skip faint targets or crowded fields. Right now it takes the scheduler a couple of minutes to run wit 30-40 blocks. A longer run is not really an option for us...
are the blocks correctly scheduled in terms of order but just slightly too long? It looks like in your examples, the block overflow is occurring on the block end rather than start each time
Yep, it always seems the block end. The funny thing is that there always is more than enough time at the beginning of the observng window. Look at the last scheduled blocks from the example and compare their start times with the end times of the previous block: they could always start at the beginning of their window.
I'm rescheduling quite often: blocks are added during the night, maybe we have to reschedule during the night after we opened late due to clouds, etc. In the future I'd even like to add seeing as a scheduling parameter, in order to skip faint targets or crowded fields. Right now it takes the scheduler a couple of minutes to run with 30-40 blocks. A longer run is not really an option for us...
Do you need to schedule the entire night if you are adding/removing during the night? We essentially use a priority dispatch scheduler to answer the question of "what can I observe right now?" and rely on a combination of target priority and constraint weight scoring to give us the "correct" target. It doesn't always work perfectly but that's because we don't have such stringent time windows so we haven't taken the time to make it Always Work™.
Could you schedule in, say, three hour time blocks with a finer time resolution? Your observing windows are all fairly small so that might work.
That said, just getting the code fixed might be the better answer. 😄
The PriorityScheduler doesn't always restrict the blocks to the requested time windows. I often get 15 seconds and more scheduled outside those windows. This is a problem for us, since the database storing the schedule doesn't accept slots that are not 100% within the requested windows. My current workaround is to make the time constraints smaller than requested. The SequentialScheduler doesn't have the same problem.
I couldn't really find a good minimum working example, with just a few observing blocks in the schedule everything seems fine. So here is an example that loads a list of 23 blocks from file and schedules them. It's just a list of of mostly TESS follow-ups we tried to do two nights ago...
Here is the code (the required blocks.yaml is attached at the end):
The output of this is:
As you can see, some of the scheduled slots do not fit in the requested time constraints.
Package versions are: astroplan==0.8 astropy==4.2
Any ideas?
blocks.yaml: