Changeset 764
- Timestamp:
- Nov 24, 2010 4:23:13 PM (11 years ago)
- Location:
- sans/Dev/trunk/NCNR_User_Procedures
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Analysis/Packages/GeneticOptimization/NCNR_GenFitUtils.ipf
r705 r764 29 29 // X add the XOP to the distribution, or instructions (better to NOT bundle...) 30 30 // X odd bug where first "fit" fails on AppendToGraph as GenCurveFit is started. May need to disable /D flag 31 // 32 // -- need to pass back the chi-squared and number of points. "V_" globals don't appear 31 // X- need to pass back the chi-squared and number of points. "V_" globals don't appear 32 // -- add the flags to calculate the residuals (/R), and then manually append the residual wave to the graph. 33 // 33 34 // 34 35 // for the speed test. try writing my own wrapper for an unsmeared calculation, and see if it's still dog-slow. … … 258 259 // other useful flags: /N /DUMP /TOL /D=fitYw 259 260 // /OPT=1 seems to make no difference whether it's used or not 261 // /N does not speed anything up at all, and you get no feedback 262 // /R does work, generating "res_" wave, but the append must be "manual" 260 263 261 264 // append the fit … … 285 288 endif 286 289 if(useRes) 287 GenCurveFit/MAT /STRC=bar /X=bar.x[0] /I=1 /TOL=(kGenOp_tol) /W=sw /D=fitYw GeneticFit_SmearedModel,bar.y,bar.w,holdStr,limits290 GenCurveFit/MAT /STRC=bar /X=bar.x[0] /I=1 /TOL=(kGenOp_tol) /W=sw /D=fitYw /R GeneticFit_SmearedModel,bar.y,bar.w,holdStr,limits 288 291 break 289 292 endif -
sans/Dev/trunk/NCNR_User_Procedures/Analysis/Packages/Wrapper_v40.ipf
r762 r764 1060 1060 1061 1061 //if GenCurveFit used, V_startRow and V_endRow may not exist - so read the cursors? but the cursors may not be used, so 1062 // there won't be anything on the graph... 1062 // there won't be anything on the graph... but pt1 and pt2 are set and passed!. The V_ variables are more foolproof 1063 // so keep these for the "normal" report 1063 1064 // 1064 W_GenerateReport(funcStr,folderStr,$parStr,cw,yesSave,V_chisq,W_sigma,V_npnts,V_FitError,V_FitQuitReason,V_startRow,V_endRow,topGraph) 1065 if(useGenCurveFit) 1066 W_GenerateReport(funcStr,folderStr,$parStr,cw,yesSave,V_chisq,W_sigma,V_npnts,V_FitError,V_FitQuitReason,pt1,pt2,topGraph) 1067 else 1068 W_GenerateReport(funcStr,folderStr,$parStr,cw,yesSave,V_chisq,W_sigma,V_npnts,V_FitError,V_FitQuitReason,V_startRow,V_endRow,topGraph) 1069 endif 1065 1070 endif 1066 1071 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/AvgGraphics.ipf
r757 r764 159 159 QxQy_Export(type,"",1) 160 160 break 161 case "Sector_PlusMinus": 162 Sector_PlusMinus1D(type) 163 If(doSave) 164 if (useXMLOutput == 1) 165 WriteXMLWaves_W_Protocol(type,"",1) 166 else 167 WriteWaves_W_Protocol(type,"",1) //"" is an empty path, 1 will force a dialog 168 endif 169 Endif 170 break 161 171 default: 162 172 Abort "no case match in average dispatch" … … 174 184 String/G root:myGlobals:Protocols:gProtoStr = "" 175 185 Endif 176 177 186 178 187 return(0) … … 226 235 case "Circular": 227 236 case "Sector": 237 case "Sector_PlusMinus": 228 238 case "Rectangular": 229 239 case "Annular": … … 258 268 break 259 269 case "Sector": 270 case "Sector_PlusMinus": 260 271 SetVariable Phi_p,disable=no 261 272 SetVariable Qctr_p,disable=yes … … 301 312 PopupMenu av_choice,pos={61,7},size={144,20},proc=AvTypePopMenuProc,title="AverageType" 302 313 PopupMenu av_choice,help={"Select the type of average to perform, then make the required selections below and click \"DoAverage\" to plot the results"} 303 PopupMenu av_choice,mode=1,popvalue="Circular",value= #"\"Circular;Sector;Annular;Rectangular;2D ASCII;QxQy ASCII \""314 PopupMenu av_choice,mode=1,popvalue="Circular",value= #"\"Circular;Sector;Annular;Rectangular;2D ASCII;QxQy ASCII;Sector_PlusMinus;\"" 304 315 Button ave_help,pos={260,7},size={25,20},proc=ShowAvePanelHelp,title="?" 305 316 Button ave_help,help={"Show the help file for averaging options"} … … 446 457 //else sector or rectangular - draw the lines 447 458 448 //if sector or rectangular, draw the phi line (on the desired side)449 if( (cmpstr(av_type,"Sector")==0) || (cmpstr(av_type,"Rectangular")==0) )459 //if sector, sector_plusminus, or rectangular, draw the phi line (on the desired side) 460 if( (cmpstr(av_type,"Sector")==0) || (cmpstr(av_type,"Rectangular")==0) || (cmpstr(av_type,"Sector_PlusMinus")==0)) 450 461 if( (cmpstr(side,"left")==0) || (cmpstr(side,"both")==0) ) 451 462 //draw the phi line on the left side … … 467 478 468 479 //if Sector, draw the +/- dphi lines 469 if (cmpstr(av_type,"Sector")==0 )480 if (cmpstr(av_type,"Sector")==0 || cmpstr(av_type,"Sector_PlusMinus")==0) 470 481 if( (cmpstr(side,"left")==0) || (cmpstr(side,"both")==0) ) 471 482 //draw the deltaPhi lines +/- lines -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/Buttons.ipf
r683 r764 189 189 190 190 LoadPlotAndDisplayRAW(-1) 191 // re-draw the sectors or annulus if this was a step to prev/next raw file 192 MasterAngleDraw() 191 193 192 194 return(0) … … 199 201 200 202 LoadPlotAndDisplayRAW(1) 203 // re-draw the sectors or annulus if this was a step to prev/next raw file 204 MasterAngleDraw() 201 205 202 206 return (0) … … 206 210 //file is read from disk, if path is set and the file number is present 207 211 //increment +1, adds 1 to run number, -1 subtracts one 212 // 213 // will automatically step a gap of 10 run numbers, but nothing larger. Don't want to loop too long 214 // trying to find a file (frustrating), don't want to look past the end of the run numbers (waste) 215 // -- may find a more elegant solution later. 216 // 208 217 Function LoadPlotAndDisplayRAW(increment) 209 218 Variable increment 210 219 211 Variable i 212 String filename 220 Variable i,val 221 String filename,tmp 213 222 //take the currently displayed RAW file (there is only one name in fileList) 214 223 SVAR oldName = root:Packages:NIST:RAW:fileList 224 oldname = RemoveAllSpaces(oldname) // the name in the file list will have 21 chars, thus leading spaces if prefix < 5 chars 215 225 216 226 // print oldName 217 227 218 228 filename = oldname 219 for (i = 0; i < abs(increment); i += 1) 220 filename = GetPrevNextRawFile(filename,increment/abs(increment)) 221 endfor 222 229 // for (i = 0; i < abs(increment); i += 1) 230 // filename = GetPrevNextRawFile(filename,increment/abs(increment)) 231 // endfor 232 i = 1 233 val = increment 234 do 235 // print filename,val 236 filename = GetPrevNextRawFile(filename,val) 237 // print "new= ",filename 238 239 val = i*increment 240 i+=1 241 tmp = ParseFilePath(0, filename, ":", 1, 0) 242 243 // print val,strlen(tmp),strlen(oldname) 244 // print cmpstr(tmp,oldname) 245 246 if(strlen(tmp) == 0) //in some cases, a null string can be returned - handle gracefully 247 return(0) 248 endif 249 250 while( (cmpstr(tmp,oldname) == 0) && i < 11) 223 251 // print filename 224 252 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/CircSectAve.ipf
r665 r764 494 494 Return 0 495 495 End 496 497 498 499 #pragma rtGlobals=1 // Use modern global access method. 500 501 502 // -- seems to work, now I need to give it a name, add it to the list, and 503 // make sure I've thought of all of the cases - then the average can be passed as case "Sector_PlusMinus" 504 // and run through the normal average and writing routines. 505 // 506 // 507 // -- depending on what value PHI has - it's [-90,90] "left" and "right" may not be what 508 // you expect. so sorting the concatenated values may be necessary (always) 509 // 510 // -- need documentation of the definition of PHI, left, and right so that it can make better sense 511 // which quadrants of the detector become "negative" depending on the choice of phi. may need a 512 // switch after a little thinking. 513 // 514 // may want a variation of this where both sides are done, in separate files. but I think that's already 515 // called a "sector" average. save them. load them. plot them. 516 // 517 // 518 Function Sector_PlusMinus1D(type) 519 String type 520 521 // do the left side (-) 522 // then hold that data in tmp_ waves 523 // then do the right (+) 524 // then concatenate the data 525 526 // the button on the pink panel copies the two strings so they're the same 527 SVAR keyListStr = root:myGlobals:Protocols:gAvgInfoStr //this is the list that has it all 528 529 String oldStr = "" 530 String CurPath="root:myGlobals:Plot_1D:" 531 String destPath = "root:Packages:NIST:"+type+":" 532 533 oldStr = StringByKey("SIDE",keyListStr,"=",";") 534 535 // do the left first, and call it negative 536 keyListStr = ReplaceStringByKey("SIDE",keyListStr,"left","=",";") 537 538 CircularAverageTo1D(type) 539 540 WAVE qval = $(destPath + "qval") 541 WAVE aveint = $(destPath + "aveint") 542 WAVE sigave = $(destPath + "sigave") 543 WAVE qbar = $(destPath + "QBar") 544 WAVE sigmaq = $(destPath + "SigmaQ") 545 WAVE fsubs = $(destPath + "fSubS") 546 547 // copy the average, set the q's negative 548 qval *= -1 549 Duplicate/O qval $(destPath+"tmp_q") 550 Duplicate/O aveint $(destPath+"tmp_i") 551 Duplicate/O sigave $(destPath+"tmp_s") 552 Duplicate/O qbar $(destPath+"tmp_qb") 553 Duplicate/O sigmaq $(destPath+"tmp_sq") 554 Duplicate/O fsubs $(destPath+"tmp_fs") 555 556 557 // do the right side 558 keyListStr = ReplaceStringByKey("SIDE",keyListStr,"right","=",";") 559 560 CircularAverageTo1D(type) 561 562 // concatenate 563 WAVE tmp_q = $(destPath + "tmp_q") 564 WAVE tmp_i = $(destPath + "tmp_i") 565 WAVE tmp_s = $(destPath + "tmp_s") 566 WAVE tmp_qb = $(destPath + "tmp_qb") 567 WAVE tmp_sq = $(destPath + "tmp_sq") 568 WAVE tmp_fs = $(destPath + "tmp_fs") 569 570 SetDataFolder destPath //to get the concatenation in the right folder 571 Concatenate/NP/O {tmp_q,qval},tmp_cat 572 Duplicate/O tmp_cat qval 573 Concatenate/NP/O {tmp_i,aveint},tmp_cat 574 Duplicate/O tmp_cat aveint 575 Concatenate/NP/O {tmp_s,sigave},tmp_cat 576 Duplicate/O tmp_cat sigave 577 Concatenate/NP/O {tmp_qb,qbar},tmp_cat 578 Duplicate/O tmp_cat qbar 579 Concatenate/NP/O {tmp_sq,sigmaq},tmp_cat 580 Duplicate/O tmp_cat sigmaq 581 Concatenate/NP/O {tmp_fs,fsubs},tmp_cat 582 Duplicate/O tmp_cat fsubs 583 584 // then sort 585 Sort qval, qval,aveint,sigave,qbar,sigmaq,fsubs 586 587 // move these to the Plot_1D folder for plotting 588 Duplicate/O qval $(curPath+"xAxisWave") 589 Duplicate/O aveint $(curPath+"yAxisWave") 590 Duplicate/O sigave $(curPath+"yErrWave") 591 592 keyListStr = ReplaceStringByKey("SIDE",keyListStr,oldStr,"=",";") 593 594 DoUpdate/W=Plot_1d 595 596 // clean up 597 KillWaves/Z tmp_q,tmp_i,tmp_s,tmp_qb,tmp_sq,tmp_fs,tmp_cat 598 599 SetDataFolder root: 600 601 return(0) 602 End -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/ILL_DataReadWrite.ipf
r588 r764 296 296 297 297 // print "function used" 298 298 299 300 301 302 303 //loadwave /H "fname" 304 305 //Duplicate/O $"fname", datates 306 307 299 308 300 309 // (1) … … 326 335 /////////DIV file created with NIST reduction so has the VAX format.... painful 327 336 337 338 339 // Detector sensitivity files have the same header structure as RAW SANS data 340 // as NCNR, just with a different data array (real, rather than integer data) 341 // 342 // So for your facility, make this reader specific to the format of whatever 343 // file you use for a pixel-by-pixel division of the raw detector data 344 // to correct for non-uniform sensitivities of the detector. This is typically a 345 // measurement of water, plexiglas, or another uniform scattering sample. 346 // 347 // The data must be normalized to a mean value of 1 348 // 349 // called from ProtocolAsPanel.ipf 350 // 351 // type is "DIV" on input 328 352 Function ReadHeaderAndWork(type,fname) 329 353 String type,fname 330 354 331 355 //type is the desired folder to read the workfile to 332 //this data will NOT be automatically displayed gDataDisplayType is unchanged333 334 // SVAR cur_folder=root:myGlobals:gDataDisplayType 356 //this data will NOT be automatically displayed 357 // gDataDisplayType is unchanged 358 335 359 String cur_folder = type 336 360 String curPath = "root:Packages:NIST:"+cur_folder … … 341 365 Variable/G $(curPath + ":gIsLogScale") = 0 //initial state is linear, keep this in DIV folder 342 366 343 Make/O/ N=23 $(curPath + ":IntegersRead")344 Make/O/ N=52 $(curPath + ":RealsRead")367 Make/O/D/N=23 $(curPath + ":IntegersRead") 368 Make/O/D/N=52 $(curPath + ":RealsRead") 345 369 Make/O/T/N=11 $(curPath + ":TextRead") 346 370 … … 349 373 WAVE/T textw=$(curPath + ":TextRead") 350 374 351 //***NOTE **** 352 // the "current path" gets mysteriously reset to "root:" after the SECOND pass through 353 // this read routine, after the open dialog is presented 354 // the "--read" waves end up in the correct folder, but the data does not! Why? 355 //must re-set data folder before writing data array (done below) 356 357 SetDataFolder curPath 358 359 //actually open the file 360 Open/R refNum as fname 361 //skip first two bytes 362 FSetPos refNum, 2 363 //read the next 21 bytes as characters (fname) 364 FReadLine/N=21 refNum,textstr 365 textw[0]= textstr 366 //read four i*4 values /F=3 flag, B=3 flag 367 FBinRead/F=3/B=3 refNum, integer 368 intw[0] = integer 369 // 370 FBinRead/F=3/B=3 refNum, integer 371 intw[1] = integer 372 // 373 FBinRead/F=3/B=3 refNum, integer 374 intw[2] = integer 375 // 376 FBinRead/F=3/B=3 refNum, integer 377 intw[3] = integer 378 // 6 text fields 379 FSetPos refNum,55 //will start reading at byte 56 380 FReadLine/N=20 refNum,textstr 381 textw[1]= textstr 382 FReadLine/N=3 refNum,textstr 383 textw[2]= textstr 384 FReadLine/N=11 refNum,textstr 385 textw[3]= textstr 386 FReadLine/N=1 refNum,textstr 387 textw[4]= textstr 388 FReadLine/N=8 refNum,textstr 389 textw[5]= textstr 390 FReadLine/N=60 refNum,textstr 391 textw[6]= textstr 392 393 //3 integers 394 FSetPos refNum,174 395 FBinRead/F=3/B=3 refNum, integer 396 intw[4] = integer 397 FBinRead/F=3/B=3 refNum, integer 398 intw[5] = integer 399 FBinRead/F=3/B=3 refNum, integer 400 intw[6] = integer 401 402 //2 integers, 3 text fields 403 FSetPos refNum,194 404 FBinRead/F=3/B=3 refNum, integer 405 intw[7] = integer 406 FBinRead/F=3/B=3 refNum, integer 407 intw[8] = integer 408 FReadLine/N=6 refNum,textstr 409 textw[7]= textstr 410 FReadLine/N=6 refNum,textstr 411 textw[8]= textstr 412 FReadLine/N=6 refNum,textstr 413 textw[9]= textstr 414 415 //2 integers 416 FSetPos refNum,244 417 FBinRead/F=3/B=3 refNum, integer 418 intw[9] = integer 419 FBinRead/F=3/B=3 refNum, integer 420 intw[10] = integer 421 422 //2 integers 423 FSetPos refNum,308 424 FBinRead/F=3/B=3 refNum, integer 425 intw[11] = integer 426 FBinRead/F=3/B=3 refNum, integer 427 intw[12] = integer 428 429 //2 integers 430 FSetPos refNum,332 431 FBinRead/F=3/B=3 refNum, integer 432 intw[13] = integer 433 FBinRead/F=3/B=3 refNum, integer 434 intw[14] = integer 435 436 //3 integers 437 FSetPos refNum,376 438 FBinRead/F=3/B=3 refNum, integer 439 intw[15] = integer 440 FBinRead/F=3/B=3 refNum, integer 441 intw[16] = integer 442 FBinRead/F=3/B=3 refNum, integer 443 intw[17] = integer 444 445 //1 text field - the file association for transmission are the first 4 bytes 446 FSetPos refNum,404 447 FReadLine/N=42 refNum,textstr 448 textw[10]= textstr 449 450 //1 integer 451 FSetPos refNum,458 452 FBinRead/F=3/B=3 refNum, integer 453 intw[18] = integer 454 455 //4 integers 456 FSetPos refNum,478 457 FBinRead/F=3/B=3 refNum, integer 458 intw[19] = integer 459 FBinRead/F=3/B=3 refNum, integer 460 intw[20] = integer 461 FBinRead/F=3/B=3 refNum, integer 462 intw[21] = integer 463 FBinRead/F=3/B=3 refNum, integer 464 intw[22] = integer 465 466 Close refNum 467 468 //now get all of the reals 469 // 470 //Do all the GBLoadWaves at the end 471 // 472 //FBinRead Cannot handle 32 bit VAX floating point 473 //GBLoadWave, however, can properly read it 474 String GBLoadStr="GBLoadWave/O/N=tempGBwave/T={2,2}/J=2/W=1/Q" 475 String strToExecute 476 //append "/S=offset/U=numofreals" to control the read 477 // then append fname to give the full file path 478 // then execute 479 480 Variable a=0,b=0 481 482 SetDataFolder curPath 483 // 4 R*4 values 484 strToExecute = GBLoadStr + "/S=39/U=4" + "\"" + fname + "\"" 485 Execute strToExecute 486 487 SetDataFolder curPath 488 Wave w=$(curPath + ":tempGBWave0") 489 b=4 //num of reals read 490 realw[a,a+b-1] = w[p-a] 491 a+=b 492 493 // 4 R*4 values 494 SetDataFolder curPath 495 strToExecute = GBLoadStr + "/S=158/U=4" + "\"" + fname + "\"" 496 Execute strToExecute 497 b=4 498 realw[a,a+b-1] = w[p-a] 499 a+=b 500 501 /////////// 502 // 2 R*4 values 503 SetDataFolder curPath 504 strToExecute = GBLoadStr + "/S=186/U=2" + "\"" + fname + "\"" 505 Execute strToExecute 506 b=2 507 realw[a,a+b-1] = w[p-a] 508 a+=b 509 510 // 6 R*4 values 511 SetDataFolder curPath 512 strToExecute = GBLoadStr + "/S=220/U=6" + "\"" + fname + "\"" 513 Execute strToExecute 514 b=6 515 realw[a,a+b-1] = w[p-a] 516 a+=b 517 518 // 13 R*4 values 519 SetDataFolder curPath 520 strToExecute = GBLoadStr + "/S=252/U=13" + "\"" + fname + "\"" 521 Execute strToExecute 522 b=13 523 realw[a,a+b-1] = w[p-a] 524 a+=b 525 526 // 3 R*4 values 527 SetDataFolder curPath 528 strToExecute = GBLoadStr + "/S=320/U=3" + "\"" + fname + "\"" 529 Execute strToExecute 530 b=3 531 realw[a,a+b-1] = w[p-a] 532 a+=b 533 534 // 7 R*4 values 535 SetDataFolder curPath 536 strToExecute = GBLoadStr + "/S=348/U=7" + "\"" + fname + "\"" 537 Execute strToExecute 538 b=7 539 realw[a,a+b-1] = w[p-a] 540 a+=b 541 542 // 4 R*4 values 543 SetDataFolder curPath 544 strToExecute = GBLoadStr + "/S=388/U=4" + "\"" + fname + "\"" 545 Execute strToExecute 546 b=4 547 realw[a,a+b-1] = w[p-a] 548 a+=b 549 550 // 2 R*4 values 551 SetDataFolder curPath 552 strToExecute = GBLoadStr + "/S=450/U=2" + "\"" + fname + "\"" 553 Execute strToExecute 554 b=2 555 realw[a,a+b-1] = w[p-a] 556 a+=b 557 558 // 2 R*4 values 559 SetDataFolder curPath 560 strToExecute = GBLoadStr + "/S=470/U=2" + "\"" + fname + "\"" 561 Execute strToExecute 562 b=2 563 realw[a,a+b-1] = w[p-a] 564 a+=b 565 566 // 5 R*4 values 567 SetDataFolder curPath 568 strToExecute = GBLoadStr + "/S=494/U=5" + "\"" + fname + "\"" 569 Execute strToExecute 570 b=5 571 realw[a,a+b-1] = w[p-a] 572 573 //if the binary VAX data ws transferred to a MAC, all is OK 574 //if the data was trasnferred to an Intel machine (IBM), all the real values must be 575 //divided by 4 to get the correct floating point values 576 // I can't find any combination of settings in GBLoadWave or FBinRead to read data in correctly 577 // on an Intel machine. 578 //With the corrected version of GBLoadWave XOP (v. 1.43 or higher) Mac and PC both read 579 //VAX reals correctly, and no checking is necessary 12 APR 99 580 //if(cmpstr("Macintosh",IgorInfo(2)) == 0) 581 //do nothing 582 //else 583 //either Windows or Windows NT 584 //realw /= 4 585 //endif 586 587 //read in the data 588 GBLoadStr="GBLoadWave/O/N=tempGBwave/T={2,2}/J=2/W=1/Q" 589 590 curPath = "root:Packages:NIST:"+cur_folder 591 SetDataFolder curPath //use the full path, so it will always work 592 593 Make/O/N=16384 $(curPath + ":data") 375 // the actual data array, dimensions are set as globals inÊ 376 // InitFacilityGlobals() 377 NVAR XPix = root:myGlobals:gNPixelsX 378 NVAR YPix = root:myGlobals:gNPixelsX 379 380 381 Make/O/D/N=(XPix,YPix) $(curPath + ":data") 594 382 WAVE data = $(curPath + ":data") 595 383 596 Variable skip,ii,offset 597 598 //read in a total of 16384 values (ii) 599 //as follows : 600 // skip first 2 bytes 601 // skip 512 byte header 602 // skip first 2 bytes of data 603 //(read 511 reals, skip 2b, 510 reals, skip 2b) -16 times = 16336 values 604 // read the final 48 values in seperately to avoid EOF error 605 606 ///////////// 607 SetDataFolder curPath 608 skip = 0 609 ii=0 610 offset = 514 +2 611 a=0 612 do 613 SetDataFolder curPath 614 615 strToExecute = GBLoadStr + "/S="+num2str(offset)+"/U=511" + "\"" + fname + "\"" 616 Execute strToExecute 617 //Print strToExecute 618 b=511 619 data[a,a+b-1] = w[p-a] 620 a+=b 621 622 offset += 511*4 +2 623 624 strToExecute = GBLoadStr + "/S="+num2str(offset)+"/U=510" + "\"" + fname + "\"" 625 SetDataFolder curPath 626 Execute strToExecute 627 //Print strToExecute 628 b=510 629 data[a,a+b-1] = w[p-a] 630 a+=b 631 632 offset += 510*4 +2 633 634 ii+=1 635 //Print "inside do, data[2] =",data[2] 636 //Print "inside do, tempGBwave0[0] = ",w[0] 637 while(ii<16) 638 639 // 16336 values have been read in -- 640 //read in last 64 values 641 strToExecute = GBLoadStr + "/S="+num2str(offset)+"/U=48" + "\"" + fname + "\"" 642 643 SetDataFolder curPath 644 Execute strToExecute 645 b=48 646 data[a,a+b-1] = w[p-a] 647 a+=b 648 // 649 /// done reading in raw data 650 // 651 //Print "in workdatareader , data = ", data[1][1] 652 653 Redimension/n=(128,128) data 654 655 //clean up - get rid of w = $"tempGBWave0" 656 KillWaves w 657 658 //divide the FP data by 4 if read from a PC (not since GBLoadWave update) 659 //if(cmpstr("Macintosh",IgorInfo(2)) == 0) 660 //do nothing 661 //else 662 //either Windows or Windows NT 663 //data /= 4 664 //endif 384 Make/O/D/N=(XPix,YPix) $(curPath + ":linear_data") 385 WAVE linear_data = $(curPath + ":linear_data") 386 387 388 // print "function used" 389 390 391 // (1) 392 // fill in your reader for the header here so that intw, realw, and textW are filled in 393 // ? possibly a duplication of the raw data reader 394 Duplicate/O $("root:Packages:NIST:raw:realsread"),$(curPath+ ":realsread") 395 Duplicate/O $("root:Packages:NIST:raw:integersread"),$(curPath+ ":integersread") 396 Duplicate/T $("root:Packages:NIST:raw:Textread"),$(curPath+ ":Textread") 397 398 399 //(2) 400 // then fill in a reader for the data array that will DIVIDE your data 401 // to get the corrected values. 402 // fill the data array with the detector values 403 404 //here you load in your file, you're already in the DIV folder 405 // LoadWave/H/O "Macintosh HD:Users:srkline:Desktop:linear_data.ibw" 406 LoadWave/H/O fname //since fname is the full path 407 408 ConvertFolderToLogScale(type) 409 410 String loadedStr = StringFromList(0,S_waveNames,";") //then name of the wave loaded 411 412 //then copy the loaded wave to data and to linear data, in the DIV folder 413 duplicate/O $("loadedStr"),$(curPath+ ":data") 414 duplicate/O $("loadedStr"),$(curPath+ ":linear_data") 415 665 416 666 417 //keep a string with the filename in the DIV folder … … 2132 1883 String type 2133 1884 1885 // should have the linear display..... 1886 ConvertFolderToLogScale(type) 1887 1888 Save/C root:packages:nist:STO:linear_data as "plex.DIV" 1889 2134 1890 // Your file writing function here. Don't try to duplicate the VAX binary format... 2135 1891 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/ILL_Utils.ipf
r750 r764 195 195 // this run number should be a unique identifier for the file 196 196 // 197 198 // 197 199 Function GetRunNumFromFile(item) 198 200 String item … … 202 204 String runStr="" 203 205 204 runstr = item 206 runStr = ParseFilePath(0, item, ":", 1, 0) 207 // runstr = item 205 208 num = str2num(runstr) 206 209 … … 229 232 retStr=invalid 230 233 231 retstr = item234 retstr = ParseFilePath(0, item, ":", 1, 0) 232 235 //your code here 233 236 … … 334 337 Function/S RunDigitString(num) 335 338 Variable num 336 339 337 340 // String fullName="",partialName="",item="" 338 341 // String numStr="" … … 361 364 // endswitch 362 365 // 363 366 364 367 String numStr="" 365 368 … … 1049 1052 ff= 0.9993575- 0.0002320264*abs(theta) + 9.751713e-5*abs(theta^2) + 1.018564e-5*abs(theta^3) -3.977445e-7*abs(theta^4) +2.960205e-9*abs(theta^5) 1050 1053 endif 1054 ff= 0.9992674-0.0001808763*abs(theta) +8.134414e-05*abs(theta^2) +1.151734e-05*abs(theta^3) - 4.401022e-07*abs(theta^4)+3.71246e-09*abs(theta^5) 1051 1055 1052 1056 return(ff) -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/MainPanel.ipf
r648 r764 19 19 20 20 PickPath() 21 // read in DEFAULT.MASK, if it exists, otherwise, do nothing 22 // 23 PathInfo catPathName 24 if(V_flag==1) 25 String str = S_Path + "DEFAULT.MASK" 26 Variable refnum 27 Open/R/Z=1 refnum as str 28 if(strlen(S_filename) != 0) 29 Close refnum //file can be found OK 30 ReadMCID_MASK(str) 31 else 32 // file not found, close just in case 33 Close/A 34 endif 35 endif 21 36 End 22 37 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/Marquee.ipf
r757 r764 451 451 Abort "There is no Marquee" 452 452 endif 453 // if cursor A on graph 454 // Do histogram pair 455 Variable aExists= strlen(CsrInfo(A)) > 0 // A is a name, not a string 456 if(aExists) 457 DoHistogramPair(hcsr(A),vcsr(A)) 458 return(0) 459 endif 453 460 // 454 461 Variable count,x1,x2,y1,y2,xwidth,ywidth,vsX=1,xx,yy … … 550 557 endif 551 558 End 559 560 // if the "A" cursor is on the graph, do +-5 pixels in each direction 561 // otherwise, you won't get here 562 Function DoHistogramPair(xin,yin) 563 Variable xin,yin 564 565 Variable count,x1,x2,y1,y2,xwidth,ywidth,pt1,pt2,xx,yy 566 SVAR cur_folder=root:myGlobals:gDataDisplayType 567 WAVE data=$("root:Packages:NIST:"+cur_folder+":data") //don't care if it's log or linear scale 568 569 570 pt1 = 1 // extent along the "long" direction of the swath 571 pt2 = 128 572 573 Make/O/D/N=(pt2-pt1) PositionX,AvgCountsX 574 Make/O/D/N=(pt2-pt1) PositionY,AvgCountsY 575 AvgCountsX=0 576 AvgCountsY=0 577 578 //set position wave 579 positionX=p+pt1 580 positionY=p+pt1 581 //convert the position to Detector coordinates 582 positionX += 1 583 positionY += 1 584 585 //do the vertical, then the horizontal 586 xwidth = 5 //+ - 587 ywidth = 5 588 x1 = xin - xwidth 589 x2 = xin + xwidth 590 y1 = pt1 591 y2 = pt2 592 593 KeepSelectionInBounds(x1,x2,y1,y2) 594 Print "x1,x2,y1,y2 (det) =",x1+1,x2+1,y1+1,y2+1 595 596 //Compute the histogram (manually) 597 for(yy=y1;yy<=y2;yy+=1) 598 for(xx=x1;xx<=x2;xx+=1) 599 AvgCountsY[yy-y1] += data[xx][yy] 600 endfor 601 endfor 602 AvgCountsY /= (xwidth+1) 603 604 // now do the Y 605 y1 = yin - ywidth 606 y2 = yin + ywidth 607 x1 = pt1 608 x2 = pt2 609 610 KeepSelectionInBounds(x1,x2,y1,y2) 611 Print "x1,x2,y1,y2 (det) =",x1+1,x2+1,y2+1,y2+1 612 for(xx=x1;xx<=x2;xx+=1) //outer loop is the "x-axis" 613 for(yy=y1;yy<=y2;yy+=1) 614 AvgCountsX[xx-x1] += data[xx][yy] 615 endfor 616 endfor 617 AvgCountsX /= (ywidth+1) 618 619 GetMarquee/K //to keep from drawing the marquee on the new histo graph 620 //draw the graph, or just bring to the front with the new data 621 DoWindow/F HistoPair 622 if(V_Flag != 1) 623 Draw_HistoPair() 624 endif 625 626 return(0) 627 end 628 629 630 Function Draw_HistoPair() 631 PauseUpdate; Silent 1 // building window... 632 Display /W=(253,683,723,950)/K=1 AvgCountsX vs PositionX as "Histogram Pair" 633 AppendToGraph/L=leftY/B=bottomY AvgCountsY vs PositionY 634 DoWindow/C HistoPair 635 ModifyGraph rgb(AvgCountsX)=(21845,21845,21845) 636 ModifyGraph hbFill(AvgCountsX)=2 637 ModifyGraph useNegPat(AvgCountsX)=1 638 ModifyGraph usePlusRGB(AvgCountsX)=1 639 ModifyGraph useNegRGB(AvgCountsX)=1 640 ModifyGraph hBarNegFill(AvgCountsX)=2 641 ModifyGraph negRGB(AvgCountsX)=(0,0,65535) 642 ModifyGraph grid(left)=1,grid(bottom)=1,grid(leftY)=1 643 ModifyGraph mirror(left)=2,mirror(bottom)=2,mirror(leftY)=2 644 ModifyGraph standoff(left)=0,standoff(bottom)=0,standoff(leftY)=0 645 ModifyGraph lblPos(left)=62,lblPos(bottom)=39 646 ModifyGraph freePos(leftY)=0 647 ModifyGraph freePos(bottomY)={0,leftY} 648 ModifyGraph axisEnab(left)={0,0.4} 649 ModifyGraph axisEnab(leftY)={0.6,1} 650 Label left "Counts" 651 Label bottom "Pixel (detector coordinates)" 652 SetAxis/A/N=2 left 653 TextBox/C/N=text0/X=5.0/Y=5.0 "TOP" 654 TextBox/C/N=text0_1/X=5.0/Y=67.0 "RIGHT" 655 TextBox/C/N=text0_2/X=84.0/Y=67.0 "LEFT" 656 TextBox/C/N=text0_3/X=84.0/Y=5.0 "BOTTOM" 657 EndMacro 658 659 660 // not used, just for testing 661 Function CursorForHistogram() 662 663 Wave w=root:Packages:NIST:RAW:RealsRead 664 665 Cursor/W=SANS_Data/F/I A data w[16],w[17] 666 Cursor/M/S=2/H=1/L=0/C=(3,52428,1) A 667 668 End -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/MultipleReduce.ipf
r699 r764 684 684 Wave isTrans = $"root:myGlobals:MRED:IsTrans" 685 685 686 Variable num=numpnts(sdd),ii,tol = 0. 001686 Variable num=numpnts(sdd),ii,tol = 0.1 687 687 ii=num-1 688 688 do 689 if(abs(sdd[ii] - tSDD) > tol) //if numerically more than 0.001 m different, they're not the same 689 // if(abs(sdd[ii] - tSDD) > tol) //if numerically more than 0.001 m different, they're not the same 690 // DeletePoints ii, 1, filenames,suffix,labels,sdd,runnum,isTrans 691 // endif 692 if(trunc(abs(sdd[ii] - tSDD)) > tol) //just get the integer portion of the difference - very coarse comparison 690 693 DeletePoints ii, 1, filenames,suffix,labels,sdd,runnum,isTrans 691 694 endif -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/ProtocolAsPanel.ipf
r750 r764 36 36 // DRAWING routines only use a subset of the total list, since saving, naming, etc. don't apply 37 37 // (10) possible keywords, some numerical, some string values 38 // AVTYPE=string string from set {Circular,Annular,Rectangular,Sector,2D_ASCII,QxQy_ASCII,PNG_Graphic }38 // AVTYPE=string string from set {Circular,Annular,Rectangular,Sector,2D_ASCII,QxQy_ASCII,PNG_Graphic;Sector_PlusMinus;} 39 39 // PHI=value azimuthal angle (-90,90) 40 40 // DPHI=value +/- angular range around phi for average … … 969 969 String av_typ,autoSave,AutoName,autoPlot,side 970 970 Variable phi=0,dphi=10,width=10,Qctr = 0.01,qDelta=10 971 Prompt av_typ, "Type of Average",popup,"Circular;Sector;Rectangular;Annular;2D_ASCII;QxQy_ASCII;PNG_Graphic "971 Prompt av_typ, "Type of Average",popup,"Circular;Sector;Rectangular;Annular;2D_ASCII;QxQy_ASCII;PNG_Graphic;Sector_PlusMinus;" 972 972 // comment out above line in DEMO_MODIFIED version, and uncomment the line below (to disable PNG save) 973 973 // Prompt av_typ, "Type of Average",popup,"Circular;Sector;Rectangular;Annular;2D_ASCII;QxQy_ASCII" … … 992 992 root:myGlobals:Protocols:gAvgInfoStr += "PLOT=" + autoPlot + ";" 993 993 994 if(cmpstr(av_typ,"Sector")==0 )994 if(cmpstr(av_typ,"Sector")==0 || cmpstr(av_typ,"Sector_PlusMinus")==0) 995 995 root:myGlobals:Protocols:gAvgInfoStr += "SIDE=" + side + ";" 996 996 root:myGlobals:Protocols:gAvgInfoStr += "PHI=" + num2str(phi) + ";" … … 1859 1859 case "Sector": 1860 1860 CircularAverageTo1D(activeType) 1861 break 1862 case "Sector_PlusMinus": 1863 Sector_PlusMinus1D(activeType) 1861 1864 break 1862 1865 default: … … 2254 2257 2255 2258 PathInfo/S catPathName 2256 fullPath = DoSaveFileDialog("Export Protocol as" )2259 fullPath = DoSaveFileDialog("Export Protocol as",fname=Protocol,suffix="") 2257 2260 If(cmpstr(fullPath,"")==0) 2258 2261 //user cancel, don't write out a file -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/SASCALC.ipf
r757 r764 417 417 CheckBox checkSim,value=0 418 418 419 CheckBox check0_1,pos={80,155},size={90,14},title="Offset Traces?",variable= root:Packages:NIST:SAS:gDoTraceOffset 420 419 421 // help, done buttons 420 422 Button SC_helpButton,pos={340,166},size={25,20},proc=showSASCALCHelp,title="?"
Note: See TracChangeset
for help on using the changeset viewer.