- Timestamp:
- Mar 14, 2016 1:34:41 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/QKK_NSORT.ipf
r908 r986 8 8 // NSORT panel for combining and inter-normalizing 2 or 3 datasets 9 9 // that have previously been averaged 10 // 11 // MAR 2016 SRK added functionality to combine 4 datasets 10 12 // 11 13 // - handles 3 or 6-column datasets … … 36 38 MedQPopMenuProc("",1,"") 37 39 HighQPopMenuProc("",1,"") 40 HighestQPopMenuProc("",1,"") 38 41 End 39 42 … … 48 51 Variable/G root:myGlobals:NSORT:gScale1_2 = 1 49 52 Variable/G root:myGlobals:NSORT:gScale2_3 = 1 53 Variable/G root:myGlobals:NSORT:gScale3_4 = 1 50 54 // 51 55 //save the number of points to trim from beginning/end of the data files … … 57 61 Variable/G root:myGlobals:NSORT:gPtsBeg3 = NumVarOrDefault("root:myGlobals:NSORT:gPtsBeg3", 0 ) 58 62 Variable/G root:myGlobals:NSORT:gPtsEnd3 = NumVarOrDefault("root:myGlobals:NSORT:gPtsEnd3", 0 ) 63 Variable/G root:myGlobals:NSORT:gPtsBeg4 = NumVarOrDefault("root:myGlobals:NSORT:gPtsBeg4", 0 ) 64 Variable/G root:myGlobals:NSORT:gPtsEnd4 = NumVarOrDefault("root:myGlobals:NSORT:gPtsEnd4", 0 ) 59 65 60 66 Variable/G root:myGlobals:NSORT:gColumns1 = 0 61 67 Variable/G root:myGlobals:NSORT:gColumns2 = 0 62 68 Variable/G root:myGlobals:NSORT:gColumns3 = 0 69 Variable/G root:myGlobals:NSORT:gColumns4 = 0 63 70 Variable/G root:myGlobals:NSORT:gNormToNum = 1 64 71 String/G root:myGlobals:NSORT:gPathStr = "" … … 73 80 Function LoadDataForNSORT(fileStr,setNum) 74 81 String fileStr //full path:name to a valid file 75 Variable setNum //number of set (used for naming) = 0, 1, or 2 (ONLY) 82 Variable setNum //number of set (used for naming) = 0, 1, or 2 (ONLY), (2016) 3 is now valid for 4th data set 76 83 77 84 Variable err=0 … … 84 91 NVAR gColumns2 = root:myGlobals:NSORT:gColumns2 85 92 NVAR gColumns3 = root:myGlobals:NSORT:gColumns3 93 NVAR gColumns4 = root:myGlobals:NSORT:gColumns4 86 94 NVAR begPts1 = root:myGlobals:NSORT:gPtsBeg1 87 95 NVAR endPts1 = root:myGlobals:NSORT:gPtsEnd1 … … 90 98 NVAR begPts3 = root:myGlobals:NSORT:gPtsBeg3 91 99 NVAR endPts3 = root:myGlobals:NSORT:gPtsEnd3 92 100 NVAR begPts4 = root:myGlobals:NSORT:gPtsBeg4 101 NVAR endPts4 = root:myGlobals:NSORT:gPtsEnd4 102 93 103 String cmd 94 104 String typStr= "", trimStr="" … … 118 128 begPts = begPts3 119 129 endPts = endPts3 130 break 131 case 4: 132 sprintf cmd , "A_LoadOneDDataToName(\"%s\",\"%s\",%d,%d)",fileStr,"HighestQSet",0,1 133 Execute cmd 134 typStr = "HighestQSet" 135 trimStr = "TrimHighestQSet" 136 begPts = begPts4 137 endPts = endPts4 120 138 break 121 139 endswitch … … 168 186 gColumns3 = numCols 169 187 break 188 case 4: 189 gColumns4 = numCols 190 break 170 191 endswitch 171 192 … … 174 195 End 175 196 176 Function WriteNSORTedFile(q3,i3,sig3,firstFileName,secondFileName,thirdFileName, normTo,norm12,norm23,[res])197 Function WriteNSORTedFile(q3,i3,sig3,firstFileName,secondFileName,thirdFileName,fourthFileName,normTo,norm12,norm23,norm34,[res]) 177 198 Wave q3,i3,sig3,res 178 String firstFileName,secondFileName,thirdFileName, normTo179 Variable norm12,norm23 199 String firstFileName,secondFileName,thirdFileName,fourthfileName,normTo 200 Variable norm12,norm23,norm34 180 201 181 202 NVAR useXMLOutput = root:Packages:NIST:gXML_Write … … 183 204 if (useXMLOutput == 1) 184 205 if(WaveExists(res)) 185 WriteNSORTedXMLFile(q3,i3,sig3,firstFileName,secondFileName,thirdFileName, normTo,norm12,norm23,res=res)206 WriteNSORTedXMLFile(q3,i3,sig3,firstFileName,secondFileName,thirdFileName,fourthFileName,normTo,norm12,norm23,norm34,res=res) 186 207 else 187 WriteNSORTedXMLFile(q3,i3,sig3,firstFileName,secondFileName,thirdFileName, normTo,norm12,norm23)208 WriteNSORTedXMLFile(q3,i3,sig3,firstFileName,secondFileName,thirdFileName,fourthFileName,normTo,norm12,norm23,norm34) 188 209 endif 189 210 else 190 211 if(WaveExists(res)) 191 WriteOLDNSORTedFile(q3,i3,sig3,firstFileName,secondFileName,thirdFileName, normTo,norm12,norm23,res=res)212 WriteOLDNSORTedFile(q3,i3,sig3,firstFileName,secondFileName,thirdFileName,fourthFileName,normTo,norm12,norm23,norm34,res=res) 192 213 else 193 WriteOLDNSORTedFile(q3,i3,sig3,firstFileName,secondFileName,thirdFileName, normTo,norm12,norm23)214 WriteOLDNSORTedFile(q3,i3,sig3,firstFileName,secondFileName,thirdFileName,fourthFileName,normTo,norm12,norm23,norm34) 194 215 endif 195 216 endif … … 198 219 199 220 200 Function WriteOLDNSORTedFile(q3,i3,sig3,firstFileName,secondFileName,thirdFileName, normTo,norm12,norm23,[res])221 Function WriteOLDNSORTedFile(q3,i3,sig3,firstFileName,secondFileName,thirdFileName,fourthFileName,normTo,norm12,norm23,norm34,[res]) 201 222 Wave q3,i3,sig3,res 202 String firstFileName,secondFileName,thirdFileName, normTo203 Variable norm12,norm23 223 String firstFileName,secondFileName,thirdFileName,fourthFileName,normTo 224 Variable norm12,norm23,norm34 204 225 205 226 Variable err=0,refNum,numCols,dialog=1 … … 287 308 // fprintf refnum, "THIRD File %s",hdr3 //new, Mar 2008 288 309 289 fprintf refNum, "NSORT-ed %s \t + %s\t + %s\r\n",firstFileName, secondFileName,thirdFileName310 fprintf refNum, "NSORT-ed %s\t + %s\t + %s\t + %s\r\n",firstFileName, secondFileName,thirdFileName,fourthFileName 290 311 fprintf refNum, "normalized to %s\r\n",normTo 291 fprintf refNum, "multiplicative factor 1-2 = %12.8g\t multiplicative factor 2-3 = %12.8g\ r\n",norm12,norm23312 fprintf refNum, "multiplicative factor 1-2 = %12.8g\t multiplicative factor 2-3 = %12.8g\t multiplicative factor 3-4 = %12.8g\r\n",norm12,norm23,norm34 292 313 293 314 if (numCols == 3) 294 formatStr = "%15 g %15g %15g\r\n"315 formatStr = "%15.4g %15.4g %15.4g\r\n" 295 316 fprintf refnum, "The 3 columns are | Q (1/A) | I(Q) (1/cm) | std. dev. I(Q) (1/cm) |\r\n" 296 317 wfprintf refnum, formatStr, q3,i3,sig3 … … 300 321 Make/O/N=(dimsize(res,0)) fs3 = res[p][2] 301 322 302 formatStr = "%15 g %15g %15g %15g %15g %15g\r\n"323 formatStr = "%15.4g %15.4g %15.4g %15.4g %15.4g %15.4g\r\n" 303 324 fprintf refnum, "The 6 columns are | Q (1/A) | I(Q) (1/cm) | std. dev. I(Q) (1/cm) | sigmaQ | meanQ | ShadowFactor|\r\n" 304 325 wfprintf refnum, formatStr, q3,i3,sig3,sigq3,qbar3,fs3 … … 376 397 KillDataFolder/Z MedQSet 377 398 KillDataFolder/Z HighQSet 399 KillDataFolder/Z HighestQSet 378 400 379 401 End … … 393 415 Variable setNum,err 394 416 //switch on ctrlName string - Plot_1, Plot_2, Plot_3 395 if(cmpstr(ctrlName,"Plot_1")==0) 396 //low-q 397 setNum = 1 398 ControlInfo $"popup_1" 399 else 400 if(cmpstr(ctrlName,"Plot_2")==0) 417 418 strswitch(ctrlName) // string switch 419 case "Plot_1": 420 //low-q 421 setNum = 1 422 ControlInfo/W=NSORT_Panel popup_1 423 break 424 case "Plot_2": 401 425 //medium-q 402 426 setNum = 2 403 ControlInfo $"popup_2" 404 else 427 ControlInfo/W=NSORT_Panel popup_2 428 break 429 case "Plot_3": 405 430 //high-q 406 431 setNum = 3 407 ControlInfo $"popup_3" 408 Endif 409 Endif 410 432 ControlInfo/W=NSORT_Panel popup_3 433 break 434 case "Plot_4": 435 //highest-q 436 setNum = 4 437 ControlInfo/W=NSORT_Panel popup_4 438 break 439 endswitch 440 441 411 442 //find the file from the partial filename 412 443 If( (cmpstr(S_value,"")==0) || (cmpstr(S_value,"none")==0) ) … … 439 470 if(WinType("NSORT_Graph")==0) 440 471 //no window, create one 441 if(cmpstr(ctrlName,"Plot_1")==0) 442 //low-q 443 Display/K=1 444 DoWindow/C NSORT_Graph 445 DisplayLowSet() 446 else 447 if(cmpstr(ctrlName,"Plot_2")==0) 472 strswitch(ctrlName) // string switch 473 case "Plot_1": 474 //low-q 475 Display/K=1 476 DoWindow/C NSORT_Graph 477 DisplayLowSet() 478 break 479 case "Plot_2": 448 480 //medium-q 449 481 Display/K=1 450 482 DoWindow/C NSORT_Graph 451 483 DisplayMedSet() 452 else 484 break 485 case "Plot_3": 453 486 //high-q 454 487 Display/K=1 455 488 DoWindow/C NSORT_Graph 456 489 DisplayHighSet() 457 Endif 458 Endif 490 break 491 case "Plot_4": 492 //highest-q 493 Display/K=1 494 DoWindow/C NSORT_Graph 495 DisplayHighestSet() 496 break 497 endswitch 459 498 Legend 460 499 else … … 463 502 list = TraceNameList("NSORT_Graph",";",1) 464 503 465 if(cmpstr(ctrlName,"Plot_1")==0) 466 //low-q 467 isOnPlot = strsearch(list, "LowQSet_i", 0) // isOnPlot == -1 if it is NOT found in the list 468 if(isOnPlot == -1) 469 DisplayLowSet() 470 Endif 471 else 472 if(cmpstr(ctrlName,"Plot_2")==0) 504 strswitch(ctrlName) // string switch 505 case "Plot_1": 506 //low-q 507 isOnPlot = strsearch(list, "LowQSet_i", 0) // isOnPlot == -1 if it is NOT found in the list 508 if(isOnPlot == -1) 509 DisplayLowSet() 510 Endif 511 break 512 case "Plot_2": 473 513 //medium-q 474 514 isOnPlot = strsearch(list, "MedQSet_i", 0) // isOnPlot == -1 if it is NOT found in the list … … 476 516 DisplayMedSet() 477 517 Endif 478 else 518 break 519 case "Plot_3": 479 520 //high-q 480 521 isOnPlot = strsearch(list, "HighQSet_i", 0) // isOnPlot == -1 if it is NOT found in the list … … 482 523 DisplayHighSet() 483 524 Endif 484 Endif 485 Endif 525 break 526 case "Plot_4": 527 //highest-q 528 isOnPlot = strsearch(list, "HighestQSet_i", 0) // isOnPlot == -1 if it is NOT found in the list 529 if(isOnPlot == -1) 530 DisplayHighestSet() 531 Endif 532 break 533 endswitch 534 486 535 Endif 536 537 487 538 //the stripPoints variable boxes should also update the graph, if necessary 488 539 return(0) 540 End 541 542 //adds both highest-q sets (full and trimmed) to the graph, which is 543 //assumed to exist along with the high-q waves 544 // 545 Function DisplayHighestSet() 546 //function assumes that the window "NSORT_Graph" already exists 547 // DoWindow/F NSORT_Graph 548 549 SetDataFolder root:HighestQSet: 550 AppendToGraph/W=NSORT_Graph $"HighestQSet_i" vs $"HighestQSet_q" 551 ModifyGraph/W=NSORT_Graph log=1,mode=3,marker($"HighestQSet_i")=8,msize=2,rgb($"HighestQSet_i")=(65535,32896,0),opaque($"HighestQSet_i")=1 552 ErrorBars/W=NSORT_Graph/T=0 $"HighestQSet_i" Y,wave=($"HighestQSet_s",$"HighestQSet_s") 553 AppendToGraph/W=NSORT_Graph $"TrimHighestQSet_i" vs $"TrimHighestQSet_q" 554 ModifyGraph/W=NSORT_Graph mode($"TrimHighestQSet_i")=3,marker($"TrimHighestQSet_i")=19,msize=2,rgb($"TrimHighestQSet_i")=(65535,32896,0) 555 SetDataFolder root: 489 556 End 490 557 … … 499 566 AppendToGraph/W=NSORT_Graph $"HighQSet_i" vs $"HighQSet_q" 500 567 ModifyGraph/W=NSORT_Graph log=1,mode=3,marker($"HighQSet_i")=8,msize=2,rgb($"HighQSet_i")=(0,0,65535),opaque($"HighQSet_i")=1 501 ErrorBars/W=NSORT_Graph $"HighQSet_i" Y,wave=($"HighQSet_s",$"HighQSet_s")568 ErrorBars/W=NSORT_Graph/T=0 $"HighQSet_i" Y,wave=($"HighQSet_s",$"HighQSet_s") 502 569 AppendToGraph/W=NSORT_Graph $"TrimHighQSet_i" vs $"TrimHighQSet_q" 503 570 ModifyGraph/W=NSORT_Graph mode($"TrimHighQSet_i")=3,marker($"TrimHighQSet_i")=19,msize=2,rgb($"TrimHighQSet_i")=(0,0,65535) … … 515 582 AppendToGraph/W=NSORT_Graph $"MedQSet_i" vs $"MedQSet_q" 516 583 ModifyGraph/W=NSORT_Graph log=1,mode=3,marker($"MedQSet_i")=8,msize=2,rgb($"MedQSet_i")=(65535,0,0),opaque($"MedQSet_i")=1 517 ErrorBars/W=NSORT_Graph $"MedQSet_i" Y,wave=($"MedQSet_s",$"MedQSet_s")584 ErrorBars/W=NSORT_Graph/T=0 $"MedQSet_i" Y,wave=($"MedQSet_s",$"MedQSet_s") 518 585 AppendToGraph/W=NSORT_Graph $"TrimMedQSet_i" vs $"TrimMedQSet_q" 519 586 ModifyGraph/W=NSORT_Graph mode($"TrimMedQSet_i")=3,marker($"TrimMedQSet_i")=19,msize=2,rgb($"TrimMedQSet_i")=(65535,0,0) … … 531 598 AppendToGraph/W=NSORT_Graph $"LowQSet_i" vs $"LowQSet_q" 532 599 ModifyGraph/W=NSORT_Graph log=1,mode=3,marker($"LowQSet_i")=8,msize=2,rgb($"LowQSet_i")=(2,39321,1),opaque($"LowQSet_i")=1 533 ErrorBars/W=NSORT_Graph $"LowQSet_i" Y,wave=($"LowQSet_s",$"LowQSet_s")600 ErrorBars/W=NSORT_Graph/T=0 $"LowQSet_i" Y,wave=($"LowQSet_s",$"LowQSet_s") 534 601 AppendToGraph/W=NSORT_Graph $"TrimLowQSet_i" vs $"TrimLowQSet_q" 535 602 ModifyGraph/W=NSORT_Graph mode($"TrimLowQSet_i")=3,marker($"TrimLowQSet_i")=19,msize=2,rgb($"TrimLowQSet_i")=(2,39321,1) 603 ModifyGraph tickUnit(left)=1 536 604 SetDataFolder root: 537 605 End … … 558 626 MedQPopMenuProc("popup_2",1,"") 559 627 HighQPopMenuProc("popup_3",1,"") 628 HighestQPopMenuProc("popup_4",1,"") 560 629 561 630 End … … 571 640 // 2 == MedQ 572 641 // 3 == HighQ 642 // 4 == HighestQ 573 643 // 574 644 //"Plot_1" is the low-q button name 575 645 //"Plot_2" is the med-q button name 576 646 //"Plot_3" is the high-q button name 647 //"Plot_4" is the high-q button name 577 648 // 578 649 //calling plot_0_Button() responds as if that named button were pressed … … 609 680 NVAR Columns2 = root:myGlobals:NSORT:gColumns2 610 681 NVAR Columns3 = root:myGlobals:NSORT:gColumns3 611 if( (Columns1 == 3) || (Columns2 == 3) || (Columns3 == 3) ) 682 NVAR Columns4 = root:myGlobals:NSORT:gColumns4 683 if( (Columns1 == 3) || (Columns2 == 3) || (Columns3 == 3) || (Columns4 == 3)) 612 684 isAThree = 1 613 685 endif 614 if( (Columns1 == 6) || (Columns2 == 6) || (Columns3 == 6) )686 if( (Columns1 == 6) || (Columns2 == 6) || (Columns3 == 6) || (Columns4 == 6)) 615 687 isASix = 1 616 688 endif … … 620 692 621 693 //is there just one data set? if so, then dispatch to a simpler routine, since no normalization is needed 622 ControlInfo/W=NSORT_Panel popup_2 //if MedQSet is "none", then so is HighQSet 694 ControlInfo/W=NSORT_Panel popup_2 //if MedQSet is "none", then so is HighQSet and HighestQSet 623 695 fileStr = S_Value 624 696 if(cmpstr(fileStr,"none") == 0) … … 657 729 ControlInfo/W=NSORT_Panel popup_1 658 730 if(isAThree) 659 WriteNSORTedFile(lowq,lowi,lows,S_Value,"none","none", S_Value,scaleFactor,1)731 WriteNSORTedFile(lowq,lowi,lows,S_Value,"none","none","none",S_Value,scaleFactor,1,1) 660 732 else 661 WriteNSORTedFile(lowq,lowi,lows,S_Value,"none","none", S_Value,scaleFactor,1,res=lowres)733 WriteNSORTedFile(lowq,lowi,lows,S_Value,"none","none","none",S_Value,scaleFactor,1,1,res=lowres) 662 734 endif 663 735 // just get the new list and return - don't actually "pop" the menu, or the selected item will change … … 672 744 //two or more datasets, combine them 673 745 //have they been manually or auto-normalized? 674 ControlInfo AutoCheck746 ControlInfo/W=NSORT_Panel AutoCheck 675 747 Variable checked = V_Value 676 748 … … 691 763 Window NSORT_Panel() 692 764 PauseUpdate; Silent 1 // building window... 693 NewPanel /W=(569,69,944, 485)/K=2765 NewPanel /W=(569,69,944,584)//K=2 694 766 ModifyPanel cbRGB=(49151,53155,65535) 695 767 ModifyPanel fixedSize=1 … … 701 773 DrawLine 0,214,346,214 702 774 DrawLine 0,295,346,295 775 DrawLine 0,372,347,372 776 DrawLine 0,460,346,460 777 703 778 SetDrawEnv fstyle= 5 704 779 DrawText 5,74,"Low Q:" … … 707 782 SetDrawEnv fstyle= 5 708 783 DrawText 8,234,"High Q: (or none)" 784 SetDrawEnv fstyle= 5 785 DrawText 8,314,"Highest Q: (or none)" 709 786 SetDrawEnv fstyle= 4 710 787 DrawText 178,75,"Delete Points?" … … 713 790 SetDrawEnv fstyle= 4 714 791 DrawText 184,236,"Delete Points?" 715 DrawLine 0,363,346,363 716 DrawText 31,357,"To Manually scale data, enter scale factors above" 717 Button NSORT_Done,pos={274,387},size={50,20},proc=NSORT_DoneButton,title="Done" 792 SetDrawEnv fstyle= 4 793 DrawText 184,316,"Delete Points?" 794 DrawText 31,456,"To Manually scale data, enter scale factors above" 795 796 Button NSORT_Done,pos={274,483},size={50,20},proc=NSORT_DoneButton,title="Done" 718 797 Button NSORT_Done,help={"closes the panel"} 719 798 Button Plot_1,pos={279,63},size={50,20},proc=Plot_0_Button,title="Plot" … … 723 802 Button Plot_3,pos={284,223},size={50,20},proc=Plot_0_Button,title="Plot" 724 803 Button Plot_3,help={"Plots the dataset from the popup, showing the full set as open circles and the trimmed set as solid circles"} 804 Button Plot_4,pos={284.00,303.00},size={50.00,20.00},proc=Plot_0_Button,title="Plot" 805 Button Plot_4,help={"Plots the dataset from the popup, showing the full set as open circles and the trimmed set as solid circles"} 806 725 807 Button PathButton,pos={6,26},size={80,20},proc=NSORTPickPathButton,title="Pick Path" 726 808 Button PathButton,help={"Select the local path to the folder containing your SANS data"} … … 739 821 SetVariable end_3,fSize=10,help={"How many points to remove from the high-q end of this dataset"} 740 822 SetVariable end_3,limits={-Inf,Inf,0},value= root:myGlobals:NSORT:gPtsEnd3 823 SetVariable end_4,pos={182.00,349.00},size={80.00,16.00},proc=SetBegOrEnd,title="End Pts" 824 SetVariable end_4,help={"How many points to remove from the high-q end of this dataset"} 825 SetVariable end_4,fSize=10 826 SetVariable end_4,limits={-inf,inf,0},value= root:myGlobals:NSORT:gPtsEnd4 741 827 SetVariable beg_1,pos={182,79},size={80,14},proc=SetBegOrEnd,title="Beg Pts" 742 828 SetVariable beg_1,fSize=10,help={"How many points to remove from the low-q end of this dataset"} … … 748 834 SetVariable beg_3,fSize=10,help={"How many points to remove from the low-q end of this dataset"} 749 835 SetVariable beg_3,limits={-Inf,Inf,0},value= root:myGlobals:NSORT:gPtsBeg3 750 Button DoCombine,pos={13,387},size={160,20},proc=WriteNSORTFileButton,title="Write Combined File" 836 SetVariable beg_4,pos={182.00,326.00},size={80.00,16.00},proc=SetBegOrEnd,title="Beg Pts" 837 SetVariable beg_4,help={"How many points to remove from the low-q end of this dataset"} 838 SetVariable beg_4,fSize=10 839 SetVariable beg_4,limits={-inf,inf,0},value= root:myGlobals:NSORT:gPtsBeg4 840 Button DoCombine,pos={13,483},size={160,20},proc=WriteNSORTFileButton,title="Write Combined File" 751 841 Button DoCombine,help={"Combine and normalize the selected files as specifed"} 752 SetVariable scale_12,pos={159,3 05},size={160,14},proc=SetScale_12,title="Mult factor 1-2"842 SetVariable scale_12,pos={159,381},size={160,14},proc=SetScale_12,title="Mult factor 1-2" 753 843 SetVariable scale_12,fSize=10,help={"Factor that will multiply medium-q set to scale to low-q set"} 754 844 SetVariable scale_12,limits={-Inf,Inf,0},value= root:myGlobals:NSORT:gScale1_2 755 SetVariable scale_23,pos={159, 325},size={160,14},proc=SetScale_23,title="Mult factor 2-3"845 SetVariable scale_23,pos={159,401},size={160,14},proc=SetScale_23,title="Mult factor 2-3" 756 846 SetVariable scale_23,fSize=10,help={"Factor that will multiply high-q set to scale to medium-q set"} 757 847 SetVariable scale_23,limits={-Inf,Inf,0},value= root:myGlobals:NSORT:gScale2_3 848 SetVariable scale_34,pos={159.00,421.00},size={160.00,16.00},proc=SetScale_34,title="Mult factor 3-4" 849 SetVariable scale_34,help={"Factor that will multiply highest-q set to scale to high-q set"} 850 SetVariable scale_34,fSize=10 851 SetVariable scale_34,limits={-inf,inf,0},value= root:myGlobals:NSORT:gScale3_4 758 852 CheckBox check1,pos={5,105},size={160,20},proc=CheckProc,title="Normalize to this file",value=1 759 853 CheckBox check1,help={"If checked, the combined dataset will be normalized to this dataset"} … … 762 856 CheckBox check3,pos={4,270},size={160,20},proc=CheckProc,title="Normalize to this file",value=0 763 857 CheckBox check3,help={"If checked, the combined dataset will be normalized to this dataset"} 858 CheckBox check4,pos={4.00,350.00},size={107.00,16.00},proc=CheckProc,title="Normalize to this file" 859 CheckBox check4,help={"If checked, the combined dataset will be normalized to this dataset"} 860 CheckBox check4,value= 0 764 861 PopupMenu popup_1,pos={6,77},size={99,19},proc=LowQPopMenuProc 765 862 PopupMenu popup_1,mode=1,value= #"root:myGlobals:NSORT:gDataPopList" … … 771 868 PopupMenu popup_3,mode=1,value= #"root:myGlobals:NSORT:gDataPopList_3" 772 869 PopupMenu popup_3,help={"Choose the dataset with the highest overall q-value (shortest detector distance), or NONE if no third set desired"} 773 CheckBox AutoCheck,pos={14,310},size={100,20},title="Auto Scale",value=0 870 PopupMenu popup_4,pos={6.00,319.00},size={58.00,23.00},proc=HighestQPopMenuProc 871 PopupMenu popup_4,help={"Choose the dataset with the highest overall q-value (shortest detector distance), or NONE if no fourth set desired"} 872 PopupMenu popup_4,mode=1,popvalue="none",value= #"root:myGlobals:NSORT:gDataPopList_3" 873 CheckBox AutoCheck,pos={14,386},size={100,20},title="Auto Scale",value=0 774 874 CheckBox AutoCheck,help={"If checked, the scale factor will be automatically determined, if not checked, the current values in the fields will be used"} 775 CheckBox PreviewCheck,pos={15, 369},size={74,14},title="Preview Only",value= 0776 CheckBox WarningCheck,pos={111, 369},size={93,14},title="Overlap warning?",value= 1875 CheckBox PreviewCheck,pos={15,465},size={74,14},title="Preview Only",value= 0 876 CheckBox WarningCheck,pos={111,465},size={93,14},title="Overlap warning?",value= 1 777 877 EndMacro 778 878 … … 800 900 801 901 Variable/G root:myGlobals:NSORT:gScale2_3 = varNum 902 End 903 904 //sets the scale factor (multiplicative) between sets 3 and 4 905 //re-sets the global variable 906 // 907 Function SetScale_34(ctrlName,varNum,varStr,varName) : SetVariableControl 908 String ctrlName 909 Variable varNum 910 String varStr 911 String varName 912 913 Variable/G root:myGlobals:NSORT:gScale3_4 = varNum 802 914 End 803 915 … … 820 932 CheckBox check2 value=1 821 933 CheckBox check3 value=0 934 CheckBox check4 value=0 822 935 Variable/G root:myGlobals:NSORT:gNormToNum = 2 823 936 break … … 827 940 CheckBox check2 value=0 828 941 CheckBox check3 value=1 942 CheckBox check4 value=0 829 943 Variable/G root:myGlobals:NSORT:gNormToNum = 3 944 break 945 Endif 946 if(cmpstr(ctrlName,"check4") == 0) 947 CheckBox check1 value=0 948 CheckBox check2 value=0 949 CheckBox check3 value=0 950 CheckBox check4 value=1 951 Variable/G root:myGlobals:NSORT:gNormToNum = 4 830 952 break 831 953 Endif … … 834 956 CheckBox check2 value=0 835 957 CheckBox check3 value=0 958 CheckBox check4 value=0 836 959 Variable/G root:myGlobals:NSORT:gNormToNum = 1 837 960 While(0) 961 838 962 ControlUpdate/A/W=NSORT_Panel 839 963 DoUpdate 840 964 841 965 End … … 897 1021 898 1022 1023 //when menu is popped, it gets a valid list to display and updates the control 1024 // - will be different, since set 3 can also be "none" if only 2 sets 1025 //are to be NSORTed 1026 // 1027 Function HighestQPopMenuProc(ctrlName,popNum,popStr) : PopupMenuControl 1028 String ctrlName 1029 Variable popNum 1030 String popStr 1031 1032 //add the option "none" to the file list (which should already end with a semicolon) 1033 String/G root:myGlobals:NSORT:gDataPopList_3 = "none;" + ReducedDataFileList("") 1034 1035 ControlUpdate/W=NSORT_Panel popup_4 1036 if(cmpstr(popStr,"none")==0) 1037 RemoveFromGraph/Z HighestQSet_i,TrimHighestQSet_i //remove the data from the graph 1038 Endif 1039 ControlInfo/W=NSORT_Panel popup_2 1040 if(cmpstr(S_Value,"none")==0) 1041 PopupMenu popup_3,win=NSORT_Panel,mode=1 //force "none" (item #1) to be the selection if medium is none 1042 PopupMenu popup_4,win=NSORT_Panel,mode=1 //force "none" (item #1) to be the selection if medium is none 1043 endif 1044 ControlInfo/W=NSORT_Panel popup_3 1045 if(cmpstr(S_Value,"none")==0) 1046 PopupMenu popup_4,win=NSORT_Panel,mode=1 //force "none" (item #1) to be the selection if medium is none 1047 endif 1048 return(0) 1049 End 1050 899 1051 //be sure to use the "Trim.." datasets that have had the bad points removed 900 1052 //and then do the scaling based on the choices in the panel … … 905 1057 906 1058 NVAR normTo = root:myGlobals:NSORT:gNormToNum 907 Variable err=0,setNum,norm12,norm23 908 String fileStr="",tempName="",name1="",name2="",name3="",normToStr="" 1059 Variable err=0,setNum,norm12,norm23,norm34 1060 String fileStr="",tempName="",name1="",name2="",name3="",normToStr="",name4="" 909 1061 910 1062 //Set the number of output columns … … 914 1066 NVAR Columns2 = root:myGlobals:NSORT:gColumns2 915 1067 NVAR Columns3 = root:myGlobals:NSORT:gColumns3 916 if( (Columns1 == 3) || (Columns2 == 3) || (Columns3 == 3) ) 1068 NVAR Columns4 = root:myGlobals:NSORT:gColumns4 1069 if( (Columns1 == 3) || (Columns2 == 3) || (Columns3 == 3) || (Columns4 == 3) ) 917 1070 numOutputColumns = 3 918 1071 else 919 if( (Columns1 == 6) && (Columns2 == 6) && ((Columns3 == 0) || (Columns3 == 6)) )1072 if( (Columns1 == 6) && (Columns2 == 6) && ((Columns3 == 0) || (Columns3 == 6)) || (Columns4 == 6) ) 920 1073 numOutputColumns = 6 921 1074 endif … … 925 1078 926 1079 //load file1 927 ControlInfo $"popup_1"1080 ControlInfo/W=NSORT_Panel popup_1 928 1081 fileStr = S_Value 929 1082 name1 = fileStr … … 939 1092 940 1093 //load file2 941 ControlInfo $"popup_2"1094 ControlInfo/W=NSORT_Panel popup_2 942 1095 fileStr = S_Value 943 1096 name2 = fileStr … … 953 1106 954 1107 //load file3 , if necessary 955 ControlInfo $"popup_3"1108 ControlInfo/W=NSORT_Panel popup_3 956 1109 fileStr = S_Value 957 1110 name3 = fileStr … … 970 1123 //////end load file3 971 1124 1125 //load file4 , if necessary 1126 ControlInfo/W=NSORT_Panel popup_4 1127 fileStr = S_Value 1128 name4 = fileStr 1129 setNum = 4 1130 if(cmpstr(fileStr,"none") == 0) 1131 //do nothing 1132 else 1133 //get a valid file based on this partialName and catPathName 1134 tempName = FindValidFilename(fileStr) 1135 1136 //prepend path to tempName for read routine 1137 PathInfo catPathName 1138 tempName = S_path + tempName 1139 err = LoadDataForNSORT(tempName,setNum) 1140 Endif 1141 //////end load file4 1142 1143 972 1144 //assign filename of file to normalize to 973 if(normTo == 1) 974 normToStr = name1 975 else 976 if(normTo == 2) 1145 switch(normTo) 1146 case 1: 1147 normToStr = name1 1148 break 1149 case 2: 977 1150 normToStr = name2 978 else 1151 break 1152 case 3: 979 1153 normToStr = name3 980 Endif 981 Endif 1154 break 1155 case 4: 1156 normToStr = name4 1157 break 1158 endswitch 1159 982 1160 983 1161 Variable n1,n2,n12,num2 984 1162 Variable n3,n123 1163 Variable n4,n1234 985 1164 986 1165 if(numOutputColumns == 3) //Start the 3-column specific stuff here. … … 1070 1249 ControlInfo/W=NSORT_Panel PreviewCheck 1071 1250 if( V_Value==0 ) //if zero skip the preview and write out the file 1072 err=WriteNSORTedFile(q12,i12,sig12,name1,name2,name3,n ormToStr,norm12,norm23)1251 err=WriteNSORTedFile(q12,i12,sig12,name1,name2,name3,name4,normToStr,norm12,norm23,norm34) 1073 1252 endif 1074 1253 //cleanup waves before exiting … … 1160 1339 ControlInfo/W=NSORT_Panel PreviewCheck 1161 1340 if( V_Value==0 ) //if zero skip the preview and write out the file 1162 err=WriteNSORTedFile(q123,i123,sig123,name1,name2,name3,n ormToStr,norm12,norm23)1341 err=WriteNSORTedFile(q123,i123,sig123,name1,name2,name3,name4,normToStr,norm12,norm23,norm34) 1163 1342 endif 1164 1343 //cleanup waves before exiting 1165 1344 KillWaves/Z q12,i12,sig12,q123,i123,sig123 1345 1346 1347 //do we need to continue, or write out the set here and stop? 1348 if(cmpstr(name4,"none") == 0) 1349 //stop here 1350 norm34 = 1 //norm34 was not used 1351 Variable/G root:myGlobals:NSORT:gScale3_4 = 1 1352 //If any of them have three columns write three column data 1353 1354 ControlInfo/W=NSORT_Panel PreviewCheck 1355 if( V_Value==0 ) //if zero skip the preview and write out the file 1356 err=WriteNSORTedFile(q123,i123,sig123,name1,name2,name3,name4,normToStr,norm12,norm23,norm34) 1357 endif 1358 //cleanup waves before exiting 1359 KillWaves/Z q123,i123,sig123 1360 return err 1361 Endif 1362 1363 //need to add the fourth file... which was already loaded at the top of the function 1364 ///// 1365 //order points in sets 123-4, indexing overlap region 1366 //put result in temporary waves 1367 WaveStats/Q q123 1368 n123 = V_npnts 1369 WaveStats/Q $"root:HighestQSet:TrimHighestQSet_q" 1370 n4 = V_npnts 1371 n1234 = n123 + n4 1372 1373 Make/O/N=(n1234) q1234,i1234,sig1234 1374 WAVE highestq = $"root:HighestQSet:TrimHighestQSet_q" 1375 WAVE highesti = $"root:HighestQSet:TrimHighestQSet_i" 1376 WAVE highests = $"root:HighestQSet:TrimHighestQSet_s" 1377 1378 q1234[0,n123-1] = q123[p] 1379 q1234[n12,n123+n4-1]= highestq[p-n123] 1380 i1234[0,n123-1] = i123[p] 1381 i1234[n12,n123+n4-1]= highesti[p-n123] 1382 sig1234[0,n123-1] = sig123[p] 1383 sig1234[n12,n123+n4-1]= highests[p-n123] 1384 1385 Sort q1234, q1234,i1234,sig1234 1386 ///////////////// 1387 1388 //find the maximum point number of set 2 in the overlap region 1389 FindLevel/P/Q highestq,(q123[n123-1]) 1390 num2 = trunc(V_levelX) 1391 //Print "num2 = ",num2 1392 1393 if (auto) 1394 //there must be overlap points to use auto-scaling 1395 if(numtype(num2) != 0) 1396 Abort "There are no data points in the overlap region. Either reduce the number of deleted points or use manual scaling." 1397 endif 1398 //do auto-scaling of data 1399 norm34 = NCNR_GetScalingInOverlap(num2,q123,i123,highestq,highesti) 1400 //Set the global variable for the 123 - 4 scale factor 1401 Variable/G root:myGlobals:NSORT:gScale3_4 = norm34 1402 else 1403 //use the value from the panel ( which is the global) 1404 NVAR temp34 = root:myGlobals:NSORT:gScale3_4 1405 norm34 = temp34 1406 Endif 1407 1408 // normalization 1409 switch (normTo) 1410 case 1: 1411 case 2: 1412 case 3: 1413 //normalize to first or second or third file, so multiply fourth by norm34 1414 highesti *= norm34 1415 highests *= norm34 1416 break 1417 case 4: 1418 //normalize to FOURTH file, 123 by multiplicative factor 1/norm34 1419 norm34 = 1/norm34 1420 i123 *= norm34 1421 sig123 *= norm34 1422 // for the display, scale the trimmed sets 1 and 2 and 3 1423 lowi *= norm34 1424 lows *= norm34 1425 medi *= norm34 1426 meds *= norm34 1427 highi *= norm34 1428 highs *= norm34 1429 break 1430 endswitch 1431 1432 ControlUpdate/A/W=NSORT_Panel 1433 DoUpdate 1434 1435 //Print "NSORT-ed ",name1," + ", name2, " + ", name3 1436 //Print "normalized to ",normTo 1437 //Print "multiplicative factor 1-2 = ",norm12," multiplicative factor 12 - 3 = ",norm23 1438 1439 1440 Make/O/N=(n1234) q1234,i1234,sig1234 1441 q1234[0,n123-1] = q123[p] 1442 q1234[n123,n123+n4-1]= highestq[p-n123] 1443 i1234[0,n123-1] = i123[p] 1444 i1234[n123,n123+n4-1]= highesti[p-n123] 1445 sig1234[0,n123-1] = sig123[p] 1446 sig1234[n123,n123+n4-1]= highests[p-n123] 1447 1448 Sort q123, q123,i123,sig123 1449 //at this point 12 - 3 are combined 1450 //write out the set here and stop 1451 1452 ControlInfo/W=NSORT_Panel PreviewCheck 1453 if( V_Value==0 ) //if zero skip the preview and write out the file 1454 err=WriteNSORTedFile(q123,i123,sig123,name1,name2,name3,name4,normToStr,norm12,norm23,norm34) 1455 endif 1456 //cleanup waves before exiting 1457 KillWaves/Z q12,i12,sig12,q123,i123,sig123 1458 1459 1460 1461 1166 1462 //combined dataset will already be displayed if the NSORT_Graph is open 1167 1463 … … 1187 1483 WAVE lows = $"root:LowQSet:TrimLowQSet_s" 1188 1484 WAVE meds = $"root:MedQSet:TrimMedQSet_s" 1189 // WAVE lowsq = $"root:LowQSet:TrimLowQSet_sq"1190 // WAVE medsq = $"root:MedQSet:TrimMedQSet_sq"1191 // WAVE lowqb = $"root:LowQSet:TrimLowQSet_qb"1192 // WAVE medqb = $"root:MedQSet:TrimMedQSet_qb"1193 // WAVE lowfs = $"root:LowQSet:TrimLowQSet_fs"1194 // WAVE medfs = $"root:MedQSet:TrimMedQSet_fs"1195 1485 WAVE lowres = $"root:LowQSet:TrimLowQSet_res" 1196 1486 WAVE medres = $"root:MedQSet:TrimMedQSet_res" … … 1208 1498 fs12[0,n1-1] = lowres[p][2] 1209 1499 fs12[n1,n1+n2-1]= medres[p-n1][2] 1210 // res12[0,n1-1][0]=lowres[p][0]1211 // res12[n1,n1+n2-1][0]=medres[p-n1][0]1212 // res12[0,n1-1][1]=lowres[p][1]1213 // res12[n1,n1+n2-1][1]=medres[p-n1][1]1214 // res12[0,n1-1][2]=lowres[p][2]1215 // res12[n1,n1+n2-1][2]=medres[p-n1][2]1216 1500 1217 1501 … … 1272 1556 fs12[0,n1-1] = lowres[p][2] 1273 1557 fs12[n1,n1+n2-1]= medres[p-n1][2] 1274 // res12[0,n1-1][0]=lowres[p][0]1275 // res12[n1,n1+n2-1][0]=medres[p-n1][0]1276 // res12[0,n1-1][1]=lowres[p][1]1277 // res12[n1,n1+n2-1][1]=medres[p-n1][1]1278 // res12[0,n1-1][2]=lowres[p][2]1279 // res12[n1,n1+n2-1][2]=medres[p-n1][2]1280 1558 1281 1559 … … 1293 1571 res12[][1] = qb12[p] 1294 1572 res12[][2] = fs12[p] 1295 err=WriteNSORTedFile(q12,i12,sig12,name1,name2,name3,n ormToStr,norm12,norm23,res=res12)1573 err=WriteNSORTedFile(q12,i12,sig12,name1,name2,name3,name4,normToStr,norm12,norm23,norm34,res=res12) 1296 1574 endif 1297 1575 // always clean up waves before exiting … … 1315 1593 WAVE highi = $"root:HighQSet:TrimHighQSet_i" 1316 1594 WAVE highs = $"root:HighQSet:TrimHighQSet_s" 1317 // WAVE highsq = $"root:HighQSet:TrimHighQSet_sq"1318 // WAVE highqb = $"root:HighQSet:TrimHighQSet_qb"1319 // WAVE highfs = $"root:HighQSet:TrimHighQSet_fs"1320 1595 WAVE highres = $"root:HighQSet:TrimHighQSet_res" 1321 1596 1322 1597 1323 1598 q123[0,n12-1] = q12[p] 1324 q123[n1 ,n12+n3-1]= highq[p-n12]1599 q123[n12,n12+n3-1]= highq[p-n12] 1325 1600 i123[0,n12-1] = i12[p] 1326 i123[n1 ,n12+n3-1]= highi[p-n12]1601 i123[n12,n12+n3-1]= highi[p-n12] 1327 1602 sig123[0,n12-1] = sig12[p] 1328 sig123[n1 ,n12+n3-1]= highs[p-n12]1603 sig123[n12,n12+n3-1]= highs[p-n12] 1329 1604 sq123[0,n12-1] = sq12[p] 1330 sq123[n1 ,n12+n3-1]= highres[p-n12][0]1605 sq123[n12,n12+n3-1]= highres[p-n12][0] 1331 1606 qb123[0,n12-1] = qb12[p] 1332 qb123[n1 ,n12+n3-1]= highres[p-n12][1]1607 qb123[n12,n12+n3-1]= highres[p-n12][1] 1333 1608 fs123[0,n12-1] = fs12[p] 1334 fs123[n1,n12+n3-1]= highres[p-n12][2] 1335 // res123[0,n12-1][0] = highres[p][0] 1336 // res123[n1,n12+n3-1][0] = highres[p-n12][0] 1337 // res123[0,n12-1][1] = highres[p][1] 1338 // res123[n1,n12+n3-1][1] = highres[p-n12][1] 1339 // res123[0,n12-1][2] = highres[p][2] 1340 // res123[n1,n12+n3-1][2] = highres[p-n12][2] 1609 fs123[n12,n12+n3-1]= highres[p-n12][2] 1341 1610 1342 1611 … … 1400 1669 fs123[0,n12-1] = fs12[p] 1401 1670 fs123[n12,n12+n3-1]= highres[p-n12][2] 1402 // res123[0,n12-1][0] = highres[p][0] 1403 // res123[n1,n12+n3-1][0] = highres[p-n12][0] 1404 // res123[0,n12-1][1] = highres[p][1] 1405 // res123[n1,n12+n3-1][1] = highres[p-n12][1] 1406 // res123[0,n12-1][2] = highres[p][2] 1407 // res123[n1,n12+n3-1][2] = highres[p-n12][2] 1671 1408 1672 1409 1673 Sort q123, q123,i123,sig123,sq123,qb123,fs123 1410 1674 //at this point 12 - 3 are combined 1411 //write out the set here and stop 1675 1676 //do we need to continue, or write out the set here and stop? 1677 if(cmpstr(name4,"none") == 0) 1678 //stop here 1679 1680 ControlInfo/W=NSORT_Panel PreviewCheck 1681 if( V_Value==0 ) //if zero skip the preview and write out the file 1682 res123[][0] = sq123[p] 1683 res123[][1] = qb123[p] 1684 res123[][2] = fs123[p] 1685 err=WriteNSORTedFile(q123,i123,sig123,name1,name2,name3,name4,normToStr,norm12,norm23,norm34,res=res123) 1686 endif 1687 // always clean up waves before exiting 1688 KillWaves/Z q12,i12,sig12,q123,i123,sig123,sq123,qb123,fs123 //,res123 1689 return err 1690 Endif 1691 1692 // new 2016 - combine the 4th data set 1693 1694 //need to add the fourth file... which was already loaded at the top of the function 1695 ///// 1696 //order points in sets 123-4, indexing overlap region 1697 //put result in temporary waves 1698 WaveStats/Q q123 1699 n123 = V_npnts 1700 WaveStats/Q $"root:HighestQSet:TrimHighestQSet_q" 1701 n4 = V_npnts 1702 n1234 = n123 + n4 1703 1704 Make/O/N=(n1234) q1234,i1234,sig1234,sq1234,qb1234,fs1234 1705 Make/O/N=(n1234,3) res1234 1706 WAVE highestq = $"root:HighestQSet:TrimHighestQSet_q" 1707 WAVE highesti = $"root:HighestQSet:TrimHighestQSet_i" 1708 WAVE highests = $"root:HighestQSet:TrimHighestQSet_s" 1709 WAVE highestres = $"root:HighestQSet:TrimHighestQSet_res" 1710 1711 1712 q1234[0,n123-1] = q123[p] 1713 q1234[n123,n123+n4-1]= highestq[p-n123] 1714 i1234[0,n123-1] = i123[p] 1715 i1234[n123,n123+n4-1]= highesti[p-n123] 1716 sig1234[0,n123-1] = sig123[p] 1717 sig1234[n123,n123+n4-1]= highests[p-n123] 1718 sq1234[0,n123-1] = sq123[p] 1719 sq1234[n123,n123+n4-1]= highestres[p-n123][0] 1720 qb1234[0,n123-1] = qb123[p] 1721 qb1234[n123,n123+n4-1]= highestres[p-n123][1] 1722 fs1234[0,n123-1] = fs123[p] 1723 fs1234[n123,n123+n4-1]= highestres[p-n123][2] 1724 1725 1726 Sort q1234, q1234,i1234,sig1234,sq1234,qb1234,fs1234 1727 ///////////////// 1728 1729 //find the maximum point number of set 2 in the overlap region 1730 FindLevel/P/Q highestq,(q123[n123-1]) 1731 num2 = trunc(V_levelX) 1732 //Print "num2 = ",num2 1733 1734 if (auto) 1735 //there must be overlap points to use auto-scaling 1736 if(numtype(num2) != 0) 1737 Abort "There are no data points in the overlap region. Either reduce the number of deleted points or use manual scaling." 1738 endif 1739 //do auto-scaling of data 1740 norm34 = NCNR_GetScalingInOverlap(num2,q123,i123,highestq,highesti) 1741 //Set the global variable for the 12 - 3 scale factor 1742 Variable/G root:myGlobals:NSORT:gScale3_4 = norm34 1743 else 1744 //use the value from the panel ( which is the global) 1745 NVAR temp34 = root:myGlobals:NSORT:gScale3_4 1746 norm34 = temp34 1747 Endif 1748 1749 // normalization 1750 switch (normTo) 1751 case 1: 1752 case 2: 1753 case 3: 1754 //normalize to first or second or third file, so multiply fourth by norm34 1755 highesti *= norm34 1756 highests *= norm34 1757 break 1758 case 4: 1759 //normalize to FOURTH file, 123 by multiplicative factor 1/norm34 1760 norm34 = 1/norm34 1761 i123 *= norm34 1762 sig123 *= norm34 1763 // for the display, scale the trimmed sets 1 and 2 and 3 1764 lowi *= norm34 1765 lows *= norm34 1766 medi *= norm34 1767 meds *= norm34 1768 highi *= norm34 1769 highs *= norm34 1770 break 1771 endswitch 1772 1773 1774 //Print "NSORT-ed ",name1," + ", name2, " + ", name3 1775 //Print "normalized to ",normTo 1776 //Print "multiplicative factor 1-2 = ",norm12," multiplicative factor 12 - 3 = ",norm23 1777 ControlUpdate/A/W=NSORT_Panel 1778 DoUpdate 1779 1780 Make/O/N=(n1234) q1234,i1234,sig1234 1781 Make/O/N=(n1234,3) res1234 1782 q1234[0,n123-1] = q123[p] 1783 q1234[n123,n123+n4-1]= highestq[p-n123] 1784 i1234[0,n123-1] = i123[p] 1785 i1234[n123,n123+n4-1]= highesti[p-n123] 1786 sig1234[0,n123-1] = sig123[p] 1787 sig1234[n123,n123+n4-1]= highests[p-n123] 1788 sq1234[0,n123-1] = sq123[p] 1789 sq1234[n123,n123+n4-1]= highestres[p-n123][0] 1790 qb1234[0,n123-1] = qb123[p] 1791 qb1234[n123,n123+n4-1]= highestres[p-n123][1] 1792 fs1234[0,n123-1] = fs123[p] 1793 fs1234[n123,n123+n4-1]= highestres[p-n123][2] 1794 1795 Sort q1234, q1234,i1234,sig1234,sq1234,qb1234,fs1234 1796 //at this point 123 - 4 are combined 1797 1798 //write out the set here and stop 1799 //stop here 1412 1800 1413 1801 ControlInfo/W=NSORT_Panel PreviewCheck 1414 1802 if( V_Value==0 ) //if zero skip the preview and write out the file 1415 res123 [][0] = sq123[p]1416 res123 [][1] = qb123[p]1417 res123 [][2] = fs123[p]1418 err=WriteNSORTedFile(q123 ,i123,sig123,name1,name2,name3,normToStr,norm12,norm23,res=res123)1803 res1234[][0] = sq1234[p] 1804 res1234[][1] = qb1234[p] 1805 res1234[][2] = fs1234[p] 1806 err=WriteNSORTedFile(q1234,i1234,sig1234,name1,name2,name3,name4,normToStr,norm12,norm23,norm34,res=res1234) 1419 1807 endif 1420 //cleanup waves before exiting 1421 KillWaves/Z q12,i12,sig12,q123,i123,sig123,sq123,qb123,fs123 //,res123 1808 // always clean up waves before exiting 1809 KillWaves/Z q123,i123,sig123,q1234,i1234,sig1234,sq1234,qb1234,fs1234 //,res1234 1810 return err 1811 1422 1812 //combined dataset will already be displayed if the NSORT_Graph is open 1423 1813 1424 1814 //////////////// 1425 1815 return err 1426 endif // End the 6-column specific stuff here 1427 1428 End 1816 endif // End the if(6-column) specific stuff here 1817 1818 1819 End 1820 1821 1822 1429 1823 1430 1824 … … 1489 1883 End 1490 1884 1885 ///////////////////////////////////////////////////////////// 1886 // testing, may speed up NSORT, NCNR-specific naming scheme of 1887 // run numbers and a run prefix 1888 // 1889 // it is assumed that you are combining data from the current reduction session, 1890 // so that the XML y/n hasn't changed. 1891 // 1892 // updated to use 4 files 1893 // 1894 // TODO: 1895 // -- still assuming ABS 1896 // 1897 Function Set4NSORTFiles(low,med,hi,highest,pref) 1898 Variable low,med,hi,highest 1899 String pref 1900 1901 //make strings from the numbers 1902 String absStr="",ext 1903 Variable popNum 1904 DoWindow/F NSORT_Panel 1905 1906 SVAR lowQPopStr = root:myGlobals:NSORT:gDataPopList 1907 SVAR medHiQPopStr = root:myGlobals:NSORT:gDataPopList_3 1908 1909 NVAR useXMLOutput = root:Packages:NIST:gXML_Write 1910 if(useXMLOutput) 1911 ext = ".ABSx" 1912 else 1913 ext = ".ABS" 1914 endif 1915 1916 //lowQ menu 1917 absStr = pref+RunDigitString(low)+ext 1918 popNum = WhichListItem(absStr,lowQPopStr,";",0) 1919 if(popNum == -1) 1920 Abort "Could not find file: " + absStr +" aborting... Be sure that your output format is the same as the input" 1921 endif 1922 popNum += 1 // add 1 to get the item number 1923 PopupMenu popup_1,win=NSORT_Panel,mode=(popNum) 1924 1925 //medQ (a different list for the popup) 1926 absStr = pref+RunDigitString(med)+ext 1927 popNum = WhichListItem(absStr,medHiQPopStr,";",0) 1928 if(popNum == -1) 1929 Abort "Could not find file: "+absStr+" aborting... Be sure that your output format is the same as the input" 1930 endif 1931 popNum += 1 // add 1 to get the item number 1932 PopupMenu popup_2,win=NSORT_Panel,mode=(popNum) 1933 1934 1935 //highQ (same pop list as medQ) 1936 if(hi != 0) 1937 absStr = pref+RunDigitString(hi)+ext 1938 popNum = WhichListItem(absStr,medHiQPopStr,";",0) 1939 if(popNum == -1) 1940 Abort "Could not find file: "+absStr+" aborting... Be sure that your output format is the same as the input" 1941 endif 1942 popNum += 1 // add 1 to get the item number 1943 PopupMenu popup_3,win=NSORT_Panel,mode=(popNum) 1944 else 1945 PopupMenu popup_3,win=NSORT_Panel,mode=(1) 1946 endif 1947 1948 //highestQ (same pop list as medQ) 1949 if(highest != 0) 1950 absStr = pref+RunDigitString(highest)+ext 1951 popNum = WhichListItem(absStr,medHiQPopStr,";",0) 1952 if(popNum == -1) 1953 Abort "Could not find file: "+absStr+" aborting... Be sure that your output format is the same as the input" 1954 endif 1955 popNum += 1 // add 1 to get the item number 1956 PopupMenu popup_4,win=NSORT_Panel,mode=(popNum) 1957 else 1958 PopupMenu popup_4,win=NSORT_Panel,mode=(1) 1959 endif 1960 1961 return(0) 1962 End 1963 1491 1964 //more beta procedures - to create a table of scattering runs to combine with NSORT 1492 1965 Proc CreateTableToCombine(ctrlName) … … 1535 2008 //write to notebook that file was not found 1536 2009 //if string is not a number, report the error 1537 //if(str2num(partialName) == NaN) // will always be false [davidm]1538 2010 if(numtype(str2num(partialName)) == 2) 1539 2011 str = "this file was not found: "+partialName+"\r\r" … … 1692 2164 MedQPopMenuProc("",1,"") 1693 2165 HighQPopMenuProc("",1,"") 2166 HighestQPopMenuProc("",1,"") 1694 2167 1695 2168 // String savedDataFolder = GetDataFolder(1) // save … … 1697 2170 Wave MediumRun = root:myGlobals:CombineTable:MediumRun 1698 2171 Wave HighRun = root:myGlobals:CombineTable:HighRun 2172 Wave HighestRun = root:myGlobals:CombineTable:HighestRun 1699 2173 Wave/T prefix = root:myGlobals:CombineTable:Prefix 1700 2174 Wave/T saveName = root:myGlobals:CombineTable:saveName … … 1702 2176 Variable/G root:myGlobals:CombineTable:useTable=1 1703 2177 1704 Variable num=numpnts(lowRun),ii,lowFile,medFile,hiFile 2178 Variable num=numpnts(lowRun),ii,lowFile,medFile,hiFile,highestFile 1705 2179 String prefixStr = "" 1706 2180 Pathinfo catPathName … … 1712 2186 medFile = MediumRun[ii] 1713 2187 hiFile = highRun[ii] 2188 highestFile = highestRun[ii] 1714 2189 prefixStr = prefix[ii] 1715 2190 1716 Set 3NSORTFiles(lowFile,medFile,hiFile,prefixStr) //set the files and pop the NSORT popups2191 Set4NSORTFiles(lowFile,medFile,hiFile,highestFile,prefixStr) //set the files and pop the NSORT popups 1717 2192 1718 2193 //pass the new file name in as a global (ugh!) … … 1783 2258 Wave medium = $"root:myGlobals:CombineTable:MediumRun" 1784 2259 Wave high = $"root:myGlobals:CombineTable:HighRun" 2260 Wave highest = $"root:myGlobals:CombineTable:HighestRun" 1785 2261 Wave/T prefix = $"root:myGlobals:CombineTable:Prefix" 1786 2262 Wave/T saveName = $"root:myGlobals:CombineTable:SaveName" … … 1805 2281 endif 1806 2282 1807 1808 if( !(num==2 || num==3) ) 1809 Abort "invalid table selection - must select either 2 or 3 files to combine" 1810 endif 1811 Make/O/T/N=(3) tmpLbl 1812 Make/O/N=(3) tmpSDD,tmpRun 2283 if( !(num==2 || num==3 || num==4) ) 2284 Abort "invalid table selection - must select either 2 or 3 or 4 files to combine" 2285 endif 2286 Make/O/T/N=(4) tmpLbl 2287 Make/O/N=(4) tmpSDD,tmpRun 2288 2289 //initialize with fake values in case 2 or 3 files are combined 2290 tmpLbl = "" 2291 tmpSDD = 0.01 //fake sdd in meters to always be the "highest" Q 2292 tmpRun = 0 //pass a run number of zero to be later interpreted as "none" 2293 2294 //fill in the real values from the selection 1813 2295 for(ii=V_startRow;ii<=V_endRow;ii+=1) 1814 2296 tmpLbl[ii-V_startRow] = gLabels[ii] … … 1816 2298 tmpRun[ii-V_startRow] = gRunNumber[ii] 1817 2299 endfor 1818 if(num==2) // then "highest" q run needs to be forced to zero1819 ii=21820 tmpLbl[ii] = ""1821 tmpSDD[ii] = 0.01 //fake sdd in meters to always be the "highest" Q1822 tmpRun[ii] = 0 //pass a run number of zero to be later interpreted as "none"1823 endif2300 // if(num==2) // then "highest" q run needs to be forced to zero 2301 // ii=2 2302 // tmpLbl[ii] = "" 2303 // tmpSDD[ii] = 0.01 //fake sdd in meters to always be the "highest" Q 2304 // tmpRun[ii] = 0 //pass a run number of zero to be later interpreted as "none" 2305 // endif 1824 2306 Sort tmpSDD, tmpSDD,tmpLbl,tmpRun 1825 2307 … … 1827 2309 1828 2310 num=numpnts(low) 1829 InsertPoints num, 1, low,medium,high,prefix,SaveName 1830 low[num] = tmpRun[2] 1831 medium[num] = tmpRun[1] 1832 high[num] = tmpRun[0] 2311 InsertPoints num, 1, low,medium,high,highest,prefix,SaveName 2312 low[num] = tmpRun[3] 2313 medium[num] = tmpRun[2] 2314 high[num] = tmpRun[1] 2315 highest[num] = tmpRun[0] 1833 2316 prefix[num] = GetPrefixStrFromFile(filenames[ii]) 1834 2317 saveName[num] = saveStr … … 1905 2388 Make/O/N=0 $"root:myGlobals:CombineTable:MediumRun" 1906 2389 Make/O/N=0 $"root:myGlobals:CombineTable:HighRun" 2390 Make/O/N=0 $"root:myGlobals:CombineTable:HighestRun" 1907 2391 Make/O/T/N=0 $"root:myGlobals:CombineTable:Prefix" 1908 2392 Make/O/T/N=0 $"root:myGlobals:CombineTable:SaveName" … … 1911 2395 1912 2396 // make the second table 1913 AppendToTable/W=CombinePanel#RunNumbersToCombine LowRun,MediumRun,HighRun, Prefix,SaveName2397 AppendToTable/W=CombinePanel#RunNumbersToCombine LowRun,MediumRun,HighRun,HighestRun,Prefix,SaveName 1914 2398 1915 2399 SetDataFolder root: 1916 2400 End 2401 2402 2403 2404 ///////////////////////////////// 2405 // currently unused 2406 // 2407 Proc MakeCombineTable_byName() 2408 NewDataFolder/O root:myGlobals:CombineTable //in case it doesn't exist yet 2409 Make/O/T/N=1 lowQfile,medQfile,hiQfile,saveName 2410 Edit/W=(330,148,973,360) lowQfile,medQfile,hiQfile,saveName 2411 ModifyTable format(Point)=1,width(lowQfile)=120,width(medQfile)=120,width(hiQfile)=120 2412 ModifyTable width(saveName)=120 2413 End 2414 2415 // 2416 // currently unused 2417 // 2418 // Another beta procedure, to allow files to be combined quickly 2419 // - make 4 waves (text) with the low, med, hi, and wave names 2420 // (if there is no hiQ, then pass a wave with "" for all entries) 2421 // - then pass the waves, and the save will work like in the DoCombineFiles 2422 // 2423 // - the named files must be there - there is no error checking 2424 // - the NSORT panel must be open with the proper selections of beg,end and autoscale, etc. 2425 // 2426 // - could write a little proc to generate a table to fill in and a button to call this 2427 // - and then think of quick ways to populate the table with file names (and minimize typos) 2428 // 2429 Function DoCombineFiles_byName(lowW,medW,hiW,saveW) 2430 Wave/T lowW,medW,hiW,saveW 2431 2432 if(WinType("NSORT_Panel") == 0) 2433 DoAlert 0, "The SORT Panel must be open to combine the files" 2434 return(0) 2435 endif 2436 2437 // pop all of the menus to make sure that they are properly populated 2438 LowQPopMenuProc("",1,"") 2439 MedQPopMenuProc("",1,"") 2440 HighQPopMenuProc("",1,"") 2441 2442 Variable num=numpnts(lowW),ii 2443 String lowFile,medFile,hiFile 2444 2445 Pathinfo catPathName 2446 String path=S_Path 2447 2448 //////// Make/O/D/N=(numpnts(lowW)) scale_4m 2449 NVAR scale12 = root:myGlobals:NSORT:gScale1_2 2450 2451 2452 // this variable must exist and be set to 1 to be able to automatically name files 2453 // and use the global saveNameStr that is passed in 2454 // -- turn this off when done 2455 Variable/G root:myGlobals:CombineTable:useTable=1 2456 2457 ii=0 2458 do 2459 lowFile = lowW[ii] 2460 medFile = medW[ii] 2461 hiFile = hiW[ii] 2462 2463 //Set3NSORTFiles(lowFile,medFile,hiFile,prefixStr) //set the files and pop the NSORT popups 2464 //lowQ menu 2465 PopupMenu popup_1 win=NSORT_Panel,popmatch=lowFile 2466 2467 // mediumQ menu 2468 if(strlen(medFile)!=0) 2469 PopupMenu popup_2 win=NSORT_Panel,popmatch=medFile 2470 else 2471 PopupMenu popup_2,win=NSORT_Panel,popmatch="none" //set to "none" 2472 endif 2473 2474 //highQ (same pop list as medQ) 2475 if(strlen(hiFile)!=0) 2476 PopupMenu popup_3 win=NSORT_Panel,popmatch=hiFile 2477 else 2478 PopupMenu popup_3,win=NSORT_Panel,popmatch="none" //set to "none" 2479 endif 2480 2481 2482 //pass the new file name in as a global (ugh!) 2483 String/G root:myGlobals:CombineTable:SaveNameStr = path+saveW[ii] 2484 //combine the files and write the data 2485 WriteNSORTFileButton("") 2486 2487 ////// scale_4m[ii] = scale12 2488 2489 Print "wrote file : ",path+saveW[ii] 2490 ii+=1 2491 while(ii<num) 2492 2493 Variable/G root:myGlobals:CombineTable:useTable=0 //turn this off immediately 2494 2495 return(0) 2496 End
Note: See TracChangeset
for help on using the changeset viewer.