Changeset 994 for sans/Dev/trunk


Ignore:
Timestamp:
Apr 27, 2016 4:16:09 PM (7 years ago)
Author:
srkline
Message:

more changes, lots of files.

Location:
sans/Dev/trunk/NCNR_User_Procedures
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Common/NIST_XML_v40.ipf

    r983 r994  
    11171117        end 
    11181118         
    1119         Function WriteNSORTedXMLFile(q3,i3,sig3,firstFileName,secondFileName,thirdFileName,normTo,norm12,norm23,[res]) 
     1119        Function WriteNSORTedXMLFile(q3,i3,sig3,firstFileName,secondFileName,thirdFileName,fourthFileName,normTo,norm12,norm23,norm34,[res]) 
    11201120                Wave q3,i3,sig3,res 
    1121                 String firstFileName,secondFileName,thirdFileName,normTo 
    1122                 Variable norm12,norm23 
     1121                String firstFileName,secondFileName,thirdFileName,fourthFileName,normTo 
     1122                Variable norm12,norm23,norm34 
    11231123 
    11241124                 Abort  "XML function provided by XMLutils XOP is not available, get the XOP from : http://www.igorexchange.com/project/XMLutils (see http://www.smallangles.net/wgwiki/index.php/cansas1d_binding_IgorPro for details)" 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/USANS/WriteUSANSData.ipf

    r739 r994  
    495495        end 
    496496         
    497         Function WriteXMLUSANSDesmeared(type,fullpath,lo,hi,dialog) 
    498                 String type,fullpath 
     497        Function WriteXMLUSANSDesmeared(fullpath,lo,hi,dialog) 
     498                String fullpath 
    499499                Variable lo,hi,dialog           //=1 will present dialog for name 
    500500         
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_BeamCenter.ipf

    r993 r994  
    2323//      ModifyGraph width={Plan,1,bottom,left} 
    2424// 
    25 Macro DetectorPanelFit() : Panel 
     25Proc DetectorPanelFit() : Panel 
    2626        PauseUpdate; Silent 1           // building window... 
    2727 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_HDF5_VSANS_Utils.ipf

    r993 r994  
    270270                        Make/O/T/N=1    name    = "NG3_VSANS" 
    271271                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_B        
    272                         Make/O/D/N=(150,150)    data    = abs(gnoise(10)) 
    273                         Make/O/D/N=(150,150)    linear_data_error       = 0.01*abs(gnoise(10)) 
     272                        Make/O/D/N=(150,150)    data    = 1 + (enoise(0.1)) 
     273                        Make/O/D/N=(150,150)    linear_data_error       = 0.01*abs(gnoise(1)) 
    274274                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_MR               
    275                         Make/O/D/N=(48,128)     data    = abs(gnoise(10)) 
    276                         Make/O/D/N=(48,128)     linear_data_error       = 0.01*abs(gnoise(10)) 
     275                        Make/O/D/N=(48,128)     data    = 1 + (enoise(0.1)) 
     276                        Make/O/D/N=(48,128)     linear_data_error       = 0.01*abs(gnoise(1)) 
    277277                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_ML               
    278                         Make/O/D/N=(48,128)     data    = abs(gnoise(10)) 
    279                         Make/O/D/N=(48,128)     linear_data_error       = 0.01*abs(gnoise(10)) 
     278                        Make/O/D/N=(48,128)     data    = 1 + (enoise(0.1)) 
     279                        Make/O/D/N=(48,128)     linear_data_error       = 0.01*abs(gnoise(1)) 
    280280                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_MT               
    281                         Make/O/D/N=(128,48)     data    = abs(gnoise(10)) 
    282                         Make/O/D/N=(128,48)     linear_data_error       = 0.01*abs(gnoise(10)) 
     281                        Make/O/D/N=(128,48)     data    = 1 + (enoise(0.1)) 
     282                        Make/O/D/N=(128,48)     linear_data_error       = 0.01*abs(gnoise(1)) 
    283283                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_MB               
    284                         Make/O/D/N=(128,48)     data    = abs(gnoise(10)) 
    285                         Make/O/D/N=(128,48)     linear_data_error       = 0.01*abs(gnoise(10)) 
     284                        Make/O/D/N=(128,48)     data    = 1 + (enoise(0.1)) 
     285                        Make/O/D/N=(128,48)     linear_data_error       = 0.01*abs(gnoise(1)) 
    286286                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_FR               
    287                         Make/O/D/N=(48,128)     data    = abs(gnoise(10)) 
    288                         Make/O/D/N=(48,128)     linear_data_error       = 0.01*abs(gnoise(10)) 
     287                        Make/O/D/N=(48,128)     data    = 1 + (enoise(0.1)) 
     288                        Make/O/D/N=(48,128)     linear_data_error       = 0.01*abs(gnoise(1)) 
    289289                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_FL               
    290                         Make/O/D/N=(48,128)     data    = abs(gnoise(10)) 
    291                         Make/O/D/N=(48,128)     linear_data_error       = 0.01*abs(gnoise(10)) 
     290                        Make/O/D/N=(48,128)     data    = 1 + (enoise(0.1)) 
     291                        Make/O/D/N=(48,128)     linear_data_error       = 0.01*abs(gnoise(1)) 
    292292                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_FT               
    293                         Make/O/D/N=(128,48)     data    = abs(gnoise(10)) 
    294                         Make/O/D/N=(128,48)     linear_data_error       = 0.01*abs(gnoise(10)) 
     293                        Make/O/D/N=(128,48)     data    = 1 + (enoise(0.1)) 
     294                        Make/O/D/N=(128,48)     linear_data_error       = 0.01*abs(gnoise(1)) 
    295295                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_FB               
    296                         Make/O/D/N=(128,48)     data    = abs(gnoise(10)) 
    297                         Make/O/D/N=(128,48)     linear_data_error       = 0.01*abs(gnoise(10)) 
     296                        Make/O/D/N=(128,48)     data    = 1 + (enoise(0.1)) 
     297                        Make/O/D/N=(128,48)     linear_data_error       = 0.01*abs(gnoise(1)) 
    298298                         
    299299        SetDataFolder root: 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_UtilityProcedures.ipf

    r993 r994  
    436436 
    437437 
    438 //////// function to take VCALC information and  
    439 // fill in the simulated information as needed to make a "fake" data file 
    440 // 
    441 // TODO: 
    442 // -- identify all of the necessary bits to change 
    443 // -- maybe want a panel to make it easier to decide what inputs to change in the file 
    444 // -- decide if it's better to write wholesale, or as individual waves 
    445 // 
    446 Macro Copy_VCALC_to_VSANSFile() 
    447          
    448         String fileName = V_DoSaveFileDialog("pick the file to write to") 
    449         print fileName 
    450 //       
    451         if(strlen(fileName) > 0) 
    452                 writeVCALC_to_file(fileName) 
    453         endif 
    454 End 
    455  
    456 // 
    457 // TODO -- fill this in as needed to get fake data that's different 
    458 // 
    459 Function writeVCALC_to_file(fileName) 
    460         String fileName 
    461  
    462  
    463 // the detectors, all 9 + the correct SDD (that accounts for the offset of T/B panels 
    464 // the data itself (as INT32) 
    465 // the front SDD (correct units) 
    466 // the middle SDD (correct units) 
    467 // the back SDD (correct units) 
    468         Variable ii,val 
    469         String detStr 
    470         for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 
    471                 detStr = StringFromList(ii, ksDetectorListAll, ";") 
    472                 Duplicate/O $("root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_"+detStr+":det_"+detStr) tmpData 
    473                 Redimension/I tmpData 
    474                 tmpData = (tmpData ==   2147483647) ? 0 : tmpData               //the NaN "mask" in the sim data (T/B only)shows up as an ugly integer 
    475                 V_writeDetectorData(fileName,detStr,tmpData) 
    476                  
    477                 val = VCALC_getTopBottomSDDOffset(detStr)/10 + VCALC_getSDD(detStr)*100         // make sure value is in cm 
    478                 print val 
    479                 V_writeDet_distance(fileName,detStr,val) 
    480                  
    481                 // x and y pixel sizes for each detector should be correct in the "base" file - but if not... 
    482                 //Function VCALC_getPixSizeX(type)              // returns the pixel X size, in [cm] 
    483                 //Function VCALC_getPixSizeY(type) 
    484                 V_writeDet_x_pixel_size(fileName,detStr,VCALC_getPixSizeX(detStr)*10)           // data file is expecting mm 
    485                 V_writeDet_y_pixel_size(fileName,detStr,VCALC_getPixSizeY(detStr)*10) 
    486          
    487                 // write out the xCtr and yCtr (pixels) that was used in the q-calculation, done in VC_CalculateQFrontPanels() 
    488                 V_writeDet_beam_center_x(fileName,detStr,V_getDet_beam_center_x("VCALC",detStr)) 
    489                 V_writeDet_beam_center_y(fileName,detStr,V_getDet_beam_center_y("VCALC",detStr)) 
    490                  
    491                  
    492          
    493                 // the calibration data for each detector (except B) is already correct in the "base" file 
    494                 //V_writeDetTube_spatialCalib(fname,detStr,inW) 
    495                 // and for "B" 
    496                 //V_writeDet_cal_x(fname,detStr,inW) 
    497                 //V_writeDet_cal_y(fname,detStr,inW) 
    498                  
    499                                  
    500                 // the dead time for each detector is already correct in the "base" file 
    501                 // V_writeDetector_deadtime(fname,detStr,inW) 
    502                 // TODO: need a new, separate function to write the single deadtime value in/out of "B" 
    503  
    504         endfor 
    505          
    506          
    507 //? other detector geometry - lateral separation? 
    508  
    509 // the wavelength 
    510 //      Variable lam = V_getWavelength("VCALC")         //doesn't work, the corresponding folder in VCALC has not been defined 
    511         V_writeWavelength(fileName,VCALC_getWavelength()) 
    512  
    513 // description of the sample 
    514  
    515 // sample information 
    516 // name, title, etc 
    517          
    518 // fake the information about the count setup, so I have different numbers to read 
    519 // count time = fake time of 100 s 
    520         V_writeCount_time(fileName,100) 
    521  
    522 // monitor count (= imon) 
    523 // returns the number of neutrons on the sample 
    524 //Function VCALC_getImon() 
    525  
    526 // ?? anything else that I'd like to see on the catalog - I could change them here to see different values 
    527 // different collimation types? 
    528 // 
    529  
    530         return(0) 
    531 end 
    532  
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_DetectorCorrections.ipf

    r993 r994  
    327327// 
    328328// TESTING ONLY 
    329 Macro MakeFakeCalibrationWaves() 
     329Proc MakeFakeCalibrationWaves() 
    330330        // make these in the RAW data folder, before converting to a work folder 
    331331        // - then they will be "found" by get() 
     
    10181018//check before re-implementing 
    10191019// 
    1020 Macro DIV_a_Workfile(type) 
     1020Proc DIV_a_Workfile(type) 
    10211021        String type 
    10221022        Prompt type,"WORK data type",popup,"SAM;EMP;BGD;ADJ;" 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_RW_Utils.ipf

    r993 r994  
    2626 
    2727// passing null file string presents a dialog 
    28 Macro LoadFakeDIVData() 
     28Proc LoadFakeDIVData() 
    2929        V_LoadHDF5Data("","DIV") 
    3030End 
    3131 
    3232// passing null file string presents a dialog 
    33 Macro LoadFakeMASKData() 
     33Proc LoadFakeMASKData() 
    3434        V_LoadHDF5Data("","MSK") 
    3535End 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_Read.ipf

    r993 r994  
    14261426End 
    14271427 
     1428// TODO - be sure this is defined correctly 
     1429// -- only returns for T/B detectors 
     1430Function V_getDet_TBSetback(fname,detStr) 
     1431        String fname,detStr 
     1432 
     1433        if(cmpstr(detStr,"B") == 0) 
     1434                return(0) 
     1435        endif 
     1436        if(cmpstr(detStr,"FR") == 0 || cmpstr(detStr,"FL") == 0) 
     1437                return(0) 
     1438        endif 
     1439        if(cmpstr(detStr,"MR") == 0 || cmpstr(detStr,"ML") == 0) 
     1440                return(0) 
     1441        endif    
     1442         
     1443        String path = "entry:instrument:detector_"+detStr+":setback" 
     1444        return(V_getRealValueFromHDF5(fname,path)) 
     1445         
     1446         
     1447End 
     1448 
    14281449//Function V_getDet_VerticalOffset(fname,detStr) 
    14291450//      String fname,detStr 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_Write.ipf

    r993 r994  
    39333933End 
    39343934 
     3935 
     3936// TODO - be sure that this is defined correctly 
     3937// -- it needs to exist in the data file, and only for TB detector panels 
     3938Function V_writeDet_TBSetback(fname,detStr,val) 
     3939        String fname,detStr 
     3940        Variable val 
     3941 
     3942//      String path = "entry:instrument:detector_"+detStr+":setback" 
     3943         
     3944        if(cmpstr(detStr,"B") == 0) 
     3945                return(0) 
     3946        endif 
     3947        if(cmpstr(detStr,"FR") == 0 || cmpstr(detStr,"FL") == 0) 
     3948                return(0) 
     3949        endif 
     3950        if(cmpstr(detStr,"MR") == 0 || cmpstr(detStr,"ML") == 0) 
     3951                return(0) 
     3952        endif    
     3953         
     3954        Make/O/D/N=1 wTmpWrite 
     3955//      Make/O/R/N=1 wTmpWrite 
     3956        String groupName = "/entry/instrument/detector_"+detStr  
     3957        String varName = "setback" 
     3958        wTmpWrite[0] = val 
     3959 
     3960        variable err 
     3961        err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite) 
     3962        if(err) 
     3963                Print "HDF write err = ",err 
     3964        endif 
     3965        // now be sure to kill the data folder to force a re-read of the data next time this file is read in 
     3966//      err = V_KillNamedDataFolder(fname) 
     3967//      if(err) 
     3968//              Print "DataFolder kill err = ",err 
     3969//      endif 
     3970        return(err) 
     3971End 
     3972 
     3973 
     3974         
     3975 
    39353976//Function V_writeDet_VerticalOffset(fname,detStr,val) 
    39363977//      String fname,detStr 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_MainPanel.ipf

    r993 r994  
    2020 
    2121 
    22  
     22// TODO-- decide whether to automatically read in the mask, or not 
     23// -- there could be a default mask, or look for the mask that is speficied in the 
     24// next file that is read in from the path 
    2325Proc PickPath_MainButtonProc(ctrlName) : ButtonControl 
    2426        String ctrlName 
     
    4951 
    5052 
     53// 
    5154// this will only load the data into RAW, overwriting whatever is there. no copy is put in rawVSANS 
    5255// 
     
    5457        String ctrlName 
    5558 
    56         Variable err=   V_LoadHDF5Data("","RAW")                        // load the data into RawVSANS storage folder (why am I doing this?) 
     59        Variable err=   V_LoadHDF5Data("","RAW")                        // load the data  
    5760//      Print "Load err = "+num2str(err) 
    5861        if(!err) 
     
    6265                // this (in SANS) just passes directly to fRawWindowHook() 
    6366                UpdateDisplayInformation("RAW")         // plot the data in whatever folder type 
     67                 
     68                FakeRestorePanelsButtonClick()          //so the panels display correctly 
    6469                 
    6570        endif 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Menu.ipf

    r984 r994  
    2121        Submenu "In Progress Panels" 
    2222                "VSANS Preferences",Show_VSANSPreferences_Panel() 
    23                  
     23                "Beam Center Panel",DetectorPanelFit() 
    2424        End 
     25        Submenu "Work Files" 
     26                "Convert to WORK",Convert_to_Workfile() 
     27                "Load Fake DIV Data" 
     28                "DIV a work file",DIV_a_Workfile() 
     29                "Load Fake MASK Data" 
     30        End 
     31         
    2532End 
    2633 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Test_RAW_Panel.ipf

    r993 r994  
    130130        Button button_status,pos={607,146},size={70,20},proc=StatusButtonProc,title="Status" 
    131131        Button button_IvsQ,pos={689,113},size={70,20},proc=IvsQPanelButtonProc,title="I vs. Q" 
    132         Button button_file_m,pos={619,55},size={50,20},proc=File_m_ButtonProc,title="File <" 
    133         Button button_file_p,pos={679,55},size={50,20},proc=File_p_ButtonProc,title="File >" 
     132        Button button_file_m,pos={619,55},size={50,20},proc=File_minus_ButtonProc,title="File <" 
     133        Button button_file_p,pos={679,55},size={50,20},proc=File_plus_ButtonProc,title="File >" 
    134134        Button button_log,pos={689,146},size={70,20},proc=LogLinButtonProc,title="isLin",userData="0" 
    135135        Button button_tab_p,pos={648,81},size={50,20},proc=Tab_p_ButtonProc,title="Tab >" 
     
    563563End 
    564564 
     565// fake restore panels button click 
     566Function FakeRestorePanelsButtonClick() 
     567 
     568        STRUCT WMButtonAction ba 
     569        ba.eventCode = 2 
     570        RestorePanelButtonProc(ba) 
     571         
     572        return(0) 
     573End 
     574 
     575 
    565576// fake status button click 
    566577Function FakeStatusButtonClick() 
     
    591602// move one file number back 
    592603// 
    593 Function File_m_ButtonProc(ba) : ButtonControl 
    594         STRUCT WMButtonAction &ba 
    595  
    596         switch( ba.eventCode ) 
    597                 case 2: // mouse up 
    598                         // click code here 
     604Function File_minus_ButtonProc(ba) : ButtonControl 
     605        STRUCT WMButtonAction &ba 
     606 
     607        switch( ba.eventCode ) 
     608                case 2: // mouse up 
     609                        // click code here 
     610                        V_LoadPlotAndDisplayRAW(-1) 
     611                         
    599612                        break 
    600613                case -1: // control being killed 
     
    609622// move one file number forward 
    610623// 
    611 Function File_p_ButtonProc(ba) : ButtonControl 
    612         STRUCT WMButtonAction &ba 
    613  
    614         switch( ba.eventCode ) 
    615                 case 2: // mouse up 
    616                         // click code here 
     624Function File_plus_ButtonProc(ba) : ButtonControl 
     625        STRUCT WMButtonAction &ba 
     626 
     627        switch( ba.eventCode ) 
     628                case 2: // mouse up 
     629                        // click code here 
     630                        V_LoadPlotAndDisplayRAW(1) 
     631 
    617632                        break 
    618633                case -1: // control being killed 
     
    640655                        endif 
    641656                        FakeTabClick(V_Value) 
     657                         
    642658                        break 
    643659                case -1: // control being killed 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Testing_Data_Procs.ipf

    r993 r994  
    11#pragma TextEncoding = "MacRoman" 
    22#pragma rtGlobals=3             // Use modern global access method and strict wave access. 
     3 
     4 
     5 
     6//////// function to take VCALC information and  
     7// fill in the simulated information as needed to make a "fake" data file 
     8// 
     9// TODO: 
     10// -- identify all of the necessary bits to change 
     11// -- maybe want a panel to make it easier to decide what inputs to change in the file 
     12// -- decide if it's better to write wholesale, or as individual waves 
     13// 
     14Macro Copy_VCALC_to_VSANSFile() 
     15         
     16        String fileName = V_DoSaveFileDialog("pick the file to write to") 
     17        print fileName 
     18//       
     19        if(strlen(fileName) > 0) 
     20                writeVCALC_to_file(fileName) 
     21        endif 
     22End 
     23 
     24// 
     25// TODO -- fill this in as needed to get fake data that's different 
     26// 
     27Function writeVCALC_to_file(fileName) 
     28        String fileName 
     29 
     30 
     31// the detectors, all 9 + the correct SDD (that accounts for the offset of T/B panels 
     32// the data itself (as INT32) 
     33// the front SDD (correct units) 
     34// the middle SDD (correct units) 
     35// the back SDD (correct units) 
     36        Variable ii,val 
     37        String detStr 
     38        for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 
     39                detStr = StringFromList(ii, ksDetectorListAll, ";") 
     40                Duplicate/O $("root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_"+detStr+":det_"+detStr) tmpData 
     41                Redimension/I tmpData 
     42                tmpData = (tmpData ==   2147483647) ? 0 : tmpData               //the NaN "mask" in the sim data (T/B only)shows up as an ugly integer 
     43                V_writeDetectorData(fileName,detStr,tmpData) 
     44                 
     45                val = VCALC_getTopBottomSDDOffset(detStr)/10 + VCALC_getSDD(detStr)*100         // make sure value is in cm 
     46                print val 
     47                V_writeDet_distance(fileName,detStr,val) 
     48                 
     49                // x and y pixel sizes for each detector should be correct in the "base" file - but if not... 
     50                //Function VCALC_getPixSizeX(type)              // returns the pixel X size, in [cm] 
     51                //Function VCALC_getPixSizeY(type) 
     52                V_writeDet_x_pixel_size(fileName,detStr,VCALC_getPixSizeX(detStr)*10)           // data file is expecting mm 
     53                V_writeDet_y_pixel_size(fileName,detStr,VCALC_getPixSizeY(detStr)*10) 
     54         
     55                // write out the xCtr and yCtr (pixels) that was used in the q-calculation, done in VC_CalculateQFrontPanels() 
     56                V_writeDet_beam_center_x(fileName,detStr,V_getDet_beam_center_x("VCALC",detStr)) 
     57                V_writeDet_beam_center_y(fileName,detStr,V_getDet_beam_center_y("VCALC",detStr)) 
     58                 
     59                 
     60         
     61                // the calibration data for each detector (except B) is already correct in the "base" file 
     62                //V_writeDetTube_spatialCalib(fname,detStr,inW) 
     63                // and for "B" 
     64                //V_writeDet_cal_x(fname,detStr,inW) 
     65                //V_writeDet_cal_y(fname,detStr,inW) 
     66                 
     67                                 
     68                // the dead time for each detector is already correct in the "base" file 
     69                // V_writeDetector_deadtime(fname,detStr,inW) 
     70                // TODO: need a new, separate function to write the single deadtime value in/out of "B" 
     71 
     72        endfor 
     73         
     74         
     75//? other detector geometry - lateral separation? 
     76 
     77// the wavelength 
     78//      Variable lam = V_getWavelength("VCALC")         //doesn't work, the corresponding folder in VCALC has not been defined 
     79        V_writeWavelength(fileName,VCALC_getWavelength()) 
     80 
     81// description of the sample 
     82 
     83// sample information 
     84// name, title, etc 
     85         
     86// fake the information about the count setup, so I have different numbers to read 
     87// count time = fake time of 100 s 
     88        V_writeCount_time(fileName,100) 
     89 
     90// monitor count (= imon) 
     91// returns the number of neutrons on the sample 
     92//Function VCALC_getImon() 
     93 
     94// ?? anything else that I'd like to see on the catalog - I could change them here to see different values 
     95// different collimation types? 
     96// 
     97 
     98        return(0) 
     99end 
     100 
     101 
    3102 
    4103 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Utilities_General.ipf

    r987 r994  
    4949        Prompt type,"WORK data type to display",popup,"RAW;SAM;EMP;BGD;ADJ;" 
    5050 
    51         UpdateDisplayInformation(type) 
    52 End 
    53  
     51// make sure that data exists before passing this on... 
     52         
     53        if(DataExists(type) > 0) 
     54                UpdateDisplayInformation(type) 
     55        else 
     56                DoAlert 0,"No data in "+type 
     57        endif 
     58End 
     59 
     60// TODO 
     61// 
     62// very simple function to look for something in a work folder 
     63// -- only checks for FR data to exist, assumes everything else is there 
     64// -- can't use the V_get() functions, these will try to load data if it's not there! 
     65Function DataExists(type) 
     66        String type 
     67         
     68        Wave/Z w = $("root:Packages:NIST:VSANS:"+type+":entry:instrument:detector_FR:data") 
     69         
     70        return(WaveExists(w)) 
     71end 
    5472// 
    5573// tests if two values are close enough to each other 
     
    204222 
    205223 
     224 
     225// 
     226// previous/next button needs these functions 
     227// as well as many other utilities that manipulate the data file names 
     228// and parse run numbers. 
     229// 
     230 
     231 
     232// TODO 
     233// x- load in the proper file 
     234// x- re-click the I(q) button 
     235// x- be sure that the globals are updated w/ filename 
     236// -- getting the file_name from the root: global is a poor choice.  
     237//     Need a better, more reliable solution than this 
     238// -- make a copy of "oldName" that is local and not the SVAR, as the SVAR changes 
     239//    when the next file is loaded in (if it's not in RawVSANS), resulting in a "skipped" file number 
     240// 
     241//displays next (or previous) file in series of run numbers 
     242//file is read from disk, if path is set and the file number is present 
     243//increment +1, adds 1 to run number, -1 subtracts one 
     244// 
     245// will automatically step a gap of 10 run numbers, but nothing larger. Don't want to loop too long 
     246// trying to find a file (frustrating), don't want to look past the end of the run numbers (waste) 
     247// -- may find a more elegant solution later. 
     248// 
     249Function V_LoadPlotAndDisplayRAW(increment) 
     250        Variable increment 
     251 
     252        Variable i,val 
     253        String filename,tmp,curFileName 
     254        //take the currently displayed RAW file  
     255        SVAR oldName = root:file_name 
     256        oldname = V_RemoveAllSpaces(oldname)            //  
     257        curFileName = oldName 
     258//      print oldName 
     259         
     260        filename = oldname 
     261//      for (i = 0; i < abs(increment); i += 1) 
     262//              filename = GetPrevNextRawFile(filename,increment/abs(increment)) 
     263//      endfor   
     264        i = 1 
     265        val = increment 
     266        do 
     267//              print filename,val 
     268                filename = V_GetPrevNextRawFile(filename,val) 
     269//              print "new= ",filename 
     270                 
     271                val = i*increment 
     272                i+=1 
     273                tmp = ParseFilePath(0, filename, ":", 1, 0) 
     274 
     275//              print val,strlen(tmp),strlen(oldname) 
     276//              print cmpstr(tmp,oldname) 
     277 
     278                if(strlen(tmp) == 0)            //in some cases, a null string can be returned - handle gracefully 
     279                        return(0) 
     280                endif 
     281                 
     282        while( (cmpstr(tmp,curFileName) == 0) && i < 11) 
     283//      print filename 
     284         
     285        // display the specified RAW data file 
     286        // this is the set of steps done in DisplayMainButtonProc(ctrlName) : ButtonControl 
     287        Variable err=   V_LoadHDF5Data(filename,"RAW")                  // load the data, set the global w/file name loaded 
     288//      Print "Load err = "+num2str(err) 
     289        if(!err) 
     290                SVAR hdfDF = root:file_name                     // last file loaded, may not be the safest way to pass 
     291                String folder = StringFromList(0,hdfDF,".") 
     292                 
     293                // this (in SANS) just passes directly to fRawWindowHook() 
     294                Execute "UpdateDisplayInformation(\"RAW\")"     // plot the data in whatever folder type 
     295                 
     296                FakeRestorePanelsButtonClick()          //so the panels display correctly 
     297                 
     298        endif 
     299 
     300        // TODO 
     301        // -- update the 1D plotting as needed. these are SANS calls (OK for now, but will need to be better) 
     302        //do the average and plot (either the default, or what is on the panel currently) 
     303        V_PlotData_Panel() 
     304         
     305 
     306        return(0) 
     307End 
     308 
     309 
     310// Return the full path:filename that represents the previous or next file. 
     311// Input is current filename and increment.  
     312// Increment should be -1 or 1 
     313// -1 => previous file 
     314// 1 => next file 
     315Function/S V_GetPrevNextRawFile(curfilename, prevnext) 
     316        String curfilename 
     317        Variable prevnext 
     318 
     319        String filename 
     320         
     321        //get the run number 
     322        Variable num = V_GetRunNumFromFile(curfilename) 
     323                 
     324        //find the next specified file by number 
     325        fileName = V_FindFileFromRunNumber(num+prevnext) 
     326 
     327        if(cmpstr(fileName,"")==0) 
     328                //null return, do nothing 
     329                fileName = V_FindFileFromRunNumber(num)         //returns the full path, not just curFileName 
     330        Endif 
     331 
     332        Return filename 
     333End 
     334 
     335 
     336//returns a string containing the full path to the file containing the  
     337//run number "num". The null string is returned if no valid file can be found 
     338//the path "catPathName" used and is hard-wired, will abort if this path does not exist 
     339//the file returned will be a RAW SANS data file, other types of files are  
     340//filtered out. 
     341// 
     342// called by Buttons.ipf and Transmission.ipf, and locally by parsing routines 
     343// 
     344Function/S V_FindFileFromRunNumber(num) 
     345        Variable num 
     346         
     347        String fullName="",partialName="",item="" 
     348        //get list of raw data files in folder that match "num" (add leading zeros) 
     349        if( (num>9999) || (num<=0) ) 
     350                Print "error in  FindFileFromRunNumber(num), file number too large or too small" 
     351                Return ("") 
     352        Endif 
     353        //make a four character string of the run number 
     354        String numStr="" 
     355        if(num<10) 
     356                numStr = "000"+num2str(num) 
     357        else 
     358                if(num<100) 
     359                        numStr = "00"+num2str(num) 
     360                else 
     361                        if(num<1000) 
     362                                numstr = "0"+num2str(num) 
     363                        else 
     364                                numStr = num2str(num) 
     365                        endif 
     366                Endif 
     367        Endif 
     368        //Print "numstr = ",numstr 
     369         
     370        //make sure that path exists 
     371        PathInfo catPathName 
     372        String path = S_path 
     373        if (V_flag == 0) 
     374                Abort "folder path does not exist - use Pick Path button" 
     375        Endif 
     376        String list="",newList="",testStr="" 
     377         
     378        list = IndexedFile(catPathName,-1,"????")       //get all files in folder 
     379        //find (the) one with the number in the run # location in the name 
     380        Variable numItems,ii,runFound,isRAW 
     381        numItems = ItemsInList(list,";")                //get the new number of items in the list 
     382        ii=0 
     383        do 
     384                //parse through the list in this order: 
     385                // 1 - does item contain run number (as a string) "TTTTTnnn.SAn_XXX_Tyyy" 
     386                // 2 - exclude by isRaw? (to minimize disk access) 
     387                item = StringFromList(ii, list  ,";" ) 
     388                if(strlen(item) != 0) 
     389                        //find the run number, if it exists as a three character string 
     390                        testStr = V_GetRunNumStrFromFile(item) 
     391                        runFound= cmpstr(numStr,testStr)        //compare the three character strings, 0 if equal 
     392                        if(runFound == 0) 
     393                                //the run Number was found 
     394                                //build valid filename 
     395                                partialName = V_FindValidFileName(item) 
     396                                if(strlen(partialName) != 0)            //non-null return from FindValidFileName() 
     397                                        fullName = path + partialName 
     398                                        //check if RAW, if so,this must be the file! 
     399                                        isRAW = V_CheckIfRawData(fullName) 
     400                                        if(isRaw) 
     401                                                //stop here 
     402                                                return(fullname) 
     403                                        Endif 
     404                                Endif 
     405                        Endif 
     406                Endif 
     407                ii+=1 
     408        while(ii<numItems)              //process all items in list 
     409        Return ("")     //null return if file not found in list 
     410End 
     411 
     412// 
     413// TODO -- for VSANS Nexus files, how do I quickly identify if a file is 
     414//   RAW VSANS data? I don't want to generate any errors, but I want to quickly 
     415//   weed out the reduced data sets, etc. from file catalogs. 
     416// 
     417//function to test a binary file to see if it is a RAW binary SANS file 
     418//first checks the total bytes in the file (which for raw data is 33316 bytes) 
     419//**note that the "DIV" file will also show up as a raw file by the run field 
     420//should be listed in CAT/SHORT and in patch windows 
     421// 
     422//Function then checks the file fname (full path:file) for "RAW" run.type field 
     423//if not found, the data is not raw data and zero is returned 
     424// 
     425// called by many procedures (both external and local) 
     426// 
     427// TODO -- as was written by SANS, this function is expecting fname to be the path:fileName 
     428// - but are the V_get() functions OK with getting a full path, and what do they 
     429//  do when they fail? I don't want them to spit up another open file dialog 
     430// 
     431Function V_CheckIfRawData(fname) 
     432        String fname 
     433         
     434        Variable refnum,totalBytes 
     435        String testStr="" 
     436         
     437        testStr = V_getInstrumentName(fname) 
     438         
     439        if(cmpstr(testStr,"") != 0) 
     440                //testStr exists, ASSUMING it's a raw VSANS data file 
     441                Return(1) 
     442        else 
     443                //some other file 
     444                Return(0) 
     445        Endif 
     446End 
     447 
     448 
     449Function V_GetRunNumFromFile(item) 
     450        String item 
     451         
     452        String str = V_GetRunNumStrFromFile(item) 
     453         
     454        return(str2num(str)) 
     455end 
     456 
     457 
     458// TODO -- the file name structure for VSANS file is undecided 
     459// so some of these base functions will need to change 
     460// 
     461//given a filename of a VSANS data filename of the form 
     462// sansNNNN.nxs.ngv 
     463//returns the run number "NNNN" as a STRING of FOUR characters 
     464//returns "ABCD" as an invalid file number 
     465// 
     466// local function to aid in locating files by run number 
     467// 
     468Function/S V_GetRunNumStrFromFile(item) 
     469        String item 
     470        String invalid = "ABCD" //"ABCD" is not a valid run number, since it's text 
     471        Variable num=-1 
     472         
     473        //find the "dot" 
     474        String runStr="" 
     475        Variable numChar = 4 
     476        Variable pos = strsearch(item,".",0) 
     477        if(pos == -1) 
     478                //"dot" not found 
     479                return (invalid) 
     480        else 
     481                //found, get the four characters preceeding it 
     482                if (pos <= numChar-1) 
     483                        //not enough characters 
     484                        return (invalid) 
     485                else 
     486                        runStr = item[pos-numChar,pos-1] 
     487                        return (runStr) 
     488                Endif 
     489        Endif 
     490End 
     491 
     492//Function attempts to find valid filename from partial name by checking for 
     493// the existence of the file on disk. 
     494// - checks as is 
     495// - strips spaces 
     496// - permutations of upper/lowercase 
     497// 
     498// added 11/99 - uppercase and lowercase versions of the file are tried, if necessary 
     499// since from marquee, the filename field (textread[0]) must be used, and can be a mix of                       //02JUL13 
     500// upper/lowercase letters, while the filename on the server (should) be all caps 
     501// now makes repeated calls to ValidFileString() 
     502// 
     503// returns a valid filename (No path prepended) or a null string 
     504// 
     505// called by any functions, both external and local 
     506// 
     507Function/S V_FindValidFilename(partialName) 
     508        String PartialName 
     509         
     510        String retStr="" 
     511         
     512        //try name with no changes - to allow for ABS files that have spaces in the names 12APR04 
     513        retStr = V_ValidFileString(partialName) 
     514        if(cmpstr(retStr,"") !=0) 
     515                //non-null return 
     516                return(retStr) 
     517        Endif 
     518         
     519        //if the partial name is derived from the file header, there can be spaces at the beginning 
     520        //or in the middle of the filename - depending on the prefix and initials used 
     521        // 
     522        //remove any leading spaces from the name before starting 
     523        partialName = V_RemoveAllSpaces(partialName) 
     524         
     525        //try name with no spaces 
     526        retStr = V_ValidFileString(partialName) 
     527        if(cmpstr(retStr,"") !=0) 
     528                //non-null return 
     529                return(retStr) 
     530        Endif 
     531         
     532        //try all UPPERCASE 
     533        partialName = UpperStr(partialName) 
     534        retStr = V_ValidFileString(partialName) 
     535        if(cmpstr(retStr,"") !=0) 
     536                //non-null return 
     537                return(retStr) 
     538        Endif 
     539         
     540        //try all lowercase (ret null if failure) 
     541        partialName = LowerStr(partialName) 
     542        retStr = V_ValidFileString(partialName) 
     543        if(cmpstr(retStr,"") !=0) 
     544                //non-null return 
     545                return(retStr) 
     546        else 
     547                return(retStr) 
     548        Endif 
     549End 
     550 
     551 
     552// Function checks for the existence of a file 
     553// partialName;vers (to account for VAX filenaming conventions) 
     554// The partial name is tried first with no version number 
     555// 
     556// *** the PATH is hard-wired to catPathName (which is assumed to exist) 
     557// version numers up to ;10 are tried 
     558// only the "name;vers" is returned if successful. The path is not prepended 
     559// 
     560// local function 
     561// 
     562// TODO -- is this really necessary anymore for the NON-VAX files of VSANS. 
     563// -- can this be made a pass-through, or will there be another function that is needed for VSANS? 
     564// 
     565Function/S V_ValidFileString(partialName) 
     566        String partialName 
     567         
     568        String tempName = "",msg="" 
     569        Variable ii,refnum 
     570         
     571        ii=0 
     572        do 
     573                if(ii==0) 
     574                        //first pass, try the partialName 
     575                        tempName = partialName 
     576                        Open/Z/R/T="????TEXT"/P=catPathName refnum tempName     //Does open file (/Z flag) 
     577                        if(V_flag == 0) 
     578                                //file exists 
     579                                Close refnum            //YES needed,  
     580                                break 
     581                        endif 
     582                else 
     583                        tempName = partialName + ";" + num2str(ii) 
     584                        Open/Z/R/T="????TEXT"/P=catPathName refnum tempName 
     585                        if(V_flag == 0) 
     586                                //file exists 
     587                                Close refnum 
     588                                break 
     589                        endif 
     590                Endif 
     591                ii+=1 
     592                //print "ii=",ii 
     593        while(ii<11) 
     594        //go get the selected bits of information, using tempName, which exists 
     595        if(ii>=11) 
     596                //msg = partialName + " not found. is version number > 11?" 
     597                //DoAlert 0, msg 
     598                //PathInfo catPathName 
     599                //Print S_Path 
     600                Return ("")             //use null string as error condition 
     601        Endif 
     602         
     603        Return (tempName) 
     604End 
     605 
     606//function to remove all spaces from names when searching for filenames 
     607//the filename (as saved) will never have interior spaces (TTTTTnnn_AB _Bnnn) 
     608//but the text field in the header WILL, if less than 3 characters were used for the  
     609//user's initials, and can have leading spaces if prefix was less than 5 characters 
     610// 
     611//returns a string identical to the original string, except with the interior spaces removed 
     612// 
     613// local function for file name manipulation 
     614// 
     615Function/S V_RemoveAllSpaces(str) 
     616        String str 
     617         
     618        String tempstr = str 
     619        Variable ii,spc,len             //should never be more than 2 or 3 trailing spaces in a filename 
     620        ii=0 
     621        do 
     622                len = strlen(tempStr) 
     623                spc = strsearch(tempStr," ",0)          //is the last character a space? 
     624                if (spc == -1) 
     625                        break           //no more spaces found, get out 
     626                endif 
     627                str = tempstr 
     628                tempStr = str[0,(spc-1)] + str[(spc+1),(len-1)] //remove the space from the string 
     629        While(1)        //should never be more than 2 or 3 
     630         
     631        If(strlen(tempStr) < 1) 
     632                tempStr = ""            //be sure to return a null string if problem found 
     633        Endif 
     634         
     635        //Print strlen(tempstr) 
     636         
     637        Return(tempStr) 
     638                 
     639End 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_WorkFolderUtils.ipf

    r993 r994  
    304304//   line fails (but reports no error), then DuplicateDataFolder fails, and reports an error. Trying 
    305305//   to simplify this condition, I can't reproduce the bug for WM... 
    306 Macro Convert_to_Workfile(newtype, doadd) 
     306Proc Convert_to_Workfile(newtype, doadd) 
    307307        String newtype,doadd 
    308308        Prompt newtype,"WORK data type",popup,"SAM;EMP;BGD;ADJ;" 
Note: See TracChangeset for help on using the changeset viewer.