 Timestamp:
 Mar 13, 2017 1:39:33 PM (6 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_DetectorCorrections.ipf
r1024 r1027 891 891 // 892 892 //test procedure, not called anymore 893 Proc V_AbsoluteScaling(type,c0,c1,c2,c3,c4,c5 )893 Proc V_AbsoluteScaling(type,c0,c1,c2,c3,c4,c5,I_err) 894 894 String type 895 Variable c0=1,c1=0.1,c2=0.95,c3=0.1,c4=1,c5=32.0 895 Variable c0=1,c1=0.1,c2=0.95,c3=0.1,c4=1,c5=32.0,I_err=0.32 896 896 Prompt type,"WORK data type",popup,"CAL;COR;SAM" 897 897 Prompt c0, "Sample Transmission" … … 901 901 Prompt c4, "I(0) from standard fit (normalized to 1E8 monitor cts)" 902 902 Prompt c5, "Standard CrossSection (cm1)" 903 Prompt I_err, "error in I(q=0) (one std dev)" 903 904 904 905 Variable err 905 906 //call the function to do the math 906 907 //data from "type" will be scaled and deposited in ABS 907 err = V_Absolute_Scale(type,c0,c1,c2,c3,c4,c5 )908 err = V_Absolute_Scale(type,c0,c1,c2,c3,c4,c5,I_err) 908 909 909 910 if(err) 910 Abort "Error in Absolute_Scale()"911 Abort "Error in V_Absolute_Scale()" 911 912 endif 912 913 913 914 //contents are always dumped to ABS 914 915 type = "ABS" 915 916 String newTitle = "WORK_"+type917 DoWindow/F SANS_Data918 DoWindow/T SANS_Data, newTitle919 KillStrings/Z newTitle920 916 921 917 //need to update the display with "data" from the correct dataFolder … … 924 920 gCurDispType = Type 925 921 926 V_ fRawWindowHook()922 V_UpdateDisplayInformation(Type) 927 923 928 924 End … … 930 926 // 931 927 // TODO: 932 //  DoAlert 0,"This has not yet been updated for VSANS" 933 // 928 // 929 // kappa comes in as s_izero, so be sure to use 1/kappa_err 930 // 931 //convert the "type" data to absolute scale using the given standard information 934 932 //s_ is the standard 935 933 //w_ is the "work" file … … 939 937 Variable w_trans,w_thick,s_trans,s_thick,s_izero,s_cross,kappa_err 940 938 941 DoAlert 0,"This has not yet been updated for VSANS" 939 940 Variable defmon = 1e8,w_moncount,s1,s2,s3,s4 941 Variable scale,trans_err 942 Variable err,ii 943 String detStr 944 945 // be sure that the starting data exists 946 err = V_WorkDataExists(type) 947 if(err==1) 948 return(err) 949 endif 942 950 943 //convert the "type" data to absolute scale using the given standard information 944 //copying the "type" waves to ABS 945 946 //check for existence of data, rescale to linear if needed 947 String destPath 948 //check for "type" 949 if(WaveExists($("root:Packages:NIST:"+Type + ":data")) == 0) 950 Print "There is no work file in "+type+"Aborting" 951 Return(1) //error condition 952 Endif 953 //check for logscaling of the "type" data and adjust if necessary 954 destPath = "root:Packages:NIST:"+Type 955 NVAR gIsLogScale = $(destPath + ":gIsLogScale") 956 if(gIsLogScale) 957 Duplicate/O $(destPath + ":linear_data") $(destPath + ":data")//back to linear scale 958 Variable/G $(destPath + ":gIsLogScale")=0 //the "type" data is not logscale anymore 959 endif 960 961 //copy "oldtype" information to ABS 962 //overwriting out the old contents of the ABS folder (/O option in Duplicate) 963 //copy over the waves data,vlegend,text,integers,reals(read) 964 965 String oldType= "root:Packages:NIST:"+type //this is where the data to be absoluted is 966 //copy from current dir (type) to ABS, defined by destPath 967 Duplicate/O $(oldType + ":data"),$"root:Packages:NIST:ABS:data" 968 Duplicate/O $(oldType + ":linear_data"),$"root:Packages:NIST:ABS:linear_data" 969 Duplicate/O $(oldType + ":linear_data_error"),$"root:Packages:NIST:ABS:linear_data_error" 970 // Duplicate/O $(oldType + ":vlegend"),$"root:Packages:NIST:ABS:vlegend" 971 Duplicate/O $(oldType + ":textread"),$"root:Packages:NIST:ABS:textread" 972 Duplicate/O $(oldType + ":integersread"),$"root:Packages:NIST:ABS:integersread" 973 Duplicate/O $(oldType + ":realsread"),$"root:Packages:NIST:ABS:realsread" 974 //need to save a copy of filelist string too (from the current type folder) 975 SVAR oldFileList = $(oldType + ":fileList") 976 //need to copy filelist string too 977 String/G $"root:Packages:NIST:ABS:fileList" = oldFileList 978 979 //now switch to ABS folder 980 //make appropriate wave references 981 WAVE data=$"root:Packages:NIST:ABS:linear_data" // these wave references point to the "type" data in ABS 982 WAVE data_err=$"root:Packages:NIST:ABS:linear_data_error" // these wave references point to the "type" data in ABS 983 WAVE data_copy=$"root:Packages:NIST:ABS:data" // just for display 984 WAVE/T textread=$"root:Packages:NIST:ABS:textread" //that are to be directly operated on 985 WAVE integersread=$"root:Packages:NIST:ABS:integersread" 986 WAVE realsread=$"root:Packages:NIST:ABS:realsread" 987 Variable/G $"root:Packages:NIST:ABS:gIsLogscale"=0 //make new flag in ABS folder, data is linear scale 988 989 //do the actual absolute scaling here, modifying the data in ABS 990 Variable defmon = 1e8,w_moncount,s1,s2,s3,s4 991 992 w_moncount = realsread[0] //monitor count in "type" 951 //copy from current dir (type) to ABS 952 V_CopyHDFToWorkFolder(type,"ABS") 953 954 955 w_moncount = V_getMonitorCount(type) //monitor count in "type" 993 956 if(w_moncount == 0) 994 957 //zero monitor counts will give divide by zero  … … 998 961 999 962 //calculate scale factor 1000 Variable scale,trans_err 1001 s1 = defmon/realsread[0] //[0] is monitor count (s1 should be 1) 963 s1 = defmon/w_moncount // monitor count (s1 should be 1) 1002 964 s2 = s_thick/w_thick 1003 965 s3 = s_trans/w_trans 1004 966 s4 = s_cross/s_izero 967 scale = s1*s2*s3*s4 968 969 trans_err = V_getSampleTransError(type) 1005 970 1006 971 // kappa comes in as s_izero, so be sure to use 1/kappa_err 1007 1008 data *= s1*s2*s3*s4 1009 1010 scale = s1*s2*s3*s4 1011 trans_err = realsRead[41] 1012 1013 // print scale 1014 // print data[0][0] 1015 1016 data_err = sqrt(scale^2*data_err^2 + scale^2*data^2*(kappa_err^2/s_izero^2 +trans_err^2/w_trans^2)) 1017 1018 // print data_err[0][0] 1019 1020 // keep "data" in sync with linear_data 1021 data_copy = data 972 973 // and now loop through all of the detectors 974 //do the actual absolute scaling here, modifying the data in ABS 975 for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 976 detStr = StringFromList(ii, ksDetectorListAll, ";") 977 Wave data = V_getDetectorDataW("ABS",detStr) 978 Wave data_err = V_getDetectorDataErrW("ABS",detStr) 979 980 data *= s1*s2*s3*s4 981 data_err = sqrt(scale^2*data_err^2 + scale^2*data^2*(kappa_err^2/s_izero^2 +trans_err^2/w_trans^2)) 982 endfor 1022 983 1023 984 //********* 15APR02 1024 // DO NO tcorrect for atenuators here  the COR step already does this, putting all of the data one equal985 // DO NOT correct for atenuators here  the COR step already does this, putting all of the data one equal 1025 986 // footing (zero atten) before doing the subtraction. 1026 //1027 //Print "ABS data multiplied by ",s1*s2*s3*s4/attenFactor1028 1029 //update the ABS header information1030 textread[1] = date() + " " + time() //date + time stamp1031 987 1032 988 Return (0) //no error
Note: See TracChangeset
for help on using the changeset viewer.