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

Add lmsi to preprocess_obs and preprocess_tod #962

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"influxdb",
"venn",
"sodetlib @ git+https://github.com/simonsobs/sodetlib",
"let-me-scroll-it",
],
"tests": [
"socs",
Expand Down
11 changes: 11 additions & 0 deletions sotodlib/site_pipeline/preprocess_obs.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@ def preprocess_obs(
start=os.path.dirname(configs['archive']['index']))
db.add_entry(db_data, h5_path)

if configs.get("lmsi_config", None) is not None:
from pathlib import Path
import lmsi.core as lmsi

new_plots = os.path.join(configs["plot_dir"],
f'{str(aman.timestamps[0])[:5]}',
aman.obs_info.obs_id)
lmsi.core([Path(x.name) for x in Path(new_plots).glob("*.png")],
Path(configs["lmsi_config"]),
Path(os.path.join(new_plots, 'index.html')))

def load_preprocess_obs(obs_id, configs="preprocess_obs_configs.yaml", context=None ):
""" Loads the saved information from the preprocessing pipeline and runs the
processing section of the pipeline.
Expand Down
19 changes: 19 additions & 0 deletions sotodlib/site_pipeline/preprocess_tod.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,11 @@ def preprocess_tod(obs_id,
db = _get_preprocess_db(configs, group_by)

pipe = Pipeline(configs["process_pipe"], plot_dir=configs["plot_dir"], logger=logger)

if configs.get("lmsi_config", None) is not None:
make_lmsi = True
else:
make_lmsi = False

n_fail = 0
for group in groups:
Expand All @@ -394,6 +399,11 @@ def preprocess_tod(obs_id,
tags = np.array(context.obsdb.get(aman.obs_info.obs_id, tags=True)['tags'])
aman.wrap('tags', tags)
proc_aman, success = pipe.run(aman)

if make_lmsi:
new_plots = os.path.join(configs["plot_dir"],
f'{str(aman.timestamps[0])[:5]}',
aman.obs_info.obs_id)
except Exception as e:
#error = f'{obs_id} {group}'
errmsg = f'{type(e)}: {e}'
Expand Down Expand Up @@ -432,6 +442,15 @@ def preprocess_tod(obs_id,
h5_path = os.path.relpath(dest_file,
start=os.path.dirname(configs['archive']['index']))
db.add_entry(db_data, h5_path)

if make_lmsi:
from pathlib import Path
import lmsi.core as lmsi

lmsi.core([Path(x.name) for x in Path(new_plots).glob("*.png")],
Path(configs["lmsi_config"]),
Path(os.path.join(new_plots, 'index.html')))

if run_parallel:
if n_fail == len(groups):
# If no groups make it to the end of the processing return error.
Expand Down