Changeset 247


Ignore:
Timestamp:
Jan 23, 2008 12:42:16 PM (15 years ago)
Author:
srkline
Message:

Changes made to read the physical detector pixel size X and Y from the file header, not from globals defined in _Utils.ipf. Now proper values must be input from instr.cfg, or patched after the fact.

Added utility procedures to write updated values (batch patch) directly to file headers, and a utility to read out the current values stored in the headers. These are available as Macros from the SANSBeta menu.

Made the corresponding changes in the FACILITY_... files for future use.

Location:
sans/SANSReduction/trunk/Put in User Procedures/SANS_Reduction_v5.00
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • sans/SANSReduction/trunk/Put in User Procedures/SANS_Reduction_v5.00/CircSectAve.ipf

    r210 r247  
    333333        Variable DDet 
    334334        NVAR apOff = root:myGlobals:apOff               //in cm 
    335         DDet = DetectorPixelResolution(fileStr,detStr)          //needs detector type and beamline 
     335         
     336//      DDet = DetectorPixelResolution(fileStr,detStr)          //needs detector type and beamline 
     337        //note that reading the detector pixel size from the header ASSUMES SQUARE PIXELS! - Jan2008 
     338        DDet = reals[10]/10                     // header value (X) is in mm, want cm here 
     339         
    336340         
    337341        //Width of annulus used for the average is gotten from the 
  • sans/SANSReduction/trunk/Put in User Procedures/SANS_Reduction_v5.00/FACILITY_DataReadWrite.ipf

    r186 r247  
    133133        // these values are set for a detctor that has a linear correspondence between 
    134134        // pixel number and real-space distance 
    135         //(soo no correction is done) 
    136         realw[10] = 5 
     135        // 10 and 13 are the X and Y pixel dimensions, respectively (in mm!) 
     136        //(11,12 and 13,14 are set to values for a linear response, as from a new Ordela detector) 
     137        realw[10] = getDetectorPixelXSize(fname) 
    137138        realw[11] = 1000 
    138139        realw[12] = 0 
    139         realw[13] = 5 
     140        realw[13] = getDetectorPixelYSize(fname) 
    140141        realw[14] = 1000 
    141142        realw[15] = 0 
     
    668669End 
    669670 
     671// physical dimension of detector x-pixel (mm) 
     672Function WriteDetPixelXToHeader(fname,num) 
     673        String fname 
     674        Variable num 
     675         
     676        //your code here 
     677         
     678        return(0) 
     679end 
     680 
     681// physical dimension of detector y-pixel (mm) 
     682Function WriteDetPixelYToHeader(fname,num) 
     683        String fname 
     684        Variable num 
     685         
     686        //your code here 
     687         
     688        return(0) 
     689end 
     690 
    670691// sample label string 
    671692Function WriteSamLabelToHeader(fname,str) 
     
    9871008         
    9881009        // your code returning value 
     1010         
     1011        return(value) 
     1012end 
     1013 
     1014// physical x-dimension of a detector pixel, in mm 
     1015Function getDetectorPixelXSize(fname) 
     1016        String fname 
     1017         
     1018        Variable value 
     1019         
     1020        // your code here returning value 
     1021         
     1022        return(value) 
     1023end 
     1024 
     1025// physical y-dimension of a detector pixel, in mm 
     1026Function getDetectorPixelYSize(fname) 
     1027        String fname 
     1028         
     1029        Variable value 
     1030         
     1031        // your code here returning value 
    9891032         
    9901033        return(value) 
  • sans/SANSReduction/trunk/Put in User Procedures/SANS_Reduction_v5.00/FACILITY_Utils.ipf

    r186 r247  
    2424        Variable/G root:myGlobals:gNPixelsY=128 
    2525         
    26         Variable/G root:myGlobals:PixelResDefault = 0.5                 //pixel resolution in cm 
     26        // pixel dimensions are now read directly from the file header. 
     27//      Variable/G root:myGlobals:PixelResDefault = 0.5                 //pixel resolution in cm 
    2728         
    2829        Variable/G root:myGlobals:DeadtimeDefault = 3.4e-6              //deadtime in seconds 
     
    142143// detStr is passed as TextRead[9] and is an identifier for the detector 
    143144// 
    144 Function DetectorPixelResolution(fileStr,detStr) 
     145// depricated - pixel dimensions are read directly from the file header 
     146Function xDetectorPixelResolution(fileStr,detStr) 
    145147        String fileStr,detStr 
    146148         
  • sans/SANSReduction/trunk/Put in User Procedures/SANS_Reduction_v5.00/Includes_v500.ipf

    r237 r247  
    8484        "Convert To Lens" 
    8585        "Convert To Pinhole" 
     86        "Patch Detector Pixel Size" 
     87        "Read Detector Pixel Size" 
    8688        "-" 
    8789        "AddALLToLayout" 
  • sans/SANSReduction/trunk/Put in User Procedures/SANS_Reduction_v5.00/NCNR_DataReadWrite.ipf

    r143 r247  
    12181218End 
    12191219 
    1220 //detector offset is at byte 260 
     1220//sample to detector distance is at byte 260 
    12211221Function WriteSDDToHeader(fname,num) 
    12221222        String fname 
     
    12271227End 
    12281228 
     1229//detector pixel X size (mm) is at byte 220 
     1230Function WriteDetPixelXToHeader(fname,num) 
     1231        String fname 
     1232        Variable num 
     1233         
     1234        WriteVAXReal(fname,num,220) 
     1235        return(0) 
     1236End 
     1237 
     1238//detector pixel Y size (mm) is at byte 232 
     1239Function WriteDetPixelYToHeader(fname,num) 
     1240        String fname 
     1241        Variable num 
     1242         
     1243        WriteVAXReal(fname,num,232) 
     1244        return(0) 
     1245End 
    12291246 
    12301247//rewrite a text field back to the header 
     
    14991516         
    15001517        return(getRealValueFromHeader(fname,388)) 
     1518end 
     1519 
     1520//detector pixel X size is at byte 220 
     1521Function getDetectorPixelXSize(fname) 
     1522        String fname 
     1523         
     1524        return(getRealValueFromHeader(fname,220)) 
     1525end 
     1526 
     1527//detector pixel Y size is at byte 232 
     1528Function getDetectorPixelYSize(fname) 
     1529        String fname 
     1530         
     1531        return(getRealValueFromHeader(fname,232)) 
    15011532end 
    15021533 
     
    16011632end 
    16021633 
     1634 
     1635// Jan 2008 
     1636// it has been determined that the true pixel dimension of the ordela detectors is not 5.0 mm 
     1637// but somewhat larger (5.08? mm). "new" data files will be written out with the proper size 
     1638// and old files will be patched batchwise to put the prpoer value in the header 
     1639 
     1640Proc PatchDetectorPixelSize(firstFile,lastFile,XSize,YSize) 
     1641        Variable firstFile=1,lastFile=100,XSize=5.08,YSize=5.08 
     1642 
     1643        fPatchDetectorPixelSize(firstFile,lastFile,XSize,YSize) 
     1644 
     1645End 
     1646 
     1647Proc ReadDetectorPixelSize(firstFile,lastFile) 
     1648        Variable firstFile=1,lastFile=100 
     1649         
     1650        fReadDetectorPixelSize(firstFile,lastFile) 
     1651End 
     1652 
     1653// simple utility to patch the detector pixel size in the file headers 
     1654// pass in the dimensions in mm 
     1655// lo is the first file number 
     1656// hi is the last file number (inclusive) 
     1657// 
     1658Function fPatchDetectorPixelSize(lo,hi,xdim,ydim) 
     1659        Variable lo,hi,xdim,ydim 
     1660         
     1661        Variable ii 
     1662        String file 
     1663         
     1664        //loop over all files 
     1665        for(ii=lo;ii<=hi;ii+=1) 
     1666                file = FindFileFromRunNumber(ii) 
     1667                if(strlen(file) != 0) 
     1668                        WriteDetPixelXToHeader(file,xdim) 
     1669                        WriteDetPixelyToHeader(file,ydim) 
     1670                else 
     1671                        printf "run number %d not found\r",ii 
     1672                endif 
     1673        endfor 
     1674         
     1675        return(0) 
     1676End 
     1677 
     1678// simple utility to read the pixel size stored in the file header 
     1679Function fReadDetectorPixelSize(lo,hi) 
     1680        Variable lo,hi 
     1681         
     1682        String file 
     1683        Variable xdim,ydim,ii 
     1684         
     1685        for(ii=lo;ii<=hi;ii+=1) 
     1686                file = FindFileFromRunNumber(ii) 
     1687                if(strlen(file) != 0) 
     1688                        xdim = getDetectorPixelXSize(file) 
     1689                        ydim = getDetectorPixelYSize(file) 
     1690                        printf "File %d:  Pixel dimensions (mm): X = %g\t Y = %g\r",ii,xdim,ydim 
     1691                else 
     1692                        printf "run number %d not found\r",ii 
     1693                endif 
     1694        endfor 
     1695         
     1696        return(0) 
     1697End 
     1698 
     1699 
     1700 
    16031701//******************* 
    16041702//************ 
  • sans/SANSReduction/trunk/Put in User Procedures/SANS_Reduction_v5.00/NCNR_Utils.ipf

    r206 r247  
    2424        Variable/G root:myGlobals:gNPixelsY=128 
    2525         
     26        // as of Jan2008, detector pixel sizes are read directly from the file header, so they MUST 
     27        // be set correctly in instr.cfg 
    2628        Variable/G root:myGlobals:PixelResNG3_ILL = 1.0         //pixel resolution in cm 
    2729        Variable/G root:myGlobals:PixelResNG5_ILL = 1.0 
     
    160162// detStr is passed as TextRead[9] 
    161163// 
    162 Function DetectorPixelResolution(fileStr,detStr) 
     164// *** as of Jan 2008, depricated. Now detector pixel sizes are read from the file header 
     165// rw[10] = x size (mm); rw[13] = y size (mm) 
     166// 
     167Function xDetectorPixelResolution(fileStr,detStr) 
    163168        String fileStr,detStr 
    164169         
  • sans/SANSReduction/trunk/Put in User Procedures/SANS_Reduction_v5.00/ProtocolAsPanel.ipf

    r116 r247  
    19971997                Variable detCnt,countTime,attenTrans,monCnt,sdd,pixel 
    19981998                String detStr=tw[9] 
    1999                 pixel = DetectorPixelResolution(acctStr,detStr)         //get the pixel size from the file information 
     1999//              pixel = DetectorPixelResolution(acctStr,detStr)         //get the pixel size from the file information 
     2000                //note that reading the detector pixel size from the header ASSUMES SQUARE PIXELS! - Jan2008 
     2001                pixel = rw[10]/10                       // header value (X) is in mm, want cm here 
     2002         
    20002003                countTime = iw[1] 
    20012004                //detCnt = rw[2]                //080802 -use sum of data, not scaler from header 
  • sans/SANSReduction/trunk/Put in User Procedures/SANS_Reduction_v5.00/RectAnnulAvg.ipf

    r210 r247  
    332332        Variable DDet 
    333333        NVAR apOff = root:myGlobals:apOff               //in cm 
    334         DDet = DetectorPixelResolution(fileStr,detStr)          //needs detector type and beamline 
    335  
     334         
     335//      DDet = DetectorPixelResolution(fileStr,detStr)          //needs detector type and beamline 
     336        //note that reading the detector pixel size from the header ASSUMES SQUARE PIXELS! - Jan2008 
     337        DDet = reals[10]/10                     // header value (X) is in mm, want cm here 
     338         
    336339        //Width of annulus used for the average is gotten from the  
    337340        //input dialog before.  This also must be passed to the resol 
Note: See TracChangeset for help on using the changeset viewer.