[GSAS-II] suggested patch
Ivo Alxneit
ivo.alxneit at psi.ch
Wed Oct 12 07:25:32 CDT 2016
Dear all
I like to have the full covariance matrix at hand after a refinement.
Attached a patch that writes the covariance matrix to basename'.cov'
after a successful refinement. I do not know, how to handle the case for
a sequential refinement. Maybe a spearate file for each member of the
sequence?
Maybe PrintCovMatrix() should go to GSASIIstrIO.py?
gruss
--
Dr. Ivo Alxneit
Catalysis for Energy Group
Bioenergy and Catalysis Laboratory phone: +41 56 310 4092
Paul Scherrer Institute fax: +41 56 310 2688
CH-5232 Villigen gnupg key: 0x515E30C7
Switzerland
https://www.psi.ch/ceg/catalysis-for-energy-group/
-------------- next part --------------
--- GSASIIstrMain.py 2016-10-12 14:14:54.449511553 +0200
+++ GSASIIstrMain_new.py 2016-10-12 14:14:00.393518260 +0200
@@ -130,6 +130,29 @@
G2stMth.GetFobsSq(Histograms,Phases,parmDict,calcControls)
return IfOK,Rvals,result,covMatrix,sig
+def PrintCovMatrix(varyList, covMatrix, path):
+ with open(path, 'w') as covFile:
+ covFile.write(128*'*' + '\n')
+ covFile.write('*' + 126*' ' + '*\n')
+ covFile.write('*{:^126}*\n'.format('Covariance Matrix'))
+ covFile.write('*' + 126*' ' + '*\n')
+ covFile.write(128*'*' + '\n\n\n\n')
+ llen = len(varyList)
+ for start in xrange(0, llen, 7): # split matrix into batches of 7 columns
+ if llen >= start + 7:
+ stop = start + 7
+ else:
+ stop = llen
+ covFile.write(16*' ' + '\t')
+ for idx in xrange(start, stop):
+ covFile.write('{:^16}\t'.format(varyList[idx]))
+ covFile.write('\n\n')
+ for line in xrange(llen):
+ covFile.write('{:>16}\t'.format(varyList[line]))
+ for idx in xrange(start, stop):
+ covFile.write('{: 16.12f}\t'.format(covMatrix[line][idx]))
+ covFile.write('\n')
+ covFile.write('\n\n\n')
def Refine(GPXfile,dlg):
'Global refinement -- refines to minimize against all histograms'
@@ -203,6 +226,7 @@
covData = {}
IfOK,Rvals,result,covMatrix,sig = RefineCore(Controls,Histograms,Phases,restraintDict,
rigidbodyDict,parmDict,varyList,calcControls,pawleyLookup,ifPrint,printFile,dlg)
+ PrintCovMatrix(varyList, covMatrix, os.path.splitext(GPXfile)[0]+'.cov')
sigDict = dict(zip(varyList,sig))
newCellDict = G2stMth.GetNewCellParms(parmDict,varyList)
newAtomDict = G2stMth.ApplyXYZshifts(parmDict,varyList)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP digital signature
URL: <http://mailman.aps.anl.gov/pipermail/gsas-ii/attachments/20161012/3add9ecf/attachment.sig>
More information about the GSAS-II
mailing list