EranOfek / AstroPack

Astronomy & Astrophysics Software Pacakge
Other
19 stars 4 forks source link

set proper persistence and resetting calls for `telescope.Scheduler.demon` #516

Open EastEriq opened 1 week ago

EastEriq commented 1 week ago

It is desirable that the demon could be launched in one of the following modalities, with the help of proper input parameters

  1. normal scheduling mode -- the persistence file AstroPack/matlab/startup/TargetList.mat is loaded when the demon is launched, so that the last working set of targets is loaded, together with the information about the last time they were visited. This file is automatically resaved onto itself any time a target is dispatched, inside the method .serviceTargetRequests(). Even if complete resave is not efficient, we have said that it is not expensive. This also provides the most senseful way for restarting a crashed scheduler, and should be the default.
  2. reset scheduling -- the persistence file is read, but LastJD is zeroed.
  3. read anew a scheduling table from the csv file specified: this is the current call telescope.Scheduler.demon('TargetList',<filename>). This resets both the list of targets and the timing. Since a csv file can be supplied, this is probably the easiest way for users to provide edited target lists.
  4. run the scheduler without updating the persistence file. This is important when testing the scheduler (or the schedule) in simulation mode. In this case the JD of the requests passed to telescope.Scheduler.selectTarget is arbitrarily in the past or in the future. Updating the persistence file is bound to lead very soon to JD must be larger then (sic!) LastJD errors (see eg. #510)

Currently only 3. is really implemented as written, and the persistence file is not read back (well, I presume it could if the demon was launched with telescope.Scheduler.demon('TargetList','~/matlab/AstroPack/matlab/startup/TargetList.mat'), but have not tried it).

Additionally, the users should have a line of instruction about how to load a scheduling object from the persistence file, save it as csv, edit it as a spreadsheet, and reimport as new TargetList. Such ability is needed for maintaining persistence fles in which ToO lists have been incrementally added; discussion about it may be opened in another ticket.

As of now there is also a mode

  1. the scheduler creates as default the default survey list by tiling the sky (method telescope.Scheduler.generateRegularGrid()). This is the current action when telescope.Scheduler.demon is called without parameters.

I think that this mode does not make so much sense as it is, because the default survey assumes that all telescopes are in open mode and all mounts are equivalent, which is most of the times not the case. Besides, the default tiling has no notion of the fields which were already visited.

EranOfek commented 6 days ago

Ok - lets discuss this in person - meanwhile, I implemented the following changes:

In telescope.Scheduler/demon - added arguments:

 'SaveTargetList' - Save TargetList after each update. Default is true.
 'SetLastJD' - if not empty, then set LastJD to this value. Default is [].
 'SetGlobalCounter' -  if not empty, then set GlobalCounter to this value. Default is [].
 'SetNightCounter' -  if not empty, then set NightCounter to this value. Default is [].

Re mode1: This is not a good idea to store files in: AstroPack/matlab/startup/TargetList.mat since it will require frequent git push... Instead, I suggest that the default will be some predefined

EastEriq commented 6 days ago

This is not a good idea to store files in: AstroPack/matlab/startup/TargetList.mat since it will require frequent git push... Instead, I suggest that the default will be some predefined

That's where you wrote in your code. I also think it is not a clever location. Whatever location in the AstroPack tree, though, it can simply be .gitignored.

EranOfek commented 6 days ago

[dev1 3d21dc5ac]

EastEriq commented 6 days ago
>> telescope.Scheduler.demon('SetLastJD',0)
Error using telescope.Scheduler/insertColList (line 1264)
Right hand side of an assignment into a table must be another table or a cell array.

Error in telescope.Scheduler.demon (line 1071)
                S = insertColList(S, 'LastJD',Args.SetLastJD, []);
EranOfek commented 6 days ago

fixed [dev1 5654d2fd5]

On Mon, Nov 11, 2024 at 11:04 AM EastEriq @.***> wrote:

telescope.Scheduler.demon('SetLastJD',0) Error using telescope.Scheduler/insertColList (line 1264) Right hand side of an assignment into a table must be another table or a cell array.

Error in telescope.Scheduler.demon (line 1071) S = insertColList(S, 'LastJD',Args.SetLastJD, []);

— Reply to this email directly, view it on GitHub https://github.com/EranOfek/AstroPack/issues/516#issuecomment-2467597419, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJUQ4JZ2ON3IFWCN646TCT2ABXJ7AVCNFSM6AAAAABRQJFMMOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINRXGU4TONBRHE . You are receiving this because you modified the open/close state.Message ID: @.***>

EastEriq commented 6 days ago

No it's not

>> telescope.Scheduler.demon('SetLastJD',0)
Error using telescope.Scheduler/insertColList (line 1266)
Right hand side of an assignment into a table must be another table or a cell array.

Error in telescope.Scheduler.demon (line 1071)
                S = insertColList(S, 'LastJD',Args.SetLastJD, []);
EastEriq commented 6 days ago

I've committed a trivial fix. However, I note:

telescope.Scheduler.demon('SetLastJD',celestial.time.julday-1)

is ok and the scheduler returns targets, but

>> telescope.Scheduler.demon('SetLastJD',0)
11:03:12.317 [INF] selecting target for mount 4, requested at JD=2460625.260458, now 2460625.960559
11:03:13.140 [WRN] No target for unit 4 at this time
11:03:23.222 [INF] selecting target for mount 10, requested at JD=2460625.260513, now 2460625.960685
11:03:23.941 [WRN] No target for unit 10 at this time
11:03:34.137 [INF] selecting target for mount 8, requested at JD=2460625.260548, now 2460625.960812
11:03:34.891 [WRN] No target for unit 8 at this time
11:03:35.052 [INF] selecting target for mount 6, requested at JD=2460625.260550, now 2460625.960822
11:03:35.816 [WRN] No target for unit 6 at this time
11:03:36.595 [INF] selecting target for mount 10, requested at JD=2460625.260752, now 2460625.960840
11:03:37.372 [WRN] No target for unit 10 at this time
11:03:40.556 [INF] selecting target for mount 1, requested at JD=2460625.260880, now 2460625.960886
11:03:41.288 [WRN] No target for unit 1 at this time
11:03:44.285 [INF] selecting target for mount 2, requested at JD=2460625.260923, now 2460625.960929
11:03:44.981 [WRN] No target for unit 2 at this time
11:03:45.193 [INF] selecting target for mount 5, requested at JD=2460625.260926, now 2460625.960940
11:03:45.896 [WRN] No target for unit 5 at this time
11:03:46.632 [INF] selecting target for mount 3, requested at JD=2460625.260935, now 2460625.960956
11:03:47.331 [WRN] No target for unit 3 at this time
....

can't find any. Why?

EranOfek commented 6 days ago

you didn't specify JD so it is running in real time and currently the SunAlt>0.

I fixed another bug.

On Mon, Nov 11, 2024 at 1:04 PM EastEriq @.***> wrote:

I've committed a trivial fix. However, I note:

telescope.Scheduler.demon('SetLastJD',celestial.time.julday-1)

is ok and the scheduler returns targets, but

telescope.Scheduler.demon('SetLastJD',0) 11:03:12.317 [INF] selecting target for mount 4, requested at JD=2460625.260458, now 2460625.960559 11:03:13.140 [WRN] No target for unit 4 at this time 11:03:23.222 [INF] selecting target for mount 10, requested at JD=2460625.260513, now 2460625.960685 11:03:23.941 [WRN] No target for unit 10 at this time 11:03:34.137 [INF] selecting target for mount 8, requested at JD=2460625.260548, now 2460625.960812 11:03:34.891 [WRN] No target for unit 8 at this time 11:03:35.052 [INF] selecting target for mount 6, requested at JD=2460625.260550, now 2460625.960822 11:03:35.816 [WRN] No target for unit 6 at this time 11:03:36.595 [INF] selecting target for mount 10, requested at JD=2460625.260752, now 2460625.960840 11:03:37.372 [WRN] No target for unit 10 at this time 11:03:40.556 [INF] selecting target for mount 1, requested at JD=2460625.260880, now 2460625.960886 11:03:41.288 [WRN] No target for unit 1 at this time 11:03:44.285 [INF] selecting target for mount 2, requested at JD=2460625.260923, now 2460625.960929 11:03:44.981 [WRN] No target for unit 2 at this time 11:03:45.193 [INF] selecting target for mount 5, requested at JD=2460625.260926, now 2460625.960940 11:03:45.896 [WRN] No target for unit 5 at this time 11:03:46.632 [INF] selecting target for mount 3, requested at JD=2460625.260935, now 2460625.960956 11:03:47.331 [WRN] No target for unit 3 at this time ....

can't find any. Why?

— Reply to this email directly, view it on GitHub https://github.com/EranOfek/AstroPack/issues/516#issuecomment-2467898396, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJUQ4JY5RHUERSDPGKDXKL2ACFNBAVCNFSM6AAAAABRQJFMMOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINRXHA4TQMZZGY . You are receiving this because you modified the open/close state.Message ID: @.***>

EastEriq commented 6 days ago

No, it's running in simulated time, yesterday night, the units are providing it. 11:03:46.632 [INF] selecting target for mount 3, requested at JD=2460625.260935, now 2460625.960956

that can't be the issue, LastJD should only be the last time the target was visited.

EastEriq commented 6 days ago

Which fix? Obj.List.Catalog.(ColName)(Index) = Val; which I overrode with Obj.List.Catalog{Index, ColInd} = Val;? (I guess that they might be equivalent)