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/
--- 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)

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
GSAS-II mailing list
GSAS-II@mailman.aps.anl.gov
https://mailman.aps.anl.gov/mailman/listinfo/gsas-ii

Reply via email to