Changeset 1193
- Timestamp:
- Jan 13, 2014 8:46:26 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIimage.py
r1189 r1193 879 879 phi = StrSta['Sample phi'] 880 880 wave = Controls['wavelength'] 881 StaType = StrSta['Type'] 881 882 StaControls['distance'] += StrSta['Sample z']*cosd(phi) 882 883 … … 887 888 ring.update(R) 888 889 p0 = ring['Emat'] 889 val,esd = FitStrain(Ring,p0,dset,wave,phi )890 val,esd = FitStrain(Ring,p0,dset,wave,phi,StaType) 890 891 ring['Emat'] = val 891 892 ring['Esig'] = esd … … 897 898 phi = StrSta['Sample phi'] 898 899 E = StrSta['strain'] 900 StaType = StrSta['Type'] 899 901 for ring in StrSta['d-zero']: 900 902 Eij = ring['Emat'] … … 902 904 th,azm = ring['ImtaObs'] 903 905 th0 = np.ones_like(azm)*npasind(wave/(2.*ring['Dset'])) 904 V = 1.+np.sum(np.sum(E*calcFij(90.,phi,azm,th0).T/1.e6,axis=2),axis=1) 905 ring['ImtaCalc'] = np.array([V*ring['Dset'],azm]) 906 V = np.sum(np.sum(E*calcFij(90.,phi,azm,th0).T/1.e6,axis=2),axis=1) 907 if StaType == 'True': 908 ring['ImtaCalc'] = np.array([np.exp(V)*ring['Dset'],azm]) 909 else: 910 ring['ImtaCalc'] = np.array([(V+1.)*ring['Dset'],azm]) 906 911 ring['Dcalc'] = np.mean(ring['ImtaCalc'][0]) 907 912 … … 928 933 return -Fij*nptand(th) 929 934 930 def FitStrain(rings,p0,dset,wave,phi ):935 def FitStrain(rings,p0,dset,wave,phi,StaType): 931 936 'Needs a doc string' 932 937 def StrainPrint(ValSig,dset): … … 946 951 print sigstr 947 952 948 def strainCalc(p,xyd,dset,wave,phi ):953 def strainCalc(p,xyd,dset,wave,phi,StaType): 949 954 E = np.array([[p[0],p[1],0],[p[1],p[2],0],[0,0,0]]) 950 955 dspo,azm,dsp = xyd 951 956 th = npasind(wave/(2.0*dspo)) 952 V = 1.+np.sum(np.sum(E*calcFij(90.,phi,azm,th).T/1.e6,axis=2),axis=1) 953 dspc = dset*V 957 V = np.sum(np.sum(E*calcFij(90.,phi,azm,th).T/1.e6,axis=2),axis=1) 958 if StaType == 'True': 959 dspc = dset*np.exp(V) 960 else: 961 dspc = dset*(V+1.) 954 962 return dspo-dspc 955 963 956 964 names = ['e11','e12','e22'] 957 965 fmt = ['%12.2f','%12.2f','%12.2f'] 958 result = leastsq(strainCalc,p0,args=(rings,dset,wave,phi ),full_output=True)966 result = leastsq(strainCalc,p0,args=(rings,dset,wave,phi,StaType),full_output=True) 959 967 vals = list(result[0]) 960 968 chisq = np.sum(result[2]['fvec']**2)/(rings.shape[1]-3) #reduced chi^2 = M/(Nobs-Nvar)
Note: See TracChangeset
for help on using the changeset viewer.