- Timestamp:
- Jun 17, 2016 11:43:46 AM (7 years ago)
- 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 222 222 Save_VSANS_file("root:VSANS_DIV_file", fileName+".h5") 223 223 224 // read in a data file using the gateway-- reads from the home path225 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 it232 // 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 gateway236 H_HDF5Gate_Write_Raw("root:VSANS_DIV_file", fileName+".h5")237 238 // re-load the data file using the gateway-- reads from the home path239 // now with attributes240 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") 241 241 242 242 End -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VSANS_Includes.ipf
r999 r1002 62 62 #include "V_MaskUtils" 63 63 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 31 31 End 32 32 33 // Moved to V_MaskUtils.ipf 33 34 // passing null file string presents a dialog 34 Proc LoadFakeMASKData()35 V_LoadHDF5Data("","MSK")36 End35 //Proc LoadFakeMASKData() 36 // V_LoadHDF5Data("","MSK") 37 //End 37 38 38 39 // passing null file string presents a dialog … … 45 46 // x- move the initialization of the raw data folder to be in the as-yet unwritten initialization routine for 46 47 // 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 VSANS48 // x- as needed, get rid of the FAKE redimension of the data from 3D->2D and from 128x128 to something else for VSANS 48 49 // This is a fake since I don't have anything close to correct fake data yet. (1/29/16) 49 50 // … … 177 178 // This is NOT CALLED anymore. 178 179 // the rescaling (SetScale) of the data sets is still done separately to a "fake" beam center 179 Function V_RedimFakeData()180 Function xV_RedimFakeData() 180 181 181 182 // check for fake data in VCALC folder... -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_IQ_Utilities.ipf
r999 r1002 99 99 100 100 101 MacroV_Combine1DData()101 Proc V_Combine1DData() 102 102 103 103 // get the current display type … … 107 107 108 108 // 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 109 112 110 113 // 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: 111 118 V_1DConcatenate(type) 112 119 … … 125 132 String/G saveName=str 126 133 End 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... 138 Function 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) 155 end 127 156 128 157 … … 136 165 // although waves may exist, they may not be the right ones to use. There 137 166 // will be a somewhat complex selection process 138 // -- detector B is currently skipped167 // x- detector B is currently skipped 139 168 // 140 169 // this seems like a lot of extra work to do something so simple... … … 207 236 // Duplicate/O tmp_res3 $("root:"+folder2+":res3") 208 237 238 // Can't kill here, since they are still needed to sort and write out! 209 239 // KillWaves/Z tmp_q,tmp_i,tmp_s,tmp_res0,tmp_res1,tmp_res2,tmp_res3 210 240 … … 215 245 216 246 // TODO: 217 // -- resolution waves are ignored 247 // -- resolution waves are ignored, since they don't exist (yet) 218 248 // -- only a sort is done, no rescaling of data sets 219 249 // (it's too late now anyways, since the data was concatenated … … 241 271 242 272 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 // 246 283 // 247 284 Function V_Trim1DData(folderStr,nEnd) -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Initialize.ipf
r999 r1002 333 333 return isDemo 334 334 End 335 336 // Clean out the RawVSANS folder before saving 337 Function 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 347 End -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_MainPanel.ipf
r1000 r1002 74 74 String ctrlName 75 75 76 PatchFiles()76 V_PatchFiles() 77 77 End 78 78 … … 165 165 End 166 166 167 // on Misc Ops tab, generates a notebook168 Proc CatShort_MainButtonProc(ctrlName) : ButtonControl169 String ctrlName170 171 BuildCatShortNotebook()172 End167 ////on Misc Ops tab, generates a notebook 168 //Proc CatShort_MainButtonProc(ctrlName) : ButtonControl 169 // String ctrlName 170 // 171 // BuildCatShortNotebook() 172 //End 173 173 174 174 //button is labeled "File Catalog" … … 176 176 String ctrlName 177 177 178 //BuildCatVeryShortNotebook() 179 BuildCatVeryShortTable() 178 V_BuildCatVeryShortTable() 179 End 180 181 Proc CatSort_MainButtonProc(ctrlName) : ButtonControl 182 String ctrlName 183 184 Catalog_Sort() 180 185 End 181 186 … … 337 342 Button MainButton_0d,pos={15,180},size={130,20},proc=RealTime_MainButtonProc,title="RealTime Display" 338 343 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 339 348 340 349 //on tab(1) - Reduction … … 407 416 Button MainButton_4c,pos={15,150},size={80,20},proc=ShowAvePanel_MainButtonProc,title="Average" 408 417 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"} 411 420 Button MainButton_4e,pos={180,90},size={130,20},proc=NG1TransConv_MainButtonProc,title="NG1 Files to Trans" 412 421 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 2 2 #pragma rtGlobals=3 // Use modern global access method and strict wave access. 3 3 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" 29 Proc LoadFakeMASKData() 30 V_LoadHDF5Data("","MSK") 31 End 32 33 34 35 //// DRAWING/SAVING 36 // 5 37 // TODO: 6 38 // x- CHANGE the mask behavior to a more logical choice - and consistent with SANS … … 11 43 12 44 13 // also,move the mask generating utilities from VC_HDF5_Utils into this procedure - to keep45 // x- move the mask generating utilities from VC_HDF5_Utils into this procedure - to keep 14 46 // all of the mask procedures together 15 47 16 48 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... 20 57 21 58 22 59 //TODO 23 // -- draw a mask24 // -- save a mask (all panels)25 // -- be able to save the mask name to the file26 // -- be able to read a mask based on what is in the data file60 // 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 27 64 // 28 65 // x- biggest thing now is to re-write the DrawDetPanel() routine from the beamCenter.ipf 29 66 // to do what this panel needs 30 67 // 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. 33 69 // 34 70 // -- for working with VCALC -- maybe have an automatic generator (if val < -2e6, mask = 0) … … 38 74 // routines need to be aware of this 39 75 40 Macro Edit_a_Mask() 76 77 78 // called from the main button "Draw Mask" 79 Proc Edit_a_Mask() 41 80 V_EditMask() 42 81 end … … 45 84 DoWindow/F MaskEditPanel 46 85 if(V_flag==0) 86 Variable/G root:Packages:NIST:VSANS:Globals:gMaskTube = 0 87 Variable/G root:Packages:NIST:VSANS:Globals:gMaskMaxIndex = 47 47 88 Execute "MaskEditorPanel()" 48 89 endif … … 52 93 // TODO - may need to adjust the display for the different pixel dimensions 53 94 // ModifyGraph width={Plan,1,bottom,left} 95 // 96 // TODO -- need buttons for: 97 // -- quit 98 // -- help (button is there, fill in the content) 54 99 // 55 100 Proc MaskEditorPanel() : Panel … … 64 109 PopupMenu popup_2,mode=1,popvalue="RAW",value= #"\"RAW;SAM;VCALC;\"" 65 110 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 83 124 84 125 // draw the correct images … … 88 129 // overlay the current mask 89 130 V_OverlayMask("FT",1) 90 // OverlayMaskPanel("FL")91 131 92 132 EndMacro 93 133 134 Function 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 147 End 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 // 154 Function 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 194 End 195 196 Function 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. 280 End 94 281 95 282 Function ToggleMaskButtonProc(ba) : ButtonControl … … 130 317 131 318 Variable val 132 ControlInfo setvar0 319 ControlInfo setvar0 //get the tube number 133 320 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 135 329 136 330 V_OverlayMask(str,1) 137 331 138 // Print "add tube to mask"139 332 break 140 333 case -1: // control being killed … … 157 350 158 351 Variable val 159 ControlInfo setvar0 352 ControlInfo setvar0 // get the tube number 160 353 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 165 365 break 166 366 case -1: // control being killed … … 202 402 //overlay the mask 203 403 V_OverlayMask(popStr,1) 204 // OverlayMaskPanel(popStr) 205 404 206 405 break 207 406 case -1: // control being killed … … 215 414 // SEE DrawDetPanel() in the BeamCenter file 216 415 // 217 // TODO - currently is hard-wired for the simulation path!218 // 416 // TODO 417 // x- currently is hard-wired for the simulation path! need to make it more generic, especially for RAW data 219 418 // 220 419 // -- need to adjust the size of the image subwindows to keep the model … … 238 437 239 438 240 Wave dispW=root:curDispPanel439 // Wave dispW=root:curDispPanel 241 440 242 441 //plot it in the subwindow with the proper aspect and positioning … … 351 550 // 352 551 // 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 358 556 // 359 557 // … … 362 560 // 363 561 // 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 // 364 566 Function V_OverlayMask(str,state) 365 567 String str … … 375 577 Duplicate/O maskW $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+str+":overlay") 376 578 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 381 585 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 385 603 CheckDisplayed/W=MaskEditPanel#DetData overlay 386 604 if(V_flag==0) //so the overlay doesn't get appended more than once 387 605 AppendImage/W=MaskEditPanel#DetData overlay 606 AppendImage/W=MaskEditPanel#DetData currentTube 388 607 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 389 609 // ModifyImage/W=MaskEditPanel#DetData overlay ctab= {0,*,BlueRedGreen,0} 390 610 endif … … 393 613 if(state == 0) 394 614 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 395 617 CheckDisplayed/W=MaskEditPanel#DetData overlay 396 618 // Print "V_flag = ",V_flag … … 398 620 If(V_Flag == 1) //overlay is present 399 621 RemoveImage/W=MaskEditPanel#DetData overlay 622 RemoveImage/W=MaskEditPanel#DetData currentTube 400 623 endif 401 624 endif … … 538 761 Save_VSANS_file("root:VSANS_MASK_file", fileName+".h5") 539 762 540 // read in a data file using the gateway-- reads from the home path541 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 it548 // 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 gateway552 H_HDF5Gate_Write_Raw("root:VSANS_MASK_file", fileName+".h5")553 554 // re-load the data file using the gateway-- reads from the home path555 // now with attributes556 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 781 End -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Utilities_General.ipf
r994 r1002 108 108 return(err) 109 109 end 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... 117 Function 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) 152 End 110 153 111 154 //given a filename of a SANS data filename of the form … … 313 356 // -1 => previous file 314 357 // 1 => next file 358 // 359 // V_CheckIfRawData(fname) 360 // 315 361 Function/S V_GetPrevNextRawFile(curfilename, prevnext) 316 362 String curfilename … … 337 383 //run number "num". The null string is returned if no valid file can be found 338 384 //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 are385 //the file returned will be a RAW VSANS data file, other types of files are 340 386 //filtered out. 341 387 // … … 399 445 isRAW = V_CheckIfRawData(fullName) 400 446 if(isRaw) 447 //print "is raw, ",fullname 401 448 //stop here 402 449 return(fullname) … … 411 458 412 459 // 413 // TODO -- for VSANS Nexus files, how do I quickly identify if a file is460 // TODO x- for VSANS Nexus files, how do I quickly identify if a file is 414 461 // RAW VSANS data? I don't want to generate any errors, but I want to quickly 415 462 // 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 427 465 // TODO -- as was written by SANS, this function is expecting fname to be the path:fileName 428 466 // - but are the V_get() functions OK with getting a full path, and what do they … … 436 474 437 475 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 484 End 485 486 // TODO -- need to fill in correctly by determining this from the INTENT field 487 // 488 Function 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 440 497 //testStr exists, ASSUMING it's a raw VSANS data file 441 498 Return(1) … … 638 695 639 696 End 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 // 714 Function/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) 750 End 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 // 765 Function/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 787 End 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 // 800 Function 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 831 End 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 // 847 Function/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) 891 End 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 // 899 Function/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 922 End 923 924 //be sure to add a trailing comma to the return string... 925 // 926 // local function 927 // 928 Function/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 947 End 948
Note: See TracChangeset
for help on using the changeset viewer.