Ignore:
Timestamp:
Nov 4, 2009 4:58:52 PM (13 years ago)
Author:
srkline
Message:

changes to how a fake VAX raw data file is written out. now call accepts optional parameters so that the index and label can be supplied, and the MC simulation can be very crudely scripted for unattended operation.

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

Legend:

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

    r589 r596  
    1111// 
    1212// 
    13  
    14  
    15  
     13// at the end of the procedure fils is a *very* simple example of scripting for unattended simulations 
     14// - not for the casual user at all. 
     15 
     16 
     17 
     18// the RNG issue is really not worth the effort. multiple copies with different RNG is as good as I need. Plus, 
     19// whatever XOP crashing was happining during threading is really unlikely to be from the RNG 
     20// 
    1621// *** look into erand48() as the (pseudo) random number generator (it's a standard c-lib function, at least on unix) 
    1722//     and is apparantly thread safe. drand48() returns values [0.0,1.0) 
    1823//http://qnxcs.unomaha.edu/help/product/neutrino/lib_ref/e/erand48.html 
    19  
     24// 
    2025 
    2126 
     
    3035// X how can I get the "data" on absolute scale? This would be a great comparison vs. the ideal model calculation 
    3136// X why does my integrated tau not match up with John's analytical calculations? where are the assumptions? 
    32 // - get rid of all small angle assumptions - to make sure that the calculation is correct at all angles 
     37// X get rid of all small angle assumptions - to make sure that the calculation is correct at all angles 
    3338 
    3439// 
     
    7277// 
    7378// 
     79 
     80 
     81 
     82 
    7483 
    7584// setting the flag to 1 == 2D simulation 
     
    10431052// currently hard-wired for SAS data folder 
    10441053// 
    1045 Function SaveAsVAXButtonProc(ctrlName) : ButtonControl 
     1054Function SaveAsVAXButtonProc(ctrlName,[runIndex,simLabel]) 
    10461055        String ctrlName 
    1047  
     1056        Variable runIndex 
     1057        String simLabel 
     1058 
     1059         
     1060        // if default parameters were passed in, use them 
     1061        // if not, set them to "bad" values so that the user will be prompted later      
     1062        NVAR autoSaveIndex = root:Packages:NIST:SAS:gAutoSaveIndex 
     1063        SVAR autoSaveLabel = root:Packages:NIST:SAS:gAutoSaveLabel 
     1064         
     1065        // Determine if the optional parameters were supplied 
     1066        if( ParamIsDefault(runIndex))           //==1 if parameter was NOT specified 
     1067                print "runIndex not specified" 
     1068                autoSaveIndex=0                                 // 0 == bad value, test for this later 
     1069        else 
     1070                autoSaveIndex=runIndex 
     1071        endif 
     1072         
     1073        if( ParamIsDefault(simLabel))           //==1 if parameter was NOT specified 
     1074                print "simLabel not specified" 
     1075                autoSaveLabel=""                                        // "" == bad value, test for this later 
     1076        else 
     1077                autoSaveLabel=simLabel 
     1078        endif 
     1079         
    10481080        String fullpath="",destStr="" 
    10491081        Variable refnum 
     
    17851817        return(mScat) 
    17861818End 
     1819 
     1820 
     1821//// this is a very simple example of how to script the MC simulation to run unattended 
     1822// 
     1823//  you need to supply for each "run":  the run index (you increment manually) 
     1824//                                                                                              the sample label (as a string) 
     1825// 
     1826// changing the various configuration paramters will have to be done on a case-by-case basis 
     1827// looking into SASCALC to see what is really changed, 
     1828// or the configuration parameters of the MC_SASCALC panel  
     1829// 
     1830// 
     1831//Function Script_2DMC() 
     1832// 
     1833//      STRUCT WMButtonAction ba 
     1834//      ba.eventCode = 2                        //fake mouse click on button 
     1835//       
     1836//      NVAR detDist = root:Packages:NIST:SAS:gDetDist 
     1837//       
     1838//      detDist = 200           //set directly in cm 
     1839//      MC_DoItButtonProc(ba) 
     1840//      SaveAsVAXButtonProc("",runIndex=105,simLabel="this is run 105, SDD = 200") 
     1841//       
     1842//      detDist = 300           //set directly in cm 
     1843//      MC_DoItButtonProc(ba) 
     1844//      SaveAsVAXButtonProc("",runIndex=106,simLabel="this is run 106, SDD = 300") 
     1845// 
     1846//      detDist = 400           //set directly in cm 
     1847//      MC_DoItButtonProc(ba) 
     1848//      SaveAsVAXButtonProc("",runIndex=107,simLabel="this is run 107, SDD = 400") 
     1849//       
     1850//      return(0) 
     1851//end 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/NCNR_DataReadWrite.ipf

    r583 r596  
    18681868        String type,fullpath 
    18691869        Variable dialog         //=1 will present dialog for name 
    1870          
     1870 
    18711871        String filename = "" 
    18721872        filename = Write_VAXRaw_Data(type,fullpath,dialog) 
     
    23582358// simulated VAX data file. 
    23592359// 
     2360// NCNR-Specific 
    23602361// 
    23612362Function SimulationVAXHeader(folder) 
     
    24042405        tw[9] = "ORNL  " 
    24052406         
     2407         
     2408        //get the run index and the sample label from the optional parameters, or from a dialog 
    24062409        NVAR index = root:Packages:NIST:SAS:gSaveIndex 
    24072410        SVAR prefix = root:Packages:NIST:SAS:gSavePrefix 
    2408  
    2409  
    2410          
    2411         String labelStr=" "      
    2412         Variable runNum = index 
    2413         Prompt labelStr, "Enter sample label "          // Set prompt for x param 
    2414         Prompt runNum,"Run Number (automatically increments)" 
    2415         DoPrompt "Enter sample label", labelStr,runNum 
    2416         if (V_Flag) 
    2417                 //Print "no sample label entered - no file written" 
    2418                 //index -=1 
    2419                 return -1                                                               // User canceled 
     2411// did the user pass in values? 
     2412        NVAR autoSaveIndex = root:Packages:NIST:SAS:gAutoSaveIndex 
     2413        SVAR autoSaveLabel = root:Packages:NIST:SAS:gAutoSaveLabel 
     2414         
     2415        String labelStr=""       
     2416        Variable runNum 
     2417        if( (autoSaveIndex != 0) && (strlen(autoSaveLabel) > 0) ) 
     2418                // all is OK, proceed with the save 
     2419                labelStr = autoSaveLabel 
     2420                runNum = autoSaveIndex          //user must take care of incrementing this! 
     2421        else 
     2422                //one or the other, or both are missing, so ask 
     2423                runNum = index 
     2424                Prompt labelStr, "Enter sample label "          // Set prompt for x param 
     2425                Prompt runNum,"Run Number (automatically increments)" 
     2426                DoPrompt "Enter sample label", labelStr,runNum 
     2427                if (V_Flag) 
     2428                        //Print "no sample label entered - no file written" 
     2429                        //index -=1 
     2430                        return -1                                                               // User canceled 
     2431                endif 
     2432                if(runNum != index) 
     2433                        index = runNum 
     2434                endif 
     2435                index += 1 
    24202436        endif 
    24212437         
    2422         if(runNum != index) 
    2423                 index = runNum 
    2424         endif 
    2425         index += 1 
     2438 
    24262439 
    24272440        //make a three character string of the run number 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/SASCALC.ipf

    r583 r596  
    124124        Variable/G root:Packages:NIST:SAS:gSaveIndex = 100 
    125125        String/G root:Packages:NIST:SAS:gSavePrefix = "SIMUL" 
     126        Variable/G root:Packages:NIST:SAS:gAutoSaveIndex = 100                  //a way to set the index for automated saves 
     127        String/G root:Packages:NIST:SAS:gAutoSaveLabel = ""                             //a way to set the "sample" label for automated saves 
    126128        Make/O/D/N=10 root:Packages:NIST:SAS:results = 0 
    127129        Make/O/T/N=10 root:Packages:NIST:SAS:results_desc = {"total X-section (1/cm)","SAS X-section (1/cm)","number that scatter","number that reach detector","avg # times scattered","fraction single coherent","fraction multiple coherent","fraction multiple scattered","fraction transmitted","detector counts w/beamstop"} 
Note: See TracChangeset for help on using the changeset viewer.