Ignore:
Timestamp:
Nov 24, 2010 4:23:13 PM (12 years ago)
Author:
srkline
Message:
  • fixed a few bugs with GenCurveFit?, and how the reports are generated


  • the DEFAULT.MASK file is automatically loaded when the path is set, if it can be found. this only happens from the main (yellow) panel. Nothing happens if that exact file is not found.


  • a "Sector_PlusMinus" averaging option is added. This defines the LEFT sector as being "negative" q-values. Everything else behaves as a normal sector average. This is from Lionel, a very old ticket #31


  • if sectors or annular regions are drawn on RAW data files, the drawn lines are re-drawn correctly as the data is scrolled using the < and > buttons.


  • a super secret option for a "histogram pair" has been added. May be useful for alignment, may ditch if Jeff and Cedric don't like it. To do this, put cursor A on the 2D image at the center of where you want the vertical and horizontal swath to be. +-5 pixels is hard-wired. draw any marquee(size, location is ignored) and select SANS Histogram, and you get the pair. If cursor A is not on the graph, you get the normal histogram as defined by the marquee.


  • arrow buttons on RAW 2D data display now search +- 10 data files for "next", in case there are missing file numbers.


  • Incorporated Lionel's changes to ILL_* files for his generation of a "DIV" file for D22


  • Added the offset traces checkbox back to the SASCALC panel. previously it was hidden on the simulation panels.


  • loosened the tolerance for SDD matching onn the MRED panel to 0.1 m



Location:
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS
Files:
10 edited

Legend:

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

    r757 r764  
    159159                        QxQy_Export(type,"",1) 
    160160                        break 
     161                case "Sector_PlusMinus": 
     162                        Sector_PlusMinus1D(type) 
     163                        If(doSave) 
     164                                if (useXMLOutput == 1) 
     165                                        WriteXMLWaves_W_Protocol(type,"",1) 
     166                                else 
     167                                        WriteWaves_W_Protocol(type,"",1)                //"" is an empty path, 1 will force a dialog 
     168                                endif 
     169                        Endif 
     170                        break 
    161171                default:                                                 
    162172                        Abort "no case match in average dispatch" 
     
    174184                String/G root:myGlobals:Protocols:gProtoStr = "" 
    175185        Endif 
    176          
    177186         
    178187        return(0) 
     
    226235                case "Circular": 
    227236                case "Sector": 
     237                case "Sector_PlusMinus": 
    228238                case "Rectangular": 
    229239                case "Annular": 
     
    258268                        break 
    259269                case "Sector": 
     270                case "Sector_PlusMinus": 
    260271                        SetVariable Phi_p,disable=no 
    261272                        SetVariable Qctr_p,disable=yes 
     
    301312        PopupMenu av_choice,pos={61,7},size={144,20},proc=AvTypePopMenuProc,title="AverageType" 
    302313        PopupMenu av_choice,help={"Select the type of average to perform, then make the required selections below and click \"DoAverage\" to plot the results"} 
    303         PopupMenu av_choice,mode=1,popvalue="Circular",value= #"\"Circular;Sector;Annular;Rectangular;2D ASCII;QxQy ASCII\"" 
     314        PopupMenu av_choice,mode=1,popvalue="Circular",value= #"\"Circular;Sector;Annular;Rectangular;2D ASCII;QxQy ASCII;Sector_PlusMinus;\"" 
    304315        Button ave_help,pos={260,7},size={25,20},proc=ShowAvePanelHelp,title="?" 
    305316        Button ave_help,help={"Show the help file for averaging options"} 
     
    446457        //else sector or rectangular - draw the lines 
    447458         
    448         //if sector or rectangular, draw the phi line (on the desired side) 
    449         if( (cmpstr(av_type,"Sector")==0) || (cmpstr(av_type,"Rectangular")==0)) 
     459        //if sector, sector_plusminus, or rectangular, draw the phi line (on the desired side) 
     460        if( (cmpstr(av_type,"Sector")==0) || (cmpstr(av_type,"Rectangular")==0) || (cmpstr(av_type,"Sector_PlusMinus")==0)) 
    450461                if( (cmpstr(side,"left")==0) || (cmpstr(side,"both")==0) ) 
    451462                        //draw the phi line on the left side 
     
    467478         
    468479        //if Sector, draw the +/- dphi lines 
    469         if (cmpstr(av_type,"Sector")==0) 
     480        if (cmpstr(av_type,"Sector")==0  || cmpstr(av_type,"Sector_PlusMinus")==0) 
    470481                if( (cmpstr(side,"left")==0) || (cmpstr(side,"both")==0) ) 
    471482                        //draw the deltaPhi lines +/- lines 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/Buttons.ipf

    r683 r764  
    189189 
    190190        LoadPlotAndDisplayRAW(-1) 
     191        // re-draw the sectors or annulus if this was a step to prev/next raw file 
     192        MasterAngleDraw() 
    191193         
    192194        return(0) 
     
    199201 
    200202        LoadPlotAndDisplayRAW(1) 
     203        // re-draw the sectors or annulus if this was a step to prev/next raw file 
     204        MasterAngleDraw() 
    201205         
    202206        return (0) 
     
    206210//file is read from disk, if path is set and the file number is present 
    207211//increment +1, adds 1 to run number, -1 subtracts one 
     212// 
     213// will automatically step a gap of 10 run numbers, but nothing larger. Don't want to loop too long 
     214// trying to find a file (frustrating), don't want to look past the end of the run numbers (waste) 
     215// -- may find a more elegant solution later. 
     216// 
    208217Function LoadPlotAndDisplayRAW(increment) 
    209218        Variable increment 
    210219 
    211         Variable i 
    212         String filename 
     220        Variable i,val 
     221        String filename,tmp 
    213222        //take the currently displayed RAW file (there is only one name in fileList) 
    214223        SVAR oldName = root:Packages:NIST:RAW:fileList 
     224        oldname = RemoveAllSpaces(oldname)              // the name in the file list will have 21 chars, thus leading spaces if prefix < 5 chars 
    215225         
    216226//      print oldName 
    217227         
    218228        filename = oldname 
    219         for (i = 0; i < abs(increment); i += 1) 
    220                 filename = GetPrevNextRawFile(filename,increment/abs(increment)) 
    221         endfor   
    222          
     229//      for (i = 0; i < abs(increment); i += 1) 
     230//              filename = GetPrevNextRawFile(filename,increment/abs(increment)) 
     231//      endfor   
     232        i = 1 
     233        val = increment 
     234        do 
     235//              print filename,val 
     236                filename = GetPrevNextRawFile(filename,val) 
     237//              print "new= ",filename 
     238                 
     239                val = i*increment 
     240                i+=1 
     241                tmp = ParseFilePath(0, filename, ":", 1, 0) 
     242 
     243//              print val,strlen(tmp),strlen(oldname) 
     244//              print cmpstr(tmp,oldname) 
     245 
     246                if(strlen(tmp) == 0)            //in some cases, a null string can be returned - handle gracefully 
     247                        return(0) 
     248                endif 
     249                 
     250        while( (cmpstr(tmp,oldname) == 0) && i < 11) 
    223251//      print filename 
    224252         
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/CircSectAve.ipf

    r665 r764  
    494494        Return 0 
    495495End 
     496 
     497 
     498 
     499#pragma rtGlobals=1             // Use modern global access method. 
     500 
     501 
     502// -- seems to work, now I need to give it a name, add it to the list, and  
     503// make sure I've thought of all of the cases - then the average can be passed as case "Sector_PlusMinus" 
     504// and run through the normal average and writing routines. 
     505// 
     506// 
     507// -- depending on what value PHI has - it's [-90,90] "left" and "right" may not be what 
     508// you expect. so sorting the concatenated values may be necessary (always) 
     509// 
     510// -- need documentation of the definition of PHI, left, and right so that it can make better sense 
     511//              which quadrants of the detector become "negative" depending on the choice of phi. may need a  
     512//              switch after a little thinking. 
     513// 
     514// may want a variation of this where both sides are done, in separate files. but I think that's already 
     515// called a "sector" average. save them. load them. plot them. 
     516// 
     517// 
     518Function Sector_PlusMinus1D(type) 
     519        String type 
     520 
     521//      do the left side (-) 
     522// then hold that data in tmp_ waves 
     523// then do the right (+) 
     524// then concatenate the data 
     525 
     526// the button on the pink panel copies the two strings so they're the same 
     527        SVAR keyListStr = root:myGlobals:Protocols:gAvgInfoStr          //this is the list that has it all 
     528 
     529        String oldStr = "" 
     530        String  CurPath="root:myGlobals:Plot_1D:" 
     531        String destPath = "root:Packages:NIST:"+type+":" 
     532 
     533        oldStr = StringByKey("SIDE",keyListStr,"=",";") 
     534 
     535// do the left first, and call it negative 
     536        keyListStr = ReplaceStringByKey("SIDE",keyListStr,"left","=",";") 
     537 
     538        CircularAverageTo1D(type) 
     539         
     540        WAVE qval = $(destPath + "qval") 
     541        WAVE aveint = $(destPath + "aveint") 
     542        WAVE sigave = $(destPath + "sigave") 
     543        WAVE qbar = $(destPath + "QBar") 
     544        WAVE sigmaq = $(destPath + "SigmaQ") 
     545        WAVE fsubs = $(destPath + "fSubS") 
     546 
     547        // copy the average, set the q's negative 
     548        qval *= -1 
     549        Duplicate/O qval $(destPath+"tmp_q") 
     550        Duplicate/O aveint $(destPath+"tmp_i") 
     551        Duplicate/O sigave $(destPath+"tmp_s") 
     552        Duplicate/O qbar $(destPath+"tmp_qb") 
     553        Duplicate/O sigmaq $(destPath+"tmp_sq") 
     554        Duplicate/O fsubs $(destPath+"tmp_fs") 
     555         
     556         
     557// do the right side 
     558        keyListStr = ReplaceStringByKey("SIDE",keyListStr,"right","=",";") 
     559 
     560        CircularAverageTo1D(type) 
     561         
     562        // concatenate 
     563        WAVE tmp_q = $(destPath + "tmp_q") 
     564        WAVE tmp_i = $(destPath + "tmp_i") 
     565        WAVE tmp_s = $(destPath + "tmp_s") 
     566        WAVE tmp_qb = $(destPath + "tmp_qb") 
     567        WAVE tmp_sq = $(destPath + "tmp_sq") 
     568        WAVE tmp_fs = $(destPath + "tmp_fs") 
     569 
     570        SetDataFolder destPath          //to get the concatenation in the right folder 
     571        Concatenate/NP/O {tmp_q,qval},tmp_cat 
     572        Duplicate/O tmp_cat qval 
     573        Concatenate/NP/O {tmp_i,aveint},tmp_cat 
     574        Duplicate/O tmp_cat aveint 
     575        Concatenate/NP/O {tmp_s,sigave},tmp_cat 
     576        Duplicate/O tmp_cat sigave 
     577        Concatenate/NP/O {tmp_qb,qbar},tmp_cat 
     578        Duplicate/O tmp_cat qbar 
     579        Concatenate/NP/O {tmp_sq,sigmaq},tmp_cat 
     580        Duplicate/O tmp_cat sigmaq 
     581        Concatenate/NP/O {tmp_fs,fsubs},tmp_cat 
     582        Duplicate/O tmp_cat fsubs 
     583 
     584// then sort 
     585        Sort qval, qval,aveint,sigave,qbar,sigmaq,fsubs 
     586 
     587// move these to the Plot_1D folder for plotting 
     588        Duplicate/O qval $(curPath+"xAxisWave") 
     589        Duplicate/O aveint $(curPath+"yAxisWave") 
     590        Duplicate/O sigave $(curPath+"yErrWave") 
     591         
     592        keyListStr = ReplaceStringByKey("SIDE",keyListStr,oldStr,"=",";") 
     593 
     594        DoUpdate/W=Plot_1d 
     595         
     596        // clean up 
     597        KillWaves/Z tmp_q,tmp_i,tmp_s,tmp_qb,tmp_sq,tmp_fs,tmp_cat 
     598         
     599        SetDataFolder root: 
     600         
     601        return(0) 
     602End 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/ILL_DataReadWrite.ipf

    r588 r764  
    296296         
    297297//      print "function used" 
    298          
     298 
     299 
     300         
     301         
     302         
     303        //loadwave /H "fname" 
     304         
     305        //Duplicate/O $"fname", datates 
     306         
     307 
    299308 
    300309                // (1) 
     
    326335/////////DIV file created with NIST reduction so has the VAX format.... painful 
    327336 
     337 
     338         
     339// Detector sensitivity files have the same header structure as RAW SANS data 
     340// as NCNR, just with a different data array (real, rather than integer data) 
     341// 
     342// So for your facility, make this reader specific to the format of whatever 
     343// file you use for a pixel-by-pixel division of the raw detector data 
     344// to correct for non-uniform sensitivities of the detector. This is typically a 
     345// measurement of water, plexiglas, or another uniform scattering sample. 
     346// 
     347// The data must be normalized to a mean value of 1 
     348// 
     349// called from ProtocolAsPanel.ipf 
     350// 
     351// type is "DIV" on input 
    328352Function ReadHeaderAndWork(type,fname) 
    329353        String type,fname 
    330354         
    331355        //type is the desired folder to read the workfile to 
    332         //this data will NOT be automatically displayed gDataDisplayType is unchanged 
    333  
    334 //      SVAR cur_folder=root:myGlobals:gDataDisplayType 
     356        //this data will NOT be automatically displayed 
     357        // gDataDisplayType is unchanged 
     358 
    335359        String cur_folder = type 
    336360        String curPath = "root:Packages:NIST:"+cur_folder 
     
    341365        Variable/G $(curPath + ":gIsLogScale") = 0              //initial state is linear, keep this in DIV folder 
    342366         
    343         Make/O/N=23 $(curPath + ":IntegersRead") 
    344         Make/O/N=52 $(curPath + ":RealsRead") 
     367        Make/O/D/N=23 $(curPath + ":IntegersRead") 
     368        Make/O/D/N=52 $(curPath + ":RealsRead") 
    345369        Make/O/T/N=11 $(curPath + ":TextRead") 
    346370         
     
    349373        WAVE/T textw=$(curPath + ":TextRead") 
    350374         
    351         //***NOTE **** 
    352         // the "current path" gets mysteriously reset to "root:" after the SECOND pass through 
    353         // this read routine, after the open dialog is presented 
    354         // the "--read" waves end up in the correct folder, but the data does not! Why? 
    355         //must re-set data folder before writing data array (done below) 
    356          
    357         SetDataFolder curPath 
    358          
    359         //actually open the file 
    360         Open/R refNum as fname 
    361         //skip first two bytes 
    362         FSetPos refNum, 2 
    363         //read the next 21 bytes as characters (fname) 
    364         FReadLine/N=21 refNum,textstr 
    365         textw[0]= textstr 
    366         //read four i*4 values  /F=3 flag, B=3 flag 
    367         FBinRead/F=3/B=3 refNum, integer 
    368         intw[0] = integer 
    369         // 
    370         FBinRead/F=3/B=3 refNum, integer 
    371         intw[1] = integer 
    372         // 
    373         FBinRead/F=3/B=3 refNum, integer 
    374         intw[2] = integer 
    375         // 
    376         FBinRead/F=3/B=3 refNum, integer 
    377         intw[3] = integer 
    378         // 6 text fields 
    379         FSetPos refNum,55               //will start reading at byte 56 
    380         FReadLine/N=20 refNum,textstr 
    381         textw[1]= textstr 
    382         FReadLine/N=3 refNum,textstr 
    383         textw[2]= textstr 
    384         FReadLine/N=11 refNum,textstr 
    385         textw[3]= textstr 
    386         FReadLine/N=1 refNum,textstr 
    387         textw[4]= textstr 
    388         FReadLine/N=8 refNum,textstr 
    389         textw[5]= textstr 
    390         FReadLine/N=60 refNum,textstr 
    391         textw[6]= textstr 
    392          
    393         //3 integers 
    394         FSetPos refNum,174 
    395         FBinRead/F=3/B=3 refNum, integer 
    396         intw[4] = integer 
    397         FBinRead/F=3/B=3 refNum, integer 
    398         intw[5] = integer 
    399         FBinRead/F=3/B=3 refNum, integer 
    400         intw[6] = integer 
    401          
    402         //2 integers, 3 text fields 
    403         FSetPos refNum,194 
    404         FBinRead/F=3/B=3 refNum, integer 
    405         intw[7] = integer 
    406         FBinRead/F=3/B=3 refNum, integer 
    407         intw[8] = integer 
    408         FReadLine/N=6 refNum,textstr 
    409         textw[7]= textstr 
    410         FReadLine/N=6 refNum,textstr 
    411         textw[8]= textstr 
    412         FReadLine/N=6 refNum,textstr 
    413         textw[9]= textstr 
    414          
    415         //2 integers 
    416         FSetPos refNum,244 
    417         FBinRead/F=3/B=3 refNum, integer 
    418         intw[9] = integer 
    419         FBinRead/F=3/B=3 refNum, integer 
    420         intw[10] = integer 
    421          
    422         //2 integers 
    423         FSetPos refNum,308 
    424         FBinRead/F=3/B=3 refNum, integer 
    425         intw[11] = integer 
    426         FBinRead/F=3/B=3 refNum, integer 
    427         intw[12] = integer 
    428          
    429         //2 integers 
    430         FSetPos refNum,332 
    431         FBinRead/F=3/B=3 refNum, integer 
    432         intw[13] = integer 
    433         FBinRead/F=3/B=3 refNum, integer 
    434         intw[14] = integer 
    435          
    436         //3 integers 
    437         FSetPos refNum,376 
    438         FBinRead/F=3/B=3 refNum, integer 
    439         intw[15] = integer 
    440         FBinRead/F=3/B=3 refNum, integer 
    441         intw[16] = integer 
    442         FBinRead/F=3/B=3 refNum, integer 
    443         intw[17] = integer 
    444          
    445         //1 text field - the file association for transmission are the first 4 bytes 
    446         FSetPos refNum,404 
    447         FReadLine/N=42 refNum,textstr 
    448         textw[10]= textstr 
    449          
    450         //1 integer 
    451         FSetPos refNum,458 
    452         FBinRead/F=3/B=3 refNum, integer 
    453         intw[18] = integer 
    454          
    455         //4 integers 
    456         FSetPos refNum,478 
    457         FBinRead/F=3/B=3 refNum, integer 
    458         intw[19] = integer 
    459         FBinRead/F=3/B=3 refNum, integer 
    460         intw[20] = integer 
    461         FBinRead/F=3/B=3 refNum, integer 
    462         intw[21] = integer 
    463         FBinRead/F=3/B=3 refNum, integer 
    464         intw[22] = integer 
    465          
    466         Close refNum 
    467          
    468         //now get all of the reals 
    469         // 
    470         //Do all the GBLoadWaves at the end 
    471         // 
    472         //FBinRead Cannot handle 32 bit VAX floating point 
    473         //GBLoadWave, however, can properly read it 
    474         String GBLoadStr="GBLoadWave/O/N=tempGBwave/T={2,2}/J=2/W=1/Q" 
    475         String strToExecute 
    476         //append "/S=offset/U=numofreals" to control the read 
    477         // then append fname to give the full file path 
    478         // then execute 
    479          
    480         Variable a=0,b=0 
    481          
    482         SetDataFolder curPath 
    483         // 4 R*4 values 
    484         strToExecute = GBLoadStr + "/S=39/U=4" + "\"" + fname + "\"" 
    485         Execute strToExecute 
    486          
    487         SetDataFolder curPath 
    488         Wave w=$(curPath + ":tempGBWave0") 
    489         b=4     //num of reals read 
    490         realw[a,a+b-1] = w[p-a] 
    491         a+=b 
    492          
    493         // 4 R*4 values 
    494         SetDataFolder curPath 
    495         strToExecute = GBLoadStr + "/S=158/U=4" + "\"" + fname + "\"" 
    496         Execute strToExecute 
    497         b=4      
    498         realw[a,a+b-1] = w[p-a] 
    499         a+=b 
    500  
    501 /////////// 
    502         // 2 R*4 values 
    503         SetDataFolder curPath 
    504         strToExecute = GBLoadStr + "/S=186/U=2" + "\"" + fname + "\"" 
    505         Execute strToExecute 
    506         b=2      
    507         realw[a,a+b-1] = w[p-a] 
    508         a+=b 
    509  
    510         // 6 R*4 values 
    511         SetDataFolder curPath 
    512         strToExecute = GBLoadStr + "/S=220/U=6" + "\"" + fname + "\"" 
    513         Execute strToExecute 
    514         b=6      
    515         realw[a,a+b-1] = w[p-a] 
    516         a+=b 
    517          
    518         // 13 R*4 values 
    519         SetDataFolder curPath 
    520         strToExecute = GBLoadStr + "/S=252/U=13" + "\"" + fname + "\"" 
    521         Execute strToExecute 
    522         b=13 
    523         realw[a,a+b-1] = w[p-a] 
    524         a+=b 
    525          
    526         // 3 R*4 values 
    527         SetDataFolder curPath 
    528         strToExecute = GBLoadStr + "/S=320/U=3" + "\"" + fname + "\"" 
    529         Execute strToExecute 
    530         b=3      
    531         realw[a,a+b-1] = w[p-a] 
    532         a+=b 
    533          
    534         // 7 R*4 values 
    535         SetDataFolder curPath 
    536         strToExecute = GBLoadStr + "/S=348/U=7" + "\"" + fname + "\"" 
    537         Execute strToExecute 
    538         b=7 
    539         realw[a,a+b-1] = w[p-a] 
    540         a+=b 
    541          
    542         // 4 R*4 values 
    543         SetDataFolder curPath 
    544         strToExecute = GBLoadStr + "/S=388/U=4" + "\"" + fname + "\"" 
    545         Execute strToExecute 
    546         b=4      
    547         realw[a,a+b-1] = w[p-a] 
    548         a+=b 
    549          
    550         // 2 R*4 values 
    551         SetDataFolder curPath 
    552         strToExecute = GBLoadStr + "/S=450/U=2" + "\"" + fname + "\"" 
    553         Execute strToExecute 
    554         b=2 
    555         realw[a,a+b-1] = w[p-a] 
    556         a+=b 
    557          
    558         // 2 R*4 values 
    559         SetDataFolder curPath 
    560         strToExecute = GBLoadStr + "/S=470/U=2" + "\"" + fname + "\"" 
    561         Execute strToExecute 
    562         b=2 
    563         realw[a,a+b-1] = w[p-a] 
    564         a+=b 
    565          
    566         // 5 R*4 values 
    567         SetDataFolder curPath 
    568         strToExecute = GBLoadStr + "/S=494/U=5" + "\"" + fname + "\"" 
    569         Execute strToExecute 
    570         b=5      
    571         realw[a,a+b-1] = w[p-a] 
    572          
    573         //if the binary VAX data ws transferred to a MAC, all is OK 
    574         //if the data was trasnferred to an Intel machine (IBM), all the real values must be 
    575         //divided by 4 to get the correct floating point values 
    576         // I can't find any combination of settings in GBLoadWave or FBinRead to read data in correctly 
    577         // on an Intel machine. 
    578         //With the corrected version of GBLoadWave XOP (v. 1.43 or higher) Mac and PC both read 
    579         //VAX reals correctly, and no checking is necessary 12 APR 99 
    580         //if(cmpstr("Macintosh",IgorInfo(2)) == 0) 
    581                 //do nothing 
    582         //else 
    583                 //either Windows or Windows NT 
    584                 //realw /= 4 
    585         //endif 
    586          
    587         //read in the data 
    588          GBLoadStr="GBLoadWave/O/N=tempGBwave/T={2,2}/J=2/W=1/Q" 
    589  
    590         curPath = "root:Packages:NIST:"+cur_folder 
    591         SetDataFolder curPath           //use the full path, so it will always work 
    592          
    593         Make/O/N=16384 $(curPath + ":data") 
     375        // the actual data array, dimensions are set as globals inÊ 
     376        // InitFacilityGlobals() 
     377        NVAR XPix = root:myGlobals:gNPixelsX 
     378        NVAR YPix = root:myGlobals:gNPixelsX 
     379         
     380 
     381        Make/O/D/N=(XPix,YPix) $(curPath + ":data") 
    594382        WAVE data = $(curPath + ":data") 
    595383         
    596         Variable skip,ii,offset 
    597          
    598         //read in a total of 16384 values (ii)  
    599         //as follows : 
    600         // skip first 2 bytes 
    601         // skip 512 byte header 
    602         // skip first 2 bytes of data 
    603         //(read 511 reals, skip 2b, 510 reals, skip 2b) -16 times = 16336 values 
    604         // read the final 48 values in seperately to avoid EOF error 
    605          
    606         ///////////// 
    607         SetDataFolder curPath 
    608         skip = 0 
    609         ii=0 
    610         offset = 514 +2 
    611         a=0 
    612         do 
    613                 SetDataFolder curPath 
    614                  
    615                 strToExecute = GBLoadStr + "/S="+num2str(offset)+"/U=511" + "\"" + fname + "\"" 
    616                 Execute strToExecute 
    617                 //Print strToExecute 
    618                 b=511 
    619                 data[a,a+b-1] = w[p-a] 
    620                 a+=b 
    621                  
    622                 offset += 511*4 +2 
    623                  
    624                 strToExecute = GBLoadStr + "/S="+num2str(offset)+"/U=510" + "\"" + fname + "\"" 
    625                 SetDataFolder curPath 
    626                 Execute strToExecute 
    627                 //Print strToExecute 
    628                 b=510 
    629                 data[a,a+b-1] = w[p-a] 
    630                 a+=b 
    631                  
    632                 offset += 510*4 +2 
    633                  
    634                 ii+=1 
    635                 //Print "inside do, data[2] =",data[2] 
    636                 //Print "inside do, tempGBwave0[0] = ",w[0] 
    637         while(ii<16) 
    638          
    639         // 16336 values have been read in -- 
    640         //read in last 64 values 
    641         strToExecute = GBLoadStr + "/S="+num2str(offset)+"/U=48" + "\"" + fname + "\"" 
    642          
    643         SetDataFolder curPath 
    644         Execute strToExecute 
    645         b=48 
    646         data[a,a+b-1] = w[p-a] 
    647         a+=b 
    648 // 
    649 /// done reading in raw data 
    650 // 
    651         //Print "in workdatareader , data = ", data[1][1] 
    652  
    653         Redimension/n=(128,128) data 
    654          
    655         //clean up - get rid of w = $"tempGBWave0" 
    656         KillWaves w 
    657          
    658         //divide the FP data by 4 if read from a PC (not since GBLoadWave update) 
    659         //if(cmpstr("Macintosh",IgorInfo(2)) == 0) 
    660                 //do nothing 
    661         //else 
    662                 //either Windows or Windows NT 
    663                 //data /= 4 
    664         //endif 
     384        Make/O/D/N=(XPix,YPix) $(curPath + ":linear_data") 
     385        WAVE linear_data = $(curPath + ":linear_data") 
     386         
     387         
     388//      print "function used" 
     389         
     390 
     391                // (1) 
     392        // fill in your reader for the header here so that intw, realw, and textW are filled in 
     393        // ? possibly a duplication of the raw data reader 
     394        Duplicate/O $("root:Packages:NIST:raw:realsread"),$(curPath+ ":realsread") 
     395        Duplicate/O $("root:Packages:NIST:raw:integersread"),$(curPath+ ":integersread") 
     396        Duplicate/T $("root:Packages:NIST:raw:Textread"),$(curPath+ ":Textread") 
     397         
     398 
     399        //(2) 
     400        // then fill in a reader for the data array that will DIVIDE your data 
     401        // to get the corrected values. 
     402        // fill the data array with the detector values 
     403 
     404        //here you load in your file, you're already in the DIV folder 
     405//      LoadWave/H/O "Macintosh HD:Users:srkline:Desktop:linear_data.ibw" 
     406        LoadWave/H/O fname              //since fname is the full path 
     407         
     408        ConvertFolderToLogScale(type) 
     409         
     410        String loadedStr = StringFromList(0,S_waveNames,";")            //then name of the wave loaded 
     411 
     412        //then copy the loaded wave to data and to linear data, in the DIV folder 
     413        duplicate/O $("loadedStr"),$(curPath+ ":data") 
     414        duplicate/O $("loadedStr"),$(curPath+ ":linear_data") 
     415         
    665416         
    666417        //keep a string with the filename in the DIV folder 
     
    21321883        String type 
    21331884         
     1885        // should have the linear display..... 
     1886ConvertFolderToLogScale(type) 
     1887         
     1888        Save/C root:packages:nist:STO:linear_data as "plex.DIV" 
     1889         
    21341890        // Your file writing function here. Don't try to duplicate the VAX binary format... 
    21351891         
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/ILL_Utils.ipf

    r750 r764  
    195195// this run number should be a unique identifier for the file 
    196196// 
     197 
     198// 
    197199Function GetRunNumFromFile(item) 
    198200        String item 
     
    202204        String runStr="" 
    203205         
    204         runstr = item 
     206        runStr = ParseFilePath(0, item, ":", 1, 0) 
     207//      runstr = item 
    205208        num = str2num(runstr) 
    206209         
     
    229232        retStr=invalid 
    230233         
    231         retstr = item 
     234        retstr = ParseFilePath(0, item, ":", 1, 0) 
    232235        //your code here 
    233236         
     
    334337Function/S RunDigitString(num) 
    335338        Variable num 
    336          
     339 
    337340//      String fullName="",partialName="",item="" 
    338341//      String numStr="" 
     
    361364//      endswitch 
    362365//       
    363          
     366 
    364367        String numStr="" 
    365368 
     
    10491052                ff= 0.9993575- 0.0002320264*abs(theta) + 9.751713e-5*abs(theta^2) + 1.018564e-5*abs(theta^3) -3.977445e-7*abs(theta^4) +2.960205e-9*abs(theta^5) 
    10501053        endif 
     1054        ff= 0.9992674-0.0001808763*abs(theta) +8.134414e-05*abs(theta^2) +1.151734e-05*abs(theta^3) - 4.401022e-07*abs(theta^4)+3.71246e-09*abs(theta^5) 
    10511055 
    10521056        return(ff) 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/MainPanel.ipf

    r648 r764  
    1919         
    2020        PickPath() 
     21        // read in DEFAULT.MASK, if it exists, otherwise, do nothing 
     22        // 
     23        PathInfo catPathName 
     24        if(V_flag==1) 
     25                String str = S_Path + "DEFAULT.MASK" 
     26                Variable refnum 
     27                Open/R/Z=1 refnum as str 
     28                if(strlen(S_filename) != 0) 
     29                        Close refnum            //file can be found OK 
     30                        ReadMCID_MASK(str) 
     31                else 
     32                        // file not found, close just in case 
     33                        Close/A 
     34                endif 
     35        endif 
    2136End 
    2237 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/Marquee.ipf

    r757 r764  
    451451                Abort "There is no Marquee" 
    452452        endif 
     453        // if cursor A on graph 
     454        // Do histogram pair 
     455        Variable aExists= strlen(CsrInfo(A)) > 0        // A is a name, not a string 
     456        if(aExists) 
     457                DoHistogramPair(hcsr(A),vcsr(A)) 
     458                return(0) 
     459        endif 
    453460        // 
    454461        Variable count,x1,x2,y1,y2,xwidth,ywidth,vsX=1,xx,yy 
     
    550557        endif 
    551558End 
     559 
     560// if the "A" cursor is on the graph, do +-5 pixels in each direction 
     561// otherwise, you won't get here 
     562Function DoHistogramPair(xin,yin) 
     563        Variable xin,yin 
     564         
     565        Variable count,x1,x2,y1,y2,xwidth,ywidth,pt1,pt2,xx,yy 
     566        SVAR cur_folder=root:myGlobals:gDataDisplayType 
     567        WAVE data=$("root:Packages:NIST:"+cur_folder+":data")           //don't care if it's log or linear scale 
     568         
     569 
     570        pt1 = 1         // extent along the "long" direction of the swath 
     571        pt2 = 128 
     572                 
     573        Make/O/D/N=(pt2-pt1) PositionX,AvgCountsX 
     574        Make/O/D/N=(pt2-pt1) PositionY,AvgCountsY 
     575        AvgCountsX=0 
     576        AvgCountsY=0 
     577         
     578        //set position wave 
     579        positionX=p+pt1 
     580        positionY=p+pt1 
     581        //convert the position to Detector coordinates 
     582        positionX += 1 
     583        positionY += 1 
     584         
     585        //do the vertical, then the horizontal 
     586        xwidth = 5              //+ - 
     587        ywidth = 5 
     588        x1 = xin - xwidth 
     589        x2 = xin + xwidth 
     590        y1 = pt1 
     591        y2 = pt2 
     592         
     593        KeepSelectionInBounds(x1,x2,y1,y2) 
     594        Print "x1,x2,y1,y2 (det) =",x1+1,x2+1,y1+1,y2+1 
     595         
     596        //Compute the histogram (manually) 
     597        for(yy=y1;yy<=y2;yy+=1) 
     598                for(xx=x1;xx<=x2;xx+=1) 
     599                        AvgCountsY[yy-y1] += data[xx][yy] 
     600                endfor 
     601        endfor 
     602        AvgCountsY /= (xwidth+1) 
     603 
     604        // now do the Y 
     605        y1 = yin - ywidth 
     606        y2 = yin + ywidth 
     607        x1 = pt1 
     608        x2 = pt2 
     609                 
     610        KeepSelectionInBounds(x1,x2,y1,y2) 
     611        Print "x1,x2,y1,y2 (det) =",x1+1,x2+1,y2+1,y2+1  
     612        for(xx=x1;xx<=x2;xx+=1)         //outer loop is the "x-axis" 
     613                for(yy=y1;yy<=y2;yy+=1) 
     614                        AvgCountsX[xx-x1] += data[xx][yy] 
     615                endfor 
     616        endfor 
     617        AvgCountsX /= (ywidth+1) 
     618         
     619        GetMarquee/K            //to keep from drawing the marquee on the new histo graph 
     620        //draw the graph, or just bring to the front with the new data 
     621        DoWindow/F HistoPair 
     622        if(V_Flag != 1) 
     623                Draw_HistoPair() 
     624        endif 
     625         
     626        return(0) 
     627end 
     628 
     629 
     630Function Draw_HistoPair() 
     631        PauseUpdate; Silent 1           // building window... 
     632        Display /W=(253,683,723,950)/K=1 AvgCountsX vs PositionX as "Histogram Pair" 
     633        AppendToGraph/L=leftY/B=bottomY AvgCountsY vs PositionY 
     634        DoWindow/C HistoPair 
     635        ModifyGraph rgb(AvgCountsX)=(21845,21845,21845) 
     636        ModifyGraph hbFill(AvgCountsX)=2 
     637        ModifyGraph useNegPat(AvgCountsX)=1 
     638        ModifyGraph usePlusRGB(AvgCountsX)=1 
     639        ModifyGraph useNegRGB(AvgCountsX)=1 
     640        ModifyGraph hBarNegFill(AvgCountsX)=2 
     641        ModifyGraph negRGB(AvgCountsX)=(0,0,65535) 
     642        ModifyGraph grid(left)=1,grid(bottom)=1,grid(leftY)=1 
     643        ModifyGraph mirror(left)=2,mirror(bottom)=2,mirror(leftY)=2 
     644        ModifyGraph standoff(left)=0,standoff(bottom)=0,standoff(leftY)=0 
     645        ModifyGraph lblPos(left)=62,lblPos(bottom)=39 
     646        ModifyGraph freePos(leftY)=0 
     647        ModifyGraph freePos(bottomY)={0,leftY} 
     648        ModifyGraph axisEnab(left)={0,0.4} 
     649        ModifyGraph axisEnab(leftY)={0.6,1} 
     650        Label left "Counts" 
     651        Label bottom "Pixel (detector coordinates)" 
     652        SetAxis/A/N=2 left 
     653        TextBox/C/N=text0/X=5.0/Y=5.0 "TOP" 
     654        TextBox/C/N=text0_1/X=5.0/Y=67.0 "RIGHT" 
     655        TextBox/C/N=text0_2/X=84.0/Y=67.0 "LEFT" 
     656        TextBox/C/N=text0_3/X=84.0/Y=5.0 "BOTTOM" 
     657EndMacro 
     658 
     659 
     660// not used, just for testing 
     661Function CursorForHistogram() 
     662 
     663        Wave w=root:Packages:NIST:RAW:RealsRead 
     664         
     665        Cursor/W=SANS_Data/F/I A data w[16],w[17] 
     666        Cursor/M/S=2/H=1/L=0/C=(3,52428,1) A 
     667         
     668End 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/MultipleReduce.ipf

    r699 r764  
    684684        Wave isTrans = $"root:myGlobals:MRED:IsTrans" 
    685685         
    686         Variable num=numpnts(sdd),ii,tol = 0.001 
     686        Variable num=numpnts(sdd),ii,tol = 0.1 
    687687        ii=num-1 
    688688        do 
    689                 if(abs(sdd[ii] - tSDD) > tol)           //if numerically more than 0.001 m different, they're not the same 
     689//              if(abs(sdd[ii] - tSDD) > tol)           //if numerically more than 0.001 m different, they're not the same 
     690//                      DeletePoints ii, 1, filenames,suffix,labels,sdd,runnum,isTrans 
     691//              endif 
     692                if(trunc(abs(sdd[ii] - tSDD)) > tol)            //just get the integer portion of the difference - very coarse comparison 
    690693                        DeletePoints ii, 1, filenames,suffix,labels,sdd,runnum,isTrans 
    691694                endif 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/ProtocolAsPanel.ipf

    r750 r764  
    3636//                      DRAWING routines only use a subset of the total list, since saving, naming, etc. don't apply 
    3737//              (10) possible keywords, some numerical, some string values 
    38 //              AVTYPE=string           string from set {Circular,Annular,Rectangular,Sector,2D_ASCII,QxQy_ASCII,PNG_Graphic} 
     38//              AVTYPE=string           string from set {Circular,Annular,Rectangular,Sector,2D_ASCII,QxQy_ASCII,PNG_Graphic;Sector_PlusMinus;} 
    3939//              PHI=value                       azimuthal angle (-90,90) 
    4040//              DPHI=value                      +/- angular range around phi for average 
     
    969969        String av_typ,autoSave,AutoName,autoPlot,side 
    970970        Variable phi=0,dphi=10,width=10,Qctr = 0.01,qDelta=10 
    971         Prompt av_typ, "Type of Average",popup,"Circular;Sector;Rectangular;Annular;2D_ASCII;QxQy_ASCII;PNG_Graphic" 
     971        Prompt av_typ, "Type of Average",popup,"Circular;Sector;Rectangular;Annular;2D_ASCII;QxQy_ASCII;PNG_Graphic;Sector_PlusMinus;" 
    972972// comment out above line in DEMO_MODIFIED version, and uncomment the line below (to disable PNG save) 
    973973//      Prompt av_typ, "Type of Average",popup,"Circular;Sector;Rectangular;Annular;2D_ASCII;QxQy_ASCII" 
     
    992992        root:myGlobals:Protocols:gAvgInfoStr += "PLOT=" + autoPlot + ";" 
    993993         
    994         if(cmpstr(av_typ,"Sector")==0) 
     994        if(cmpstr(av_typ,"Sector")==0 || cmpstr(av_typ,"Sector_PlusMinus")==0) 
    995995                root:myGlobals:Protocols:gAvgInfoStr += "SIDE=" + side + ";" 
    996996                root:myGlobals:Protocols:gAvgInfoStr += "PHI=" + num2str(phi) + ";" 
     
    18591859                case "Sector": 
    18601860                        CircularAverageTo1D(activeType) 
     1861                        break 
     1862                case "Sector_PlusMinus": 
     1863                        Sector_PlusMinus1D(activeType) 
    18611864                        break 
    18621865                default:         
     
    22542257         
    22552258        PathInfo/S catPathName 
    2256         fullPath = DoSaveFileDialog("Export Protocol as") 
     2259        fullPath = DoSaveFileDialog("Export Protocol as",fname=Protocol,suffix="") 
    22572260        If(cmpstr(fullPath,"")==0) 
    22582261                //user cancel, don't write out a file 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/SASCALC.ipf

    r757 r764  
    417417        CheckBox checkSim,value=0 
    418418         
     419        CheckBox check0_1,pos={80,155},size={90,14},title="Offset Traces?",variable= root:Packages:NIST:SAS:gDoTraceOffset 
     420 
    419421        // help, done buttons 
    420422        Button SC_helpButton,pos={340,166},size={25,20},proc=showSASCALCHelp,title="?" 
Note: See TracChangeset for help on using the changeset viewer.