scippneutron.io.cif#
CIF file writer.
This module contains tools for writing CIF files with diffraction data. It does not support reading CIF files.
Examples
Make mockup powder diffraction data:
>>> import scipp as sc
>>> tof = sc.array(dims=['tof'], values=[1.2, 1.4, 2.3], unit='us')
>>> intensity = sc.array(
... dims=['tof'],
... values=[13.6, 26.0, 9.7],
... variances=[0.7, 1.1, 0.5],
... )
Wrap the data in a Loop
to write them together as columns.
(Note that this particular example could more easily be done with
\(scippneutron.io.cif.Block.add_reduced_powder_data\).)
>>> from scippneutron.io import cif
>>> tof_loop = cif.Loop({
... 'pd_meas.time_of_flight': tof,
... 'pd_meas.intensity_total': sc.values(intensity),
... 'pd_meas.intensity_total_su': sc.stddevs(intensity),
... })
Write the data to file along with some metadata:
>>> block = cif.Block('example', [
... {
... 'diffrn_radiation.probe': 'neutron',
... 'diffrn_source.beamline': 'some-beamline',
... },
... tof_loop,
... ])
>>> cif.save_cif('example.cif', block)
This results in a file containing
#\#CIF_1.1
data_example
_diffrn_radiation.probe neutron
_diffrn_source.beamline some-beamline
loop_
_pd_meas.time_of_flight
_pd_meas.intensity_total
_pd_meas.intensity_total_su
1.2 13.6 0.8366600265340756
1.4 26.0 1.0488088481701516
2.3 9.7 0.7071067811865476
Functions
|
Save data blocks to a CIF file. |
Classes
|
A CIF data block. |
|
|
|
A group of CIF key-value pairs. |
|
A CIF loop. |