areaDetector / ADmarCCD

An EPICS areaDetector driver for the Rayonix (formerly MarCCD) detectors from Rayonix/MarUSA.
https://areadetector.github.io/areaDetector/ADmarCCD/marCCDDoc.html
1 stars 3 forks source link

Rotation Axis and Start Angle behaviour is inconsistent #4

Open michel4j opened 7 years ago

michel4j commented 7 years ago

The wrong header is written to images if MAR_ROTATION_AXIS is set to anything other than "phi". Since there is no MAR_START_OMEGA. Writing the starting angle value to MAR_START_PHI always updates the Phi starting angle in the header irrespective of which axis is set.

Preferably, rename MAR_START_PHI to MAR_START_ANGLE, then use the selected rotation axis to decide which header field to update.

The workaround for the moment is to always pretend to be using the "phi" axis.

MarkRivers commented 3 years ago

@michel4j this is the documentation for the marccd_server application:

https://github.com/areaDetector/ADmarCCD/blob/master/documentation/legacy_remote_mode_manual%20v0.1.pdf

Look at the section called Remote Commands, and the documentation for the "header" command. Note that it only supports start_phi, it does not include a start_omega or other angle. Since the driver needs to send the "start_phi" command it seems to be up to the user to set that to whatever angle is actually being moved?

I am not sure how you would like to change the driver given the limitation of the header command?

michel4j commented 3 years ago

@MarkRivers I see. I think their documentation may be incomplete. Looking at the marccd_client_socket.c file included with the marccd_socket_server, it does the following:

sprintf(buffer, "header,rotation_axis=%s,detector_distance=%.3f,source_wavelength=%.6f,beam_x=%.3f,beam_y=%.3f,exposure_time=%.3f,phi=%.3f,omega=%.3f", "Phi", 100.0, 1.234567, 1024.0, 1025.0, exposure_time, phi, 45.0);

This implies that the following header commands are also supported:

A while ago, we used the "phi" header command instead of the "start_phi". Or rather, the command was the same as the rotation axis. The marccd software would itself correctly set the appropriate start_xxx and end_xxx header variables.

MarkRivers commented 3 years ago

I have written to Rayonix asking them to clarify the disagreement between the manual and the example C code.

MarkRivers commented 3 years ago

I don't think that I have ever actually tried to access that metadata from the TIFF files that marccd writes before.

I am examining a file that was definitely written by marccd, controlled by ADmarCCD, so it was setting phi_start, etc.

This is the output of tiffinfo:

corvette:/archives/2014/dac_user>tiffinfo IDD_2014-1/Alex/SSDA12/SSDA12_042.tif
TIFFReadDirectory: Warning, Unknown field with tag 34710 (0x8796) encountered.
TIFF Directory at offset 0x8 (8)
  Image Width: 2048 Image Length: 2048
  Resolution: 126.582, 126.582 pixels/cm
  Bits/Sample: 16
  Compression Scheme: None
  Photometric Interpretation: min-is-black
  Orientation: row 0 top, col 0 lhs
  Rows/Strip: 2048
  Planar Configuration: single image plane
  Tag 34710: 1024

This is the output of tiffdump:

corvette:/archives/2014/dac_user>tiffdump IDD_2014-1/Alex/SSDA12/SSDA12_042.tif
IDD_2014-1/Alex/SSDA12/SSDA12_042.tif:
Magic: 0x4949 <little-endian> Version: 0x2a <ClassicTIFF>
Directory 0: offset 8 (0x8) next 0 (0)
ImageWidth (256) LONG (4) 1<2048>
ImageLength (257) LONG (4) 1<2048>
BitsPerSample (258) SHORT (3) 1<16>
Compression (259) SHORT (3) 1<1>
Photometric (262) SHORT (3) 1<1>
StripOffsets (273) LONG (4) 1<4096>
Orientation (274) SHORT (3) 1<1>
RowsPerStrip (278) LONG (4) 1<2048>
StripByteCounts (279) LONG (4) 1<8388608>
XResolution (282) RATIONAL (5) 1<126.582>
YResolution (283) RATIONAL (5) 1<126.582>
ResolutionUnit (296) SHORT (3) 1<3>
34710 (0x8796) LONG (4) 1<1024>

This is the output of "strings" which just shows the printable text at the start of the file:

corvette:/archives/2014/dac_user>strings IDD_2014-1/Alex/SSDA12/SSDA12_042.tif
-!Jq
Corrected <untitled>
//home/marccd/dac/Alex/SSDA12
SSDA12_042.tif
030105392014.48
030105392014.48
030105392014.48
Created by: marccd v. 0.18.7 on Enterprise Linux 5
Microcode 65535 Rev 255
Detector Serial Number = 82
CCD Temperature = -79.35 Celsius.
Chamber Pressure = 0.00 Torr
Readout Rate = 625.000 kHz
Gain setting = 4
Readout from 4 Corner(s): A | B | C | D
Analog Offsets  = 2000 2000 2000 2000
Digital Offsets =  629  642  628  622
Parallel Shift Delay = 250
Shutter Close Delay = 50

I don't see the metadata like phi_start with any of those 3 ways of examining the file?

@michel4j how did you access that information?

MarkRivers commented 3 years ago

Ross Doyle from Rayonix told me that I need to use the dump_header program to see the metadata values. That works:


[marccd@gse-marccd4 ~]$ dump_header -Z marccd4_sensitivity_002.tif

marccd4_sensitivity_002.tif:
Field Name                     Header Offset Structure Offset    Value
header_type                             1024                0        2
header_name                             1028                4       16 bytes - "MMX"
header_major_version                    1044               20        0
header_minor_version                    1048               24        0
header_byte_order                       1052               28     1234
data_byte_order                         1056               32     1234
header_size                             1060               36     3072
frame_type                              1064               40        0
magic_number                            1068               44 1365180540
compression_type                        1072               48     1003
compression1                            1076               52        0
compression1                            1076               52        0
compression1                            1076               52        0
compression1                            1076               52        0
compression1                            1076               52        0
compression1                            1076               52        0
nheaders                                1100               76        1
nfast                                   1104               80     2048
nslow                                   1108               84     2048
depth                                   1112               88        2
record_length                           1116               92     4096
signif_bits                             1120               96       16
data_type                               1124              100        0
saturated_value                         1128              104    65535
sequence                                1132              108        0
nimages                                 1136              112        1
origin                                  1140              116        0
orientation                             1144              120        0
view_direction                          1148              124        0
overflow_location                       1152              128        0
over_8_bits                             1156              132        0
over_16_bits                            1160              136        0
multiplexed                             1164              140        0
nfastimages                             1168              144        1
nslowimages                             1172              148        1
darkcurrent_applied                     1176              152        1
bias_applied                            1180              156        1
flatfield_applied                       1184              160        1
distortion_applied                      1188              164        1
original_header_type                    1192              168        2
file_saved                              1196              172        0
n_valid_pixels                          1200              176  4194304
defectmap_applied                       1204              180        1
subimage_nfast                          1208              184        0
subimage_nslow                          1212              188        0
subimage_origin_fast                    1216              192        0
subimage_origin_slow                    1220              196        0
readout_pattern                         1224              200       15
saturation_level                        1228              204    65535
orientation_code                        1232              208        0
frameshift_multiplexed                  1236              212        0
prescan_nfast                           1240              216        0
prescan_nslow                           1244              220        0
postscan_nfast                          1248              224        0
postscan_nslow                          1252              228        0
prepost_trimmed                         1256              232        0
total_counts[0]                         1280              256        0
total_counts[1]                         1284              260        0
special_counts1[0]                      1288              264        0
special_counts1[1]                      1292              268        0
special_counts2[0]                      1296              272        0
special_counts2[1]                      1300              276        0
min                                     1304              280        1
max                                     1308              284      534
mean                                    1312              288    11286
rms                                     1316              292     2184
n_zeros                                 1320              296   900488
n_saturated                             1324              300        0
stats_uptodate                          1328              304        1
pixel_noise                             1332              308        0
reserve2                                1368              344       40 bytes - unprintable
barcode                                 1408              384       16 bytes - ""
xtal_to_detector                        1664              640        0
beam_x                                  1668              644  1023998
beam_y                                  1672              648  1023998
integration_time                        1676              652     2048
exposure_time                           1680              656     2000
readout_time                            1684              660     2359
nreads                                  1688              664        1
start_twotheta                          1692              668        0
start_omega                             1696              672        0
start_chi                               1700              676        0
start_kappa                             1704              680        0
start_phi                               1708              684        0
start_delta                             1712              688        0
start_gamma                             1716              692        0
start_xtal_to_detector                  1720              696        0
end_twotheta                            1724              700        0
end_omega                               1728              704        0
end_chi                                 1732              708        0
end_kappa                               1736              712        0
end_phi                                 1740              716        0
end_delta                               1744              720        0
end_gamma                               1748              724        0
end_xtal_to_detector                    1752              728        0
rotation_axis                           1756              732        4
rotation_range                          1760              736        0
detector_rotx                           1764              740        0
detector_roty                           1768              744        0
detector_rotz                           1772              748        0
total_dose                              1776              752        0
reserve3                                1780              756       12 bytes - unprintable
detector_type                           1792              768        0
pixelsize_x                             1796              772    79590
pixelsize_y                             1800              776    79590
mean_bias                               1804              780    10000
photons_per_100adu                      1808              784      100
measured_bias                           1812              788        0
measured_temperature                    1848              824   203200
measured_pressure                       1884              860    -1000
source_type                             1920              896        0
source_dx                               1924              900        0
source_dy                               1928              904        0
source_wavelength                       1932              908   103318
source_power                            1936              912        0
source_voltage                          1940              916        0
source_current                          1944              920        0
source_bias                             1948              924        0
source_polarization_x                   1952              928        0
source_polarization_y                   1956              932        0
source_intensity_0                      1960              936        0
source_intensity_1                      1964              940        0
reserve_source                          1968              944        8 bytes - unprintable
optics_type                             1976              952        0
optics_dx                               1980              956        0
optics_dy                               1984              960        0
optics_wavelength                       1988              964        0
optics_dispersion                       1992              968        0
optics_crossfire_x                      1996              972        0
optics_angle                            2004              980        0
optics_polarization_x                   2008              984        0
optics_polarization_y                   2012              988        0
reserve_optics                          2016              992       16 bytes - unprintable
reserve5                                2032             1008       16 bytes - unprintable
filetitle                               2048             1024      128 bytes - "Corrected <untitled>"
filepath                                2176             1152      128 bytes - "/local/home/marccd"
filename                                2304             1280       64 bytes - "marccd4_sensitivity_002.tif"
acquire_timestamp                       2368             1344       32 bytes - "102113152015.35"
header_timestamp                        2400             1376       32 bytes - "102113152015.35"
save_timestamp                          2432             1408       32 bytes - "102113152015.35"
file_comment                            2464             1440      512 bytes - "marccd v.0.21.1(Linux-2.6.32-220.el6.i686-i686-)
DSP 6075.1 CS: 17629  S/N: 113
T:-69.95C  P:-0.00 Torr
Rate: 794.000kHz  Gain:2; 4 Ports: A | B | C | D
Voltages:
28      =  27.880 <==  28.019(  0.139)
24      =  23.736 <==  24.255(  0.519)
+5      =   4.897 <==   5.524(  0.627)
 3.3    =   3.283      -3.337
 Preamp =   5.077      -5.095
 Clock  =  13.090 <==  13.170(  0.080)  -12.869
 Analog =   8.939 <==   9.528(  0.589)   -9.064
Anlg(PS)=  12.047     -12.039
+3.3(PS)=   3.307
 Aux(PS)=  24.244
"
reserve6                                2976             1952       96 bytes - unprintable
dataset_comment                         3072             2048      512 bytes - ""
user_data                               3584             2560      512 bytes - unprintable

We would need to test to see if writing a value for omega would actually result in this header being correct.

michel4j commented 3 years ago

There's also http://www.biophysics.fsu.edu/~xray/Manuals/marCCD165header.html which I used to write a python module for parsing it.

https://github.com/michel4j/mxio/blob/master/mxio/formats/marccd.py