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

Issue33 #38

Merged
merged 8 commits into from
Jul 10, 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
10 changes: 9 additions & 1 deletion sif_parser/_sif_open.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,15 @@ def _open(fp):
for _ in range(8):
fp.readline() # Skip to Line 22
info['spectrograph'] = _to_string(fp.readline().split()[1])
for _ in range(9):
# intensifier info, such as gate, gain
fp.readline()
for _ in range(3):
_read_float(fp)
info['GateGain'] = _read_float(fp)
_read_float(fp); _read_float(fp);
info['GateDelay'] = _read_float(fp) * 1e-12 # make it in seconds
info['GateWidth'] = _read_float(fp) * 1e-12 # make it in seconds
for _ in range(8):
fp.readline() # skipping bunch of lines from 20 to 37

if 'spectrograph' not in info.keys():
Expand Down
Binary file not shown.
Binary file not shown.
21 changes: 20 additions & 1 deletion testings/test_open.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,26 @@
[e + dd for dd in os.listdir(e) if not dd.startswith(".DS")], key=str.lower
)



@pytest.mark.parametrize(
("filename", "gate_width", "gate_delay", "gain"),
[
(THIS_DIR + "/issue37/shot25-Ar-delay 480us-width 2us-gain 3900.sif", 2000, 480000, 4095),
(THIS_DIR + "/issue37/shot34-Ar-delay 470us-width 2us-gain 4095.sif", 2000, 470000, 4095),
],
)
def test_gatewidth(filename, gate_width, gate_delay, gain):
# issue 33
data, info = sif_parser.np_open(filename)
assert "GateWidth" in info
assert "GateDelay" in info
assert "GateGain" in info
assert np.allclose(info["GateWidth"], gate_width * 1e-9)
assert np.allclose(info["GateDelay"], gate_delay * 1e-9)
assert np.allclose(info["GateGain"], gain)
assert np.allclose(info["GainDAC"], gain)


def test_issue27():
filename = THIS_DIR + "/issue27/test.sif"
with open(filename, "rb") as f:
Expand Down
Loading