[INSTRM-1110] Factor out telescope and environmental conditions into new table(s) Created: 14/Nov/20  Updated: 05/Nov/21  Resolved: 05/Nov/21

Status: Done
Project: Instrument control development
Component/s: spt_operational_database
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Normal
Reporter: cloomis Assignee: Kiyoto Yabe
Resolution: Done Votes: 0
Labels: EngRun, PFI
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Relates
relates to INSTRM-1325 Have gen2 populate telescope and envi... Done
relates to INSTRM-1008 Design and create operational databas... Done
Story Points: 3
Sprint: EngRun03

 Description   

This has cropped up in a couple of places. SPS, MCS, and AGC variously need to know the telescope positions (alt/az/rot/adc/focus/etc), the environmental conditions (temperature/humidity/etc), and the observing conditions (seeing, cloud conditions, etc). All of this comes from Gen2, via the gen2Actor.

As it stands, the mcs_exposure and tel_condition tables and the MCS and SPS headers have some/all of this information, all populated from the gen2 MHS keywords, which are direct copies of the gen2 keywords.

Can we create system-independent tables just for these properties, and have the appropriate mcs, arc, and sps tables link to them? The gen2Actor can easily add rows periodically and/or at roughly the right times for each system's exposures, and can certainly create one row per MCS/AGC/SPS integration or readout (thinking about H4s and AGC here).

I do not know about the timing properties of the telescope or environmental info in the gen2 keywords – there is no point in doing better than that. On the PFS side, the H4/AGC cadence (one per 5-10s) is the fastest we would ever care about. eric?

tel_condition is empty, so we can rethink that completely.
I think two tables (telescope and everything else), but one would also work and be nicer for queries. Or also split out the human-generated conditions into its own table?



 Comments   
Comment by Kiyoto Yabe [ 19/Nov/20 ]

My initial, very naive thought is:

Assuming that we can get every status periodically and utilizing `tel_visit_id`, we have three tables:

  • tel_condition
    • pfs_visit_id (not null)
    • tel_visit_id  (not null)
    • tel_az
    • tel_el
    • tel_ra
    • tel_dec
    • tel_rot
    • tel_adc
    • tel_focus
    • timestamp
    • ...
  • env_condition
    • pfs_visit_id (not null)
    • tel_visit_id (not null)
    • dome_temperature
    • dome_humidity
    • dome_pressure
    • outside_temperature
    • ...
  • obs_condition
    • pfs_visit_id (not null)
    • tel_visit_id (not null)
    • seeing
    • transparency
    • cloud_condition
    • ...

, where `tel_visit_id` is just like a counter with a certain cadence starting just after pfs_visit_id is issued. (pfs_visit_id, tel_visit_id) is a unique key, so we probably need to have `tel_visit_id` in mcs_exposure, sps_exposure, agc_exposure, and obslog table, which should be the closest one to each exposure, so that we can easily identify conditions we want to know for each subsystem.

I surely do not know if this works and how to do this, but any comments are welcome.

Comment by cloomis [ 15/Jun/21 ]

Yes. I think all the tables should have pfs_visit_id and timestamp columns, but am not sure what the benefit of tel_visit_id is or what the value should be.

There will be multiple AGCC and MCS exposures per visit, and I think we can guarantee that there will be at least one (and probably no more than one) tel/env/obs update per AGCC/MCS exposure. So a variant of (visit == $visit AND timestamp between $agcc_tStart and $agcc_tEnd) query should be good for all reasonable sps/agcc/mcs investigations. I think that would be simpler than tracking some additional "telescope"/agcc/mcs id, since it would work in all cases.

As a side note, I would add some other dome information that we know we can track. For now:

  • dome shutter open/closed/unknown
  • dome (room) light mask integer.
Comment by Kiyoto Yabe [ 16/Jun/21 ]

Thank you for your comments. 

I feel timestamp is essentially all what we need to identify conditions of interest. `tel_visit_id` (or any unique identifiers) is beneficial only if we cannot guarantee the uniquness of the timestamp, but probably not? So, `timestamp` (or a combination with `pfs_visit_id` just in case) would be a primary key (if we want PK in each table). I'm not sure whether this is a standard design method, though.

One stupid question is whether we guarantee these timestamps are syncronized well enough with each subsystem (probably yes because we use the same gen2actor)? The record timing may be what we need to think about seriously.

Additional columns such as dome shutter/light status are surely fine to me.

Comment by cloomis [ 14/Jul/21 ]

The actual values dribble in from parts of the telescope systems at various rates and without any exploitable synchronization. The gen2Actor currently queries for new values when it needs to, but it could also passively listen to a 1 Hz update stream from gen2. The sunssActor currently does that.

The obvious times when we want good values are at the start of integration, particularly for the faster exposures (AGCC, MCS, H4 reads), and otherwise every 15s or so while observing.

Given the understandable reluctance to use timestamps in a key, I propose that all tables have a primary key of (pfs_visit_id, status_sequence_id), where the sequence id is maintained per-visit by the gen2Actor, and that all tables also have an indexed timestamp column. The gen2Actor would grow an updateConditions command which would force a update; that could be called by the agcc/mcs actors when they start an integration.

I am worried about delays if the real gen2 pauses as it seems to occasionally pause when getting a new frame/visit id. So will probably use the passive 1Hz stream whenever safe.

Comment by cloomis [ 19/Aug/21 ]

Per 2021-08-18 phone con, will be implemented as written.

Comment by hassan [ 08/Sep/21 ]

Kiyoto Yabe : what is the progress on this ticket? Can we close it based on your branch?

Comment by Kiyoto Yabe [ 08/Sep/21 ]

I believe so. cloomis?

Comment by Kiyoto Yabe [ 04/Nov/21 ]

Since the current schema at summit actually includes this revision, I'll merge the branch and close this ticket. We will file a new ticket if further revisions are necessary.

Generated at Sat Feb 10 16:31:59 JST 2024 using Jira 8.3.4#803005-sha1:1f96e09b3c60279a408a2ae47be3c745f571388b.