Ignore:
Timestamp:
May 15, 2015 11:35:18 AM (8 years ago)
Author:
srkline
Message:

some reorganization of the r/w routines to generate HDF test files for SANS and VSANS (all are housed together for testing). also some reorganization of the detector binning routines to get functions grouped in more logical locations.

Location:
sans/Dev/trunk/NCNR_User_Procedures/Reduction
Files:
3 added
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/HDF5gateway_NCNR.ipf

    r946 r955  
    22 
    33#include <HDF5 Browser> 
     4 
     5// 
     6// !!! search for "SRK" to see what I have modified to work with NCNR files 
     7// -- these changes may only be for testing, and may need to be removed in the final version!!! 
     8// 
     9// 
     10// 
     11 
    412 
    513// requires the Wavemetrics "HDF5.xop" to be installed for IgorPro 
     
    939947 
    940948        Variable fileID = 0 
    941 //      HDF5OpenFile/R/P=home/Z fileID as fileName 
    942         HDF5OpenFile/R/P=catPathName/Z fileID as fileName 
     949        HDF5OpenFile/R/P=home/Z fileID as fileName 
     950//      HDF5OpenFile/R/P=catPathName/Z fileID as fileName 
    943951        if (V_Flag != 0) 
    944952                return 0 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_DetectorBinning_Q.ipf

    r954 r955  
    22 
    33 
    4 ///// Procedures for: 
    5 //      Generating the detector panels 
    6 //      Filling the panels with Qtot, QxQyQz 
    7 // Filling the "data" with a model function 
    8 // Averaging the panels (independently) into I(Q) 
    9 // 
    10 // 
    11 //There are some things in the current circular averaging that don't make any sense 
    12 //and don't seem to really do anything at all, so trim them out. 
    13 //1) subdividing pixels near the beam stop into 9 sub-pixels 
    14 //2) non-linear correction (maybe keep this as a dummy). I may need to put some sort 
    15 //of correction here for the offset, or it may already be done as I receive it. 
    16 // 
    17 // 
    18 // 
    19 //Do I separate out the circular, sector, rectangular, annular averaging into 
    20 //separate routines?  
    21 // 
    22 // 
    23 // 
     4////////////////// 
     5//  
     6// Procedures for: 
     7// 
     8//              Gathering information to calculate QxQyQz 
     9//              Filling the panels with Qtot, QxQyQz 
     10//              Filling the "data" with a model function 
     11//              Averaging the panels (independently) into I(Q) 
     12//              Plotting the 9 detector panels in 2D 
     13//              Plotting the 1D I(q) data depending on the panel combinations 
     14// 
     15// 
     16//  There are some things in the current circular averaging that don't make any sense 
     17//  and don't seem to really do anything at all, so i have decided to trim them out. 
     18//  1) subdividing pixels near the beam stop into 9 sub-pixels 
     19//  2) non-linear correction (only applies to Ordela) 
     20// 
     21// 
     22//  Do I separate out the circular, sector, rectangular, annular averaging into 
     23//   separate routines?  
     24// 
     25// 
     26// 
     27/////////////////// 
    2428 
    2529 
     
    2832End 
    2933 
    30 // to plot I(q) for the 4 front panels 
     34// 
     35// Plot the front panels in 2D and 1D 
     36//              calcualate Q 
     37//              fill w/model data 
     38//              "shadow" the T/B detectors 
     39//              bin the data to I(q) 
     40//              draw I(q) graph 
     41//              draw 2D panel graph 
    3142// 
    3243// *** Call this function when front panels are adjusted, or wavelength, etc. changed 
     
    5667        FillPanel_wModelData(det_FT,qTot_FT,"FT") 
    5768        FillPanel_wModelData(det_FB,qTot_FB,"FB") 
    58 //      det_FL = V_SphereForm(1,60,1e-6,1,qTot_FL[p][q])                                 
    59 //      det_FR = V_SphereForm(1,60,1e-6,1,qTot_FR[p][q])                                 
    60 //      det_FT = V_SphereForm(1,60,1e-6,1,qTot_FT[p][q])                                 
    61 //      det_FB = V_SphereForm(1,60,1e-6,1,qTot_FB[p][q])                         
    6269 
    6370        SetDataFolder root: 
     
    7683        Execute "Front_IQ_Graph()" 
    7784        Execute "FrontPanels_AsQ()" 
     85         
     86        return(0) 
    7887End 
    7988 
     
    218227 
    219228 
    220 // TODO" - this doesn't quite mask things out as they should be (too much is masked L/R of center) 
     229// TODO - this doesn't quite mask things out as they should be (too much is masked L/R of center) 
    221230// and the outer edges of the detector are masked even if the TB panels extend past the TB of the LR panels. 
    222231// ? skip the masking? but then I bin the detector data directly to get I(q), skipping the masked NaN values... 
     
    245254// TODO - these are to be set from globals, not hard-wired 
    246255// pixel sizes are in cm for T/B detector 
    247 // TODO: the "FT" check is hard wired for FRONT -- get rid of this... 
     256// TODO - the "FT" check is hard wired for FRONT -- get rid of this... 
    248257 
    249258        pixSizeX = VCALC_getPixSizeX(type) 
     
    266275 
    267276 
     277// After the panels have been calculated and rescaled in terms of Q, and filled with simulated data 
     278// they can be appended to the subwindow. If they are already there, the axes and coloring 
     279// are rescaled as needed 
     280// 
    268281Window FrontPanels_AsQ() : Graph 
    269 //      DoWindow/F FrontPanels_AsQ 
    270 //      if(V_flag == 0) 
    271 //      PauseUpdate; Silent 1           // building window... 
    272 //      Display /W=(1477,44,1978,517) 
    273282 
    274283        SetDataFolder root:Packages:NIST:VSANS:VCALC:Front 
     
    303312        SetDataFolder root: 
    304313         
    305 //      ModifyGraph width={Aspect,1},height={Aspect,1},gbRGB=(56797,56797,56797) 
    306 //      ModifyGraph grid=2 
    307 //      ModifyGraph mirror=2 
    308 //      SetAxis left -0.2,0.2 
    309 //      SetAxis bottom -0.2,0.2 
    310 //      endif 
    311314EndMacro 
    312315 
     
    419422        Execute "Middle_IQ_Graph()" 
    420423        Execute "MiddlePanels_AsQ()" 
     424         
     425        return(0) 
    421426End 
    422427 
     
    805810        Execute "Back_IQ_Graph()" 
    806811        Execute "BackPanels_AsQ()" 
     812 
     813        return(0) 
     814 
    807815End 
    808816 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_DetectorBinning_Slit.ipf

    r954 r955  
    22 
    33 
     4////////////////// 
     5// 
     6// Procedures to average data taken in "slit" apertuere geometry. The fake data on the detector panels 
     7//  is as would be collected in PINHOLE geometry - I do not currently have a simulation for slit 
     8//  apertures (this would need to be MonteCarlo) - the I(q) averaging here gives the I(q) that you 
     9//  would measure in 1D using slit geometry. It is done by simply summing the columns of data on each detector. 
     10// 
     11////////////////// 
    412// 
    513// 
     
    1018// - best answer so far is to skip the T/B panels, and simply not use them 
    1119// 
     20// TODO -- be sure that the absolute scaling of this is correct. I have no guarantee that  
     21//                      it'll be correct. 
     22// 
     23///////////////// 
     24 
    1225 
    1326// 
     27// seems backwards to call this "byRows", but this is the way that Igor indexes 
     28// LR banks are defined as (48,256) (n,m), sumRows gives sum w/ dimension (n x 1) 
    1429// 
    1530Function V_fBinDetector_byRows(folderStr,type) 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_DetectorBinning_Utils.ipf

    r954 r955  
    11#pragma rtGlobals=3             // Use modern global access method and strict wave access. 
     2 
     3///////////////////////// 
     4// 
     5// Utility functions to: 
     6//              calculate Q, Qx, Qy, Qz 
     7//              fill the detector panels with simulated data (the model functions are here) 
     8//              bin the 2D detector to 1D I(Q) based on Q and deltaQ (bin width) 
     9// 
     10///////////////////////// 
     11 
     12 
    213 
    314 
     
    3142        //?? pick the function from a popup on the panel? (bypass the analysis panel, or maybe it's better to  
    3243        //  keep the panel to keep people used to using it.) 
     44        // peak @ 0.1 ~ AgBeh 
     45        //      Make/O/D coef_BroadPeak = {1e-9, 3, 20, 100.0, 0.1,3,0.1}                
     46        // 
     47        // peak @ 0.015 in middle of middle detector, maybe not "real" vycor, but that is to be resolved 
     48        //      Make/O/D coef_BroadPeak = {1e-9, 3, 20, 500.0, 0.015,3,0.1}              
    3349        String funcStr = VCALC_getModelFunctionStr() 
    3450        strswitch(funcStr) 
     
    4561                        tmpInten = V_SphereForm(1,60,1e-6,0.001,qTot[p][q])      
    4662                        break 
     63                case "AgBeh": 
     64                        tmpInten = V_BroadPeak(1e-9,3,20,100.0,0.1,3,0.1,qTot[p][q]) 
     65                        break 
     66                case "Vycor": 
     67                        tmpInten = V_BroadPeak(1e-9,3,20,500.0,0.015,3,0.1,qTot[p][q]) 
     68                        break    
     69                case "Empty Cell": 
     70                        tmpInten = V_EC_Empirical(2.2e-8,3.346,0.0065,9.0,0.016,qTot[p][q]) 
     71                        break 
     72                case "Blocked Beam": 
     73                        tmpInten = V_BlockedBeam(1,qTot[p][q]) 
     74                        break 
    4775                default: 
    4876                        tmpInten = V_Debye(10,300,0.1,qTot[p][q]) 
     
    148176 
    149177//function to calculate the overall q-value, given all of the necesary trig inputs 
    150 //NOTE: detector locations passed in are pixels = 0.5cm real space on the detector 
    151178//and are in detector coordinates (1,128) rather than axis values 
    152179//the pixel locations need not be integers, reals are ok inputs 
     
    177204//ALL inputs are in detector coordinates 
    178205// 
    179 //NOTE: detector locations passed in are pixel = 0.5cm real space on the Ordela detector 
    180206//sdd is in meters 
    181207//wavelength is in Angstroms 
     
    208234//input/output is the same as CalcQval() 
    209235//ALL inputs are in detector coordinates 
    210 //NOTE: detector locations passed in are pixel = 0.5cm real space on the Ordela detector 
    211236//sdd is in meters 
    212237//wavelength is in Angstroms 
     
    239264//input/output is the same as CalcQval() 
    240265//ALL inputs are in detector coordinates 
    241 //NOTE: detector locations passed in are pixel = 0.5cm real space on the Ordela detector 
    242266//sdd is in meters 
    243267//wavelength is in Angstroms 
     
    366390End 
    367391 
     392// a sum of a power law and debye to approximate the scattering from a real empty cell 
     393// 
     394//      make/O/D coef_ECEmp = {2.2e-8,3.346,0.0065,9.0,0.016} 
     395// 
     396Function V_EC_Empirical(aa,mm,scale,rg,bkg,x) 
     397        Variable aa,mm,scale,rg,bkg 
     398        Variable x 
     399         
     400        // variables are: 
     401        //[0] = A 
     402        //[1] = power m 
     403        //[2] scale factor 
     404        //[3] radius of gyration [A] 
     405        //[4] background        [cm-1] 
     406         
     407        Variable Iq 
     408         
     409        // calculates (scale*debye)+bkg 
     410        Variable Pq,qr2 
     411         
     412//      if(x*Rg < 1e-3)         //added Oct 2008 to avoid numerical errors at low arg values 
     413//              return(scale+bkg) 
     414//      endif 
     415         
     416        Iq = aa*x^-mm 
     417         
     418        qr2=(x*rg)^2 
     419        Pq = 2*(exp(-(qr2))-1+qr2)/qr2^2 
     420         
     421        //scale 
     422        Pq *= scale 
     423        // then add the terms up 
     424        return (Iq + Pq + bkg) 
     425End 
     426 
     427// blocked beam 
     428// 
     429Function V_BlockedBeam(bkg,x) 
     430        Variable bkg 
     431        Variable x 
     432         
     433        return (bkg) 
     434End 
     435 
     436 
     437// 
     438// a broad peak to simulate silver behenate or vycor 
     439// 
     440// peak @ 0.1 ~ AgBeh 
     441//      Make/O/D coef_BroadPeak = {1e-9, 3, 20, 100.0, 0.1,3,0.1}                
     442// 
     443// 
     444// peak @ 0.015 in middle of middle detector, maybe not "real" vycor, but that is to be resolved 
     445//      Make/O/D coef_BroadPeak = {1e-9, 3, 20, 500.0, 0.015,3,0.1}              
     446// 
     447// 
     448Function V_BroadPeak(aa,nn,cc,LL,Qzero,mm,bgd,x) 
     449        Variable aa,nn,cc,LL,Qzero,mm,bgd 
     450        Variable x 
     451         
     452        // variables are:                                                        
     453        //[0] Porod term scaling 
     454        //[1] Porod exponent 
     455        //[2] Lorentzian term scaling 
     456        //[3] Lorentzian screening length [A] 
     457        //[4] peak location [1/A] 
     458        //[5] Lorentzian exponent 
     459        //[6] background 
     460         
     461//      local variables 
     462        Variable inten, qval 
     463//      x is the q-value for the calculation 
     464        qval = x 
     465//      do the calculation and return the function value 
     466         
     467        inten = aa/(qval)^nn + cc/(1 + (abs(qval-Qzero)*LL)^mm) + bgd 
     468 
     469        Return (inten) 
     470         
     471End 
    368472 
    369473 
     
    429533 
    430534 
     535 
     536////////// 
     537// 
     538//              Function that bins a 2D detctor panel into I(q) based on the q-value of the pixel 
     539//              - each pixel QxQyQz has been calculated beforehand 
     540//              - if multiple panels are selected to be combined, it is done here during the binning 
     541//              - the setting of deltaQ step is still a little suspect (TODO) 
     542// 
     543// 
    431544// see the equivalent function in PlotUtils2D_v40.ipf 
    432545// 
     
    436549// -- type = FL or FR or...other panel identifiers 
    437550// 
    438 // TODO "iErr" is all messed up since it doesn't really apply here for data that is not 2D simulation 
    439 // 
     551// TODO "iErr" is not always defined correctly since it doesn't really apply here for data that is not 2D simulation 
    440552// 
    441553Function V_fDoBinning_QxQy2D(folderStr,type) 
     
    592704 
    593705//TODO: properly define the errors here - I'll have this if I do the simulation 
    594         if(WaveExists(iErr)==0) 
     706        if(WaveExists(iErr)==0  && WaveExists(inten) != 0) 
    595707                Duplicate/O inten,iErr 
    596708                Wave iErr=iErr 
    597709//              iErr = 1+sqrt(inten+0.75)                       // can't use this -- it applies to counts, not intensity (already a count rate...) 
    598710                iErr = sqrt(inten+0.75)                 // TODO -- here I'm just using some fictional value 
     711        endif 
     712        if(WaveExists(iErr2)==0 && WaveExists(inten2) != 0) 
     713                Duplicate/O inten2,iErr2 
     714                Wave iErr2=iErr2 
     715//              iErr2 = 1+sqrt(inten2+0.75)                     // can't use this -- it applies to counts, not intensity (already a count rate...) 
     716                iErr2 = sqrt(inten2+0.75)                       // TODO -- here I'm just using some fictional value 
     717        endif 
     718        if(WaveExists(iErr3)==0  && WaveExists(inten3) != 0) 
     719                Duplicate/O inten3,iErr3 
     720                Wave iErr3=iErr3 
     721//              iErr3 = 1+sqrt(inten3+0.75)                     // can't use this -- it applies to counts, not intensity (already a count rate...) 
     722                iErr3 = sqrt(inten3+0.75)                       // TODO -- here I'm just using some fictional value 
     723        endif 
     724        if(WaveExists(iErr4)==0  && WaveExists(inten4) != 0) 
     725                Duplicate/O inten4,iErr4 
     726                Wave iErr4=iErr4 
     727//              iErr4 = 1+sqrt(inten4+0.75)                     // can't use this -- it applies to counts, not intensity (already a count rate...) 
     728                iErr4 = sqrt(inten4+0.75)                       // TODO -- here I'm just using some fictional value 
    599729        endif 
    600730 
     
    622752         
    623753//      delQ = abs(sqrt(qx[2]^2+qy[2]^2+qz[2]^2) - sqrt(qx[1]^2+qy[1]^2+qz[1]^2))               //use bins of 1 pixel width  
    624 // TODO: not sure if I want to so dQ in x or y direction... 
     754// TODO: not sure if I want to set dQ in x or y direction... 
    625755        // the short dimension is the 8mm tubes, use this direction as dQ? 
    626756        // but don't use the corner of the detector, since dQ will be very different on T/B or L/R due to the location of [0,0] 
     
    680810                                        iBin_qxqy[binIndex] += val 
    681811                                        iBin2_qxqy[binIndex] += val*val 
    682                                         eBin2D_qxqy[binIndex] += iErr[ii][jj]*iErr[ii][jj] 
     812                                        eBin2D_qxqy[binIndex] += iErr2[ii][jj]*iErr2[ii][jj] 
    683813                                        nBin_qxqy[binIndex] += 1 
    684814                                endif 
     
    702832                                        iBin_qxqy[binIndex] += val 
    703833                                        iBin2_qxqy[binIndex] += val*val 
    704                                         eBin2D_qxqy[binIndex] += iErr[ii][jj]*iErr[ii][jj] 
     834                                        eBin2D_qxqy[binIndex] += iErr3[ii][jj]*iErr3[ii][jj] 
    705835                                        nBin_qxqy[binIndex] += 1 
    706836                                endif 
     
    721851                                        iBin_qxqy[binIndex] += val 
    722852                                        iBin2_qxqy[binIndex] += val*val 
    723                                         eBin2D_qxqy[binIndex] += iErr[ii][jj]*iErr[ii][jj] 
     853                                        eBin2D_qxqy[binIndex] += iErr4[ii][jj]*iErr4[ii][jj] 
    724854                                        nBin_qxqy[binIndex] += 1 
    725855                                endif 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_FrontView_Deg.ipf

    r954 r955  
    11#pragma rtGlobals=3             // Use modern global access method and strict wave access. 
    22 
     3 
     4///////////////////////// 
    35// 
    4 // draw boxes for the detector coverage based on the geometry of the instrument setup 
     6// Function to draw schematic boxes for the detector coverage based on the geometry 
     7// of the instrument setup 
    58// 
    6 // this will draw all of the panels. Zooming is then simply rescaling the axes 
     9// -- all of the dimensions are based on the angles and ranges in degrees 
    710// 
    8 // Now it is part of the main panel and is updated when any detector settings are changed 
     11// -- this draws all 9 of the panels. Zooming is then simply rescaling the axes 
    912// 
     13// -- Now it is part of the main panel. This function is then called again 
     14//    to update the drawing when any detector settings are changed 
     15// 
     16////////////////////////// 
     17 
    1018Function FrontView_1x() 
    1119         
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_UtilityProcedures.ipf

    r954 r955  
    11#pragma rtGlobals=3             // Use modern global access method and strict wave access. 
    22 
    3  
    4 // a bunch of utility procedures to get information from the VCALC panel and to access 
     3//////////////////////// 
     4// 
     5// 
     6// a bunch of utility procedures to access information from the VCALC panel and to access 
    57// constants based in which of the detectors I'm trying to work with. Saves a lot of repetitive switches 
    68// 
    79// start the function names with VCALC_ to avoid the eventual conflicts with the file loading utilities 
    810// for reduction of real VSANS data 
    9  
    10  
    11 ///  Values from the VCALC panel 
     11// 
     12// 
     13// -- add more of these procedures as more items are added to the panel 
     14// 
     15//////////////////////// 
     16 
     17 
     18//  Values from the VCALC panel 
    1219 
    1320 
     
    308315/////////// procedure to concatenate I(q) files into a single file 
    309316// 
    310 // currently, no rescaling is done, just simple concatentate and sort 
    311 // 
     317// currently, no rescaling is done, just crude concatentate and sort 
     318// 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_VCALCPanel_MockUp.ipf

    r954 r955  
    686686 
    687687// tab 5 
    688         String/G gModelFunctionType = "Debye;Sphere;Big Debye;Big Sphere;" 
     688        String/G gModelFunctionType = "Debye;Sphere;Big Debye;Big Sphere;AgBeh;Vycor;Empty Cell;Blocked Beam;" 
    689689 
    690690 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VSANS_Includes.ipf

    r954 r955  
    55#include "VC_DetectorBinning_Utils" 
    66#include "VC_FrontView_Deg"      
    7 #include "VC_HDF5_VSANS_Write" 
     7#include "VC_HDF5_VSANS_Utils" 
    88#include "VC_SideView" 
    99#include "VC_UtilityProcedures" 
    1010#include "VC_VCALCPanel_MockUp" 
     11 
     12#include "HDF5gateway_NCNR" 
     13#include "Nexus_SANS_Write" 
     14#include "Nexus_VSANS_Write" 
Note: See TracChangeset for help on using the changeset viewer.