# Accurate Direct Beam Position Now in Image Header

|
For the MX endstation we've characterized the dependence of the direct beam on detector distance and 2-theta. We collected 4 sweeps of the detector from 120mm to 1600mm combined with 2-theta offsets from 0º up to 12º. These are the gnuplot 3D plots of the data.
This set of 3D plots uses gnuplots pm3d settings to generate colorful versions:
Click the images to view larger versions, and hit the "jump" to read the gory details of the polynomial equation used to determine x-beam and y-beam given any value of detector distance (CCD_Z) and 2-theta.

This is the polynomial equation for calculating x-beam:

`Xpoly2D(r,t) = Xc + Xr1*r + Xt1*t + Xr2*r2 + Xr3*r3 + Xr4*r4 + Xrt1*r*t`

The coefficients:

```
Xc              = 156.011
Xr1             = 0.00128001
Xr2             = -5.2293e-06
Xr3             = 4.64778e-09
Xr4             = -1.21722e-12
Xt1             = 0.0152727
Xrt1            = 7.19852e-05
```

and this is the polynomial equation for calculating y-beam:

`Ypoly2D(r,t) = Yc - r*tan(t) + Yr1*r + Yt1*t + Yr2*r2 + Yr3*r3 + Yr4*r4 + Yrt1*r*t`

The coefficients:

```
Yc              = 157.417
Yr1             = 1.77669e-05
Yr2             = 1.8827e-06
Yr3             = -1.27893e-09
Yr4             = 1.8721e-13
Yt1             = -0.0402058
Yrt1            = -1.70116e-05
```

We've converted the equations above into Tcl/Tk syntax and written a scripted operation for DCSS to continually update the x-beam and y-beam values each time CCD_Z or 2-Theta change. The detector DHS then writes these values into the image header as:

```
BEAM_CENTER_X=156.30
BEAM_CENTER_Y=157.95
```

We also convert the above ADXV values to the HKL2000/Denzo convention and report them as:

```
DENZO_X_BEAM=157.21
DENZO_Y_BEAM=156.30
```

Unfortunately HKL2000 does not read the direct beam values from the image header but instead uses the values in found in the site.def file. Until HKL2000 changes their code to use the values in the header you can manually grab the values, either by inspecting your images in adxv or with the following command from a terminal shell:

`head -30 your_sweet_data_collected_at_sibyls.img | grep DENZO`
which will return:
```
DENZO_X_BEAM=157.21;
DENZO_Y_BEAM=156.30;
```

## Funding

### March 2020

Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31