FUNCTION chararr, n ; return a string of n zeros RETURN, STRING( REPLICATE( BYTE('0'), n)) END FUNCTION read_spe_header, filename ; Created by Dennis Boyle March 2012 ; Based on WINHEAD.TXT Header Structure For WinView/WinSpec (WINX) Files ; ; Returns a structure that .spe file headers can be read into ; If filename is specified, reads header of that file into structure ; Tag names are as given in WINHEAD.TXT ; x and y calibrations and ROIinfo are in substructures 'xcal', 'ycal', and 'ROIinfo' ; ; WINHEAD.TXT ; ; $Date: 3/23/04 11:36 $ ; ; Header Structure For WinView/WinSpec (WINX) Files ; ; The current data file used for WINX files consists of a 4100 (1004 Hex) ; byte header followed by the data. ; ; Beginning with Version 2.5, many more items were added to the header to ; make it a complete as possible record of the data collection. This includes ; spectrograph and pulser information. Much of these additions were accomplished ; by recycling old information which had not been used in many versions. ; All data files created under previous 2.x versions of WinView/WinSpec CAN ; still be read correctly. HOWEVER, files created under the new versions ; (2.5 and higher) CANNOT be read by previous versions of WinView/WinSpec ; OR by the CSMA software package. ; ; ; *************************************************** HDRNAMEMAX = 120 ;Max char str length for file name USERINFOMAX = 1000 ;User information space COMMENTMAX = 80 ;User comment string max length (5 comments) LABELMAX = 16 ;Label string max length FILEVERMAX = 16 ;File version string max length DATEMAX = 10 ;String length of file creation date string as ddmmmyyyy\0 ROIMAX = 10 ;Max size of roi array of structures TIMEMAX = 7 ;Max time store as hhmmss\0 ; ; Decimal Byte ; Offset ; ----------- spe_header = { $ ControllerVersion :0 ,$; short ControllerVersion 0 Hardware Version LogicOutput :0 ,$; short LogicOutput 2 Definition of Output BNC AmpHiCapLowNoise :0U ,$; WORD AmpHiCapLowNoise 4 Amp Switching Mode xDimDet :0U ,$; WORD xDimDet 6 Detector x dimension of chip. mode :0 ,$; short mode 8 timing mode exp_sec :0.0 ,$; float exp_sec 10 alternitive exposure, in sec. VChipXdim :0 ,$; short VChipXdim 14 Virtual Chip X dim VChipYdim :0 ,$; short VChipYdim 16 Virtual Chip Y dim yDimDet :0U ,$; WORD yDimDet 18 y dimension of CCD or detector. date :chararr(DATEMAX) ,$; char date[DATEMAX] 20 date VirtualChipFlag :0 ,$; short VirtualChipFlag 30 On/Off Spare_1 :chararr(2) ,$; char Spare_1[2] 32 noscan :0 ,$; short noscan 34 Old number of scans - should always be -1 DetTemperature :0.0 ,$; float DetTemperature 36 Detector Temperature Set DetType :0 ,$; short DetType 40 CCD/DiodeArray type xdim :0U ,$; WORD xdim 42 actual # of pixels on x axis stdiode :0 ,$; short stdiode 44 trigger diode DelayTime :0.0 ,$; float DelayTime 46 Used with Async Mode ShutterControl :0U ,$; WORD ShutterControl 50 Normal, Disabled Open, Disabled Closed AbsorbLive :0 ,$; short AbsorbLive 52 On/Off AbsorbMode :0U ,$; WORD AbsorbMode 54 Reference Strip or File CanDoVirtualChipFlag:0 ,$; short CanDoVirtualChipFlag 56 T/F Cont/Chip able to do Virtual Chip ThresholdMinLive :0 ,$; short ThresholdMinLive 58 On/Off ThresholdMinVal :0.0 ,$; float ThresholdMinVal 60 Threshold Minimum Value ThresholdMaxLive :0 ,$; short ThresholdMaxLive 64 On/Off ThresholdMaxVal :0.0 ,$; float ThresholdMaxVal 66 Threshold Maximum Value SpecAutoSpectroMode :0 ,$; short SpecAutoSpectroMode 70 T/F Spectrograph Used SpecCenterWlNm :0.0 ,$; float SpecCenterWlNm 72 Center Wavelength in Nm SpecGlueFlag :0 ,$; short SpecGlueFlag 76 T/F File is Glued SpecGlueStartWlNm :0.0 ,$; float SpecGlueStartWlNm 78 Starting Wavelength in Nm SpecGlueEndWlNm :0.0 ,$; float SpecGlueEndWlNm 82 Starting Wavelength in Nm SpecGlueMinOvrlpNm :0.0 ,$; float SpecGlueMinOvrlpNm 86 Minimum Overlap in Nm SpecGlueFinalResNm :0.0 ,$; float SpecGlueFinalResNm 90 Final Resolution in Nm PulserType :0 ,$; short PulserType 94 0=None, PG200=1, PTG=2, DG535=3 CustomChipFlag :0 ,$; short CustomChipFlag 96 T/F Custom Chip Used XPrePixels :0 ,$; short XPrePixels 98 Pre Pixels in X direction XPostPixels :0 ,$; short XPostPixels 100 Post Pixels in X direction YPrePixels :0 ,$; short YPrePixels 102 Pre Pixels in Y direction YPostPixels :0 ,$; short YPostPixels 104 Post Pixels in Y direction asynen :0 ,$; short asynen 106 asynchron enable flag 0 = off datatype :0 ,$; short datatype 108 experiment datatype ; 0 = float (4 bytes) ; 1 = long (4 bytes) ; 2 = short (2 bytes) ; 3 = unsigned short (2 bytes) PulserMode :0 ,$; short PulserMode 110 Repetitive/Sequential PulserOnChipAccums :0U ,$; WORD PulserOnChipAccums 112 Num PTG On-Chip Accums PulserRepeatExp :0UL ,$; DWORD PulserRepeatExp 114 Num Exp Repeats (Pulser SW Accum) PulseRepWidth :0.0 ,$; float PulseRepWidth 118 Width Value for Repetitive pulse (usec) PulseRepDelay :0.0 ,$; float PulseRepDelay 122 Width Value for Repetitive pulse (usec) PulseSeqStartWidth :0.0 ,$; float PulseSeqStartWidth 126 Start Width for Sequential pulse (usec) PulseSeqEndWidth :0.0 ,$; float PulseSeqEndWidth 130 End Width for Sequential pulse (usec) PulseSeqStartDelay :0.0 ,$; float PulseSeqStartDelay 134 Start Delay for Sequential pulse (usec) PulseSeqEndDelay :0.0 ,$; float PulseSeqEndDelay 138 End Delay for Sequential pulse (usec) PulseSeqIncMode :0 ,$; short PulseSeqIncMode 142 Increments: 1=Fixed, 2=Exponential PImaxUsed :0 ,$; short PImaxUsed 144 PI-Max type controller flag PImaxMode :0 ,$; short PImaxMode 146 PI-Max mode PImaxGain :0 ,$; short PImaxGain 148 PI-Max Gain BackGrndApplied :0 ,$; short BackGrndApplied 150 1 if background subtraction done PImax2nsBrdUsed :0 ,$; short PImax2nsBrdUsed 152 T/F PI-Max 2ns Board Used minblk :0U ,$; WORD minblk 154 min. # of strips per skips numminblk :0U ,$; WORD numminblk 156 # of min-blocks before geo skps SpecMirrorLocation :INTARR(2) ,$; short SpecMirrorLocation[2] 158 Spectro Mirror Location, 0=Not Present SpecSlitLocation :INTARR(4) ,$; short SpecSlitLocation[4] 162 Spectro Slit Location, 0=Not Present CustomTimingFlag :0 ,$; short CustomTimingFlag 170 T/F Custom Timing Used ExperimentTimeLocal :chararr(TIMEMAX) ,$; char ExperimentTimeLocal[TIMEMAX] 172 Experiment Local Time as hhmmss\0 ExperimentTimeUTC :chararr(TIMEMAX) ,$; char ExperimentTimeUTC[TIMEMAX] 179 Experiment UTC Time as hhmmss\0 ExposUnits :0 ,$; short ExposUnits 186 User Units for Exposure ADCoffset :0U ,$; WORD ADCoffset 188 ADC offset ADCrate :0U ,$; WORD ADCrate 190 ADC rate ADCtype :0U ,$; WORD ADCtype 192 ADC type ADCresolution :0U ,$; WORD ADCresolution 194 ADC resolution ADCbitAdjust :0U ,$; WORD ADCbitAdjust 196 ADC bit adjust gain :0U ,$; WORD gain 198 gain Comments:REPLICATE(chararr(COMMENTMAX),5),$; char Comments[5][COMMENTMAX] 200 File Comments geometric :0U ,$; WORD geometric 600 geometric ops: rotate 0x01, ; reverse 0x02, flip 0x04 xlabel :chararr(LABELMAX) ,$; char xlabel[LABELMAX] 602 intensity display string cleans :0U ,$; WORD cleans 618 cleans NumSkpPerCln :0U ,$; WORD NumSkpPerCln 620 number of skips per clean. SpecMirrorPos :INTARR(2) ,$; short SpecMirrorPos[2] 622 Spectrograph Mirror Positions SpecSlitPos :FLTARR(4) ,$; float SpecSlitPos[4] 626 Spectrograph Slit Positions AutoCleansActive :0 ,$; short AutoCleansActive 642 T/F UseContCleansInst :0 ,$; short UseContCleansInst 644 T/F AbsorbStripNum :0 ,$; short AbsorbStripNum 646 Absorbance Strip Number SpecSlitPosUnits :0 ,$; short SpecSlitPosUnits 648 Spectrograph Slit Position Units SpecGrooves :0.0 ,$; float SpecGrooves 650 Spectrograph Grating Grooves srccmp :0 ,$; short srccmp 654 number of source comp. diodes ydim :0U ,$; WORD ydim 656 y dimension of raw data. scramble :0 ,$; short scramble 658 0=scrambled,1=unscrambled ContinuousCleansFlag:0 ,$; short ContinuousCleansFlag 660 T/F Continuous Cleans Timing Option ExternalTriggerFlag :0 ,$; short ExternalTriggerFlag 662 T/F External Trigger Timing Option lnoscan :0L ,$; long lnoscan 664 Number of scans (Early WinX) lavgexp :0L ,$; long lavgexp 668 Number of Accumulations ReadoutTime :0.0 ,$; float ReadoutTime 672 Experiment readout time TriggeredModeFlag :0 ,$; short TriggeredModeFlag 676 T/F Triggered Timing Option Spare_2 :chararr(10) ,$; char Spare_2[10] 678 sw_version :chararr(FILEVERMAX),$; char sw_version[FILEVERMAX] 688 Version of SW creating this file type :0 ,$; short type 704 1 = new120 (Type II) ; 2 = old120 (Type I ) ; 3 = ST130 ; 4 = ST121 ; 5 = ST138 ; 6 = DC131 (PentaMax) ; 7 = ST133 (MicroMax/SpectroMax) ; 8 = ST135 (GPIB) ; 9 = VICCD ; 10 = ST116 (GPIB) ; 11 = OMA3 (GPIB) ; 12 = OMA4 flatFieldApplied :0 ,$; short flatFieldApplied 706 1 if flat field was applied. Spare_3 :chararr(16) ,$; char Spare_3[16] 708 kin_trig_mode :0 ,$; short kin_trig_mode 724 Kinetics Trigger Mode dlabel :chararr(LABELMAX) ,$; char dlabel[LABELMAX] 726 Data label. Spare_4 :chararr(436) ,$; char Spare_4[436] 742 PulseFileName :chararr(HDRNAMEMAX),$; char PulseFileName[HDRNAMEMAX] 1178 Name of Pulser File with ; Pulse Widths/Delays (for Z-Slice) AbsorbFileName :chararr(HDRNAMEMAX),$; char AbsorbFileName[HDRNAMEMAX] 1298 Name of Absorbance File (if File Mode) NumExpRepeats :0UL ,$; DWORD NumExpRepeats 1418 Number of Times experiment repeated NumExpAccums :0UL ,$; DWORD NumExpAccums 1422 Number of Time experiment accumulated YT_Flag :0 ,$; short YT_Flag 1426 Set to 1 if this file contains YT data clkspd_us :0.0 ,$; float clkspd_us 1428 Vert Clock Speed in micro-sec HWaccumFlag :0 ,$; short HWaccumFlag 1432 set to 1 if accum done by Hardware. StoreSync :0 ,$; short StoreSync 1434 set to 1 if store sync used BlemishApplied :0 ,$; short BlemishApplied 1436 set to 1 if blemish removal applied CosmicApplied :0 ,$; short CosmicApplied 1438 set to 1 if cosmic ray removal applied CosmicType :0 ,$; short CosmicType 1440 if cosmic ray applied, this is type CosmicThreshold :0.0 ,$; float CosmicThreshold 1442 Threshold of cosmic ray removal. NumFrames :0L ,$; long NumFrames 1446 number of frames in file. MaxIntensity :0.0 ,$; float MaxIntensity 1450 max intensity of data (future) MinIntensity :0.0 ,$; float MinIntensity 1454 min intensity of data (future) ylabel :chararr(LABELMAX) ,$; char ylabel[LABELMAX] 1458 y axis label. ShutterType :0U ,$; WORD ShutterType 1474 shutter type. shutterComp :0.0 ,$; float shutterComp 1476 shutter compensation time. readoutMode :0U ,$; WORD readoutMode 1480 readout mode, full,kinetics, etc WindowSize :0U ,$; WORD WindowSize 1482 window size for kinetics only. clkspd :0U ,$; WORD clkspd 1484 clock speed for kinetics & frame transfer interface_type :0U ,$; WORD interface_type 1486 computer interface $; (isa-taxi, pci, eisa, etc.) NumROIsInExperiment :0 ,$; short NumROIsInExperiment 1488 May be more than the 10 allowed in $; this header (if 0, assume 1) Spare_5 :chararr(16) ,$; char Spare_5[16] 1490 controllerNum :0U ,$; WORD controllerNum 1506 if multiple controller system will $; have controller number data came from. $; this is a future item. SWmade :0U ,$; WORD SWmade 1508 Which software package created this file NumROI :0 ,$; short NumROI 1510 number of ROIs used. if 0 assume 1. ; ; ;---------------------------------------------------------------------------------------------------------- ; ; ROI entries (1512 - 1631) ; ; struct ROIinfo ; { ROIinfo:REPLICATE({ $; startx :0U ,$; WORD startx left x start value. endx :0U ,$; WORD endx right x value. groupx :0U ,$; WORD groupx amount x is binned/grouped in hw. starty :0U ,$; WORD starty top y start value. endy :0U ,$; WORD endy bottom y value. groupy :0U }$; WORD groupy amount y is binned/grouped in hw. ,10) ,$; } ROIinfoblk[ROIMAX] $; ROI Starting Offsets: $; $; ROI 1 = 1512 $; ROI 2 = 1524 $; ROI 3 = 1536 $; ROI 4 = 1548 $; ROI 5 = 1560 $; ROI 6 = 1572 $; ROI 7 = 1584 $; ROI 8 = 1596 $; ROI 9 = 1608 $; ROI 10 = 1620 ; ;----------------------------------------------------------------------------------------------------------- ; FlatField :chararr(HDRNAMEMAX),$; char FlatField[HDRNAMEMAX] 1632 Flat field file name. background :chararr(HDRNAMEMAX),$; char background[HDRNAMEMAX] 1752 background sub. file name. blemish :chararr(HDRNAMEMAX),$; char blemish[HDRNAMEMAX] 1872 blemish file name. file_header_ver :0.0 ,$; float file_header_ver 1992 version of this file header YT_Info :chararr(1000) ,$; char YT_Info[1000] 1996-2995 Reserved for YT information WinView_id :0L ,$; long WinView_id 2996 == 0x01234567L if file created by WinX ; ;-------------------------------------------------------------------------------------------- ; ; START OF X CALIBRATION STRUCTURE (3000 - 3488) ; xcal:{ $ offset :0D ,$; double offset 3000 offset for absolute data scaling factor :0D ,$; double factor 3008 factor for absolute data scaling current_unit :0B ,$; char current_unit 3016 selected scaling unit reserved1 :0B ,$; char reserved1 3017 reserved string :chararr(40) ,$; char string[40] 3018 special string for scaling reserved2 :chararr(40) ,$; char reserved2[40] 3058 reserved calib_valid :0B ,$; char calib_valid 3098 flag if calibration is valid input_unit :0B ,$; char input_unit 3099 current input units for $; "calib_value" polynom_unit :0B ,$; char polynom_unit 3100 linear UNIT and used ; in the "polynom_coeff" polynom_order :0B ,$; char polynom_order 3101 ORDER of calibration POLYNOM calib_count :0B ,$; char calib_count 3102 valid calibration data pairs pixel_position :DBLARR(10) ,$; double pixel_position[10] 3103 pixel pos. of calibration data calib_value :DBLARR(10) ,$; double calib_value[10] 3183 calibration VALUE at above pos polynom_coeff :DBLARR(6) ,$; double polynom_coeff[6] 3263 polynom COEFFICIENTS laser_position :0D ,$; double laser_position 3311 laser wavenumber for relativ WN reserved3 :0B ,$; char reserved3 3319 reserved new_calib_flag :0B ,$; BYTE new_calib_flag 3320 If set to 200, valid label below calib_label :chararr(81) ,$; char calib_label[81] 3321 Calibration label (NULL term'd) expansion :chararr(87) }$; char expansion[87] 3402 Calibration Expansion area ,$ ; ;-------------------------------------------------------------------------------------------- ; ; START OF Y CALIBRATION STRUCTURE (3489 - 3977) ; ycal:{ $ offset :0D ,$; double offset 3489 offset for absolute data scaling factor :0D ,$; double factor 3497 factor for absolute data scaling current_unit :0B ,$; char current_unit 3505 selected scaling unit reserved1 :0B ,$; char reserved1 3506 reserved string :chararr(40) ,$; char string[40] 3507 special string for scaling reserved2 :chararr(40) ,$; char reserved2[40] 3547 reserved calib_valid :0B ,$; char calib_valid 3587 flag if calibration is valid input_unit :0B ,$; char input_unit 3588 current input units for ; "calib_value" polynom_unit :0B ,$; char polynom_unit 3589 linear UNIT and used ; in the "polynom_coeff" polynom_order :0B ,$; char polynom_order 3590 ORDER of calibration POLYNOM calib_count :0B ,$; char calib_count 3591 valid calibration data pairs pixel_position :DBLARR(10) ,$; double pixel_position[10] 3592 pixel pos. of calibration data calib_value :DBLARR(10) ,$; double calib_value[10] 3672 calibration VALUE at above pos polynom_coeff :DBLARR(6) ,$; double polynom_coeff[6] 3752 polynom COEFFICIENTS laser_position :0D ,$; double laser_position 3800 laser wavenumber for relativ WN reserved3 :0B ,$; char reserved3 3808 reserved new_calib_flag :0B ,$; BYTE new_calib_flag 3809 If set to 200, valid label below calib_label :chararr(81) ,$; char calib_label[81] 3810 Calibration label (NULL term'd) expansion :chararr(87) }$; char expansion[87] 3891 Calibration Expansion area ,$ ; ; END OF CALIBRATION STRUCTURES ; ;--------------------------------------------------------------------------------------------- ; Istring :chararr(40) ,$; char Istring[40] 3978 special intensity scaling string Spare_6 :chararr(25) ,$; char Spare_6[25] 4018 SpecType :0B ,$; BYTE SpecType 4043 spectrometer type (acton, spex, etc.) SpecModel :0B ,$; BYTE SpecModel 4044 spectrometer model (type dependent) PulseBurstUsed :0B ,$; BYTE PulseBurstUsed 4045 pulser burst mode on/off PulseBurstCount :0UL ,$; DWORD PulseBurstCount 4046 pulser triggers per burst PulseBurstPeriod :0D ,$; double PulseBurstPeriod 4050 pulser burst period (in usec) PulseBracketUsed :0B ,$; BYTE PulseBracketUsed 4058 pulser bracket pulsing on/off PulseBracketType :0B ,$; BYTE PulseBracketType 4059 pulser bracket pulsing type PulseTimeConstFast :0D ,$; double PulseTimeConstFast 4060 pulser slow exponential time constant (in usec) PulseAmplitudeFast :0D ,$; double PulseAmplitudeFast 4068 pulser fast exponential amplitude constant PulseTimeConstSlow :0D ,$; double PulseTimeConstSlow 4076 pulser slow exponential time constant (in usec) PulseAmplitudeSlow :0D ,$; double PulseAmplitudeSlow 4084 pulser slow exponential amplitude constant AnalogGain :0 ,$; short AnalogGain; 4092 analog gain AvGainUsed :0 ,$; short AvGainUsed 4094 avalanche gain was used AvGain :0 ,$; short AvGain 4096 avalanche gain value lastvalue :0 } ; short lastvalue 4098 Always the LAST value in the header ; END OF HEADER ; ;------------------------------------------------------------------------------- ;STOP,'.c' IF N_ELEMENTS(filename) NE 0 THEN BEGIN OPENR, unit, filename, /GET_LUN, ERROR=err IF err NE 0 THEN BEGIN PRINT, !ERROR_STATE.MSG RETURN, spe_header ENDIF READU, unit, spe_header FREE_LUN, unit ENDIF RETURN, spe_header END ; ; 4100 Start of Data ; ; ; ; ***************************** E.O.F.***************************** ; ; ; ; ; Definitions of array sizes: ; --------------------------- ; ; HDRNAMEMAX = 120 Max char str length for file name ; USERINFOMAX = 1000 User information space ; COMMENTMAX = 80 User comment string max length (5 comments) ; LABELMAX = 16 Label string max length ; FILEVERMAX = 16 File version string max length ; DATEMAX = 10 String length of file creation date string as ddmmmyyyy\0 ; ROIMAX = 10 Max size of roi array of structures ; TIMEMAX = 7 Max time store as hhmmss\0 ; ; ; ; Custom Data Types used in the structure: ; ---------------------------------------- ; ; BYTE = unsigned char ; WORD = unsigned short ; DWORD = unsigned long ; ; ; ; ; READING DATA: ; ------------- ; ; The data follows the header beginning at offset 4100. ; ; Data is stored as sequential points. ; ; The X, Y and Frame dimensions are determined by the header. ; ; The X dimension of the stored data is in "xdim" ( Offset 42 ). ; The Y dimension of the stored data is in "ydim" ( Offset 656 ). ; The number of frames of data stored is in "NumFrames" ( Offset 1446 ). ; ; The size of a frame (in bytes) is: ; ; One frame size = xdim x ydim x (datatype Offset 108) ; ; ;