- Timestamp:
- May 9, 2020 2:14:54 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIddataGUI.py
r4370 r4416 242 242 h,k,l = hkl 243 243 Obj.SetValue('%3d %3d %3d'%(h,k,l)) 244 G2plt.PlotSizeStrainPO(G2frame,data,G2frame.hist)244 wx.CallAfter(G2plt.PlotSizeStrainPO,G2frame,data,hist) 245 245 246 246 def OnResetStrain(event): -
trunk/GSASIIplot.py
r4415 r4416 290 290 fil.write(line+'\n') 291 291 292 # def MPLsubplots(figure, nrows=1, ncols=1, sharex=False, sharey=False,293 # squeeze=True, subplot_kw=None, gridspec_kw=None):294 # """295 # Add a set of subplots to this figure.296 297 # This is a copy of Figure.figure.subplots from matplotlib.figure.py.298 # Included here because this appears only in later versions of299 # matplotlib. When v2.2 is standard, this should be removed from GSAS-II.300 301 # :param int nrows, ncols: default: 1302 # Number of rows/cols of the subplot grid.303 # :param bool/str sharex, sharey: True/False or {'none', 'all', 'row', 'col'}, default: False304 305 # Controls sharing of properties among x (`sharex`) or y (`sharey`)306 # axes:307 308 # - True or 'all': x- or y-axis will be shared among all309 # subplots.310 # - False or 'none': each subplot x- or y-axis will be311 # independent.312 # - 'row': each subplot row will share an x- or y-axis.313 # - 'col': each subplot column will share an x- or y-axis.314 315 # When subplots have a shared x-axis along a column, only the x tick316 # labels of the bottom subplot are visible. Similarly, when317 # subplots have a shared y-axis along a row, only the y tick labels318 # of the first column subplot are visible.319 # :param bool squeeze: default: True320 321 # - If True, extra dimensions are squeezed out from the returned322 # axis object:323 324 # - if only one subplot is constructed (nrows=ncols=1), the325 # resulting single Axes object is returned as a scalar.326 # - for Nx1 or 1xN subplots, the returned object is a 1D numpy327 # object array of Axes objects are returned as numpy 1D328 # arrays.329 # - for NxM, subplots with N>1 and M>1 are returned as a 2D330 # arrays.331 332 # - If False, no squeezing at all is done: the returned Axes object333 # is always a 2D array containing Axes instances, even if it ends334 # up being 1x1.335 336 # :param dict subplot_kw: default: {}337 # Dict with keywords passed to the338 # :meth:`matplotlib.figure.Figure.add_subplot` call used to create339 # each subplots.340 # :param dict gridspec_kw: default: {}341 # Dict with keywords passed to the342 # :class:`matplotlib.gridspec.GridSpec` constructor used to create343 # the grid the subplots are placed on.344 345 # :returns: A single Axes object or array of Axes objects with346 # the added axes. The dimensions of the resulting array can be347 # controlled with the squeeze keyword, see above.348 349 # See also: pyplot.subplots: pyplot API; docstring includes examples.350 351 # """352 353 # # for backwards compatibility354 # if isinstance(sharex, bool):355 # sharex = "all" if sharex else "none"356 # if isinstance(sharey, bool):357 # sharey = "all" if sharey else "none"358 # share_values = ["all", "row", "col", "none"]359 # if sharex not in share_values:360 # # This check was added because it is very easy to type361 # # `subplots(1, 2, 1)` when `subplot(1, 2, 1)` was intended.362 # # In most cases, no error will ever occur, but mysterious behavior363 # # will result because what was intended to be the subplot index is364 # # instead treated as a bool for sharex.365 # if isinstance(sharex, int):366 # warnings.warn(367 # "sharex argument to subplots() was an integer. "368 # "Did you intend to use subplot() (without 's')?")369 370 # raise ValueError("sharex [%s] must be one of %s" %371 # (sharex, share_values))372 # if sharey not in share_values:373 # raise ValueError("sharey [%s] must be one of %s" %374 # (sharey, share_values))375 # if subplot_kw is None:376 # subplot_kw = {}377 # if gridspec_kw is None:378 # gridspec_kw = {}379 380 # # if figure.get_constrained_layout():381 # # gs = GridSpec(nrows, ncols, figure=figure, **gridspec_kw)382 # # else:383 # # # this should turn constrained_layout off if we don't want it384 # # gs = GridSpec(nrows, ncols, figure=None, **gridspec_kw)385 # gs = mpl.gridspec.GridSpec(nrows, ncols, **gridspec_kw)386 387 # # Create array to hold all axes.388 # axarr = np.empty((nrows, ncols), dtype=object)389 # for row in range(nrows):390 # for col in range(ncols):391 # shared_with = {"none": None, "all": axarr[0, 0],392 # "row": axarr[row, 0], "col": axarr[0, col]}393 # subplot_kw["sharex"] = shared_with[sharex]394 # subplot_kw["sharey"] = shared_with[sharey]395 # axarr[row, col] = figure.add_subplot(gs[row, col], **subplot_kw)396 397 # # turn off redundant tick labeling398 # if sharex in ["col", "all"]:399 # # turn off all but the bottom row400 # for ax in axarr[:-1, :].flat:401 # ax.xaxis.set_tick_params(which='both',402 # labelbottom=False, labeltop=False)403 # ax.xaxis.offsetText.set_visible(False)404 # if sharey in ["row", "all"]:405 # # turn off all but the first column406 # for ax in axarr[:, 1:].flat:407 # ax.yaxis.set_tick_params(which='both',408 # labelleft=False, labelright=False)409 # ax.yaxis.offsetText.set_visible(False)410 411 # if squeeze:412 # # Discarding unneeded dimensions that equal 1. If we only have one413 # # subplot, just return it instead of a 1-element array.414 # return axarr.item() if axarr.size == 1 else axarr.squeeze()415 # else:416 # # Returned axis array will be always 2-d, even if nrows=ncols=1.417 # return axarr418 292 419 293 class _tabPlotWin(wx.Panel): … … 512 386 self.nb.Bind(wx.EVT_KEY_UP,self.OnNotebookKey) 513 387 self.G2frame = G2frame 388 self.MPLwarn = False 514 389 515 390 self.plotList = [] # contains the tab label for each plot … … 666 541 self._addPage(name,page) 667 542 mplv = mpl.__version__.split('.') 668 if mplv[0] == '3' and (mplv[1] == '1' or mplv[1] == '2') : # patch for bad MPL 3D669 543 if mplv[0] == '3' and (mplv[1] == '1' or mplv[1] == '2') and not self.MPLwarn: # patch for bad MPL 3D 544 self.MPLwarn = True 670 545 G2G.G2MessageBox(self,'3D plots with Matplotlib 3.1.x and 3.2.x are distorted, we suggest regressing to MPL 3.0.3 until 3.3.x or later is available.. You have '+mpl.__version__, 671 546 'Avoid Matplotlib 3.1 & 3.2') … … 5866 5741 PHI = np.linspace(0.,360.,40,True) 5867 5742 PSI = np.linspace(0.,180.,40,True) 5868 X = np.outer(npcosd(PHI),npsind(PSI)) /2.5869 Y = np.outer(npsind(PHI),npsind(PSI)) /2.5870 Z = np.outer(np.ones(np.size(PHI)),npcosd(PSI)) /2.5743 X = np.outer(npcosd(PHI),npsind(PSI)) 5744 Y = np.outer(npsind(PHI),npsind(PSI)) 5745 Z = np.outer(np.ones(np.size(PHI)),npcosd(PSI)) 5871 5746 try: #temp patch instead of 'mustrain' for old files with 'microstrain' 5872 5747 if plotDict[plotType]: … … 5875 5750 return 5876 5751 if plotType in ['Mustrain','Size']: 5752 diam = 0.5 5753 if plotType == 'Mustrain': 5754 diam = 1.0 5877 5755 if coeff[0] == 'isotropic': 5878 X *= coeff[1][0]5879 Y *= coeff[1][0]5880 Z *= coeff[1][0]5756 X *= diam*coeff[1][0] 5757 Y *= diam*coeff[1][0] 5758 Z *= diam*coeff[1][0] 5881 5759 elif coeff[0] == 'uniaxial': 5882 5760 … … 5886 5764 sp = np.sqrt(1.-cp**2) 5887 5765 R = iso*aniso/np.sqrt((iso*cp)**2+(aniso*sp)**2) 5888 return R*xyz 5766 return R*xyz*diam 5889 5767 5890 5768 iso,aniso = coeff[1][:2] … … 5903 5781 def ellipseCalc(xyz,E,R): 5904 5782 XYZ = xyz*E.T 5905 return np.inner(XYZ.T,R) 5783 return np.inner(XYZ.T,R)*diam 5906 5784 5907 5785 S6 = coeff[4] -
trunk/GSASIIpwd.py
r4415 r4416 1180 1180 dRdS[i] = (lenP-lenM)/(2.*delt) 1181 1181 return lenR,dRdS 1182 1183 def getMustrain(HKL,G,SGData,muStrData): 1184 if muStrData[0] == 'isotropic': 1185 return np.ones(HKL.shape[1])*muStrData[1][0] 1186 elif muStrData[0] == 'uniaxial': 1187 H = np.array(HKL) 1188 P = np.array(muStrData[3]) 1189 cosP,sinP = np.array([G2lat.CosSinAngle(h,P,G) for h in H.T]).T 1190 Si = muStrData[1][0] 1191 Sa = muStrData[1][1] 1192 return Si*Sa/(np.sqrt((Si*cosP)**2+(Sa*sinP)**2)) 1193 else: #generalized - P.W. Stephens model 1194 H = np.array(HKL) 1195 rdsq = np.array([G2lat.calc_rDsq2(h,G) for h in H.T]) 1196 Strms = np.array(G2spc.MustrainCoeff(H,SGData)) 1197 Sum = np.sum(np.array(muStrData[4])[:,nxs]*Strms,axis=0) 1198 return np.sqrt(Sum)/rdsq 1199 1200 def getCrSize(HKL,G,GB,sizeData): 1201 if sizeData[0] == 'isotropic': 1202 return np.ones(HKL.shape[1])*sizeData[1][0] 1203 elif sizeData[0] == 'uniaxial': 1204 H = np.array(HKL) 1205 P = np.array(sizeData[3]) 1206 cosP,sinP = np.array([G2lat.CosSinAngle(h,P,G) for h in H.T]).T 1207 Si = sizeData[1][0] 1208 Sa = sizeData[1][1] 1209 return Si*Sa/(np.sqrt((Si*cosP)**2+(Sa*sinP)**2)) 1210 else: 1211 Sij =[sizeData[4][i] for i in range(6)] 1212 H = np.array(HKL) 1213 return 1./np.array([ellipseSize(h,Sij,GB) for h in H.T])**2 1182 1214 1183 1215 def getHKLpeak(dmin,SGData,A,Inst=None,nodup=False): -
trunk/GSASIIpwdGUI.py
r4410 r4416 4727 4727 if phaseId: #is phase deleted? 4728 4728 General = G2frame.GPXtree.GetItemPyData(phaseId)['General'] 4729 G,g = G2lat.cell2Gmat(General['Cell'][1:7]) 4730 GA,GB = G2lat.Gmat2AB(G) #Orthogonalization matricies 4731 SGData = General['SGData'] 4729 4732 if General.get('Modulated',False): 4730 4733 Super = 1 4734 Histograms = G2frame.GPXtree.GetItemPyData(phaseId)['Histograms'] 4735 histName = G2frame.GPXtree.GetItemText(G2frame.PatternId) 4736 histData = Histograms[histName] 4737 muStrData = histData['Mustrain'] 4738 sizeData = histData['Size'] 4731 4739 rowLabels = [] 4732 4740 if HKLF: … … 4744 4752 refList = np.array([refl[:11+Super] for refl in data[phaseName]]) 4745 4753 I100 = refList.T[8+Super]*np.array([refl[11+Super] for refl in data[phaseName]]) 4754 MuStr = G2pwd.getMustrain(refList.T[:3],G,SGData,muStrData) 4755 CrSize = G2pwd.getCrSize(refList.T[:3],G,GB,sizeData) 4746 4756 Imax = np.max(I100) 4747 4757 if Imax: 4748 4758 I100 *= 100.0/Imax 4749 4759 if 'C' in Inst['Type'][0]: 4750 refs = np.vstack((refList.T[:15+Super],I100 )).T4760 refs = np.vstack((refList.T[:15+Super],I100,MuStr,CrSize)).T 4751 4761 elif 'T' in Inst['Type'][0]: 4752 refs = np.vstack((refList.T[:18+Super],I100 )).T4762 refs = np.vstack((refList.T[:18+Super],I100,MuStr,CrSize)).T 4753 4763 rowLabels = [str(i) for i in range(len(refs))] 4754 4764 Types = (4+Super)*[wg.GRID_VALUE_LONG,]+4*[wg.GRID_VALUE_FLOAT+':10,4',]+ \ … … 4764 4774 else: 4765 4775 if 'C' in Inst['Type'][0]: 4766 colLabels = ['H','K','L','mul','d','pos','sig','gam','Fosq','Fcsq','phase','Icorr','Prfo','Trans','ExtP','I100' ]4767 Types += 4*[wg.GRID_VALUE_FLOAT+':10,3',]4776 colLabels = ['H','K','L','mul','d','pos','sig','gam','Fosq','Fcsq','phase','Icorr','Prfo','Trans','ExtP','I100','mustrain','Size'] 4777 Types += 6*[wg.GRID_VALUE_FLOAT+':10,3',] 4768 4778 elif 'T' in Inst['Type'][0]: 4769 colLabels = ['H','K','L','mul','d','pos','sig','gam','Fosq','Fcsq','phase','Icorr','alp','bet','wave','Prfo','Abs','Ext','I100' ]4770 Types += 7*[wg.GRID_VALUE_FLOAT+':10,3',]4779 colLabels = ['H','K','L','mul','d','pos','sig','gam','Fosq','Fcsq','phase','Icorr','alp','bet','wave','Prfo','Abs','Ext','I100','mustrain','Size'] 4780 Types += 9*[wg.GRID_VALUE_FLOAT+':10,3',] 4771 4781 if Super: 4772 4782 colLabels.insert(3,'M') -
trunk/GSASIIstrMain.py
r4399 r4416 512 512 refPlotUpdate=refPlotUpdate) 513 513 G2fil.G2Print (' wR = %7.2f%%, chi**2 = %12.6g, reduced chi**2 = %6.2f, last delta chi = %.4f, last shft/sig = %.4f'%( 514 Rvals['Rwp'],Rvals['chisq'],Rvals['GOF']**2,Rvals['DelChi2'],Rvals ['Max shft/sig']))514 Rvals['Rwp'],Rvals['chisq'],Rvals['GOF']**2,Rvals['DelChi2'],Rvals.get('Max shft/sig',np.nan))) 515 515 # add the uncertainties into the esd dictionary (sigDict) 516 516 if not IfOK:
Note: See TracChangeset
for help on using the changeset viewer.