-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from CMB-S4/85-tube_LAT
Draft pre-baseline design (85-tube LATs, SAT tube config)
- Loading branch information
Showing
74 changed files
with
6,761 additions
and
350 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
env/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*,cover | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# atmospheric cache | ||
atm_cache/ | ||
|
||
# output directories | ||
out*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env python | ||
|
||
# Copyright (c) 2020-2020 CMB-S4 Collaboration.. | ||
# Full license can be found in the top level "LICENSE" file. | ||
|
||
# This script will convert TOML hardware maps into Python pickle | ||
# format for efficient access | ||
|
||
import os | ||
import pickle | ||
import sys | ||
|
||
from s4sim import hardware | ||
|
||
|
||
if len(sys.argv) < 2: | ||
print("Usage: pickle_hardware.py <TOML file1> [<TOML file2>] ...") | ||
else: | ||
for fname_in in sys.argv[1:]: | ||
print(f"Loading {fname_in}") | ||
hw = hardware.Hardware(fname_in) | ||
|
||
fname_out = fname_in.replace(".toml", "").replace(".gz", "") + ".pkl" | ||
print(f"Writing {fname_out}") | ||
with open(fname_out, "wb") as fout: | ||
pickle.dump(hw, fout) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/usr/bin/env/python | ||
|
||
# Copyright (c) 2020-2020 CMB-S4 Collaboration. | ||
# Full license can be found in the top level "LICENSE" file. | ||
"""Trim a hardware model to include only some detectors. | ||
""" | ||
|
||
from collections import OrderedDict | ||
import sys | ||
import argparse | ||
|
||
import numpy as np | ||
import toast.qarray as qa | ||
|
||
from s4sim.hardware import Hardware | ||
|
||
|
||
XAXIS, YAXIS, ZAXIS = np.eye(3) | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser( | ||
description="This program reads a hardware model from disk " | ||
"and writes out per-wafer geometry.", | ||
usage="s4_hardware_trim [options] (use --help for details)", | ||
) | ||
|
||
parser.add_argument( | ||
"--hardware", required=True, default=None, help="Input hardware file" | ||
) | ||
|
||
parser.add_argument( | ||
"--out", | ||
required=False, | ||
default="trimmed", | ||
help="Name (without extensions) of the output hardware file", | ||
) | ||
|
||
args = parser.parse_args() | ||
|
||
print("Loading hardware from {}...".format(args.hardware), flush=True) | ||
hw = Hardware(args.hardware) | ||
|
||
wafers = {} | ||
|
||
for det_name, det_data in hw.data["detectors"].items(): | ||
wafer = det_data["wafer"] | ||
pol = det_data["pol"] | ||
quat = qa.norm(det_data["quat"]) | ||
if wafer not in wafers: | ||
wafers[wafer] = {} | ||
wx, wy, wz = qa.rotate(quat, ZAXIS) | ||
wdir = np.array([wx, wy, wz]) | ||
posrot = qa.norm(qa.from_vectors(ZAXIS, wdir)) | ||
angrot = qa.norm(qa.mult(qa.inv(posrot), quat)) | ||
psi = np.degrees(qa.to_angles(angrot)[2]) % 180 | ||
wafers[wafer][det_name] = np.array([wx, wy, psi]) | ||
|
||
for wafer_name in sorted(wafers): | ||
wafer_data = wafers[wafer_name] | ||
ndet = len(wafer_data) | ||
det_data = np.empty([ndet, 3]) | ||
for idet, det_name in enumerate(wafer_data): | ||
det_data[idet] = wafer_data[det_name] | ||
xoffset, yoffset, psioffset = np.mean(det_data, 0) | ||
fname = f"wafer_{wafer_name}.txt" | ||
with open(fname, "w") as fout: | ||
for det_name in sorted(wafer_data): | ||
x, y, psi = wafer_data[det_name] | ||
x -= xoffset | ||
y -= yoffset | ||
phi = np.degrees(np.arcsin(x)) | ||
theta = np.degrees(np.arcsin(y)) | ||
fout.write(f"{det_name} {phi} {theta} {psi}\n") | ||
|
||
return | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.