Changeset 868 for sans/Dev/trunk/NCNR_User_Procedures/Reduction
- Timestamp:
- Oct 5, 2012 3:00:52 PM (10 years ago)
- Location:
- sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/NCNR_Utils.ipf
r857 r868 1612 1612 default: 1613 1613 //return error? 1614 Print "if you're using the 10m SANS, this needs to be fixed, atten = 1" 1614 1615 attenFactor=1 1615 1616 endswitch … … 1659 1660 default: 1660 1661 //return error? 1662 Print "if you're using the 10m SANS, this needs to be fixed, atten = 1" 1661 1663 attenFactor=1 1662 1664 endswitch -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/SASCALC.ipf
r842 r868 22 22 // 03 MAR 2012 SRK - Added new source apertures in 6th and 7th boxes of NG3 23 23 // 24 // 05 OCT 2012 SRK - (not visible) but added the skeleton bits for the 10m SANS instrument. Don't have the 25 // details of the distances, etc, but I'll fill that in as needed 26 // -- to "un-hide" the 10m SANS, uncomment the CheckBox control in the panel (see the constant declared below) 24 27 // 25 28 // calculate what q-values you get based on the instruments settings … … 29 32 // - NOT true intensity, not counts, just a display 30 33 // 31 // To Do: 34 // TODO: 35 // 36 // -- For the 10m SANS... 37 // - how many guides are there 38 // - no lenses? focusing pinholes? 39 // - aperture sizes? 40 // - flux values 41 // - huber/sample chamber is inline, so get rid of this for 10m (gray out?) 42 // - does this hook into anywhere in the main program? Attenuators, etc. 43 // where knowledge of the 10m SANS is necessary?? 44 // 32 45 // 33 46 // Optional: … … 54 67 // 55 68 // 69 70 Constant show10mSANS = 0 71 72 56 73 57 74 Proc SASCALC() … … 147 164 Make/O/D/N=5 root:Packages:NIST:SAS:tickSDDNG3,root:Packages:NIST:SAS:tickSDDNG7 148 165 Make/O/T/N=5 root:Packages:NIST:SAS:lblSDDNG3,root:Packages:NIST:SAS:lblSDDNG7 166 Make/O/D/N=5 root:Packages:NIST:SAS:tickSDDNG10 167 Make/O/T/N=5 root:Packages:NIST:SAS:lblSDDNG10 149 168 root:Packages:NIST:SAS:tickSDDNG3 = {133,400,700,1000,1317} 150 169 root:Packages:NIST:SAS:lblSDDNG3 = {"133","400","700","1000","1317"} 151 170 root:Packages:NIST:SAS:tickSDDNG7 = {100,450,800,1150,1530} 152 171 root:Packages:NIST:SAS:lblSDDNG7 = {"100","450","800","1150","1530"} 153 172 root:Packages:NIST:SAS:tickSDDNG10 = {100,200,300,400,500} 173 root:Packages:NIST:SAS:lblSDDNG10 = {"100","200","300","400","500"} 174 154 175 //for the fake dependency 155 176 Variable/G root:Packages:NIST:SAS:gTouched=0 … … 165 186 SetDataFolder root:Packages:NIST:SAS 166 187 188 String/G gSelectedInstrument="checkNG3" 167 189 Variable/G instrument = 3 190 168 191 Variable/G s12 = 54.8 169 192 Variable/G d_det = 0.5 … … 226 249 227 250 SetDataFolder root:Packages:NIST:SAS 228 251 252 String/G gSelectedInstrument="checkNG7" 229 253 Variable/G instrument = 7 254 230 255 Variable/G s12 = 54.8 231 256 Variable/G d_det = 0.5 … … 284 309 SetDataFolder root: 285 310 end 311 312 /// this is the (incomplete) definition of the 10m SANS instrument 313 // on NG-B, which may be referred to as NG10 here to keep the NG(number) notation 314 // which may be simpler here to keep functions from breaking... 315 316 // *** check ALL of these values to make sure they are correct. They were copied from NG3 and 317 // most are completey wrong for the 10m SANS 318 // 319 Function initNG10() 320 321 SetDataFolder root:Packages:NIST:SAS 322 323 String/G gSelectedInstrument="checkNG10" 324 Variable/G instrument = 10 325 326 Variable/G s12 = 0 //** no difference between sample and huber position 327 Variable/G d_det = 0.5 328 Variable/G a_pixel = 0.5 329 Variable/G del_r = 0.5 330 Variable/G det_width = 64.0 331 Variable/G lambda_t = 5.50 332 Variable/G l2r_lower = 100 333 Variable/G l2r_upper = 500 334 Variable/G lambda_lower = 2.5 335 Variable/G lambda_upper = 20.0 336 Variable/G d_upper = 25.0 //** 337 Variable/G bs_factor = 1.05 //** 338 Variable/G t1 = 0.63 //** 339 Variable/G t2 = 1.0 //** 340 Variable/G t3 = 0.75 //** 341 Variable/G l_gap = 100.0 //** 342 Variable/G guide_width = 6.0 //** 343 Variable/G idmax = 100.0 //** 344 // //old values, from 3/2002 345 // Variable/G phi_0 = 2.95e13 346 // Variable/G b = 0.023 347 // Variable/G c = 0.023 348 349 //new values, from 11/2009 --- BeamFluxReport_2009.ifn 350 Variable/G phi_0 = 2.42e13 351 Variable/G b = 0.0 352 Variable/G c = -0.0243 353 Variable/G gGuide_loss = 0.924 354 355 //fwhm values (new variables) (+3, 0, -3, calibrated 2009) 356 Variable/G fwhm_narrow = 0.109 357 Variable/G fwhm_mid = 0.125 358 Variable/G fwhm_wide = 0.236 359 360 //source apertures (cm) 361 Variable/G a1_0_0 = 1.43 362 Variable/G a1_0_1 = 2.54 363 Variable/G a1_0_2 = 3.81 364 Variable/G a1_7_0 = 2.5 // after the polarizer 365 Variable/G a1_7_1 = 5.0 366 Variable/G a1_7_1 = 0.95 // new Mar 2012 9.5 mm diameter source aperture 367 Variable/G a1_def = 5.00 368 369 //default configuration values 370 // ng = 0 371 // a1 = 3.81 372 // pos_table = 2 373 // l2r = 1310.0 374 // a2 = 1.27 375 // det_off = 0.0 376 // lambda = 6.0 377 // lambda_width = 0.15 378 Variable/G l2diff = 5.0 379 // 380 SetDataFolder root: 381 end 382 286 383 287 384 Function S_fillDefaultHeader(iW,rW,tW) … … 388 485 CheckBox checkNG7,pos={66,19},size={36,14},proc=SelectInstrumentCheckProc,title="NG7" 389 486 CheckBox checkNG7,value=0,mode=1 487 // -- hide/unhide the 10m SANS 488 if(show10mSANS) 489 CheckBox checkNG10,pos={110,19},size={40,14},proc=SelectInstrumentCheckProc,title="NG10" 490 CheckBox checkNG10,value=0,mode=1 491 endif 492 // 390 493 CheckBox checkChamber,pos={172,48},size={57,14},proc=TableCheckProc,title="Chamber" 391 494 CheckBox checkChamber,value=1,mode=1 … … 408 511 Button ClearButton title="Clear",size={60,20},pos={250,166} 409 512 Button ClearButton proc=S_ClearButtonProc 410 GroupBox group0,pos={6,1},size={108,36},title="Instrument" 513 // GroupBox group0,pos={6,1},size={108,36},title="Instrument" 514 GroupBox group0,pos={6,1},size={160,36},title="Instrument" 411 515 SetDataFolder fldrSav0 412 516 … … 452 556 453 557 // based on the instrument selected... 454 // set the SDD range558 // set the SDD range 455 559 // set the source aperture popup (based on NGx and number of guides) 456 560 // set the wavelength spread popup … … 459 563 //poll the controls on the panel, and change needed values 460 564 Variable isNG3,Ng,mode 461 ControlInfo/W=SASCALC checkNG3462 isNG3=V_value565 // ControlInfo/W=SASCALC checkNG3 566 // isNG3=V_value 463 567 ControlInfo/W=SASCALC SC_slider 464 568 Ng=V_value 465 569 SVAR A1str= root:Packages:NIST:SAS:gSourceApString// = "1.43 cm;2.54 cm;3.81 cm;" 466 570 SVAR dlStr = root:Packages:NIST:SAS:gDeltaLambdaStr 467 if(isNG3) 468 switch(ng) 469 case 0: 470 ControlInfo/W=SASCALC popup0 471 mode=V_value 472 A1str="1.43 cm;2.54 cm;3.81 cm;" 473 break 474 // case 6: //Mar 2012 - 6 guides is OK now, 5 cm aperture present in 7th box 475 // A1str = "! 6 Guides invalid;" 476 // mode=1 477 // break 478 case 7: // switched order in 2009 to keep 5 cm as default, 2.5 cm for polarizer 479 A1Str = "5.00 cm;2.50 cm;0.95 cm;" // Mar 2012 - 3rd aperture added 480 mode = 1 481 break 482 default: 483 A1str = "5 cm;" 484 mode=1 485 endswitch 486 //wavelength spread 487 dlStr = "0.109;0.125;0.236;" //updated calibration 2009 488 //detector limits 489 SetVariable setvar0,win=SASCALC,limits={133,1317,1} 490 NVAR detDist=root:Packages:NIST:SAS:gDetDist 491 if(detDist < 133 ) 492 detDist = 133 493 elseif (detDist > 1317 ) 494 detDist = 1317 495 endif 496 Slider SC_Slider_1,win=SASCALC,limits={133,1317,1},userTicks={root:Packages:NIST:SAS:tickSDDNG3,root:Packages:NIST:SAS:lblSDDNG3 } 497 Slider SC_Slider_1,win=SASCALC,variable=root:Packages:NIST:SAS:gDetDist //forces update 498 else //ng7 499 switch(ng) 500 case 0: 501 ControlInfo/W=SASCALC popup0 502 mode=V_value 503 A1str="1.43 cm;2.22 cm;3.81 cm;" 504 break 505 default: 506 A1str = "5.08 cm;" 507 mode=1 508 endswitch 509 510 dlStr = "0.09;0.115;0.22;" 511 Slider SC_Slider_1,win=SASCALC,limits={100,1531,1},userTicks={root:Packages:NIST:SAS:tickSDDNG7,root:Packages:NIST:SAS:lblSDDNG7 } 512 SetVariable setvar0,win=SASCALC,limits={100,1531,1} 513 Slider SC_Slider_1,win=SASCALC,variable=root:Packages:NIST:SAS:gDetDist //forces update 514 endif 571 SVAR selInstr = root:Packages:NIST:SAS:gSelectedInstrument 572 573 strswitch(selInstr) // string switch 574 case "checkNG3": // 575 switch(ng) 576 case 0: 577 ControlInfo/W=SASCALC popup0 578 mode=V_value 579 A1str="1.43 cm;2.54 cm;3.81 cm;" 580 break 581 // case 6: //Mar 2012 - 6 guides is OK now, 5 cm aperture present in 7th box 582 // A1str = "! 6 Guides invalid;" 583 // mode=1 584 // break 585 case 7: // switched order in 2009 to keep 5 cm as default, 2.5 cm for polarizer 586 A1Str = "5.00 cm;2.50 cm;0.95 cm;" // Mar 2012 - 3rd aperture added 587 mode = 1 588 break 589 default: 590 A1str = "5 cm;" 591 mode=1 592 endswitch 593 //wavelength spread 594 dlStr = "0.109;0.125;0.236;" //updated calibration 2009 595 Slider SC_Slider,limits={0,8,1},ticks=1 596 //detector limits 597 SetVariable setvar0,win=SASCALC,limits={133,1317,1} 598 NVAR detDist=root:Packages:NIST:SAS:gDetDist 599 if(detDist < 133 ) 600 detDist = 133 601 elseif (detDist > 1317 ) 602 detDist = 1317 603 endif 604 Slider SC_Slider_1,win=SASCALC,limits={133,1317,1},userTicks={root:Packages:NIST:SAS:tickSDDNG3,root:Packages:NIST:SAS:lblSDDNG3 } 605 Slider SC_Slider_1,win=SASCALC,variable=root:Packages:NIST:SAS:gDetDist //forces update 606 607 break 608 609 case "checkNG7": // 610 switch(ng) 611 case 0: 612 ControlInfo/W=SASCALC popup0 613 mode=V_value 614 A1str="1.43 cm;2.22 cm;3.81 cm;" 615 break 616 default: 617 A1str = "5.08 cm;" 618 mode=1 619 endswitch 620 621 dlStr = "0.09;0.115;0.22;" 622 Slider SC_Slider,limits={0,8,1},ticks=1 623 Slider SC_Slider_1,win=SASCALC,limits={100,1531,1},userTicks={root:Packages:NIST:SAS:tickSDDNG7,root:Packages:NIST:SAS:lblSDDNG7 } 624 SetVariable setvar0,win=SASCALC,limits={100,1531,1} 625 Slider SC_Slider_1,win=SASCALC,variable=root:Packages:NIST:SAS:gDetDist //forces update 626 627 break 628 629 case "checkNG10": // 10m SANS 630 switch(ng) 631 case 0: 632 ControlInfo/W=SASCALC popup0 633 mode=V_value 634 A1str="1.43 cm;2.22 cm;3.81 cm;" 635 break 636 default: 637 A1str = "5.08 cm;" 638 mode=1 639 endswitch 640 641 dlStr = "0.10;0.20;0.30;" 642 Slider SC_Slider,limits={0,2,1},ticks=2 //number of guides different on 10m SANS, 3 ticks 643 644 Slider SC_Slider_1,win=SASCALC,limits={100,500,1},userTicks={root:Packages:NIST:SAS:tickSDDNG10,root:Packages:NIST:SAS:lblSDDNG10 } 645 646 NVAR detDist=root:Packages:NIST:SAS:gDetDist 647 if(detDist < 100 ) 648 detDist = 100 649 elseif (detDist > 500 ) 650 detDist = 500 651 endif 652 SetVariable setvar0,win=SASCALC,limits={100,500,1} 653 Slider SC_Slider_1,win=SASCALC,variable=root:Packages:NIST:SAS:gDetDist //forces update 654 655 break 656 657 default: // optional default expression executed 658 // when no case matches 659 endswitch 660 661 515 662 ControlUpdate popup0 516 663 PopupMenu popup0,win=SASCALC,mode=mode //source Ap … … 585 732 // update the controls to appropriate limits/choices 586 733 // 734 // updated for 10m SANS 587 735 Function SelectInstrumentCheckProc(ctrlName,checked) : CheckBoxControl 588 736 String ctrlName 589 737 Variable checked 590 738 591 if(cmpstr(ctrlName,"checkNG3")==0) 592 checkBox checkNG3,win=SASCALC, value=1 593 checkBox checkNG7,win=SASCALC, value=0 594 initNG3() 595 else 596 checkBox checkNG3,win=SASCALC, value=0 597 checkBox checkNG7,win=SASCALC, value=1 598 initNG7() 599 endif 739 740 strswitch(ctrlName) // string switch 741 case "checkNG3": // 742 checkBox checkNG3,win=SASCALC, value=1 743 checkBox checkNG7,win=SASCALC, value=0 744 checkBox checkNG10,win=SASCALC, value=0 745 initNG3() 746 break 747 case "checkNG7": // 748 checkBox checkNG3,win=SASCALC, value=0 749 checkBox checkNG7,win=SASCALC, value=1 750 checkBox checkNG10,win=SASCALC, value=0 751 initNG7() 752 break 753 case "checkNG10": // 10m SANS 754 checkBox checkNG3,win=SASCALC, value=0 755 checkBox checkNG7,win=SASCALC, value=0 756 checkBox checkNG10,win=SASCALC, value=1 757 initNG10() 758 break 759 default: // optional default expression executed 760 // when no case matches 761 endswitch 762 763 600 764 LensCheckProc("",2) //check if lenses are still valid (they won't be) 601 765 UpdateControls() … … 663 827 // check the box, enforce the proper conditions 664 828 if(checked == 1) 665 lens = checked 666 if(instrument == 3) 667 dist = 1317 668 DetDistSliderProc("",1317,1) 669 670 lam = 8.4 671 LambdaSetVarProc("",8.4,"8.4","") 672 673 ng=0 674 GuideSliderProc("",0,1) //this updates the controls to the new # of guides 675 676 PopupMenu popup0,win=SASCALC,mode=1,popvalue="1.43 cm" //first item in source aperture menu 677 678 PopupMenu popup0_2,win=SASCALC,mode=2 //deltaLambda 679 ControlInfo/W=SASCALC popup0_2 680 DeltaLambdaPopMenuProc("",0,S_value) //zero as 2nd param skips recalculation 681 else 682 dist = 1531 683 DetDistSliderProc("",1531,1) 684 685 lam = 8.09 686 LambdaSetVarProc("",8.09,"8.09","") 687 688 ng=0 689 GuideSliderProc("",0,1) 690 PopupMenu popup0,win=SASCALC,mode=1,popvalue="1.43 cm" //first item 691 692 PopupMenu popup0_2,win=SASCALC,mode=2 //deltaLambda 693 ControlInfo/W=SASCALC popup0_2 694 DeltaLambdaPopMenuProc("",0,S_value) //zero as 2nd param skips recalculation 695 endif 696 rw[28]=1 //flag for lenses in (not the true number, but OK) 697 ReCalculateInten(1) 829 lens = checked 830 switch(instrument) // numeric switch 831 case 3: 832 dist = 1317 833 DetDistSliderProc("",1317,1) 834 835 lam = 8.4 836 LambdaSetVarProc("",8.4,"8.4","") 837 838 ng=0 839 GuideSliderProc("",0,1) //this updates the controls to the new # of guides 840 841 PopupMenu popup0,win=SASCALC,mode=1,popvalue="1.43 cm" //first item in source aperture menu 842 843 PopupMenu popup0_2,win=SASCALC,mode=2 //deltaLambda 844 ControlInfo/W=SASCALC popup0_2 845 DeltaLambdaPopMenuProc("",0,S_value) //zero as 2nd param skips recalculation 846 rw[28]=1 //flag for lenses in (not the true number, but OK) 847 848 break 849 case 7: 850 dist = 1531 851 DetDistSliderProc("",1531,1) 852 853 lam = 8.09 854 LambdaSetVarProc("",8.09,"8.09","") 855 856 ng=0 857 GuideSliderProc("",0,1) 858 PopupMenu popup0,win=SASCALC,mode=1,popvalue="1.43 cm" //first item 859 860 PopupMenu popup0_2,win=SASCALC,mode=2 //deltaLambda 861 ControlInfo/W=SASCALC popup0_2 862 DeltaLambdaPopMenuProc("",0,S_value) //zero as 2nd param skips recalculation 863 rw[28]=1 //flag for lenses in (not the true number, but OK) 864 865 break 866 case 10: 867 // 10m SANS - force no lenses for now 868 // TODO: -- put in CORRECT VALUES -- THESE ARE FICTIONAL 869 lens = 0 //no lenses 870 CheckBox checkLens,win=SASCALC,value=0 871 rw[28]=0 //flag for lenses out 872 873 break 874 default: 875 876 endswitch 698 877 endif 699 878 700 879 // this is my internal check to see if conditions are still valid 880 // I get to this point by calling this myself and passing the fictional value of (2) for the 881 // checkbox value... 882 // 701 883 // I'll uncheck as needed 884 Variable lensNotAllowed=0 702 885 if(checked == 2) 703 886 … … 706 889 Variable a1 = sourceApertureDiam() 707 890 if(a1 != 1.43 || Ng !=0) 708 lens = 0 709 CheckBox checkLens,win=SASCALC,value=0 710 rw[28]=0 //flag for lenses out 711 return(0) 891 lensNotAllowed=1 712 892 endif 713 893 714 894 // instrument specific distance requirements 715 895 if(instrument == 3 && dist != 1317) 716 lens = 0 717 CheckBox checkLens,win=SASCALC,value=0 718 rw[28]=0 //flag for lenses out 719 return(0) 896 lensNotAllowed=1 720 897 endif 721 898 722 899 if(instrument == 7 && dist != 1531) 723 lens = 0 724 CheckBox checkLens,win=SASCALC,value=0 725 rw[28]=0 //flag for lenses out 726 return(0) 900 lensNotAllowed=1 727 901 endif 728 902 729 903 // instrument specific wavelength requirements 730 904 if(instrument == 3 && !(lam == 8.4 || lam == 17.2) ) 731 lens = 0 732 CheckBox checkLens,win=SASCALC,value=0 733 rw[28]=0 //flag for lenses out 734 return(0) 905 lensNotAllowed=1 735 906 endif 736 907 737 908 if(instrument == 7 && lam != 8.09 ) 738 lens = 0 739 CheckBox checkLens,win=SASCALC,value=0 740 rw[28]=0 //flag for lenses out 741 return(0) 909 lensNotAllowed=1 910 endif 911 912 // right now, if 10m instrument, no lenses allowed 913 if(instrument == 10 ) 914 lensNotAllowed=1 742 915 endif 743 916 744 917 endif 918 919 if(lensNotAllowed) 920 lens = 0 921 CheckBox checkLens,win=SASCALC,value=0 922 rw[28]=0 //flag for lenses out 923 return(0) 924 endif 925 926 ReCalculateInten(1) 927 745 928 746 929 return(1) //return value not used … … 1768 1951 //compute SSD and update both the global and the wave 1769 1952 // 1953 // for the 10m SANS, table position is inline, so S12 = 0 1954 // 1955 // TODO -- for the 10m SANS - all of the numbers here are hard-wired and are WRONG 1956 // 1770 1957 Function sourceToSampleDist() 1771 1958 … … 1774 1961 NVAR L2Diff = root:Packages:NIST:SAS:L2Diff 1775 1962 NVAR SSD = root:Packages:NIST:SAS:gSSD 1776 1777 SSD = 1632 - 155*NG - s12*(2-tableposition()) - L2Diff 1963 NVAR instrument = root:Packages:NIST:SAS:instrument 1964 1965 switch(instrument) // numeric switch 1966 case 3: 1967 case 7: 1968 // NG3 and NG7 are both the same 1969 SSD = 1632 - 155*NG - s12*(2-tableposition()) - L2Diff 1970 break 1971 case 10: 1972 // 10m SANS handled differently 1973 // TODO: -- put in CORRECT VALUES -- THESE ARE FICTIONAL 1974 SSD = 500 - 155*NG - s12*(2-tableposition()) - L2Diff 1975 break 1976 default: 1977 1978 endswitch 1979 1980 1778 1981 1779 1982 WAVE rw=root:Packages:NIST:SAS:realsRead … … 1786 1989 // 1787 1990 // SSD in meters 1991 // 1992 // TODO -- for the 10m SANS - all of the numbers here are hard-wired and are WRONG 1993 // 1788 1994 Function numGuides(SSD) 1789 1995 variable SSD 1790 1996 1791 1997 Variable Ng 1792 Ng = SSD*100 + 5 - 1632 1793 Ng /= -155 1794 1998 1999 NVAR instrument = root:Packages:NIST:SAS:instrument 2000 2001 switch(instrument) // numeric switch 2002 case 3: 2003 case 7: 2004 // NG3 and NG7 are both the same 2005 Ng = SSD*100 + 5 - 1632 2006 Ng /= -155 2007 2008 break 2009 case 10: 2010 // 10m SANS handled differently 2011 // TODO: -- put in CORRECT VALUES -- THESE ARE FICTIONAL 2012 Ng = SSD*100 + 5 - 1632 2013 Ng /= -155 2014 2015 break 2016 default: 2017 2018 endswitch 2019 2020 1795 2021 Ng = round(Ng) 1796 2022 return(Ng) … … 2025 2251 // other values are changed in the initialization routines 2026 2252 // 2253 // 2254 // TODO -- for the 10m SANS - all of the numbers need to be updated in the initialization 2255 // 2027 2256 Function beamIntensity() 2028 2257 … … 2056 2285 2057 2286 retVal = as * d2_phi * lambda_width * solid_angle * t 2058 2287 SetDataFolder root: 2059 2288 return (retVal) 2060 2289 end
Note: See TracChangeset
for help on using the changeset viewer.