diff --git a/sif_parser/_sif_open.py b/sif_parser/_sif_open.py index b29ad5c..2ba71bf 100644 --- a/sif_parser/_sif_open.py +++ b/sif_parser/_sif_open.py @@ -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(): diff --git a/testings/issue37/shot25-Ar-delay 480us-width 2us-gain 3900.sif b/testings/issue37/shot25-Ar-delay 480us-width 2us-gain 3900.sif new file mode 100644 index 0000000..1ae118a Binary files /dev/null and b/testings/issue37/shot25-Ar-delay 480us-width 2us-gain 3900.sif differ diff --git a/testings/issue37/shot34-Ar-delay 470us-width 2us-gain 4095.sif b/testings/issue37/shot34-Ar-delay 470us-width 2us-gain 4095.sif new file mode 100644 index 0000000..859877f Binary files /dev/null and b/testings/issue37/shot34-Ar-delay 470us-width 2us-gain 4095.sif differ diff --git a/testings/test_open.py b/testings/test_open.py index 5821bfe..00365e9 100644 --- a/testings/test_open.py +++ b/testings/test_open.py @@ -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: