###CBF: VERSION 1.1
# Template for Diamond MX beamlines phase 1 - replacing what we currently
# have in ADSC, Rayonix and DECTRIS image headers with a standard syntax
# and description.
#
# DECTRIS translation table follows...
#
@ Exposure_time     _expt_
@ Exposure_period   _expp_
@ Start_angle       _omega_
@ Angle_increment   _domega_
@ Timestamp         _timestamp_
@ Count_cutoff      _cutoff_
@ Compression_type  _compress_
@ X_dimension       _wide_
@ Y_dimension       _high_
@ Wavelength        _wave_
#
# Detector_distance _dist_
# Beam_x            _beam_x_
# Beam_y            _beam_y_
#
# These items will be pre-populated in the template so need not be included:
#
# Alpha
# Kappa
# Phi
# Chi
# Oscillation_axis
# Pixel_size
# Detector
#
# Once we get this end of things done properly in GDA.
#
--- End of preamble
# This and all subsequent lines will appear in the header

_diffrn.id %(beamline)s
_diffrn.crystal_id %(xtal_id)s

# the following items will be fixed for the beamline

loop_
_diffrn_source.diffrn_id
_diffrn_source.source
_diffrn_source.type
 %(beamline)s synchrotron 'Diamond Light Source Beamline I03'

# FIXME need to verify that the values which follow below are correct

loop_
_diffrn_radiation.diffrn_id
_diffrn_radiation.wavelength_id
_diffrn_radiation.monochromator
_diffrn_radiation.polarizn_source_ratio
_diffrn_radiation.polarizn_source_norm
_diffrn_radiation.div_x_source
_diffrn_radiation.div_y_source
_diffrn_radiation.div_x_y_source
 %(beamline)s WAVELENGTH1 'Si 111' 0.8 0.0 0.08 0.01 0.00

# category DIFFRN_DETECTOR
loop_
_diffrn_detector.diffrn_id
_diffrn_detector.id
_diffrn_detector.type
_diffrn_detector.number_of_axes
 %(beamline)s %(detector_id)s '%(detector_name)s' 3

loop_
_diffrn_detector_axis.detector_id
_diffrn_detector_axis.axis_id
 %(detector_id)s DETECTOR_X
 %(detector_id)s DETECTOR_Y
 %(detector_id)s DETECTOR_Z

loop_
_diffrn_detector_element.id
_diffrn_detector_element.detector_id
 ELEMENT1 %(detector_id)s

loop_
_diffrn_data_frame.id
_diffrn_data_frame.detector_element_id
_diffrn_data_frame.array_id
_diffrn_data_frame.binary_id
 FRAME1 ELEMENT1 ARRAY1 1

loop_
_diffrn_scan.id
_diffrn_scan.frame_id_start
_diffrn_scan.frame_id_end
_diffrn_scan.frames
 SCAN1 FRAME1 FRAME1 1

loop_
_diffrn_measurement.diffrn_id
_diffrn_measurement.id
_diffrn_measurement.number_of_axes
_diffrn_measurement.method
_diffrn_measurement.sample_detector_distance
 %(beamline)s GONIOMETER 1 rotation %(distance).2f

loop_
_diffrn_measurement_axis.measurement_id
_diffrn_measurement_axis.axis_id
 GONIOMETER GONIOMETER_OMEGA

# these items will be written by GDA on a scan-by-scan basis - one day

loop_
_diffrn_radiation_wavelength.id
_diffrn_radiation_wavelength.wavelength
_diffrn_radiation_wavelength.wt
 WAVELENGTH1 _wave_ 1

loop_
_diffrn_scan_axis.scan_id
_diffrn_scan_axis.axis_id
_diffrn_scan_axis.angle_start
_diffrn_scan_axis.angle_range
_diffrn_scan_axis.angle_increment
_diffrn_scan_axis.displacement_start
_diffrn_scan_axis.displacement_range
_diffrn_scan_axis.displacement_increment
 SCAN1 GONIOMETER_OMEGA _omega_ _domega_ _domega_ 0.0 0.0 0.0
 SCAN1 DETECTOR_Z 0.0 0.0 0.0 %(distance).2f 0.0 0.0
 SCAN1 DETECTOR_Y 0.0 0.0 0.0 0.0 0.0 0.0
 SCAN1 DETECTOR_X 0.0 0.0 0.0 0.0 0.0 0.0

loop_
_diffrn_scan_frame.frame_id
_diffrn_scan_frame.frame_number
_diffrn_scan_frame.integration_time
_diffrn_scan_frame.exposure_time
_diffrn_scan_frame.scan_id
_diffrn_scan_frame.date
 FRAME1 1 _expt_ _expp_ SCAN1 _timestamp_

loop_
_diffrn_scan_frame_axis.frame_id
_diffrn_scan_frame_axis.axis_id
_diffrn_scan_frame_axis.angle
_diffrn_scan_frame_axis.displacement
 FRAME1 GONIOMETER_OMEGA _omega_ 0.0
 FRAME1 DETECTOR_Z 0.0 %(distance).2f
 FRAME1 DETECTOR_Y 0.0 0.0
 FRAME1 DETECTOR_X 0.0 0.0

loop_
_axis.id
_axis.type
_axis.equipment
_axis.depends_on
_axis.vector[1] _axis.vector[2] _axis.vector[3]
_axis.offset[1] _axis.offset[2] _axis.offset[3]
 GONIOMETER_OMEGA rotation goniometer . 1 0 0 . . .
 SOURCE           general source . 0 0 1 . . .
 GRAVITY          general gravity . 0 -1 0 . . .
 DETECTOR_Z       translation detector . 0 0 -1 0 0 0
 DETECTOR_Y       translation detector DETECTOR_Z 0 1 0 0 0 0
 DETECTOR_X       translation detector DETECTOR_Y 1 0 0 0 0 0
 ELEMENT_X        translation detector DETECTOR_X 1 0 0 -%(beam_x).2f %(beam_y).2f 0
 ELEMENT_Y        translation detector ELEMENT_X 0 1 0 0 0 0

loop_
_array_structure_list.array_id
_array_structure_list.index
_array_structure_list.dimension
_array_structure_list.precedence
_array_structure_list.direction
_array_structure_list.axis_set_id
 ARRAY1 1 _wide_ 1 increasing ELEMENT_X
 ARRAY1 2 _high_ 2 increasing ELEMENT_Y

loop_
_array_structure_list_axis.axis_set_id
_array_structure_list_axis.axis_id
_array_structure_list_axis.displacement
_array_structure_list_axis.displacement_increment
 ELEMENT_X ELEMENT_X 0.0 %(pixel_x).4f
 ELEMENT_Y ELEMENT_Y 0.0 -%(pixel_y).4f

loop_
_array_element_size.array_id
_array_element_size.index
_array_element_size.size
 ARRAY1 1 0.000172
 ARRAY1 2 0.000172

loop_
_array_intensities.array_id
_array_intensities.binary_id
_array_intensities.linearity
_array_intensities.gain
_array_intensities.gain_esd
_array_intensities.overload
_array_intensities.undefined_value
 ARRAY1 1 linear 1.0 . _cutoff_ -1

loop_
_array_structure.id
_array_structure.encoding_type
_array_structure.compression_type
_array_structure.byte_order
 ARRAY1 "signed 32-bit integer" _compress_ little_endian
