Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hkutils hkdb #840

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Hkutils hkdb #840

wants to merge 2 commits into from

Conversation

sanahabhimani
Copy link
Contributor

@sanahabhimani sanahabhimani commented May 10, 2024

Updated hk_utils to use hkdb.load_hk()

Note that the use of this is slightly different from load_range() so HK loading documentation should be updated as well. Is it advised to also add hk_utils documentation as a subsection in hkdb documentation?

Saved as a draft PR because I assumed it'd be best to approve and merge hkdb-related changes piece-meal rather than in one PR in #787

Example config file, hk.yaml:

hk_root: /so/data/satp1/hk
hk_db: /so/home/sanahbhim/repos/sotodlib/sotodlib/io/satp1_hk_test.db
aliases:
    fp_temp: cryo-ls372-lsa21yc.temperatures.Channel_02_T
    bd-dr-port: cryo-ls240-lsa2619.temperatures.Channel_2_T
    urh: cryo-ls240-lsa2619.temperatures.Channel_1_T

Setup code below:

from sotodlib.io import hkdb, hk_utils
from sotodlib import core
import yaml

t1 = 1710979091
t0 = t1 - 2*24*3600
config = 'hk.yaml'

HK Axis Manager examples:

[IN]
# using fields in config file
hkaman = hk_utils.get_hkaman(config=config, start=t0, end=t1, fields=None)
print(hkaman)
print(hkaman['cryo-ls240-lsa2619']['hklabels_cryo-ls240-lsa2619'])

[OUT]
AxisManager(cryo-ls240-lsa2619*[hklabels_cryo-ls240-lsa2619,hksamps_cryo-ls240-lsa2619], fp_temp*[hklabels_fp_temp,hksamps_fp_temp], hklabels_cryo-ls240-lsa2619:LabelAxis(2), hksamps_cryo-ls240-lsa2619:OffsetAxis(277269), hklabels_fp_temp:LabelAxis(1), hksamps_fp_temp:OffsetAxis(694971))

LabelAxis(2:'urh','bd-dr-port')

[IN]
time = hkaman['cryo-ls240-lsa2619']['timestamps']
urh = hkaman['cryo-ls240-lsa2619']['cryo-ls240-lsa2619_data'][0]

plt.plot(time, urh, '.')

[IN]
# loading cryo data for a field name not identified in the .yaml file
hkaman = hk_utils.get_hkaman(config=config, start=t0, end=t1, fields=['cryo-ls240-lsa2619.temperatures.Channel_3_T'])

[OUT]
AxisManager(cryo-ls240-lsa2619*[hklabels_cryo-ls240-lsa2619,hksamps_cryo-ls240-lsa2619], hklabels_cryo-ls240-lsa2619:LabelAxis(1), hksamps_cryo-ls240-lsa2619:OffsetAxis(277269))

Detector Cosampled HK Axismanagers
Assume an observation aman named aman has already been loaded

[IN]
# using a field name not identified in config file
hkdetaman = hk_utils.get_detcosamp_hkaman(det_aman=aman, config=config, fields=['hwp-bbb-e2.HWPEncoder.approx_hwp_freq'])
print(hkdetaman)

[OUT]
AxisManager(hwp-bbb-e2*[hklabels_hwp-bbb-e2,detector_timestamps], hklabels_hwp-bbb-e2:LabelAxis(1), detector_timestamps:OffsetAxis(734866)

[IN]
time = hkdetaman['hwp-bbb-e2']['timestamps']
hwp = hkdetaman['hwp-bbb-e2']['hwp-bbb-e2_data'][0]

plt.plot(time, hwp, '.')
[IN]
# using field names/aliases in config file
hkdetaman = hk_utils.get_detcosamp_hkaman(det_aman=aman, config=config, fields=None)
print(hkdetaman)

[OUT]
AxisManager(cryo-ls240-lsa2619*[hklabels_cryo-ls240-lsa2619,detector_timestamps], cryo-ls372-lsa21yc*[hklabels_cryo-ls372-lsa21yc,detector_timestamps], hklabels_cryo-ls240-lsa2619:LabelAxis(2), detector_timestamps:OffsetAxis(734866), hklabels_cryo-ls372-lsa21yc:LabelAxis(1))

Added check for a third element in `group[field]` before accessing it.
@sanahabhimani sanahabhimani self-assigned this May 14, 2024
@sanahabhimani sanahabhimani marked this pull request as ready for review July 2, 2024 06:19
@sanahabhimani
Copy link
Contributor Author

(sorry, I was convinced that this was not a draft PR so I'm glad I checked)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant