Mccd xdsparams.pl: Difference between revisions
|  New page: The following is a script that I obtained from Ana Gonzalez (thanks a lot, Ana!) and which may be re-distributed according to the copyright and permission notice given. It is called mccd_x... | No edit summary | ||
| Line 1: | Line 1: | ||
| The following is a script that I obtained from Ana Gonzalez (thanks a lot, Ana!) and which may be re-distributed according to the copyright and permission notice given. | The following is a script that I obtained from Ana Gonzalez (thanks a lot, Ana!) and which may be re-distributed according to the copyright and permission notice given. It serves to read the header information from MarCCD frames. | ||
| The script is called mccd_xdsparams.pl and should be in your $PATH . Formerly it was used in my [[generate_XDS.INP]] script. | |||
| <pre> | |||
| #!/usr/bin/perl -w | |||
| # | |||
| # | |||
| #                        Copyright 2004 | |||
| #                              by | |||
| #                 The Board of Trustees of the | |||
| #               Leland Stanford Junior University | |||
| #                      All rights reserved. | |||
| # | |||
| #                       Disclaimer Notice | |||
| # | |||
| #     The items furnished herewith were developed under the sponsorship | |||
| # of the U.S. Government.  Neither the U.S., nor the U.S. D.O.E., nor the | |||
| # Leland Stanford Junior University, nor their employees, makes any war- | |||
| # ranty, express or implied, or assumes any liability or responsibility | |||
| # for accuracy, completeness or usefulness of any information, apparatus, | |||
| # product or process disclosed, or represents that its use will not in- | |||
| # fringe privately-owned rights.  Mention of any product, its manufactur- | |||
| # er, or suppliers shall not, nor is it intended to, imply approval, dis- | |||
| # approval, or fitness for any particular use.  The U.S. and the Univer- | |||
| # sity at all times retain the right to use and disseminate the furnished | |||
| # items for any purpose whatsoever. | |||
| # | |||
| #                       Permission Notice | |||
| # | |||
| # Permission is hereby granted, free of charge, to any person obtaining a | |||
| # copy of this software and associated documentation files (the "Software"), | |||
| # to deal in the Software without restriction, including without limitation | |||
| # the rights to use, copy, modify, merge, publish, distribute, sublicense, | |||
| # and/or sell copies of the Software, and to permit persons to whom the | |||
| # Software is furnished to do so, subject to the following conditions: | |||
| # | |||
| # The above copyright notice and this permission notice shall be included | |||
| # in all copies or substantial portions of the Software. | |||
| # | |||
| # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |||
| # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTA- | |||
| # BILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO | |||
| # EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | |||
| # DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | |||
| # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR | |||
| # THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |||
| # | |||
| # MARCDD image header format | |||
| # | |||
| # TIFF header 1024 bytes | |||
| # Private frame header 3072 bytes | |||
| ## file/header format parameters 256 bytes | |||
| ## data statistics 128 bytes | |||
| ## more statistics 256 bytes | |||
| ## goniostat parameters 128 bytes | |||
| ### xtal_to_detector int32 (mm*1000) | |||
| ### beam_x int32 (pixel*1000) | |||
| ### beam_y int32 (pixel*1000) | |||
| ## detector parameters 128 bytes | |||
| ### detector_type int32 | |||
| ### pixelsize_x int32 (nanometers | |||
| ### pixelsize_y int32 (nanometers | |||
| ##X-ray source parameters 128 bytes | |||
| die "ERROR: Missing Argument. \nUsage: $0 [options] <image_filename>\n" unless @ARGV; | |||
| while ($_ = $ARGV[0], /^-/) { | |||
|         shift; | |||
|         last if /^--$/; | |||
|         # if (/^-D(.*)/) { $debug = $1 } | |||
|         if (/^-v/)     { $verbose = 1 } | |||
|         # ...           # other switches | |||
| } | |||
| open ( FILE, '<', $ARGV[0] ) or | |||
|         die ( "ERROR: Cannot open file" ); | |||
| seek ( FILE, 1024+80, 0 ); | |||
| read ( FILE , $size_fast, 4 ); | |||
| read ( FILE , $size_slow, 4 ); | |||
| seek ( FILE, 1024+256+128+256, 0 ); | |||
| read ( FILE , $xtal_to_detector, 4 ); | |||
| read ( FILE , $beam_x, 4 ); | |||
| read ( FILE , $beam_y, 4 ); | |||
| seek ( FILE, 1024+256+128+256+16, 0); | |||
| read ( FILE , $exp, 4 ); #exp time x 1000 | |||
| seek ( FILE, 1024+256+128+256+44, 0); | |||
| read ( FILE , $start_phi, 4 ); #start phi x 1000 | |||
| seek ( FILE, 1024+256+128+256+76, 0); | |||
| read ( FILE , $end_phi, 4 ); #end phi x 1000 | |||
| seek ( FILE, 1024+256+128+256+128, 0 ); | |||
| read ( FILE , $detector_type, 4 ); | |||
| read ( FILE , $pixelsize_x, 4 ); | |||
| read ( FILE , $pixelsize_y, 4 ); | |||
| seek ( FILE, 1024+256+128+256+128+128+12, 0 ); | |||
| read ( FILE , $wavelength, 4 ); #wavelength x 10000 | |||
| close ( FILE ); | |||
| $size_fast = unpack ('i*' ,$size_fast); | |||
| $size_slow = unpack ('i*' ,$size_slow); | |||
| $xtal_to_detector =unpack('i*' ,$xtal_to_detector) / 1000; | |||
| $detector_type =unpack('i*' ,$detector_type); | |||
| $beam_x = unpack ('i*' ,$beam_x) / 1000 ; # pixels | |||
| $beam_y = unpack ('i*' ,$beam_y) / 1000 ; # pixels | |||
| $beam_xc = $size_fast - $beam_x ; | |||
| $beam_yc = $size_fast - $beam_y ; | |||
| $pixelsize_x = unpack ('i*' ,$pixelsize_x) / 1000000 ;  # mm | |||
| $pixelsize_y = unpack ('i*' ,$pixelsize_y) / 1000000 ;  # mm | |||
| $beam_x_mm = $beam_x * $pixelsize_x  ; # mm | |||
| $beam_y_mm = $beam_y * $pixelsize_y ; # mm | |||
| $exp = unpack ('i*' ,$exp) / 1000 ; #seconds | |||
| $start_phi = unpack ('i*' ,$start_phi); #mdeg | |||
| $end_phi = unpack ('i*' ,$end_phi); #mdeg | |||
| $osc = ($end_phi - $start_phi)/1000; # deg | |||
| $wavelength = unpack ('i*' ,$wavelength)/100000  ; #A | |||
| if ($verbose) { | |||
|        print "NX= ${size_fast} NY= ${size_slow} QX= ${pixelsize_x} QY= ${pixelsize_y} \n"; | |||
|        print "DETECTOR_DISTANCE= ${xtal_to_detector} \n"; | |||
|        print "ORGX= ${beam_xc}  ORGY= ${beam_yc} \n"; | |||
|        print "OSCILLATION_RANGE= ${osc} \n"; | |||
|        print "X-RAY_WAVELENGTH= ${wavelength} \n"; | |||
| } else { | |||
|        print "$size_fast,$size_slow", "\n"; | |||
|        print "$xtal_to_detector", "\n"; | |||
|        print "$beam_x_mm,$beam_y_mm", "\n"; | |||
|        print "$pixelsize_x", "\n"; | |||
|        print "$exp","\n"; | |||
|        print "$osc","\n"; | |||
|        print "$wavelength","\n"; | |||
| } | |||
| exit | |||
| </pre> | |||