Changeset 976 for sans/Dev/trunk/NCNR_User_Procedures
- Timestamp:
- Jan 29, 2016 3:59:18 PM (7 years ago)
- Location:
- sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_RW_Utils.ipf
r972 r976 24 24 25 25 // passing null file string presents a dialog 26 MacroRead_HDF5_Raw_No_Attributes()27 V_LoadHDF5Data("" )26 Proc Read_HDF5_Raw_No_Attributes() 27 V_LoadHDF5Data("","RAW") 28 28 End 29 29 … … 31 31 // x- move the initializtion of the raw data folder to be in the as-yet unwritten initialization routine for 32 32 // reduction. be sure that it's duplicated in the VCALC initialization too. 33 // 34 Function V_LoadHDF5Data(file) 35 String file 36 37 SetDataFolder root:Packages:NIST:VSANS:RawVSANS 33 // -- as needed, get rid of the FAKE redimension of the data from 3D->2D and from 128x128 to something else for VSANS 34 // This is a fake since I don't have anything close to correct fake data yet. (1/29/16) 35 // 36 Function V_LoadHDF5Data(file,folder) 37 String file,folder 38 39 String base_name 40 SetDataFolder $("root:Packages:NIST:VSANS:"+folder) 38 41 // SetDataFolder root: 39 Variable err= V_LoadHDF5_NoAtt(file) // reads into current folder 42 if(cmpstr(folder,"RAW")==0) 43 base_name="entry" 44 else 45 base_name="" 46 endif 47 48 Variable err= V_LoadHDF5_NoAtt(file,base_name) // reads into current folder 49 50 // if RAW data, then generate the errors and linear data copy 51 // do this 9x 52 string tmpStr = "root:Packages:NIST:VSANS:RAW:entry:entry:instrument:" 53 if(cmpstr(folder,"RAW")==0) 54 V_MakeDataError(tmpStr+"detector_B") 55 V_MakeDataError(tmpStr+"detector_MB") 56 V_MakeDataError(tmpStr+"detector_MT") 57 V_MakeDataError(tmpStr+"detector_ML") 58 V_MakeDataError(tmpStr+"detector_MR") 59 V_MakeDataError(tmpStr+"detector_FB") 60 V_MakeDataError(tmpStr+"detector_FT") 61 V_MakeDataError(tmpStr+"detector_FL") 62 V_MakeDataError(tmpStr+"detector_FR") 63 64 // TODO -- once I get "real" data, get rid of this call to force the data to be proper dimensions. 65 V_RedimFakeData() 66 67 /// END FAKE DATA CORRECTIONS 68 69 endif 70 40 71 SetDataFolder root: 41 72 return(err) 73 End 74 75 // 76 // TODO -- this is all FAKED since all the data arrays are (1,128,128) 77 // I'm intentionally using the wrong number of pixels so I'm more likely to go back and get rid of this later. 78 // 79 // the SetScale parts may be useful later. 80 // 81 Function V_RedimFakeData() 82 83 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_B 84 Wave det_B=data 85 Redimension/N=(300,300)/E=1 det_B 86 87 Variable ctr=20,npix=100 88 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_MT 89 Wave det_MT=data 90 Redimension/N=(npix,48)/E=1 det_MT 91 SetScale/I x -npix/2,npix/2,"",det_MT 92 SetScale/I y ctr,ctr+48,"",det_MT 93 94 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_MB 95 Wave det_MB=data 96 Redimension/N=(npix,48)/E=1 det_MB 97 SetScale/I x -npix/2,npix/2,"",det_MB 98 SetScale/I y -ctr,-ctr-48,"",det_MB 99 100 ctr=30 101 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_ML 102 Wave det_ML=data 103 Redimension/N=(48,npix)/E=1 det_ML 104 SetScale/I x -ctr-48,-ctr,"",det_ML 105 SetScale/I y -npix/2,npix/2,"",det_ML 106 107 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_MR 108 Wave det_MR=data 109 Redimension/N=(48,npix)/E=1 det_MR 110 SetScale/I x ctr,ctr+48,"",det_MR 111 SetScale/I y -npix/2,npix/2,"",det_MR 112 113 ctr=30 114 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_FT 115 Wave det_FT=data 116 Redimension/N=(npix,48)/E=1 det_FT 117 SetScale/I x -npix/2,npix/2,"",det_FT 118 SetScale/I y ctr,ctr+48,"",det_FT 119 120 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_FB 121 Wave det_FB=data 122 Redimension/N=(npix,48)/E=1 det_FB 123 SetScale/I x -npix/2,npix/2,"",det_FB 124 SetScale/I y -ctr,-ctr-48,"",det_FB 125 126 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_FL 127 Wave det_FL=data 128 Redimension/N=(48,npix)/E=1 det_FL 129 SetScale/I x -ctr-48,-ctr,"",det_FL 130 SetScale/I y -npix/2,npix/2,"",det_FL 131 132 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_FR 133 Wave det_FR=data 134 Redimension/N=(48,npix)/E=1 det_FR 135 SetScale/I x ctr,ctr+48,"",det_FR 136 SetScale/I y -npix/2,npix/2,"",det_FR 137 138 139 return(0) 42 140 End 43 141 … … 51 149 // -- get rid of bits leftover here that I don't need 52 150 // -- be sure I'm using all of the correct flags in the HDF5LoadGroup operation 53 // 54 Function V_LoadHDF5_NoAtt(fileName, [hdf5Path]) 55 String fileName, hdf5Path 56 if ( ParamIsDefault(hdf5Path) ) 57 hdf5Path = "/" 58 endif 59 151 // -- settle on how the base_name is to be used. "entry" for the RAW, fileName for the "rawVSANS"? 152 // 153 // passing in "" for base_name will take the name from the file name as selected 154 // 155 Function V_LoadHDF5_NoAtt(fileName,base_name) 156 String fileName, base_name 157 158 // if ( ParamIsDefault(hdf5Path) ) 159 // hdf5Path = "/" 160 // endif 161 162 String hdf5path = "/" //always read from the top 60 163 String status = "" 61 164 … … 78 181 79 182 SVAR tmpStr=root:file_name 80 fileName=tmpStr //SRK - in case the file was chosen from a dialog 183 fileName=tmpStr //SRK - in case the file was chosen from a dialog, I'll need access to the name later 81 184 82 185 // read the data (too bad that HDF5LoadGroup does not read the attributes) 83 String base_name = StringFromList(0,FileName,".") 186 if(cmpstr(base_name,"") == 0) 187 base_name = StringFromList(0,FileName,".") 188 endif 189 //base_name = "entry" 190 84 191 HDF5LoadGroup/Z/L=7/O/R/T=$base_name :, fileID, hdf5Path // recursive 85 192 if ( V_Flag != 0 ) … … 118 225 if(!valExists) 119 226 //then read in the file 120 V_LoadHDF5_NoAtt(fname )227 V_LoadHDF5_NoAtt(fname,"") 121 228 endif 122 229 … … 155 262 if(!valExists) 156 263 //then read in the file 157 V_LoadHDF5_NoAtt(fname )264 V_LoadHDF5_NoAtt(fname,"") 158 265 endif 159 266 … … 189 296 if(!valExists) 190 297 //then read in the file 191 V_LoadHDF5_NoAtt(fname )298 V_LoadHDF5_NoAtt(fname,"") 192 299 endif 193 300 … … 249 356 if(!valExists) 250 357 //then read in the file 251 V_LoadHDF5_NoAtt(fname )358 V_LoadHDF5_NoAtt(fname,"") 252 359 endif 253 360 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_MainPanel.ipf
r975 r976 48 48 End 49 49 50 51 // this will only load the data into RAW, overwriting whatever is there. no copy is put in rawVSANS 52 // 50 53 Proc DisplayMainButtonProc(ctrlName) : ButtonControl 51 54 String ctrlName 52 55 53 Variable err= V_LoadHDF5Data("" ) // load the data into RawVSANS storage folder (why am I doing this?)56 Variable err= V_LoadHDF5Data("","RAW") // load the data into RawVSANS storage folder (why am I doing this?) 54 57 if(!err) 55 58 String hdfDF = root:file_name // last file loaded, may not be the safest way to pass 56 CopyHDFToWorkFolder(hdfDF,"RAW") // copy what is needed for data processing (not the DAS_logs)59 String folder = StringFromList(0,hdfDF,".") 57 60 58 61 // this (in SANS) just passes directly to fRawWindowHook() -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Test_RAW_Panel.ipf
r975 r976 5 5 6 6 7 Proc UpdateDisplayInformation(type) 8 String type 9 10 DoWindow VSANS_Data 11 if(V_flag==0) 12 VSANS_DataPanel() //draws the panel 13 endif 14 15 // update the information here - in either case 16 17 end 7 18 8 19 20 Window VSANS_DataPanel() :Panel 21 PauseUpdate; Silent 1 // building window... 22 NewPanel /W=(37,45,1042,784) /N=VSANS_Data 23 ShowTools/A 24 25 SetDrawLayer UserBack 26 SetDrawEnv linethick= 2,dash= 1,fillpat= 0 27 DrawRect 200,140,310,230 28 SetDrawEnv linethick= 2,dash= 1,fillpat= 0 29 DrawRect 320,140,430,230 30 SetDrawEnv linethick= 2,dash= 1,fillpat= 0 31 DrawRect 440,140,550,230 32 33 SetDrawEnv fsize= 18 34 DrawText 230,185,"Front" 35 SetDrawEnv fsize= 18 36 DrawText 348,185,"Middle" 37 SetDrawEnv fsize= 18 38 DrawText 476,185,"Back" 39 40 ToolsGrid visible=1 9 41 10 Window VSANS_Data() : Panel11 PauseUpdate; Silent 1 // building window...12 NewPanel /W=(37,45,1042,784)13 ShowTools/A14 42 TabControl tab0,pos={13,111},size={572,617},proc=VDataTabProc,tabLabel(0)="Front" 15 43 TabControl tab0,tabLabel(1)="Middle",tabLabel(2)="Back",value= 2 … … 20 48 Button button0_4,pos={622,247},size={140,20} 21 49 Button button0_5,pos={772,247},size={140,20} 50 51 // for back panels (in pixels?) 52 Display/W=(50,239,546,710)/HOST=# root:Packages:NIST:VSANS:VCALC:fv_degY vs root:Packages:NIST:VSANS:VCALC:fv_degX 53 RenameWindow #,det_panelsB 54 ModifyGraph mode=2 // mode = 2 = dots 55 ModifyGraph marker=19 56 ModifyGraph rgb=(0,0,0) 57 ModifyGraph tick=2,mirror=1 58 Label left "pixels" 59 Label bottom "pixels" 60 SetActiveSubwindow ## 61 62 // for middle panels (in pixels?) 63 Display/W=(50,239,546,710)/HOST=# root:Packages:NIST:VSANS:VCALC:fv_degY vs root:Packages:NIST:VSANS:VCALC:fv_degX 64 RenameWindow #,det_panelsM 65 ModifyGraph mode=2 // mode = 2 = dots 66 ModifyGraph marker=19 67 ModifyGraph rgb=(0,0,0) 68 ModifyGraph tick=2,mirror=1 69 Label left "pixels" 70 Label bottom "pixels" 71 SetActiveSubwindow ## 72 73 // for front panels (in pixels?) 74 Display/W=(50,239,546,710)/HOST=# root:Packages:NIST:VSANS:VCALC:fv_degY vs root:Packages:NIST:VSANS:VCALC:fv_degX 75 RenameWindow #,det_panelsF 76 ModifyGraph mode=2 // mode = 2 = dots 77 ModifyGraph marker=19 78 ModifyGraph rgb=(0,0,0) 79 ModifyGraph tick=2,mirror=1 80 Label left "pixels" 81 Label bottom "pixels" 82 SetActiveSubwindow ## 83 22 84 EndMacro 23 85 24 86 25 87 // 88 //lots to to here: 89 // 90 // - 1 - display the appropriate controls for each tab, and hide the others 91 // - 2 - display the correct detector data for each tab, and remove the others from the graph 92 // -----?? can I draw 3 graphs, and just put the right one on top?? move the other two to the side? 93 // 94 // 95 // TODO 96 // -- add all of the controls of the VCALC panel (log scaling, adjusting the axes, etc.) 97 // -- get the panel to be correctly populated first, rather than needing to click everywhere to fill in 26 98 Function VDataTabProc(tca) : TabControl 27 99 STRUCT WMTabControlAction &tca … … 30 102 case 2: // mouse up 31 103 Variable tab = tca.tab 104 105 SetDataFolder root:Packages:NIST:VSANS:VCALC 106 RemoveFromGraph/Z /W=VSANS_Data#det_panelsB fv_degY 107 RemoveFromGraph/Z /W=VSANS_Data#det_panelsM fv_degY 108 RemoveFromGraph/Z /W=VSANS_Data#det_panelsF fv_degY 109 SetDataFolder root: 110 111 if(tab==2) 112 //SetDataFolder root:Packages:NIST:VSANS:VCALC:Back 113 //Wave det_B 114 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_B 115 Wave det_B=data 116 CheckDisplayed /W=VSANS_Data#det_panelsB det_B 117 if(V_flag == 0) 118 AppendImage/W=VSANS_Data#det_panelsB det_B 119 // ModifyImage/W=VSANS_Data#det_panelsB det_B ctab= {*,*,ColdWarm,0} 120 ModifyImage/W=VSANS_Data#det_panelsB ''#0 ctab= {*,*,ColdWarm,0} 121 endif 122 MoveSubWindow/W=VSANS_Data#det_panelsB fnum=(50,239,546,710) 123 MoveSubWindow/W=VSANS_Data#det_panelsM fnum=(320,140,430,230) 124 MoveSubWindow/W=VSANS_Data#det_panelsF fnum=(200,140,310,230) 125 SetDataFolder root: 126 endif 127 128 if(tab==1) 129 //SetDataFolder root:Packages:NIST:VSANS:VCALC:Middle 130 //Wave det_MR,det_ML,det_MB,det_MT 131 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_ML 132 Wave det_ML=data 133 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_MR 134 Wave det_MR=data 135 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_MT 136 Wave det_MT=data 137 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_MB 138 Wave det_MB=data 139 CheckDisplayed /W=VSANS_Data#det_panelsM det_MR 140 if(V_flag == 0) 141 AppendImage/W=VSANS_Data#det_panelsM det_MT //order is important here to get LR on "top" of display 142 AppendImage/W=VSANS_Data#det_panelsM det_MB 143 AppendImage/W=VSANS_Data#det_panelsM det_ML 144 AppendImage/W=VSANS_Data#det_panelsM det_MR 145 // ModifyImage/W=VSANS_Data#det_panelsM det_MT ctab= {*,*,ColdWarm,0} 146 // ModifyImage/W=VSANS_Data#det_panelsM det_MB ctab= {*,*,ColdWarm,0} 147 // ModifyImage/W=VSANS_Data#det_panelsM det_ML ctab= {*,*,ColdWarm,0} 148 // ModifyImage/W=VSANS_Data#det_panelsM det_MR ctab= {*,*,ColdWarm,0} 149 ModifyImage/W=VSANS_Data#det_panelsM ''#0 ctab= {*,*,ColdWarm,0} // ''#n means act on the nth image (there are 4) 150 ModifyImage/W=VSANS_Data#det_panelsM ''#1 ctab= {*,*,ColdWarm,0} 151 ModifyImage/W=VSANS_Data#det_panelsM ''#2 ctab= {*,*,ColdWarm,0} 152 ModifyImage/W=VSANS_Data#det_panelsM ''#3 ctab= {*,*,ColdWarm,0} 153 endif 154 MoveSubWindow/W=VSANS_Data#det_panelsM fnum=(50,239,546,710) 155 MoveSubWindow/W=VSANS_Data#det_panelsB fnum=(440,140,550,230) 156 MoveSubWindow/W=VSANS_Data#det_panelsF fnum=(200,140,310,230) 157 SetDataFolder root: 158 endif 159 160 if(tab==0) 161 //SetDataFolder root:Packages:NIST:VSANS:VCALC:Front 162 //Wave det_FL,det_FR,det_FT,det_FB 163 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_FL 164 Wave det_FL=data 165 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_FR 166 Wave det_FR=data 167 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_FT 168 Wave det_FT=data 169 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_FB 170 Wave det_FB=data 171 CheckDisplayed /W=VSANS_Data#det_panelsF det_FL 172 if(V_flag == 0) 173 AppendImage/W=VSANS_Data#det_panelsF det_FB 174 AppendImage/W=VSANS_Data#det_panelsF det_FT 175 AppendImage/W=VSANS_Data#det_panelsF det_FL 176 AppendImage/W=VSANS_Data#det_panelsF det_FR 177 // ModifyImage/W=VSANS_Data#det_panelsF det_FB ctab= {*,*,ColdWarm,0} 178 // ModifyImage/W=VSANS_Data#det_panelsF det_FT ctab= {*,*,ColdWarm,0} 179 // ModifyImage/W=VSANS_Data#det_panelsF det_FL ctab= {*,*,ColdWarm,0} 180 // ModifyImage/W=VSANS_Data#det_panelsF det_FR ctab= {*,*,ColdWarm,0} 181 ModifyImage/W=VSANS_Data#det_panelsF ''#0 ctab= {*,*,ColdWarm,0} 182 ModifyImage/W=VSANS_Data#det_panelsF ''#1 ctab= {*,*,ColdWarm,0} 183 ModifyImage/W=VSANS_Data#det_panelsF ''#2 ctab= {*,*,ColdWarm,0} 184 ModifyImage/W=VSANS_Data#det_panelsF ''#3 ctab= {*,*,ColdWarm,0} 185 endif 186 MoveSubWindow/W=VSANS_Data#det_panelsF fnum=(50,239,546,710) 187 MoveSubWindow/W=VSANS_Data#det_panelsB fnum=(440,140,550,230) 188 MoveSubWindow/W=VSANS_Data#det_panelsM fnum=(320,140,430,230) 189 SetDataFolder root: 190 endif 191 192 32 193 break 33 194 case -1: // control being killed -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_WorkFolderUtils.ipf
r975 r976 7 7 // 8 8 9 // TODO: write function 10 // KillVANSObjects() //Kills (/Z) the list of objects that I generate 11 // !! but I must maintain the list 12 // 13 9 10 11 // 12 //Entry procedure from main panel 13 // 14 Proc CopyWorkFolder(oldType,newType) 15 String oldType,newType 16 Prompt oldType,"Source WORK data type",popup,"SAM;EMP;BGD;DIV;COR;CAL;RAW;ABS;STO;SUB;DRK;" 17 Prompt newType,"Destination WORK data type",popup,"SAM;EMP;BGD;DIV;COR;CAL;RAW;ABS;STO;SUB;DRK;" 18 // Prompt oldType,"Source WORK data type",popup,"AAA;BBB;CCC;DDD;EEE;FFF;GGG;" 19 // Prompt newType,"Destination WORK data type",popup,"AAA;BBB;CCC;DDD;EEE;FFF;GGG;" 20 21 // data folder "old" will be copied to "new" (and will overwrite) 22 CopyHDFToWorkFolder(oldtype,newtype) 23 End 14 24 15 25 // … … 35 45 // type is the destination WORK folder for the copy 36 46 // 37 Function CopyHDFToWorkFolder(hdfDF,type) 38 String hdfDF,type 39 40 // Printf "CopyHDFToWorkFolder(%s,%s) stub\r",hdfDF,type 41 42 String loadedDF,fromDF, toDF 43 // clean up the hdfDF to get a proper DF (same method as in file loader) 44 loadedDF = StringFromList(0,hdfDF,".") 47 Function CopyHDFToWorkFolder(fromStr,toStr) 48 String fromStr,toStr 49 50 String fromDF, toDF 45 51 46 52 // make the DF paths - source and destination 47 fromDF = "root:Packages:NIST:VSANS:RawVSANS:"+loadedDF+":entry" 48 toDF = "root:Packages:NIST:VSANS:"+type+":entry" 53 fromDF = "root:Packages:NIST:VSANS:"+fromStr 54 toDF = "root:Packages:NIST:VSANS:"+toStr 55 56 // // make a copy of the file name for my own use, since it's not in the file 57 // String/G $(toDF+":file_name") = root: 58 49 59 // copy the folders 50 60 KillDataFolder/Z toDF //DuplicateDataFolder will not overwrite, so Kill 51 // this will fail if something was in use 52 DuplicateDataFolder $fromDF,$toDF 53 54 // make a copy of the file name for my own use, since it's not in the file 55 String/G $(toDF+":file_name") = hdfDF 56 57 // ***need to copy folders: 58 // control 59 // instrument 60 // reduction 61 // sample 62 63 64 65 KillDataFolder/Z toDF+":control" 66 Print V_flag 67 // if not OK, need to duplicate/O 68 69 70 71 // ***what about the variables @ the top level? 72 // data directory, identifiers, etc.? 73 74 // ***I can skip (or delete) 75 // DAS_logs 76 // top-level copies of data (duplicate links) 77 KillDataFolder/Z $(toDF+":DAS_logs") 78 KillDataFolder/Z $(toDF+":data") 79 KillDataFolder/Z $(toDF+":data_B") 80 KillDataFolder/Z $(toDF+":data_ML") 81 KillDataFolder/Z $(toDF+":data_MR") 82 KillDataFolder/Z $(toDF+":data_MT") 83 KillDataFolder/Z $(toDF+":data_MB") 84 KillDataFolder/Z $(toDF+":data_FL") 85 KillDataFolder/Z $(toDF+":data_FR") 86 KillDataFolder/Z $(toDF+":data_FT") 87 KillDataFolder/Z $(toDF+":data_FB") 88 61 62 if(V_flag == 0) // kill DF was OK 63 DuplicateDataFolder $fromDF,$toDF 64 65 // I can delete these if they came along with RAW 66 // DAS_logs 67 // top-level copies of data (duplicate links) 68 KillDataFolder/Z $(toDF+":entry:entry:DAS_logs") 69 KillDataFolder/Z $(toDF+":entry:entry:data") 70 KillDataFolder/Z $(toDF+":entry:entry:data_B") 71 KillDataFolder/Z $(toDF+":entry:entry:data_ML") 72 KillDataFolder/Z $(toDF+":entry:entry:data_MR") 73 KillDataFolder/Z $(toDF+":entry:entry:data_MT") 74 KillDataFolder/Z $(toDF+":entry:entry:data_MB") 75 KillDataFolder/Z $(toDF+":entry:entry:data_FL") 76 KillDataFolder/Z $(toDF+":entry:entry:data_FR") 77 KillDataFolder/Z $(toDF+":entry:entry:data_FT") 78 KillDataFolder/Z $(toDF+":entry:entry:data_FB") 79 80 return(0) 81 else 82 // need to do this the hard way, duplicate/O recursively 83 // see V_CopyToWorkFolder() 84 85 // everything on the top level 86 V_DuplicateDataFolder($(toDF+":entry:entry"),fromStr,toStr,0,"",0) //no recursion here 87 // control 88 V_DuplicateDataFolder($(toDF+":entry:entry:control"),fromStr,toStr,0,"",1) //yes recursion here 89 // instrument 90 V_DuplicateDataFolder($(toDF+":entry:entry:instrument"),fromStr,toStr,0,"",1) //yes recursion here 91 // reduction 92 V_DuplicateDataFolder($(toDF+":entry:entry:reduction"),fromStr,toStr,0,"",1) //yes recursion here 93 // sample 94 V_DuplicateDataFolder($(toDF+":entry:entry:sample"),fromStr,toStr,0,"",1) //yes recursion here 95 96 endif 89 97 90 98 return(0) … … 92 100 93 101 94 95 // 96 // copy from one local WORK folder to another 97 // does NO rescaling of the data or any other modifications to data 98 // 99 // TODO -- do I need to do more to clean out the destination folder first? 100 // 101 // CopyWorkToWorkFolder("RAW","EMP") 102 // 103 Function CopyWorkToWorkFolder(fromDF,toDF) 104 String fromDF,toDF 105 106 // Printf "CopyWorkToWorkFolder(%s,%s) stub\r",fromDF,toDF 107 108 109 // make the DF paths - source and destination 110 fromDF = "root:Packages:NIST:VSANS:"+fromDF+":entry" 111 toDF = "root:Packages:NIST:VSANS:"+toDF+":entry" 112 // copy the folders 113 KillDataFolder/Z toDF //DuplicateDataFolder will not overwrite, so Kill 114 DuplicateDataFolder $fromDF,$toDF 115 102 //////// 103 // see the help entry for IndexedDir for help on (possibly) how to do this faster 104 // -- see the function Function ScanDirectories(pathName, printDirNames) 105 // 106 107 108 // from IgorExchange On July 17th, 2011 jtigor 109 // started from "Recursively List Data Folder Contents" 110 // Posted July 15th, 2011 by hrodstein 111 // 112 // 113 // 114 Proc V_CopyToWorkFolder(dataFolderStr, fromStr, toStr, level, sNBName, recurse) 115 String dataFolderStr="root:Packages:NIST:VSANS:RAW" 116 String fromStr = "RAW" 117 String toStr="SAM" 118 Variable level=0 119 String sNBName="DataFolderTree" 120 Variable recurse = 1 121 122 V_DuplicateDataFolder($dataFolderStr, fromStr, toStr, level, sNBName, recurse) 123 124 125 end 126 127 // ListDataFolder(dfr, level) 128 // Recursively lists objects in data folder. 129 // Pass data folder path for dfr and 0 for level. 130 // pass level == 0 for the first call 131 // sNBName = "" prints nothing. any name will generate a notebook 132 // 133 // recurse == 0 will do only the specified folder, anything else will recurse all levels 134 // toStr is the string name of the top-level folder only, not the full path 135 // 136 // 137 Function V_DuplicateDataFolder(dfr, fromStr, toStr, level, sNBName,recurse) 138 DFREF dfr 139 String fromStr 140 String toStr 141 Variable level // Pass 0 to start 142 String sNBName 143 Variable recurse 144 145 String name 146 String dfName 147 String sString 148 149 String toDF = "" 150 151 if (level == 0) // this is the data folder, generate if needed in the destination 152 name = GetDataFolder(1, dfr) 153 // sPrintf sString, "%s (data folder)\r", name 154 toDF = ReplaceString(fromStr,name,toStr,1) // case-sensitive replace 155 sprintf sString, "NewDataFolder/O %s\r",toDF 156 NewDataFolder/O $(RemoveEnding(toDF,":")) // remove trailing semicolon if it's there 157 158 V_WriteBrowserInfo(sString, 1, sNBName) 159 endif 160 161 dfName = GetDataFolder(1, dfr) 162 toDF = ReplaceString(fromStr,dfName,toStr,1) // case-sensitive replace 163 Variable i 164 165 String indentStr = "\t" 166 for(i=0; i<level; i+=1) 167 indentStr += "\t" 168 endfor 169 170 Variable numWaves = CountObjectsDFR(dfr, 1) 171 for(i=0; i<numWaves; i+=1) 172 name = GetIndexedObjNameDFR(dfr, 1, i) 173 // 174 // wave type does not matter now. Duplicate does not care 175 // 176 sPrintf sString, "Duplicate/O %s, %s\r",dfName+name,toDF+name 177 Duplicate/O $(dfName+name),$(toDF+name) 178 179 V_WriteBrowserInfo(sString, 2, sNBName) 180 endfor 181 182 Variable numNumericVariables = CountObjectsDFR(dfr, 2) 183 for(i=0; i<numNumericVariables; i+=1) 184 name = GetIndexedObjNameDFR(dfr, 2, i) 185 sPrintf sString, "%s%s (numeric variable)\r", indentStr, name 186 V_WriteBrowserInfo(sString, 3, sNBName) 187 endfor 188 189 Variable numStringVariables = CountObjectsDFR(dfr, 3) 190 for(i=0; i<numStringVariables; i+=1) 191 name = GetIndexedObjNameDFR(dfr, 3, i) 192 sPrintf sString, "%s%s (string variable)\r", indentStr, name 193 V_WriteBrowserInfo(sString, 4, sNBName) 194 endfor 195 196 if(recurse) 197 Variable numDataFolders = CountObjectsDFR(dfr, 4) 198 for(i=0; i<numDataFolders; i+=1) 199 name = GetIndexedObjNameDFR(dfr, 4, i) 200 // sPrintf sString, "%s%s (data folder)\r", indentStr, name 201 dfName = GetDataFolder(1, dfr) 202 203 toDF = ReplaceString(fromStr,dfName,toStr,1) // case-sensitive replace 204 sprintf sString, "NewDataFolder/O %s\r",toDF+name 205 NewDataFolder/O $(toDF+name) 206 207 208 V_WriteBrowserInfo(sString, 1, sNBName) 209 DFREF childDFR = dfr:$(name) 210 V_DuplicateDataFolder(childDFR, fromStr, toStr, level+1, sNBName, recurse) 211 endfor 212 endif 213 214 //when finished walking tree, save as RTF with dialog 215 // if(level == 0 && strlen(sNBName) != 0) 216 // SaveNotebook /I /S=4 $sNBName 217 // endif 218 End 219 220 Function V_WriteBrowserInfo(sString, vType, sNBName) 221 String sString 222 Variable vType 223 String sNBName 224 225 if(strlen(sNBName) == 0) 226 // print sString 227 return 0 228 endif 229 DoWindow $sNBName 230 if(V_flag != 1) 231 NewNoteBook/F=0 /N=$sNBName /V=1 as sNBName 232 else 233 DoWindow/F $sNBName 234 endif 235 Notebook $sNBName selection={endOfFile, endOfFile} 236 if(vType == 1) // a data folder 237 // Notebook $sNBName fstyle=1 238 Notebook $sNBName text=sString 239 // Notebook $sNBName fstyle=-1 240 else 241 Notebook $sNBName text=sString 242 endif 243 244 End 245 246 /////////////////////////////// 247 248 249 // given the folder, duplicate the data -> linear_data and generate the error 250 Function V_MakeDataError(folderStr) 251 String folderStr 252 253 SetDataFolder $folderStr 254 Wave data=data 255 Duplicate/O data linear_data // at this point, the data is still the raw data, and is linear_data 256 257 // proper error for counting statistics, good for low count values too 258 // rather than just sqrt(n) 259 // see N. Gehrels, Astrophys. J., 303 (1986) 336-346, equation (7) 260 // for S = 1 in eq (7), this corresponds to one sigma error bars 261 Duplicate/O linear_data linear_data_error 262 linear_data_error = 1 + sqrt(linear_data + 0.75) 263 // 264 265 SetDataFolder root: 116 266 return(0) 117 end267 End
Note: See TracChangeset
for help on using the changeset viewer.