Skip to content

Commit f25c122

Browse files
committed
Check if proposal and run numbers are in run_metadata.
1 parent 3d9e3d1 commit f25c122

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

extra_data/write_cxi.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,14 @@ def write(self, filename, fillvalues=None):
245245
dtype=h5py.special_dtype(vlen=str))
246246
d[:] = experiment_ids
247247

248-
# proposal, run, pulseId, trainId, cellId are not part of the CXI standard,
249-
# but it allows extra data.
248+
# proposal, run, pulseId, trainId, cellId are not part of
249+
# the CXI standard, but it allows extra data.
250250
run_metadata = self.detdata.data.run_metadata()
251-
f.create_dataset(f'entry_1/proposal', data=run_metadata['proposalNumber'])
252-
f.create_dataset(f'entry_1/run', data=run_metadata['runNumber'])
251+
if 'proposalNumber' in run_metadata and 'runNumber' in run_metadata:
252+
f.create_dataset(f'entry_1/proposalNumber',
253+
data=run_metadata['proposalNumber'])
254+
f.create_dataset(f'entry_1/runNumber',
255+
data=run_metadata['runNumber'])
253256
f.create_dataset(f'entry_1/{self.pulse_id_label}', data=pulse_ids)
254257
f.create_dataset('entry_1/trainId', data=self.train_ids_perframe)
255258
cellids = f.create_virtual_dataset('entry_1/cellId',

0 commit comments

Comments
 (0)