Changeset 1002 for sans


Ignore:
Timestamp:
Jun 17, 2016 11:43:46 AM (7 years ago)
Author:
srkline
Message:

main changes here are the addition of a first pass at the file catalog, and patch panel. each of these is based on the old SANS file (for now) and has been updated to at least compile.

Much more work needs to be done to get the functionality to be what VSANS needs, both in what is important to report in the file catalog, and how to best present the patch GUI for different situations

Location:
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS
Files:
2 added
8 edited

Legend:

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

    r999 r1002  
    222222        Save_VSANS_file("root:VSANS_DIV_file", fileName+".h5") 
    223223         
    224         // read in a data file using the gateway-- reads from the home path 
    225         H_HDF5Gate_Read_Raw(fileName+".h5") 
    226          
    227         // after reading in a "partial" file using the gateway (to generate the xref) 
    228         // Save the xref to disk (for later use) 
    229         Save_HDF5___xref("root:"+fileName,"HDF5___xref") 
    230          
    231         // after you've generated the HDF5___xref, load it in and copy it 
    232         // to the necessary folder location. 
    233         Copy_HDF5___xref("root:VSANS_DIV_file", "HDF5___xref") 
    234          
    235         // writes out the contents of a data folder using the gateway 
    236         H_HDF5Gate_Write_Raw("root:VSANS_DIV_file", fileName+".h5") 
    237  
    238         // re-load the data file using the gateway-- reads from the home path 
    239         // now with attributes 
    240         H_HDF5Gate_Read_Raw(fileName+".h5") 
     224//      // read in a data file using the gateway-- reads from the home path 
     225//      H_HDF5Gate_Read_Raw(fileName+".h5") 
     226//       
     227//      // after reading in a "partial" file using the gateway (to generate the xref) 
     228//      // Save the xref to disk (for later use) 
     229//      Save_HDF5___xref("root:"+fileName,"HDF5___xref") 
     230//       
     231//      // after you've generated the HDF5___xref, load it in and copy it 
     232//      // to the necessary folder location. 
     233//      Copy_HDF5___xref("root:VSANS_DIV_file", "HDF5___xref") 
     234//       
     235//      // writes out the contents of a data folder using the gateway 
     236//      H_HDF5Gate_Write_Raw("root:VSANS_DIV_file", fileName+".h5") 
     237// 
     238//      // re-load the data file using the gateway-- reads from the home path 
     239//      // now with attributes 
     240//      H_HDF5Gate_Read_Raw(fileName+".h5") 
    241241         
    242242End 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VSANS_Includes.ipf

    r999 r1002  
    6262#include "V_MaskUtils" 
    6363 
    64  
     64// more functionality 
     65#include "V_FileCatalog" 
     66#include "V_PatchFiles"         //still in progress and won't compile 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_RW_Utils.ipf

    r995 r1002  
    3131End 
    3232 
     33// Moved to V_MaskUtils.ipf 
    3334// passing null file string presents a dialog 
    34 Proc LoadFakeMASKData() 
    35         V_LoadHDF5Data("","MSK") 
    36 End 
     35//Proc LoadFakeMASKData() 
     36//      V_LoadHDF5Data("","MSK") 
     37//End 
    3738 
    3839// passing null file string presents a dialog 
     
    4546//  x- move the initialization of the raw data folder to be in the as-yet unwritten initialization routine for 
    4647// reduction. be sure that it's duplicated in the VCALC initialization too. 
    47 // -- as needed, get rid of the FAKE redimension of the data from 3D->2D and from 128x128 to something else for VSANS 
     48// x- as needed, get rid of the FAKE redimension of the data from 3D->2D and from 128x128 to something else for VSANS 
    4849//    This is a fake since I don't have anything close to correct fake data yet. (1/29/16) 
    4950// 
     
    177178// This is NOT CALLED anymore. 
    178179// the rescaling (SetScale) of the data sets is still done separately to a "fake" beam center 
    179 Function V_RedimFakeData() 
     180Function xV_RedimFakeData() 
    180181         
    181182        // check for fake data in VCALC folder... 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_IQ_Utilities.ipf

    r999 r1002  
    9999 
    100100 
    101 Macro V_Combine1DData() 
     101Proc V_Combine1DData() 
    102102 
    103103// get the current display type 
     
    107107 
    108108// trim the data if needed 
     109        // remove the q=0 point from the back detector, if it's there 
     110        V_RemoveQ0_B(type) 
     111 
    109112 
    110113// concatenate the data sets 
     114        // clear the old tmp waves first, if they still exist 
     115        SetDataFolder $("root:Packages:NIST:VSANS:"+type) 
     116        Killwaves/Z tmp_q,tmp_i,tmp_s 
     117        setDataFolder root: 
    111118        V_1DConcatenate(type) 
    112119         
     
    125132        String/G saveName=str 
    126133End 
     134 
     135 
     136// blindly assumes that there is only one zero at the top of the wave 
     137// could be more sophisticated in the future... 
     138Function V_RemoveQ0_B(type) 
     139        String type 
     140         
     141        SetDataFolder $("root:Packages:NIST:VSANS:"+type) 
     142 
     143        WAVE/Z qBin = qBin_qxqy_B 
     144        WAVE/Z iBin = iBin_qxqy_B 
     145        WAVE/Z eBin = eBin_qxqy_B 
     146        WAVE/Z nBin = nBin_qxqy_B 
     147        WAVE/Z iBin2 = iBin2_qxqy_B 
     148 
     149        if(qBin[0] == 0) 
     150                DeletePoints 0, 1, qBin,iBin,eBin,nBin,iBin2 
     151        endif 
     152         
     153        SetDataFolder root: 
     154        return(0) 
     155end 
    127156 
    128157 
     
    136165//    although waves may exist, they may not be the right ones to use. There 
    137166//    will be a somewhat complex selection process 
    138 // -- detector B is currently skipped 
     167// x- detector B is currently skipped 
    139168// 
    140169// this seems like a lot of extra work to do something so simple... 
     
    207236//      Duplicate/O tmp_res3 $("root:"+folder2+":res3") 
    208237 
     238// Can't kill here, since they are still needed to sort and write out! 
    209239//      KillWaves/Z tmp_q,tmp_i,tmp_s,tmp_res0,tmp_res1,tmp_res2,tmp_res3        
    210240         
     
    215245 
    216246// TODO: 
    217 // -- resolution waves are ignored 
     247// -- resolution waves are ignored, since they don't exist (yet) 
    218248// -- only a sort is done, no rescaling of data sets 
    219249//    (it's too late now anyways, since the data was concatenated 
     
    241271 
    242272 
    243 // trims the beamstop out (based on shadow) 
    244 // trims num from the highQ end 
    245 // splits the res wave into individual waves in anticipation of concatenation 
     273// TODO 
     274// -- currently, this function is NOT called by anything 
     275// needs: 
     276// -- trim the beamstop out (based on shadow) 
     277// -- trim out zero q from the file (bad actor in analysis functions) 
     278// -- trim num from the highQ end or lowQ end? 
     279// -- splits the res wave into individual waves in anticipation of concatenation 
     280//   -- or -- deal with the res wave after? 
     281// 
     282// 
    246283// 
    247284Function V_Trim1DData(folderStr,nEnd) 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Initialize.ipf

    r999 r1002  
    333333        return isDemo 
    334334End 
     335 
     336// Clean out the RawVSANS folder before saving 
     337Function BeforeExperimentSaveHook(rN,fileName,path,type,creator,kind) 
     338        Variable rN,kind 
     339        String fileName,path,type,creator 
     340 
     341        // clean out, so that the file SAVE is not slow due to the large experiment size 
     342        // TODO -- decide if this is really necessary 
     343//       
     344        V_CleanOutRawVSANS() 
     345        Printf "Hook cleaned out RawVSANS, experiment saved\r" 
     346 
     347End 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_MainPanel.ipf

    r1000 r1002  
    7474        String ctrlName 
    7575 
    76         PatchFiles() 
     76        V_PatchFiles() 
    7777End 
    7878 
     
    165165End 
    166166 
    167 //on Misc Ops tab, generates a notebook 
    168 Proc CatShort_MainButtonProc(ctrlName) : ButtonControl 
    169         String ctrlName 
    170  
    171         BuildCatShortNotebook() 
    172 End 
     167////on Misc Ops tab, generates a notebook 
     168//Proc CatShort_MainButtonProc(ctrlName) : ButtonControl 
     169//      String ctrlName 
     170// 
     171//      BuildCatShortNotebook() 
     172//End 
    173173 
    174174//button is labeled "File Catalog" 
     
    176176        String ctrlName 
    177177 
    178         //BuildCatVeryShortNotebook() 
    179         BuildCatVeryShortTable() 
     178        V_BuildCatVeryShortTable() 
     179End 
     180 
     181Proc CatSort_MainButtonProc(ctrlName) : ButtonControl 
     182        String ctrlName 
     183         
     184        Catalog_Sort() 
    180185End 
    181186 
     
    337342        Button MainButton_0d,pos={15,180},size={130,20},proc=RealTime_MainButtonProc,title="RealTime Display" 
    338343        Button MainButton_0d,help={"Shows the panel for control of the RealTime data display. Only used during data collection"} 
     344        Button MainButton_0e,pos={15,210},size={130,20},proc=CatSort_MainButtonProc,title="Sort Catalog" 
     345        Button MainButton_0e,help={"Sort the Data Catalog, courtesy of ANSTO"} 
     346 
     347 
    339348 
    340349//on tab(1) - Reduction 
     
    407416        Button MainButton_4c,pos={15,150},size={80,20},proc=ShowAvePanel_MainButtonProc,title="Average" 
    408417        Button MainButton_4c,help={"Shows a panel for interactive selection of the 1-D averaging step"} 
    409         Button MainButton_4d,pos={15,180},size={110,20},proc=CatShort_MainButtonProc,title="CAT/Notebook" 
    410         Button MainButton_4d,help={"This will generate a CATalog notebook of all files in a specified local folder"} 
     418//      Button MainButton_4d,pos={15,180},size={110,20},proc=CatShort_MainButtonProc,title="CAT/Notebook" 
     419//      Button MainButton_4d,help={"This will generate a CATalog notebook of all files in a specified local folder"} 
    411420        Button MainButton_4e,pos={180,90},size={130,20},proc=NG1TransConv_MainButtonProc,title="NG1 Files to Trans" 
    412421        Button MainButton_4e,help={"Converts NG1 transmission data files to be interpreted as such"} 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_MaskUtils.ipf

    r1000 r1002  
    22#pragma rtGlobals=3             // Use modern global access method and strict wave access. 
    33 
    4  
     4// 
     5// Mask utilities: 
     6// - loader 
     7// - simple editor 
     8// - save mask file 
     9// - assign mask file to data file 
     10// 
     11// 
     12//  this is (at first) to be a very simple editor to generate masks row/column wise, not drawing 
     13//  masks with arbitrary shape.  
     14// 
     15//  
     16// 
     17 
     18///// LOADING 
     19 
     20// TODO - when maks is loaded, need to be sure to clean up the "extra" waves that may be present 
     21//  - the overlay and the currentTube waves since these are not overwritten or killed when new mask  
     22//  data is read in from HDF. need to manually? check for these and delete then, or the data and 
     23//  mask overlay will be out of sync. 
     24// 
     25 
     26 
     27// passing null file string presents a dialog 
     28// called from the Main Button " Read Mask" 
     29Proc LoadFakeMASKData() 
     30        V_LoadHDF5Data("","MSK") 
     31End 
     32 
     33 
     34 
     35//// DRAWING/SAVING 
     36// 
    537// TODO: 
    638// x- CHANGE the mask behavior to a more logical choice - and consistent with SANS 
     
    1143 
    1244 
    13 // also, move the mask generating utilities from VC_HDF5_Utils into this procedure - to keep 
     45// x- move the mask generating utilities from VC_HDF5_Utils into this procedure - to keep 
    1446// all of the mask procedures together 
    1547 
    1648 
    17 // 
    18 // -- this is to be a very simple editor to generate masks row/column wise, not drawing 
    19 // 
     49// TODO -- document the arrow keys moving the tube number and adding/deleting tubes from the mask 
     50//  this is done through a window hook function (LR moves tube number, up/down = add/delete) 
     51// 
     52// TODO -- make the arrow keys Igor 6 compatible - search for specialKeyCode or Keyboard Events in the help file 
     53//     and what needs to be replaced for Igor 6 
     54// TODO -- for L/R panels, the maksing of columns should be sufficient. Tubes are vertical. For the T/B panels 
     55//         the L/R panels cast a vertical shadow (=vertical mask) AND the tubes are horizontal, so the individual 
     56//         tubes will likely need to be masked in a horizontal line too, per tube. ADD this in... 
    2057 
    2158 
    2259//TODO 
    23 // -- draw a mask 
    24 // -- save a mask (all panels) 
    25 // -- be able to save the mask name to the file 
    26 // -- be able to read a mask based on what is in the data file 
     60// x- draw a mask 
     61// x- save a mask (all panels) 
     62// -- be able to save the mask name to the RAW data file 
     63// -- be able to read a mask based on what name is in the data file 
    2764// 
    2865// x- biggest thing now is to re-write the DrawDetPanel() routine from the beamCenter.ipf 
    2966//    to do what this panel needs 
    3067// 
    31 // -- lots to clean up 
    32 // -- add this to the list of includes, move the file to SVN, and add it. 
     68// x- add this to the list of includes, move the file to SVN, and add it. 
    3369// 
    3470// -- for working with VCALC -- maybe have an automatic generator (if val < -2e6, mask = 0) 
     
    3874//    routines need to be aware of this 
    3975 
    40 Macro Edit_a_Mask() 
     76 
     77 
     78// called from the main button "Draw Mask" 
     79Proc Edit_a_Mask() 
    4180        V_EditMask() 
    4281end 
     
    4584        DoWindow/F MaskEditPanel 
    4685        if(V_flag==0) 
     86                Variable/G root:Packages:NIST:VSANS:Globals:gMaskTube = 0 
     87                Variable/G root:Packages:NIST:VSANS:Globals:gMaskMaxIndex = 47 
    4788                Execute "MaskEditorPanel()" 
    4889        endif 
     
    5293// TODO - may need to adjust the display for the different pixel dimensions 
    5394//      ModifyGraph width={Plan,1,bottom,left} 
     95// 
     96// TODO -- need buttons for: 
     97//              -- quit 
     98//    -- help (button is there, fill in the content) 
    5499// 
    55100Proc MaskEditorPanel() : Panel 
     
    64109        PopupMenu popup_2,mode=1,popvalue="RAW",value= #"\"RAW;SAM;VCALC;\"" 
    65110 
    66         SetVariable setvar0,pos={247.00,20.00},size={150.00,14.00},title="tube number" 
    67         SetVariable setvar0,limits={0,128,1},value= _NUM:0 
    68         Button button_0,pos={249.00,46.00},size={50.00,20.00},proc=AddToMaskButtonProc,title="Add" 
    69         Button button_1,pos={309.00,46.00},size={50.00,20.00},proc=RemoveFromMaskButtonProc,title="Del" 
    70         Button button_2,pos={389.00,46.00},size={90.00,20.00},proc=ToggleMaskButtonProc,title="Toggle" 
    71         Button button_3,pos={489.00,46.00},size={80.00,20.00},proc=SaveMaskButtonProc,title="Save" 
    72  
    73 // TODO -- need buttons for save? quit? 
    74 // setVariable to add a row to the mask, column to the mask, toggle the mask on/off to see what's 
    75 //     happening with the data 
    76  
    77  
    78 // TODO - get rid of the hard-wired panel choice 
    79 //      duplicate/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FL:det_FL curDispPanel 
    80         Make/O/D/N=(48,128) curDispPanel                //will this work? 
    81         SetScale/P x 0,1, curDispPanel 
    82         SetScale/P y 0,1, curDispPanel 
     111        SetVariable setvar0,pos={257.00,20.00},size={150.00,14.00},title="tube number" 
     112        SetVariable setvar0,limits={0,127,1},value=root:Packages:NIST:VSANS:Globals:gMaskTube 
     113        Button button_0,pos={257,46.00},size={50.00,20.00},proc=AddToMaskButtonProc,title="Add" 
     114        Button button_1,pos={319.00,46.00},size={50.00,20.00},proc=RemoveFromMaskButtonProc,title="Del" 
     115        Button button_2,pos={409.00,46.00},size={90.00,20.00},proc=ToggleMaskButtonProc,title="Toggle" 
     116        Button button_3,pos={509.00,46.00},size={80.00,20.00},proc=SaveMaskButtonProc,title="Save" 
     117        Button button_4,pos={603.00,10.00},size={20.00,20.00},proc=DrawMaskHelpButtonProc,title="?" 
     118        CheckBox check_0,pos={190.00,23.00},size={37.00,15.00},proc=DrawMaskRadioCheckProc,title="Row" 
     119        CheckBox check_0,value= 0,mode=1 
     120        CheckBox check_1,pos={190.00,46.00},size={32.00,15.00},proc=DrawMaskRadioCheckProc,title="Col" 
     121        CheckBox check_1,value= 1,mode=1 
     122 
     123        SetWindow MaskEditPanel, hook(MyHook)=MaskWindowHook 
    83124 
    84125        // draw the correct images 
     
    88129        // overlay the current mask 
    89130        V_OverlayMask("FT",1) 
    90 //      OverlayMaskPanel("FL") 
    91131 
    92132EndMacro 
    93133 
     134Function DrawMaskHelpButtonProc(ba) : ButtonControl 
     135        STRUCT WMButtonAction &ba 
     136 
     137        switch( ba.eventCode ) 
     138                case 2: // mouse up 
     139                        // click code here 
     140                        DoAlert 0, "Draw Mask Help not written yet..." 
     141                        break 
     142                case -1: // control being killed 
     143                        break 
     144        endswitch 
     145 
     146        return 0 
     147End 
     148 
     149// 
     150//a simple toggle between the two, so the logic is not done in the cleanest way. 
     151// 
     152// update the limits on the tube nubmer based on row/col and the panel (gMaskMaxIndex global) 
     153// 
     154Function DrawMaskRadioCheckProc(cba) : CheckBoxControl 
     155        STRUCT WMCheckboxAction &cba 
     156 
     157        switch( cba.eventCode ) 
     158                case 2: // mouse up 
     159                        Variable checked = cba.checked 
     160                        String name = cba.ctrlName 
     161                         
     162                        //get information to update the limits on the tube number setvar 
     163                        ControlInfo popup_0 
     164                        String str=S_Value 
     165                        wave data = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+str+":data") 
     166                        Variable val 
     167                         
     168                        // update the radio button status and the setvar limits                  
     169                        if(cmpstr(name,"check_0") == 0)         // ROW is being selected 
     170                                CheckBox check_0,value = 1 
     171                                CheckBox check_1,value = 0 
     172                                val = DimSize(data, 1) -1 
     173                        else 
     174                                // COL is being selected 
     175                                CheckBox check_0,value = 0 
     176                                CheckBox check_1,value = 1 
     177                                val = DimSize(data, 0) -1 
     178                        endif 
     179                         
     180                        SetVariable setvar0,limits={0,val,1} 
     181                        NVAR gVal = root:Packages:NIST:VSANS:Globals:gMaskTube 
     182                        NVAR gMax = root:Packages:NIST:VSANS:Globals:gMaskMaxIndex 
     183                        gMax = val 
     184                        if(gVal > val) 
     185                                gVal = val 
     186                        endif 
     187                         
     188                        break 
     189                case -1: // control being killed 
     190                        break 
     191        endswitch 
     192 
     193        return 0 
     194End 
     195 
     196Function MaskWindowHook(s) 
     197        STRUCT WMWinHookStruct &s 
     198         
     199        Variable hookResult = 0 // 0 if we do not handle event, 1 if we handle it. 
     200         
     201        String message = "" 
     202 
     203        switch(s.eventCode) 
     204                case 11:        // Keyboard event 
     205//                      String keyCodeInfo 
     206//                      sprintf keyCodeInfo, "s.keycode = 0x%04X", s.keycode 
     207//                      if (strlen(message) > 0) 
     208//                              message += "\r" 
     209//                      endif 
     210//                      message +=keyCodeInfo 
     211// 
     212//                      message += "\r" 
     213//                      String specialKeyCodeInfo 
     214//                      sprintf specialKeyCodeInfo, "s.specialKeyCode = %d", s.specialKeyCode 
     215//                      message +=specialKeyCodeInfo 
     216//                      message += "\r" 
     217// 
     218//                      String keyTextInfo 
     219//                      sprintf keyTextInfo, "s.keyText = \"%s\"", s.keyText 
     220//                      message +=keyTextInfo 
     221// 
     222//                      String text = "\\Z24" + message 
     223//                      Textbox /C/N=Message/W=KeyboardEventsGraph/A=MT/X=0/Y=15 text 
     224 
     225                // TODO:  this is all Igor-7 ONLY 
     226 
     227// Note that I need to keep track of the index value since I'm intercepting the  
     228// SetVariable event here. I need to keep the index in range.            
     229                        STRUCT WMButtonAction ba 
     230                        ba.eventCode = 2 
     231                        NVAR tubeVal = root:Packages:NIST:VSANS:Globals:gMaskTube 
     232                        if(s.specialKeyCode == 100) 
     233                                //left arrow 
     234                                tubeVal -= 1 
     235                        endif 
     236                        if(s.specialKeyCode == 101) 
     237                                //right arrow 
     238                                tubeVal += 1 
     239                        endif 
     240                        if(s.specialKeyCode == 102) 
     241                                //up arrow 
     242                                AddToMaskButtonProc(ba) 
     243                        endif 
     244                        if(s.specialKeyCode == 103) 
     245                                //down arrow 
     246                                RemoveFromMaskButtonProc(ba) 
     247                        endif 
     248 
     249// enforce the limits on the setvar 
     250                        NVAR gMax = root:Packages:NIST:VSANS:Globals:gMaskMaxIndex 
     251                        if(tubeVal > gMax) 
     252                                tubeVal = gMax 
     253                        endif 
     254                        if(tubeVal < 0) 
     255                                tubeVal = 0 
     256                        endif 
     257                         
     258// draw the "currentTube" every time 
     259                        ControlInfo popup_0 
     260                        String str=S_Value 
     261                        wave currentTube = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+str+":currentTube") 
     262 
     263                        // update so that the proper row is displayed on the currentTube 
     264                        currentTube = 0 
     265                         
     266                        ControlInfo check_0             // is it row? 
     267                        Variable isRow = V_value 
     268                        if(isRow) 
     269                                currentTube[][tubeVal] = 1                       
     270                        else 
     271                                currentTube[tubeVal][] = 1 
     272                        endif            
     273 
     274 
     275                        hookResult = 1  // We handled keystroke 
     276                        break 
     277        endswitch 
     278         
     279        return hookResult               // If non-zero, we handled event and Igor will ignore it. 
     280End 
    94281 
    95282Function ToggleMaskButtonProc(ba) : ButtonControl 
     
    130317                         
    131318                        Variable val 
    132                         ControlInfo setvar0 
     319                        ControlInfo setvar0             //get the tube number 
    133320                        val = V_Value 
    134                         maskData[val][] = 1 
     321                         
     322                        ControlInfo check_0             // is it row? 
     323                        Variable isRow = V_value 
     324                        if(isRow) 
     325                                maskData[][val] = 1                      
     326                        else 
     327                                maskData[val][] = 1 
     328                        endif 
    135329                         
    136330                        V_OverlayMask(str,1) 
    137331                         
    138 //                      Print "add tube to mask" 
    139332                        break 
    140333                case -1: // control being killed 
     
    157350                         
    158351                        Variable val 
    159                         ControlInfo setvar0 
     352                        ControlInfo setvar0 // get the tube number 
    160353                        val = V_Value 
    161                         maskData[val][] = 0 
    162                          
    163                         V_OverlayMask(str,1)                     
    164 //                      Print "remove tube from mask" 
     354                         
     355                        ControlInfo check_0             // is it row? 
     356                        Variable isRow = V_value 
     357                        if(isRow) 
     358                                maskData[][val] = 0                      
     359                        else 
     360                                maskData[val][] = 0 
     361                        endif 
     362                         
     363                        V_OverlayMask(str,1)     
     364                                         
    165365                        break 
    166366                case -1: // control being killed 
     
    202402                        //overlay the mask 
    203403                        V_OverlayMask(popStr,1) 
    204 //                      OverlayMaskPanel(popStr) 
    205                          
     404 
    206405                        break 
    207406                case -1: // control being killed 
     
    215414// SEE DrawDetPanel() in the BeamCenter file 
    216415// 
    217 // TODO - currently is hard-wired for the simulation path! 
    218 //     need to make it more generic, especially for RAW data 
     416// TODO 
     417// x- currently is hard-wired for the simulation path!   need to make it more generic, especially for RAW data 
    219418// 
    220419// -- need to adjust the size of the image subwindows to keep the model 
     
    238437 
    239438         
    240         Wave dispW=root:curDispPanel 
     439//      Wave dispW=root:curDispPanel 
    241440 
    242441        //plot it in the subwindow with the proper aspect and positioning 
     
    351550// 
    352551// TODO 
    353 // -- make it work 
    354 // -- remove the old mask first 
    355 // -- make the mask "toggle" to remove it 
    356 // -- go see SANS for color, implementation, etc. 
    357 // -- un-comment the (two) calls 
     552// x- remove the old mask first 
     553// x- make the mask "toggle" to remove it 
     554// x- go see SANS for color, implementation, etc. 
     555// x- un-comment the (two) calls 
    358556// 
    359557// 
     
    362560// 
    363561// if state==1, show the mask, if ==0, hide the mask 
     562// 
     563//** This assumes that if the overlay is/not present on the image display, then the currentTiube is also there/not 
     564// and is not checked 
     565// 
    364566Function V_OverlayMask(str,state) 
    365567        String str 
     
    375577                        Duplicate/O maskW $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+str+":overlay") 
    376578                        wave overlay = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+str+":overlay") 
    377          
    378                         Redimension/D overlay 
    379                         SetScale/P x 0,1, overlay 
    380                         SetScale/P y 0,1, overlay 
     579                        Duplicate/O maskW $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+str+":currentTube") 
     580                        wave currentTube = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+str+":currentTube") 
     581 
     582                        Redimension/D overlay,currentTube 
     583                        SetScale/P x 0,1, overlay,currentTube 
     584                        SetScale/P y 0,1, overlay,currentTube 
    381585                 
    382                         String tempStr = "root:Packages:NIST:MSK:overlay" 
    383         //              overlay = (maskW == 1) ? 1 : NaN                        //no need to do this - simply adjust the coloring 
    384          
     586                        //              overlay = (maskW == 1) ? 1 : NaN                        //no need to do this - simply adjust the coloring 
     587 
     588                        // update so that the proper row is displayed on the currentTube 
     589                        currentTube = 0 
     590                                                 
     591                        Variable val 
     592                        ControlInfo setvar0             //get the tube number 
     593                        val = V_Value 
     594                         
     595                        ControlInfo check_0             // is it row? 
     596                        Variable isRow = V_value 
     597                        if(isRow) 
     598                                currentTube[][val] = 1                   
     599                        else 
     600                                currentTube[val][] = 1 
     601                        endif                    
     602                                 
    385603                        CheckDisplayed/W=MaskEditPanel#DetData overlay 
    386604                        if(V_flag==0)           //so the overlay doesn't get appended more than once 
    387605                                AppendImage/W=MaskEditPanel#DetData overlay 
     606                                AppendImage/W=MaskEditPanel#DetData currentTube 
    388607                                ModifyImage/W=MaskEditPanel#DetData overlay ctab= {0.9,1,BlueRedGreen,0}        ,minRGB=NaN,maxRGB=0 
     608                                ModifyImage/W=MaskEditPanel#DetData currentTube ctab= {0.9,1,CyanMagenta,0}     ,minRGB=NaN,maxRGB=0 
    389609                //              ModifyImage/W=MaskEditPanel#DetData overlay ctab= {0,*,BlueRedGreen,0}   
    390610                        endif 
     
    393613                if(state == 0) 
    394614                        wave overlay = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+str+":overlay") 
     615                        wave currentTube = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+str+":currentTube") 
     616 
    395617                        CheckDisplayed/W=MaskEditPanel#DetData overlay 
    396618//                      Print "V_flag = ",V_flag 
     
    398620                        If(V_Flag == 1)         //overlay is present 
    399621                                RemoveImage/W=MaskEditPanel#DetData overlay 
     622                                RemoveImage/W=MaskEditPanel#DetData currentTube 
    400623                        endif 
    401624                endif 
     
    538761        Save_VSANS_file("root:VSANS_MASK_file", fileName+".h5") 
    539762         
    540         // read in a data file using the gateway-- reads from the home path 
    541         H_HDF5Gate_Read_Raw(fileName+".h5") 
    542          
    543         // after reading in a "partial" file using the gateway (to generate the xref) 
    544         // Save the xref to disk (for later use) 
    545         Save_HDF5___xref("root:"+fileName,"HDF5___xref") 
    546          
    547         // after you've generated the HDF5___xref, load it in and copy it 
    548         // to the necessary folder location. 
    549         Copy_HDF5___xref("root:VSANS_MASK_file", "HDF5___xref") 
    550          
    551         // writes out the contents of a data folder using the gateway 
    552         H_HDF5Gate_Write_Raw("root:VSANS_MASK_file", fileName+".h5") 
    553  
    554         // re-load the data file using the gateway-- reads from the home path 
    555         // now with attributes 
    556         H_HDF5Gate_Read_Raw(fileName+".h5") 
    557          
    558 End 
     763//      // read in a data file using the gateway-- reads from the home path 
     764//      H_HDF5Gate_Read_Raw(fileName+".h5") 
     765//       
     766//      // after reading in a "partial" file using the gateway (to generate the xref) 
     767//      // Save the xref to disk (for later use) 
     768//      Save_HDF5___xref("root:"+fileName,"HDF5___xref") 
     769//       
     770//      // after you've generated the HDF5___xref, load it in and copy it 
     771//      // to the necessary folder location. 
     772//      Copy_HDF5___xref("root:VSANS_MASK_file", "HDF5___xref") 
     773//       
     774//      // writes out the contents of a data folder using the gateway 
     775//      H_HDF5Gate_Write_Raw("root:VSANS_MASK_file", fileName+".h5") 
     776// 
     777//      // re-load the data file using the gateway-- reads from the home path 
     778//      // now with attributes 
     779//      H_HDF5Gate_Read_Raw(fileName+".h5") 
     780         
     781End 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Utilities_General.ipf

    r994 r1002  
    108108        return(err) 
    109109end 
     110 
     111// TODO: 
     112// -- this still does not quite work. If there are no sub folders present in the RawVSANS folder 
     113//    it still thinks there are (1) item there. 
     114// -- if I replace the semicolon with a comma, it thinks there are two folders present and appears 
     115//    to delete the RawVSANS folder itself! seems very dangerous...this is because DataFolderDir returns 
     116//    a comma delimited list, but with a semicolon and \r at the end. need to remove these... 
     117Function V_CleanOutRawVSANS() 
     118 
     119        SetDataFolder root:Packages:NIST:VSANS:RawVSANS: 
     120         
     121        // get a list of the data folders there 
     122        // kill them all if possible 
     123        String list,item 
     124        Variable numFolders,ii,pt 
     125         
     126        list = DataFolderDir(1) 
     127        // this has FOLDERS: at the beginning and is comma-delimited 
     128        list = list[8,strlen(list)] 
     129        pt = strsearch(list,";",inf,1) 
     130        list = list[0,pt-1]                     //remove the ";\r" from the end of the string 
     131//      print list 
     132         
     133        numFolders = ItemsInList(list , ",") 
     134//      Print List 
     135//      print strlen(list) 
     136 
     137        for(ii=0;ii<numFolders;ii+=1) 
     138                item = StringFromList(ii, list ,",") 
     139//              Print item 
     140                KillDataFolder/Z $(item) 
     141        endfor 
     142 
     143        list = DataFolderDir(1) 
     144        list = list[8,strlen(list)] 
     145        pt = strsearch(list,";",inf,1) 
     146        list = list[0,pt-1] 
     147        numFolders = ItemsInList(list, ",") 
     148        Printf "%g RawVSANS folders could not be killed\r",numFolders 
     149                 
     150        SetDataFolder root: 
     151        return(0) 
     152End 
    110153 
    111154//given a filename of a SANS data filename of the form 
     
    313356// -1 => previous file 
    314357// 1 => next file 
     358// 
     359// V_CheckIfRawData(fname) 
     360// 
    315361Function/S V_GetPrevNextRawFile(curfilename, prevnext) 
    316362        String curfilename 
     
    337383//run number "num". The null string is returned if no valid file can be found 
    338384//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  
     385//the file returned will be a RAW VSANS data file, other types of files are  
    340386//filtered out. 
    341387// 
     
    399445                                        isRAW = V_CheckIfRawData(fullName) 
    400446                                        if(isRaw) 
     447                                                //print "is raw, ",fullname 
    401448                                                //stop here 
    402449                                                return(fullname) 
     
    411458 
    412459// 
    413 // TODO -- for VSANS Nexus files, how do I quickly identify if a file is 
     460// TODO x- for VSANS Nexus files, how do I quickly identify if a file is 
    414461//   RAW VSANS data? I don't want to generate any errors, but I want to quickly 
    415462//   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 // 
     463//      (check the instrument name...) 
     464 
    427465// TODO -- as was written by SANS, this function is expecting fname to be the path:fileName 
    428466// - but are the V_get() functions OK with getting a full path, and what do they 
     
    436474         
    437475        testStr = V_getInstrumentName(fname) 
    438          
    439         if(cmpstr(testStr,"") != 0) 
     476 
     477        if(cmpstr(testStr,"NG3-VSANS") == 0) 
     478                //testStr exists, ASSUMING it's a raw VSANS data file 
     479                Return(1) 
     480        else 
     481                //some other file 
     482                Return(0) 
     483        Endif 
     484End 
     485 
     486// TODO -- need to fill in correctly by determining this from the INTENT field 
     487// 
     488Function V_isTransFile(fname) 
     489        String fname 
     490         
     491        Variable refnum,totalBytes 
     492        String testStr="" 
     493         
     494//      testStr = V_getInstrumentName(fname) 
     495 
     496        if(cmpstr(testStr,"NG3-VSANS") == 0)            //wrong test 
    440497                //testStr exists, ASSUMING it's a raw VSANS data file 
    441498                Return(1) 
     
    638695                 
    639696End 
     697 
     698// returns a list of raw data files in the catPathName directory on disk 
     699// - list is SEMICOLON-delimited 
     700// 
     701// TODO: decide how to do this... 
     702// (1) 
     703// checks each file in the directory to see if it is a RAW data file by 
     704// call to V_CheckIfRawData() which currently looks for the instrument name in the file. 
     705// -- CON - this is excruciatingly slow, and by checking a field in the file, has to load in the  
     706//  ENTIRE data file, and will load EVERY file in the folder. ugh. 
     707// 
     708// (2) 
     709// as was done for VAX files, look for a specific string in the file name as written by the acquisition 
     710//  (was .saN), now key on ".nxs.ngv"? 
     711// 
     712// called by PatchFiles.ipf, Tile_2D.ipf 
     713// 
     714Function/S V_GetRawDataFileList() 
     715         
     716        //make sure that path exists 
     717        PathInfo catPathName 
     718        if (V_flag == 0) 
     719                Abort "Folder path does not exist - use Pick Path button on Main Panel" 
     720        Endif 
     721        String path = S_Path 
     722         
     723        String list=IndexedFile(catPathName,-1,"????") 
     724        String newList="",item="",validName="",fullName="" 
     725        Variable num=ItemsInList(list,";"),ii 
     726         
     727        for(ii=0;ii<num;ii+=1) 
     728                item = StringFromList(ii, list  ,";") 
     729 
     730                validName = V_FindValidFileName(item) 
     731                if(strlen(validName) != 0)              //non-null return from FindValidFileName() 
     732                        fullName = path + validName              
     733 
     734        //method (1)                     
     735//                      if(V_CheckIfRawData(item)) 
     736//                              newlist += item + ";" 
     737//                      endif 
     738 
     739        //method (2)                     
     740                        if( stringmatch(item,"*.nxs.ngv*") ) 
     741                                newlist += item + ";" 
     742                        endif 
     743 
     744                         
     745                endif 
     746                //print "ii=",ii 
     747        endfor 
     748        newList = SortList(newList,";",0) 
     749        return(newList) 
     750End 
     751 
     752 
     753//the following is a WaveMetrics procedure from <StrMatchList> 
     754// MatchList(matchStr,list,sep) 
     755// Returns the items of the list whose items match matchStr 
     756// The lists are separated by the sep character, usually ";" 
     757// 
     758// matchStr may be something like "abc", in which case it is identical to CmpStr 
     759// matchStr may also be "*" to match anything, "abc*" to match anything starting with "abc", 
     760//      "*abc" to match anything ending with "abc". 
     761// matchStr may also begin with "!" to indicate a match to anything not matching the rest of 
     762//      the pattern. 
     763// At most one "*" and one "!" are allowed in matchStr, otherwise the results are not guaranteed. 
     764// 
     765Function/S V_MyMatchList(matchStr,list,sep) 
     766        String matchStr,list,sep 
     767        String item,outList="" 
     768        Variable n=strlen(list) 
     769        Variable en,st=0 
     770        do 
     771                en= strsearch(list,sep,st) 
     772                if( en < 0 ) 
     773                        if( st < n-1 ) 
     774                                en= n   // no trailing separator 
     775                                sep=""  // don't put sep in output, either 
     776                        else 
     777                                break   // no more items in list 
     778                        endif 
     779                endif 
     780                item=list[st,en-1] 
     781                if( V_MyStrMatch(matchStr,item) == 0 ) 
     782                        outlist += item+sep 
     783                Endif 
     784                st=en+1  
     785        while (st < n ) // exit is by break, above 
     786        return outlist 
     787End 
     788 
     789//the following is a WaveMetrics procedure from <StrMatchList> 
     790// StrMatch(matchStr,str) 
     791// Returns 0 if the pattern in matchStr matches str, else it returns 1 
     792// 
     793// matchStr may be something like "abc", in which case it is identical to CmpStr 
     794// matchStr may also be "*" to match anything, "abc*" to match anything starting with "abc", 
     795//      "*abc" to match anything ending with "abc". 
     796// matchStr may also begin with "!" to indicate a match to anything not matching the rest of 
     797//      the pattern. 
     798// At most one "*" and one "!" are allowed in matchStr, otherwise the results are not guaranteed. 
     799// 
     800Function V_MyStrMatch(matchStr,str) 
     801        String matchStr,str 
     802        Variable match = 1              // 0 means match 
     803        Variable invert= strsearch(matchStr,"!",0) == 0 
     804        if( invert ) 
     805                matchStr[0,0]=""        // remove the "!" 
     806        endif 
     807        Variable st=0,en=strlen(str)-1 
     808        Variable starPos= strsearch(matchStr,"*",0) 
     809        if( starPos >= 0 )      // have a star 
     810                if( starPos == 0 )      // at start 
     811                        matchStr[0,0]=""                                // remove star at start 
     812                else                                    // at end 
     813                        matchStr[starPos,999999]=""     // remove star and rest of (ignored, illegal) pattern 
     814                endif 
     815                Variable len=strlen(matchStr) 
     816                if( len > 0 ) 
     817                        if(starPos == 0)        // star at start, match must be at end 
     818                                st=en-len+1 
     819                        else 
     820                                en=len-1        // star at end, match at start 
     821                        endif 
     822                else 
     823                        str=""  // so that "*" matches anything 
     824                endif 
     825        endif 
     826        match= !CmpStr(matchStr,str[st,en])==0  // 1 or 0 
     827        if( invert ) 
     828                match= 1-match 
     829        endif 
     830        return match 
     831End 
     832 
     833 
     834//input is a list of run numbers, and output is a list of filenames (not the full path) 
     835//*** input list must be COMMA delimited*** 
     836//output is equivalent to selecting from the CAT table 
     837//if some or all of the list items are valid filenames, keep them... 
     838//if an error is encountered, notify of the offending element and return a null list 
     839// 
     840//output is COMMA delimited 
     841// 
     842// this routine is expecting that the "ask", "none" special cases are handled elsewhere 
     843//and not passed here 
     844// 
     845// called by Marquee.ipf, MultipleReduce.ipf, ProtocolAsPanel.ipf 
     846// 
     847Function/S ParseRunNumberList(list) 
     848        String list 
     849         
     850        String newList="",item="",tempStr="" 
     851        Variable num,ii,runNum 
     852         
     853        //expand number ranges, if any 
     854        list = V_ExpandNumRanges(list) 
     855         
     856        num=itemsinlist(list,",") 
     857         
     858        for(ii=0;ii<num;ii+=1) 
     859                //get the item 
     860                item = StringFromList(ii,list,",") 
     861                //is it already a valid filename? 
     862                tempStr=V_FindValidFilename(item) //returns filename if good, null if error 
     863                if(strlen(tempstr)!=0) 
     864                        //valid name, add to list 
     865                        //Print "it's a file" 
     866                        newList += tempStr + "," 
     867                else 
     868                        //not a valid name 
     869                        //is it a number? 
     870                        runNum=str2num(item) 
     871                        //print runnum 
     872                        if(numtype(runNum) != 0) 
     873                                //not a number -  maybe an error                         
     874                                DoAlert 0,"List item "+item+" is not a valid run number or filename. Please enter a valid number or filename." 
     875                                return("") 
     876                        else 
     877                                //a run number or an error 
     878                                tempStr = V_GetFileNameFromPathNoSemi( V_FindFileFromRunNumber(runNum) ) 
     879                                if(strlen(tempstr)==0) 
     880                                        //file not found, error 
     881                                        DoAlert 0,"List item "+item+" is not a valid run number. Please enter a valid number." 
     882                                        return("") 
     883                                else 
     884                                        newList += tempStr + "," 
     885                                endif 
     886                        endif 
     887                endif 
     888        endfor          //loop over all items in list 
     889         
     890        return(newList) 
     891End 
     892 
     893//takes a comma delimited list that MAY contain number range, and 
     894//expands any range of run numbers into a comma-delimited list... 
     895//and returns the new list - if not a range, return unchanged 
     896// 
     897// local function 
     898// 
     899Function/S V_ExpandNumRanges(list) 
     900        String list 
     901         
     902        String newList="",dash="-",item,str 
     903        Variable num,ii,hasDash 
     904         
     905        num=itemsinlist(list,",") 
     906//      print num 
     907        for(ii=0;ii<num;ii+=1) 
     908                //get the item 
     909                item = StringFromList(ii,list,",") 
     910                //does it contain a dash? 
     911                hasDash = strsearch(item,dash,0)                //-1 if no dash found 
     912                if(hasDash == -1) 
     913                        //not a range, keep it in the list 
     914                        newList += item + "," 
     915                else 
     916                        //has a dash (so it's a range), expand (or add null) 
     917                        newList += V_ListFromDash(item)          
     918                endif 
     919        endfor 
     920         
     921        return newList 
     922End 
     923 
     924//be sure to add a trailing comma to the return string... 
     925// 
     926// local function 
     927// 
     928Function/S V_ListFromDash(item) 
     929        String item 
     930         
     931        String numList="",loStr="",hiStr="" 
     932        Variable lo,hi,ii 
     933         
     934        loStr=StringFromList(0,item,"-")        //treat the range as a list 
     935        hiStr=StringFromList(1,item,"-") 
     936        lo=str2num(loStr) 
     937        hi=str2num(hiStr) 
     938        if( (numtype(lo) != 0) || (numtype(hi) !=0 ) || (lo > hi) ) 
     939                numList="" 
     940                return numList 
     941        endif 
     942        for(ii=lo;ii<=hi;ii+=1) 
     943                numList += num2str(ii) + "," 
     944        endfor 
     945         
     946        Return numList 
     947End 
     948 
Note: See TracChangeset for help on using the changeset viewer.