Ignore:
Timestamp:
Feb 13, 2013 9:58:28 AM (10 years ago)
Author:
srkline
Message:

modified event loader so that it compiles correctly if the XOP is not installed

changed control polling in NSORT to explicitly look for the NSORT panel

added a testing procedure to NSORT to use only names to combine. Somewhat more "manual" in implementation than the combine panel, but very useful for combining the results from a simulation. Uses the NSORT panel in the same way ay the Combine Panel.

Changes to saving the 1D sim data to get proper header information into the file, including a proper label.

Added a macros menu for the MC Scripting beta operations. Can use an "x" to turn them off/on since they are really not for general use (yet).

Updated the simulation examples, including dry run for 2D to estimate overall run time, and 1D simulation to return a table of count rates.

Added a function stub (totally non-functional) for Write_ABSHeader_toNotebook() that in the future could be used to mine the 1D data files - to help group them, combine them, process them, and at the very least, help to identify what is in them and what was done to them.

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

Legend:

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

    r886 r898  
    605605End 
    606606 
     607//writes out the CATalog information to the notebook named CatWin (which must exist) 
     608//fname is the full path for opening (and reading) information from the file 
     609//which alreay was found to exist. sname is the file;vers to be written out, 
     610//avoiding the need to re-extract it from fname. 
     611// 
     612// this is just for 1D (not Raw) data files 
     613Function Write_ABSHeader_toNotebook(fname,sname) 
     614        String fname,sname 
     615         
     616        String textstr,temp,lbl,date_time 
     617        Variable ctime,lambda,sdd,detcnt,cntrate,refNum,trans,thick 
     618         
     619        //read the file creation date 
     620        date_time = getFileCreationDate(fname) 
     621 
     622        // read the sample.label text field 
     623        lbl = getSampleLabel(fname) 
     624         
     625        //read the counting time (integer) 
     626        ctime = getCountTime(fname) 
     627                 
     628        //read the reals 
     629         
     630        //detector count + countrate 
     631        detcnt = getDetCount(fname) 
     632        cntrate = detcnt/ctime 
     633         
     634        //wavelength 
     635        lambda = getWavelength(fname) 
     636         
     637        //SDD 
     638        sdd = getSDD(fname) 
     639         
     640        //Transmission 
     641        trans = getSampleTrans(fname) 
     642         
     643        //Thickness 
     644        thick = getSampleThickness(fname) 
     645                 
     646        temp = "FILE:  " 
     647        Notebook CatWin,textRGB=(0,0,0),text=temp 
     648        Notebook CatWin,fstyle=1,text=sname 
     649        temp = "\t\t"+date_time+"\r" 
     650        Notebook CatWin,fstyle=0,text=temp 
     651        temp = "LABEL: "+lbl+"\r" 
     652        Notebook CatWin,text=temp 
     653        temp = "COUNTING TIME: "+num2str(ctime)+" secs \t\tDETECTOR COUNT: "+num2str(detcnt)+"\r" 
     654        Notebook CatWin,text=temp 
     655        temp = "WAVELENGTH: "+num2str(lambda)+" A \tSDD: "+num2str(sdd)+" m \t" 
     656        temp += "DET. CNT. RATE: "+num2str(cntrate)+"  cts/sec\r" 
     657        Notebook CatWin,text=temp 
     658        temp = "TRANS: "  
     659        Notebook CatWin,text=temp 
     660        temp =  num2str(trans) 
     661        Notebook CatWin,textRGB=(50000,0,0),fStyle = 1,text=temp 
     662        temp =  "\t\tTHICKNESS: " 
     663        Notebook CatWin,textRGB=(0,0,0),fStyle = 0,text=temp 
     664        temp =  num2str(thick) 
     665        Notebook CatWin,textRGB=(50000,0,0),fStyle = 1,text=temp 
     666        temp = " cm\r\r" 
     667        Notebook CatWin,textRGB=(0,0,0),fStyle = 0,text=temp 
     668End 
     669 
    607670 
    608671//**************** 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/EventModeProcessing.ipf

    r897 r898  
    14681468// -- it's about 35x faster than the Igor code, so I guess that's OK. 
    14691469// 
    1470 // 
     1470// conditional compile the whole inner workings in case XOP is not present 
    14711471Function LoadEvents_XOP() 
     1472#if (exists("EventLoadWave")==4) 
    14721473         
    14731474//      NVAR time_msw = root:Packages:NIST:gEvent_time_msw 
     
    15521553//      endif 
    15531554 
    1554 #if (exists("EventLoadWave")==4) 
    15551555        if(removeBadEvents) 
    15561556                EventLoadWave/R/N=EventWave filepathstr 
     
    15581558                EventLoadWave/N=EventWave  filepathstr 
    15591559        endif 
    1560 #endif 
     1560 
    15611561 
    15621562        Print "XOP files loaded = ",S_waveNames 
     
    16281628 
    16291629        SetDataFolder root: 
    1630          
     1630 
     1631#endif   
    16311632        return(0) 
    16321633         
     
    16781679// only show the first 1500 data points 
    16791680// 
    1680 Proc ShowRescaledTimeGraph() : Graph 
     1681Proc ShowRescaledTimeGraph() 
    16811682 
    16821683        DoWindow/F RescaledTimeGraph 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/MC_SimulationScripting.ipf

    r890 r898  
    4747// 
    4848//              Sim_SetDeadTimeTiny() 
    49  
     49// 
     50// When you have a lot of 1D waves to combine, and they are not numbered like in a real reduction 
     51// experiment, see: 
     52// 
     53//  MakeCombineTable_byName() 
     54//  DoCombineFiles_byName(lowQfile,medQfile,hiQfile,saveName) (in NSORT.ipf) 
     55// 
     56// this works with 1, 2, or 3 data files 
     57// 
     58 
     59 
     60// In general, when setting up a simulation, it's easier to set up sample conditions for a particular 
     61// sample, and loop through the configurations. If you want your 2D data to "look" like a typical  
     62// experiment, then you'll need to simulate each different sample at one configuration, then "move" 
     63// to a different configuration and loop through the samples again. Somewhat more cumbersome, all to  
     64// get the file catalog to be "grouped" like a real SANS experiment. 
    5065 
    5166 
     
    90105// -- scattering from an empty cell is NOT provided in 2D 
    91106 
    92  
     107Menu "Macros" 
     108        Submenu "Simulation Scripting - Beta" 
     109                "Save Configuration",Sim_saveConfProc() 
     110                "Move to Configuration",Sim_moveConfProc() 
     111                "List Configurations",ListSASCALCConfigs() 
     112                "Setup Sim Example",Setup_Sim_Example() 
     113                "1D Count Rates",DryRunProc_1D() 
     114                "2D Dry Run",DryRunProc_2D() 
     115                "Optimal Count Times",OptimalCountProc() 
     116                "Make Table to Combine By Name",MakeCombineTable_byName() 
     117                "Combine by Name",DoCombineFiles_byName(lowQfile,medQfile,hiQfile,saveName) 
     118                "Turn Off Dead Time Correction",Sim_SetDeadTimeTiny() 
     119        End 
     120End 
    93121 
    94122// run this before the examples to make sure that the proper named configurations exist. 
     
    109137Function Example_1DSim() 
    110138 
    111         String confList,ctTimeList,saveNameList,funcStr 
     139        String confList,ctTimeList,saveNameList,funcStr,titleStr 
    112140         
    113141 
     
    133161//(3) set the configuration list, times, and saved names 
    134162// -- the mumber of listed configurations must match the number of discrete count times and save names 
     163// titleStr is the label and is the same for each run of the same sample 
    135164        confList = "Config_1m;Config_4m;Config_13m;" 
    136165        ctTimeList = "100;300;900;" 
    137166        saveNameList = "sim_1m.abs;sim_4m.abs;sim_13m.abs;" 
    138  
     167        titleStr = "MySample 1" 
    139168 
    140169        // then this runs the samples as listed 
    141         Sim_RunSample_1D(confList,ctTimeList,saveNameList) 
     170        Sim_RunSample_1D(confList,ctTimeList,titleStr,saveNameList) 
    142171 
    143172        // no transmissions or empty beam measurements to make for 1D simulation 
     
    182211         
    183212//(4) starting run index for the saved raw data files. this will automatically increment 
     213//    as the sample is "Run" 
    184214        runIndex = 400 
    185215         
     
    216246 
    217247// pass in a semicolon delimited list of configurations + corresponding count times + saved names 
    218 Function Sim_RunSample_1D(confList,ctTimeList,saveNameList) 
    219         String confList,ctTimeList,saveNameList 
    220          
    221         Variable ii,num,ct 
     248Function Sim_RunSample_1D(confList,ctTimeList,titleStr,saveNameList) 
     249        String confList,ctTimeList,titleStr,saveNameList 
     250         
     251        Variable ii,num,ct,cr,numPt 
    222252        String twStr,fname,type 
    223          
     253        NVAR g_estimateOnly = root:Packages:NIST:SAS:g_estimateOnly             // == 1 for just count rate, == 0 (default) to do the simulation and save 
     254        WAVE/Z crWave = root:CR_1D 
     255        WAVE/Z/T fileWave = root:Files_1D 
     256 
    224257        type = "SAS"            // since this is a simulation 
    225258        num=ItemsInList(confList) 
     
    233266                Sim_MoveToConfiguration(tw) 
    234267                Sim_SetCountTime(ct) 
    235                 Sim_Do1DSimulation() 
    236                 Sim_Save1D_wName(type,fname) 
     268                cr = Sim_Do1DSimulation() 
     269                 
     270                // either save it out, or return a table of the count rates 
     271                if(g_estimateOnly) 
     272                        numPt = numpnts(crWave) 
     273                        InsertPoints numPt, 1, crWave,fileWave 
     274                        crWave[numPt] = cr 
     275                        fileWave[numPt] = fname 
     276                else 
     277                        Sim_Save1D_wName(type,titleStr,fname)           //this function will increment the runIndex 
     278                endif 
     279         
    237280        endfor 
    238281 
     
    357400End 
    358401 
     402Proc DryRunProc_2D(funcStr) 
     403        String funcStr 
     404        Sim_2DDryRun(funcStr) 
     405end 
     406 
    359407// pass the function string, no parameters 
    360 Function Sim_DryRun(funcStr) 
     408Function Sim_2DDryRun(funcStr) 
    361409        String funcStr 
    362410         
     
    375423end 
    376424 
     425Proc DryRunProc_1D(funcStr) 
     426        String funcStr 
     427        Sim_1DDryRun(funcStr) 
     428end 
     429 
     430// pass the function string, no parameters 
     431// makes a (new) table of the files and CR 
     432Function Sim_1DDryRun(funcStr) 
     433        String funcStr 
     434         
     435        FUNCREF Sim_Expt_Proto func=$funcStr 
     436         
     437        NVAR g_estimateOnly = root:Packages:NIST:SAS:g_estimateOnly 
     438        g_estimateOnly = 1 
     439         
     440        Variable totalTime 
     441         
     442        Make/O/D/N=0 root:CR_1D 
     443        Make/O/T/N=0 root:Files_1D 
     444         
     445        totalTime = func() 
     446        g_estimateOnly = 0 
     447         
     448        Edit Files_1D,CR_1D 
     449         
     450//      Printf "Total Estimated Time = %g s or %g h\r",totalTime,totalTime/3600 
     451        return(0) 
     452end 
     453 
     454 
     455 
     456 
     457 
     458Proc OptimalCountProc(samCountRate,emptyCountRate) 
     459        Variable samCountRate,emptyCountRate 
     460        OptimalCount(samCountRate,emptyCountRate) 
     461End 
    377462 
    378463Function OptimalCount(samCR,empCR) 
     
    600685 
    601686        ReCalculateInten(1) 
    602         return(0) 
     687        NVAR estCR = root:Packages:NIST:SAS:g_1DEstDetCR 
     688        return(estCR) 
    603689End 
    604690 
     
    758844// (no sense to use catPathName, since this is simulation, not real data 
    759845// 
    760 Function Sim_Save1D_wName(type,fname) 
    761         String type,fname 
     846Function Sim_Save1D_wName(type,titleStr,fname) 
     847        String type,titleStr,fname 
    762848         
    763849        String fullPath 
    764          
    765         // fill a fake protocol to pass information to the data writer about the simulation      
    766         FillFake_SIMProtocol(type) 
    767          
     850        NVAR autoSaveIndex = root:Packages:NIST:SAS:gAutoSaveIndex 
     851 
    768852        //now save the data      
    769853        PathInfo home 
    770854        fullPath = S_path + fname 
    771855         
    772         WriteWaves_W_Protocol(type,fullPath,0)          //0 means no dialog 
    773          
    774         return(0) 
    775 End 
    776  
     856        Save_1DSimData("",runIndex=autoSaveIndex,simLabel=titleStr,saveName=fullPath) 
     857         
     858        autoSaveIndex += 1 
     859        return(0) 
     860End 
     861 
     862Proc Sim_saveConfProc(waveStr) 
     863        String waveStr 
     864         
     865        Sim_SaveConfiguration(waveStr) 
     866End 
    777867// 
    778868// just make a wave and fill it 
     
    860950End 
    861951 
     952Proc Sim_moveConfProc(waveStr) 
     953        String waveStr 
     954        Prompt waveStr,"Select Configuration",popup,ListSASCALCConfigs() 
     955         
     956        Sim_MoveToConfiguration($("root:Packages:NIST:SAS:"+waveStr)) 
     957End 
    862958// restore the configuration given a wave of information 
    863959// 
     
    9051001///////////// a panel to (maybe) write to speed the setup of the runs 
    9061002// 
    907 Proc ListSASCALCConfigs() 
    908          
     1003Function/S ListSASCALCConfigs() 
     1004        String str 
    9091005        SetDataFolder root:Packages:NIST:SAS 
    910         Print WaveList("Conf*",";","") 
     1006        str = WaveList("Conf*",";","") 
    9111007        SetDataFolder root: 
     1008        print str 
     1009        return(str) 
    9121010End 
    9131011 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/MultScatter_MonteCarlo_2D.ipf

    r890 r898  
    18131813// standard writing routines 
    18141814// 
    1815 Function Save_1DSimData(ctrlName) : ButtonControl 
     1815Function Save_1DSimData(ctrlName,[runIndex,simLabel,saveName]) : ButtonControl 
    18161816        String ctrlName 
    1817  
    1818         String type="SAS",fullpath="" 
     1817        Variable runIndex 
     1818        String simLabel 
     1819        String saveName 
     1820         
     1821        String type="SAS",fname="" 
    18191822        Variable dialog=1               //=1 will present dialog for name 
    1820          
    1821         // fill a fake protocol to pass information to the data writer about the simulation 
     1823        Variable err 
     1824         
     1825 
     1826        // if default parameters were passed in, use them 
     1827        // if not, set them to "bad" values so that the user will be prompted later      
     1828        NVAR autoSaveIndex = root:Packages:NIST:SAS:gAutoSaveIndex 
     1829        SVAR autoSaveLabel = root:Packages:NIST:SAS:gAutoSaveLabel 
     1830         
     1831        // Determine if the optional parameters were supplied 
     1832        if( ParamIsDefault(runIndex))           //==1 if parameter was NOT specified 
     1833                print "runIndex not specified" 
     1834                autoSaveIndex=0                                 // 0 == bad value, test for this later 
     1835        else 
     1836                autoSaveIndex=runIndex 
     1837        endif 
     1838         
     1839        if( ParamIsDefault(simLabel))           //==1 if parameter was NOT specified 
     1840                print "simLabel not specified" 
     1841                autoSaveLabel=""                                        // "" == bad value, test for this later 
     1842        else 
     1843                autoSaveLabel=simLabel 
     1844        endif 
     1845 
     1846        if( ParamIsDefault(saveName))           //==1 if parameter was NOT specified 
     1847                print "saveName not specified" 
     1848                fname=""                                        // "" == bad value, test for this later and ask for dialog 
     1849        else 
     1850                fname=saveName 
     1851        endif 
     1852         
     1853// fill a fake protocol to pass information to the data writer about the simulation 
    18221854        FillFake_SIMProtocol(type) 
    18231855 
     1856 
     1857// fill the last bits of the header, so that the writer can find them 
     1858        err = Sim_Fill1DHeader(type) 
     1859         
    18241860        NVAR useXMLOutput = root:Packages:NIST:gXML_Write 
    18251861         
    18261862        if (useXMLOutput == 1) 
    1827                 WriteXMLWaves_W_Protocol(type,"",1) 
     1863                WriteXMLWaves_W_Protocol(type,fname,0) 
    18281864        else 
    1829                 WriteWaves_W_Protocol(type,"",1)                //"" is an empty path, 1 will force a dialog 
     1865                WriteWaves_W_Protocol(type,fname,0)             //"" is an empty path, 1 will force a dialog 
    18301866        endif 
    18311867         
    18321868        return(0) 
    18331869         
     1870End 
     1871 
     1872 
     1873// fills the bits that would be part of the VAX header, these are read from during the  
     1874// save of the 1D data file 
     1875Function Sim_Fill1DHeader(folder) 
     1876        String folder 
     1877 
     1878        if(cmpstr(folder,"SAS")!=0)             //if not the SAS folder passed in, get out now, and return 1 
     1879                return(1) 
     1880        endif 
     1881         
     1882        Wave rw=root:Packages:NIST:SAS:realsRead 
     1883        Wave iw=root:Packages:NIST:SAS:integersRead 
     1884        Wave/T tw=root:Packages:NIST:SAS:textRead 
     1885        Wave res=root:Packages:NIST:SAS:results 
     1886         
     1887// integers needed: 
     1888        //[2] count time 
     1889        NVAR ctTime = root:Packages:NIST:SAS:gCntTime 
     1890        iw[2] = ctTime 
     1891         
     1892//reals are partially set in SASCALC initializtion 
     1893        //remaining values are updated automatically as SASCALC is modified 
     1894        // -- but still need: 
     1895        //      [0] monitor count 
     1896        //      [2] detector count (w/o beamstop) 
     1897        //      [4] transmission 
     1898        //      [5] thickness (in cm) 
     1899        NVAR imon = root:Packages:NIST:SAS:gImon 
     1900//      NVAR trans1D = root:Packages:NIST:SAS:g_1DEstTrans              // this is the estimated trans from the simulation (don't use) 
     1901        NVAR trans1D = root:Packages:NIST:SAS:gSamTrans                 //this is the input value used 
     1902        NVAR totCts = root:Packages:NIST:SAS:g_1DTotCts 
     1903        NVAR thick = root:Packages:NIST:SAS:gThick 
     1904        rw[0] = imon 
     1905        rw[2] = totCts 
     1906        rw[4] = trans1D 
     1907        rw[5] = thick 
     1908         
     1909// text values needed: 
     1910// be sure they are padded to the correct length 
     1911        // [0] filename (do I fake a VAX name? probably yes...) 
     1912        // [1] date/time in VAX format 
     1913        // [2] type (use SIM) 
     1914        // [3] def dir (use [NG7SANS99]) 
     1915        // [4] mode? C 
     1916        // [5] reserve (another date), prob not needed 
     1917        // [6] sample label 
     1918        // [9] det type "ORNL  " (6 chars) 
     1919 
     1920        SVAR gInstStr = root:Packages:NIST:SAS:gInstStr 
     1921                 
     1922        tw[1] = Secs2Date(DateTime,-2)+"  "+ Secs2Time(DateTime,3)              //20 chars, not quite VAX format 
     1923        tw[2] = "SIM" 
     1924        tw[3] = "["+gInstStr+"SANS99]" 
     1925        tw[4] = "C" 
     1926        tw[5] = "01JAN09 " 
     1927        tw[9] = "ORNL  " 
     1928         
     1929         
     1930        //get the run index and the sample label from the optional parameters, or from a dialog 
     1931        NVAR index = root:Packages:NIST:SAS:gSaveIndex 
     1932        SVAR prefix = root:Packages:NIST:SAS:gSavePrefix 
     1933// did the user pass in values? 
     1934        NVAR autoSaveIndex = root:Packages:NIST:SAS:gAutoSaveIndex 
     1935        SVAR autoSaveLabel = root:Packages:NIST:SAS:gAutoSaveLabel 
     1936         
     1937        String labelStr=""       
     1938        Variable runNum 
     1939        if( (autoSaveIndex != 0) && (strlen(autoSaveLabel) > 0) ) 
     1940                // all is OK, proceed with the save 
     1941                labelStr = autoSaveLabel 
     1942                runNum = autoSaveIndex          //user must take care of incrementing this! 
     1943        else 
     1944                //one or the other, or both are missing, so ask 
     1945                runNum = index 
     1946                Prompt labelStr, "Enter sample label "          // Set prompt for x param 
     1947                Prompt runNum,"Run Number (automatically increments)" 
     1948                DoPrompt "Enter sample label", labelStr,runNum 
     1949                if (V_Flag) 
     1950                        //Print "no sample label entered - no file written" 
     1951                        //index -=1 
     1952                        return -1                                                               // User canceled 
     1953                endif 
     1954                if(runNum != index) 
     1955                        index = runNum 
     1956                endif 
     1957                index += 1 
     1958        endif 
     1959         
     1960 
     1961 
     1962        //make a three character string of the run number 
     1963        String numStr="" 
     1964        if(runNum<10) 
     1965                numStr = "00"+num2str(runNum) 
     1966        else 
     1967                if(runNum<100) 
     1968                        numStr = "0"+num2str(runNum) 
     1969                else 
     1970                        numStr = num2str(runNum) 
     1971                Endif 
     1972        Endif 
     1973        //date()[0] is the first letter of the day of the week 
     1974        // OK for most cases, except for an overnight simulation! then the suffix won't sort right... 
     1975//      tw[0] = prefix+numstr+".SA2_SIM_"+(date()[0])+numStr 
     1976 
     1977//fancier, JAN=A, FEB=B, etc... 
     1978        String timeStr= secs2date(datetime,-1) 
     1979        String monthStr=StringFromList(1, timeStr  ,"/") 
     1980 
     1981        tw[0] = prefix+numstr+".SA2_SIM_"+(num2char(str2num(monthStr)+64))+numStr 
     1982         
     1983        labelStr = PadString(labelStr,60,0x20)  //60 fortran-style spaces 
     1984        tw[6] = labelStr[0,59] 
     1985         
     1986        return(0) 
    18341987End 
    18351988 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/NSORT.ipf

    r811 r898  
    396396                //low-q 
    397397                setNum = 1 
    398                 ControlInfo $"popup_1" 
     398                ControlInfo/W=NSORT_Panel popup_1 
    399399        else 
    400400                if(cmpstr(ctrlName,"Plot_2")==0) 
    401401                        //medium-q 
    402402                        setNum = 2 
    403                         ControlInfo $"popup_2" 
     403                        ControlInfo/W=NSORT_Panel popup_2 
    404404                else 
    405405                        //high-q 
    406406                        setNum = 3 
    407                         ControlInfo $"popup_3" 
     407                        ControlInfo/W=NSORT_Panel popup_3 
    408408                Endif 
    409409        Endif 
     
    534534        AppendToGraph/W=NSORT_Graph $"TrimLowQSet_i" vs $"TrimLowQSet_q" 
    535535        ModifyGraph/W=NSORT_Graph mode($"TrimLowQSet_i")=3,marker($"TrimLowQSet_i")=19,msize=2,rgb($"TrimLowQSet_i")=(2,39321,1) 
     536        ModifyGraph tickUnit(left)=1 
    536537        SetDataFolder root: 
    537538End 
     
    672673        //two or more datasets, combine them 
    673674        //have they been manually or auto-normalized? 
    674         ControlInfo AutoCheck 
     675        ControlInfo/W=NSORT_Panel AutoCheck 
    675676        Variable checked = V_Value 
    676677         
     
    925926         
    926927        //load file1 
    927         ControlInfo $"popup_1" 
     928        ControlInfo/W=NSORT_Panel popup_1 
    928929        fileStr = S_Value 
    929930        name1 = fileStr 
     
    939940         
    940941        //load file2 
    941         ControlInfo $"popup_2" 
     942        ControlInfo/W=NSORT_Panel popup_2 
    942943        fileStr = S_Value 
    943944        name2 = fileStr 
     
    953954         
    954955        //load file3 , if necessary 
    955         ControlInfo $"popup_3" 
     956        ControlInfo/W=NSORT_Panel popup_3 
    956957        fileStr = S_Value 
    957958        name3 = fileStr 
     
    19141915        SetDataFolder root: 
    19151916End 
     1917 
     1918 
     1919 
     1920///////////////////////////////// 
     1921 
     1922Proc MakeCombineTable_byName() 
     1923        NewDataFolder/O root:myGlobals:CombineTable                     //in case it doesn't exist yet 
     1924        Make/O/T/N=1 lowQfile,medQfile,hiQfile,saveName 
     1925        Edit/W=(330,148,973,360) lowQfile,medQfile,hiQfile,saveName 
     1926        ModifyTable format(Point)=1,width(lowQfile)=120,width(medQfile)=120,width(hiQfile)=120 
     1927        ModifyTable width(saveName)=120  
     1928End 
     1929 
     1930// Another beta procedure, to allow files to be combined quickly 
     1931// - make 4 waves (text) with the low, med, hi, and wave names 
     1932// (if there is no hiQ, then pass a wave with "" for all entries) 
     1933// - then pass the waves, and the save will work like in the DoCombineFiles 
     1934// 
     1935// - the named files must be there - there is no error checking 
     1936// - the NSORT panel must be open with the proper selections of beg,end and autoscale, etc. 
     1937// 
     1938// - could write a little proc to generate a table to fill in and a button to call this 
     1939// - and then think of quick ways to populate the table with file names (and minimize typos) 
     1940// 
     1941Function DoCombineFiles_byName(lowW,medW,hiW,saveW) 
     1942        Wave/T lowW,medW,hiW,saveW 
     1943                 
     1944        if(WinType("NSORT_Panel") == 0) 
     1945                DoAlert 0, "The SORT Panel must be open to combine the files" 
     1946                return(0) 
     1947        endif 
     1948         
     1949        // pop all of the menus to make sure that they are properly populated 
     1950        LowQPopMenuProc("",1,"") 
     1951        MedQPopMenuProc("",1,"") 
     1952        HighQPopMenuProc("",1,"") 
     1953         
     1954        Variable num=numpnts(lowW),ii 
     1955        String lowFile,medFile,hiFile 
     1956         
     1957        Pathinfo catPathName 
     1958        String path=S_Path 
     1959         
     1960         
     1961// this variable must exist and be set to 1 to be able to automatically name files 
     1962// and use the global saveNameStr that is passed in 
     1963// -- turn this off when done    
     1964        Variable/G root:myGlobals:CombineTable:useTable=1                
     1965 
     1966        ii=0 
     1967        do 
     1968                lowFile = lowW[ii] 
     1969                medFile = medW[ii] 
     1970                hiFile = hiW[ii] 
     1971                 
     1972                //Set3NSORTFiles(lowFile,medFile,hiFile,prefixStr)              //set the files and pop the NSORT popups 
     1973                //lowQ menu 
     1974                PopupMenu popup_1 win=NSORT_Panel,popmatch=lowFile 
     1975                 
     1976                // mediumQ menu 
     1977                if(strlen(medFile)!=0) 
     1978                        PopupMenu popup_2 win=NSORT_Panel,popmatch=medFile 
     1979                else 
     1980                        PopupMenu popup_2,win=NSORT_Panel,popmatch="none"       //set to "none" 
     1981                endif 
     1982         
     1983                //highQ (same pop list as medQ) 
     1984                if(strlen(hiFile)!=0) 
     1985                        PopupMenu popup_3 win=NSORT_Panel,popmatch=hiFile 
     1986                else 
     1987                        PopupMenu popup_3,win=NSORT_Panel,popmatch="none"       //set to "none" 
     1988                endif 
     1989                 
     1990                 
     1991                //pass the new file name in as a global (ugh!) 
     1992                String/G root:myGlobals:CombineTable:SaveNameStr = path+saveW[ii] 
     1993                //combine the files and write the data 
     1994                WriteNSORTFileButton("") 
     1995                 
     1996                Print "wrote file : ",path+saveW[ii] 
     1997                ii+=1 
     1998        while(ii<num) 
     1999 
     2000        Variable/G root:myGlobals:CombineTable:useTable=0               //turn this off immediately 
     2001         
     2002        return(0) 
     2003End 
Note: See TracChangeset for help on using the changeset viewer.