- Timestamp:
- May 1, 2009 2:29:57 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/ProDiv.ipf
r418 r496 313 313 Return(0) 314 314 End 315 316 317 ///////////////////// 318 // 319 // for the DIV "protocol" panel, I probably need to have parts of the protocol panel initialized... 320 // folders are generated at the startup initialization, before protocol panel 321 // 322 Proc BuildDIVPanel() 323 DoWindow/F DIV_Panel 324 if(V_flag==0) 325 InitDIVPanel() 326 DIV_Panel() 327 Endif 328 End 329 330 //initialization procedure for the protocol panel 331 //note that :gAbsStr is also shared (common global) to that used in 332 //the questionnare form of the protcol (see protocol.ipf) 333 // 334 //0901, uses 8 points in protocol wave 335 Proc InitDIVPanel() 336 337 //set up the global variables needed for the protocol panel 338 //global strings to put in a temporary protocol textwave 339 Variable ii=0,nsteps=8 340 String waveStr="DIV_Protocol" 341 SetDataFolder root:myGlobals:Protocols 342 Make/O/T/N=(nsteps) $"root:myGlobals:Protocols:DIV_Protocol" = "" 343 344 DIV_protocol[2] = "none" 345 DIV_protocol[3] = "none" 346 DIV_protocol[4] = "none" 347 DIV_protocol[5] = "AVTYPE=none;" 348 DIV_protocol[6] = "DRK=none,DRKMODE=0," 349 350 351 String/G root:myGlobals:Protocols:gPlex="Plex" 352 String/G root:myGlobals:Protocols:gPlexBgd="Bgd" 353 String/G root:myGlobals:Protocols:gPlexEmp="Emp" 354 String/G root:myGlobals:Protocols:gPlex_off="Plex offset" 355 String/G root:myGlobals:Protocols:gPlexBgd_off="Bgd offset" 356 String/G root:myGlobals:Protocols:gPlexEmp_off="Emp offset" 357 String/G root:myGlobals:Protocols:gPlexName="Plex_date.div" 358 359 Variable/G root:myGlobals:Protocols:gPlexX1=45 360 Variable/G root:myGlobals:Protocols:gPlexX2=87 361 Variable/G root:myGlobals:Protocols:gPlexY1=43 362 Variable/G root:myGlobals:Protocols:gPlexY2=85 363 Variable/G root:myGlobals:Protocols:gPlexTrans=0.48 364 365 SetDataFolder root: 366 367 End 368 369 // load in one on-center file and show the box 370 // 371 Function ShowBoxButtonProc(ba) : ButtonControl 372 STRUCT WMButtonAction &ba 373 374 switch( ba.eventCode ) 375 case 2: // mouse up 376 // click code here 377 //parse for the first run number 378 SVAR gPlex = root:myGlobals:Protocols:gPlex 379 String item,fname 380 381 item = StringFromList(0, gPlex ,",") 382 fname = FindFileFromRunNumber(str2num(item)) 383 if(strlen(fname) == 0) 384 Abort "Bad file number in Plex field" 385 endif 386 // load the file 387 ReadHeaderAndData(fname) //this is the full Path+file 388 UpdateDisplayInformation("RAW") 389 //draw a box of the specified size. This is persistent on the display as you scroll to the offset data 390 NVAR x1 = root:myGlobals:Protocols:gPlexX1 391 NVAR x2 = root:myGlobals:Protocols:gPlexX2 392 NVAR y1 = root:myGlobals:Protocols:gPlexY1 393 NVAR y2 = root:myGlobals:Protocols:gPlexY2 394 395 SetDrawLayer/W=SANS_Data/K UserFront //set the layer, and clear it 396 SetDrawEnv/W=SANS_Data xcoord=bottom,ycoord=left,fillpat=0,linethick=3,linefgc=(65535, 65535, 65535) 397 DrawRect/W=SANS_Data x1, y2, x2, y1 398 399 break 400 endswitch 401 402 return 0 403 End 404 405 // do everything... 406 // 407 Function GenerateDIVButtonProc(ba) : ButtonControl 408 STRUCT WMButtonAction &ba 409 410 switch( ba.eventCode ) 411 case 2: // mouse up 412 // click code here 413 SVAR gPlex = root:myGlobals:Protocols:gPlex 414 SVAR gPlexBgd = root:myGlobals:Protocols:gPlexBgd 415 SVAR gPlexEmp = root:myGlobals:Protocols:gPlexEmp 416 SVAR gPlex_off = root:myGlobals:Protocols:gPlex_off 417 SVAR gPlexBgd_off = root:myGlobals:Protocols:gPlexBgd_off 418 SVAR gPlexEmp_off = root:myGlobals:Protocols:gPlexEmp_off 419 SVAR gPlexName = root:myGlobals:Protocols:gPlexName 420 421 NVAR X1 = root:myGlobals:Protocols:gPlexX1 422 NVAR X2 = root:myGlobals:Protocols:gPlexX2 423 NVAR Y1 = root:myGlobals:Protocols:gPlexY1 424 NVAR Y2 = root:myGlobals:Protocols:gPlexY2 425 NVAR gPlexTrans = root:myGlobals:Protocols:gPlexTrans 426 427 WAVE/T proto = $"root:myGlobals:Protocols:DIV_Protocol" 428 429 String item,fname,str 430 Variable ii,num 431 // reduce the on-center 432 //patch trans 433 num = ItemsInList(gPlex, ",") 434 for(ii=0;ii<num;ii+=1) 435 item = StringFromList(ii, gPlex ,",") 436 fname = FindFileFromRunNumber(str2num(item)) 437 if(strlen(fname) == 0) 438 Abort "Bad file number in no offset Plex field" 439 endif 440 WriteTransmissionToHeader(fname,gPlexTrans) 441 endfor 442 443 //go through the protocol 444 str = ParseRunNumberList(gPlexBgd) 445 if(strlen(str) > 0) 446 proto[0] = str 447 else 448 Abort "Bad file number in no offset Bgd" 449 endif 450 str = ParseRunNumberList(gPlexEmp) 451 if(strlen(str) > 0) 452 proto[1] = str 453 else 454 Abort "Bad file number in no offset Emp" 455 endif 456 str = ParseRunNumberList(gPlex) 457 if(strlen(str) > 0) 458 ExecuteProtocol("root:myGlobals:Protocols:DIV_Protocol",str) 459 else 460 Abort "Bad file number in no offset Plex" 461 endif 462 // move it into STO 463 Execute "CopyWorkFolder(\"COR\",\"STO\")" 464 465 466 467 // reduce the off-center, keep in STO 468 //patch trans 469 num = ItemsInList(gPlex_off, ",") 470 for(ii=0;ii<num;ii+=1) 471 item = StringFromList(ii, gPlex_off ,",") 472 fname = FindFileFromRunNumber(str2num(item)) 473 if(strlen(fname) == 0) 474 Abort "Bad file number in Plex field" 475 endif 476 WriteTransmissionToHeader(fname,gPlexTrans) 477 endfor 478 479 //go through the protocol 480 str = ParseRunNumberList(gPlexBgd_off) 481 if(strlen(str) > 0) 482 proto[0] = str 483 else 484 Abort "Bad file number in offset Bgd" 485 endif 486 str = ParseRunNumberList(gPlexEmp_off) 487 if(strlen(str) > 0) 488 proto[1] = str 489 else 490 Abort "Bad file number in offset Emp" 491 endif 492 str = ParseRunNumberList(gPlex_off) 493 if(strlen(str) > 0) 494 ExecuteProtocol("root:myGlobals:Protocols:DIV_Protocol",str) 495 else 496 Abort "Bad file number in offset Emp" 497 endif 498 499 500 501 // replace the patch 502 // on-center data is changed (STO) 503 ReplaceDataBlock("STO","COR",x1,x2,y1,y2) 504 // normalize 505 NormalizeDiv("STO") 506 UpdateDisplayInformation("STO") 507 //write out the new data file 508 WriteVAXWorkFile("STO") 509 510 break 511 endswitch 512 513 return 0 514 End 515 516 // if a dark color is used, then 517 //¥SetVariable setvar0 labelBack=(65535,65535,65535) 518 // for each variable will give a white background to the label text 519 Window DIV_Panel() : Panel 520 PauseUpdate; Silent 1 // building window... 521 NewPanel /W=(594,44,932,570)/K=1 as "DIV_Panel" 522 // ModifyPanel cbRGB=(35867,28177,65535) //purple 523 // ModifyPanel cbRGB=(1,16019,65535) //electric blue 524 ModifyPanel cbRGB=(36631,59604,33902) //spring green 525 SetDrawLayer UserBack 526 DrawRect 71,324,145,391 527 TitleBox title0,pos={14,16},size={50,20},title="No Offset" 528 TitleBox title0_1,pos={17,125},size={35,20},title="Offset" 529 SetVariable setvar0,pos={15,46},size={250,15},title="PLEX",value= root:myGlobals:Protocols:gPlex 530 SetVariable setvar0_1,pos={16,69},size={250,15},title="EMP",value= root:myGlobals:Protocols:gPlexEmp 531 SetVariable setvar0_2,pos={14,92},size={250,15},title="BGD",value= root:myGlobals:Protocols:gPlexBgd 532 SetVariable setvar1,pos={17,158},size={250,15},title="PLEX",value= root:myGlobals:Protocols:gPlex_off 533 SetVariable setvar001,pos={18,181},size={250,15},title="EMP",value= root:myGlobals:Protocols:gPlexEmp_off 534 SetVariable setvar002,pos={16,204},size={250,15},title="BGD",value= root:myGlobals:Protocols:gPlexBgd_off 535 SetVariable setvar002_1,pos={14,251},size={150,15},title="Transmission" 536 SetVariable setvar002_1,limits={0,1,0.01},value= root:myGlobals:Protocols:gPlexTrans 537 // SetVariable setvar003,pos={16,441},size={250,15},title="DIV FILE NAME" 538 // SetVariable setvar003,value= root:myGlobals:Protocols:gPlexName 539 Button button0,pos={226,325},size={90,20},proc=ShowBoxButtonProc,title="Show Box" 540 Button button1,pos={25,441},size={150,20},proc=GenerateDIVButtonProc,title="Generate DIV File" 541 Button button2,pos={25,481},size={150,20},proc=ReloadDIVButtonProc,title="Load DIV File" 542 Button button3,pos={240,10},size={50,20},proc=DIVHelpButtonProc,title="Help" 543 SetVariable setvar00201,pos={84,297},size={50,15},limits={0,128,1},title=" ",value= root:myGlobals:Protocols:gPlexY2 544 SetVariable setvar00202,pos={15,350},size={50,15},limits={0,128,1},title=" ",value= root:myGlobals:Protocols:gPlexX1 545 SetVariable setvar00203,pos={85,399},size={50,15},limits={0,128,1},title=" ",value= root:myGlobals:Protocols:gPlexY1 546 SetVariable setvar00204,pos={156,348},size={50,15},limits={0,128,1},title=" ",value= root:myGlobals:Protocols:gPlexX2 547 EndMacro 548 549 550 // load in a DIV file, print out the stats, display in SANS_Data 551 // 552 Function ReloadDIVButtonProc(ba) : ButtonControl 553 STRUCT WMButtonAction &ba 554 555 switch( ba.eventCode ) 556 case 2: // mouse up 557 // click code here 558 Execute "ReadWork_DIV()" 559 WaveStats root:Packages:NIST:DIV:data 560 Print "*" 561 // Execute "ChangeDisplay(\"DIV\")" 562 break 563 endswitch 564 565 return 0 566 End 567 568 // 569 Function DIVHelpButtonProc(ba) : ButtonControl 570 STRUCT WMButtonAction &ba 571 572 switch( ba.eventCode ) 573 case 2: // mouse up 574 // click code here 575 DisplayHelpTopic/Z/K=1 "SANS Data Reduction Tutorial[Detector Sensitivity File]" 576 if(V_flag !=0) 577 DoAlert 0,"The SANS Data Reduction Tutorial Help file could not be found" 578 endif 579 break 580 endswitch 581 582 return 0 583 End
Note: See TracChangeset
for help on using the changeset viewer.