Skip to content

Commit

Permalink
Fixed issue33
Browse files Browse the repository at this point in the history
  • Loading branch information
fujiisoup committed Jul 10, 2024
1 parent d1e8e1a commit 79b2cc3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
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.
19 changes: 19 additions & 0 deletions testings/test_open.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,25 @@
)


@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

0 comments on commit 79b2cc3

Please sign in to comment.