Esempio n. 1
0
def test_run_get_array_error(mock_fxe_raw_run):
    run = RunDirectory(mock_fxe_raw_run)

    with pytest.raises(SourceNameError):
        run.get_array('bad_name', 'data.intensityTD')

    with pytest.raises(PropertyNameError):
        run.get_array('SA1_XTD2_XGM/DOOCS/MAIN:output', 'bad_name')
Esempio n. 2
0
def test_run_get_array_empty(mock_fxe_raw_run):
    run = RunDirectory(mock_fxe_raw_run)
    arr = run.get_array('FXE_XAD_GEC/CAM/CAMERA_NODATA:daqOutput',
                        'data.image.pixels')

    assert isinstance(arr, DataArray)
    assert arr.dims[0] == 'trainId'
    assert arr.shape == (0, 255, 1024)
Esempio n. 3
0
def test_run_get_array(mock_fxe_raw_run):
    run = RunDirectory(mock_fxe_raw_run)
    arr = run.get_array('SA1_XTD2_XGM/DOOCS/MAIN:output',
                        'data.intensityTD',
                        extra_dims=['pulse'])

    assert isinstance(arr, DataArray)
    assert arr.dims == ('trainId', 'pulse')
    assert arr.shape == (480, 1000)
    assert arr.coords['trainId'][0] == 10000
Esempio n. 4
0
 def get_xgm_data(self, cxi):
     run_raw = RunDirectory(self.params.xgm_dir)
     # Photon energy: E = hc/λ
     hc = 1.9864458571489e-25  # [joule * meter]
     # wavelength is in ångström, it gives the 1E10 factor
     pe = hc * 1e10 / self.params.wavelength  # photon energy in joules
     tids = cxi["entry_1/trainId"]
     intensity = run_raw.get_array(self.params.xgm_addr,
                                   "data.intensityTD",
                                   extra_dims=["pulseID"])
     xgm_data = intensity[(intensity["trainId"] >= tids[0]) & (
         intensity["trainId"] <= tids[-1])][:, :self.params.xgm_pulse_num]
     # XGM data is in μJ, it gives the 1E-6 factor
     # Finally, we normalize this per 220 nanoseconds (2.2E-7)
     return xgm_data * 1e-6 / pe / 2.2e-7