Changeset 4884 for trunk


Ignore:
Timestamp:
Apr 15, 2021 10:22:56 PM (5 months ago)
Author:
toby
Message:

add all cell params to CIF when Dij values are used

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIctrlGUI.py

    r4873 r4884  
    722722        elif self.OKcontrol and previousInvalid:
    723723            self.OKcontrol(True)
    724         # always store the result
    725         if self.CIFinput and '2' in platform.python_version_tuple()[0]: # CIF/Py2 make results ASCII
    726             self.result[self.key] = val.encode('ascii','replace')
    727         else:
    728             self.result[self.key] = val
    729         log.LogVarChange(self.result,self.key)
     724        self._SaveStringValue()         # always store the result
    730725
    731726    def _GetStringValue(self,event):
  • trunk/exports/G2export_CIF.py

    r4883 r4884  
    6060import GSASIImapvars as G2mv
    6161import GSASIIElem as G2el
     62import GSASIIpy3 as G2py3
    6263
    6364DEBUG = False    #True to skip printing of reflection/powder profile lists
    6465
    6566CIFdic = None
     67
     68cellNames = ['length_a','length_b','length_c',
     69             'angle_alpha','angle_beta ','angle_gamma',
     70             'volume']
     71
    6672
    6773# Refactored over here to allow access by GSASIIscriptable.py
     
    695701            return ('?',None)
    696702
     703    def ShowHstrainCells(self,phasenam,datablockidDict):
     704        '''Displays the unit cell parameters for phases where Dij values create
     705        mutiple sets of lattice parameters. At present there is no way defined for this in
     706        CIF, so local data names are used.
     707        '''
     708        phasedict = self.Phases[phasenam] # pointer to current phase info
     709        Tlist = {}  # histname & T values used for cell w/o Hstrain
     710        DijTlist = {} # hId & T values used for cell w/Hstrain
     711        # scan over histograms used in this phase
     712        for h in phasedict['Histograms']:
     713            if not phasedict['Histograms'][h]['Use']: continue
     714            if np.any(abs(np.array(phasedict['Histograms'][h]['HStrain'][0])) > 1e-8):
     715                DijTlist[h] = self.Histograms[h]['Sample Parameters']['Temperature']
     716            else:
     717                Tlist[h] = self.Histograms[h]['Sample Parameters']['Temperature']
     718        if len(DijTlist) == 0: return
     719        if len(Tlist) + len(DijTlist) < 2: return
     720        SGData = phasedict['General']['SGData']
     721        for i in range(len(G2py3.cellGUIlist)):
     722            if SGData['SGLaue'] in G2py3.cellGUIlist[i][0]:
     723                terms = G2py3.cellGUIlist[i][5] + [6]
     724                break
     725        else:
     726            print('ShowHstrainCells error: Laue class not found',SGData['SGLaue'])
     727            terms = list(range(7))
     728       
     729        WriteCIFitem(self.fp, '\n# cell parameters generated by hydrostatic strain')
     730        WriteCIFitem(self.fp, 'loop_')
     731        WriteCIFitem(self.fp, '\t _gsas_measurement_temperature')
     732        for i in terms:
     733            WriteCIFitem(self.fp, '\t _gsas_cell_'+cellNames[i])
     734        WriteCIFitem(self.fp, '\t _gsas_cell_histogram_blockid')
     735        for h,T in Tlist.items():
     736            pId = phasedict['pId']
     737            hId = self.Histograms[h]['hId']
     738            cellList,cellSig = G2strIO.getCellSU(pId,hId,
     739                                        phasedict['General']['SGData'],
     740                                        self.parmDict,
     741                                        self.OverallParms['Covariance'])
     742            line = '  ' + PutInCol(G2mth.ValEsd(T,-1.),6)
     743            for i in terms:
     744                line += PutInCol(G2mth.ValEsd(cellList[i],cellSig[i]),12)
     745            line += ' ' + datablockidDict[h]
     746            WriteCIFitem(self.fp, line)
     747        for h,T in DijTlist.items():
     748            pId = phasedict['pId']
     749            hId = self.Histograms[h]['hId']
     750            cellList,cellSig = G2strIO.getCellSU(pId,hId,
     751                                        phasedict['General']['SGData'],
     752                                        self.parmDict,
     753                                        self.OverallParms['Covariance'])
     754            line = '  ' + PutInCol(G2mth.ValEsd(T,-1.),6)
     755            for i in terms:
     756                line += PutInCol(G2mth.ValEsd(cellList[i],cellSig[i]),12)
     757            line += ' ' + datablockidDict[h]
     758            WriteCIFitem(self.fp, line)       
     759
    697760    def _Exporter(self,event=None,phaseOnly=None,histOnly=None,IncludeOnlyHist=None):
    698761        '''Basic code to export a CIF. Export can be full or simple, as set by
    699762        phaseOnly and histOnly which skips distances & angles, etc.
    700763
    701           phaseOnly: used to export only one phase
    702           histOnly: used to export only one histogram
    703           IncludeOnlyHist: used for a full CIF that includes only one of the
     764        :param bool phaseOnly: used to export only one phase
     765        :param bool histOnly: used to export only one histogram
     766        :param bool IncludeOnlyHist: used for a full CIF that includes only one of the
    704767            histograms (from a sequential fit) #TODO: needs lots of work!
    705768        '''
     
    12591322
    12601323            defsigL = 3*[-0.00001] + 3*[-0.001] + [-0.01] # significance to use when no sigma
    1261             names = ['length_a','length_b','length_c',
    1262                      'angle_alpha','angle_beta ','angle_gamma',
    1263                      'volume']
    12641324            prevsig = 0
    1265             for lbl,defsig,val,sig in zip(names,defsigL,cellList,cellSig):
     1325            for lbl,defsig,val,sig in zip(cellNames,defsigL,cellList,cellSig):
    12661326                if sig:
    12671327                    txt = G2mth.ValEsd(val,sig)
     
    21422202        if phaseOnly: #====Phase only CIF ================================
    21432203            print('Writing CIF output to file '+self.filename)
    2144             #self.OpenFile()
    21452204            oneblock = True
    21462205            self.quickmode = True
     
    21512210            # report the phase info
    21522211            WritePhaseInfo(phaseOnly)
    2153             #self.CloseFile()
    21542212            return
    21552213        elif histOnly: #====Histogram only CIF ================================
    21562214            print('Writing CIF output to file '+self.filename)
    2157             #self.OpenFile()
    21582215            hist = histOnly
    21592216            #histname = histOnly.replace(' ','')
     
    23122369        #======================================================================
    23132370        print('Writing CIF output to file '+self.filename+"...")
    2314         #self.OpenFile()
    23152371        if self.currentExportType == 'single' or self.currentExportType == 'powder':
    23162372            #======Data only CIF (powder/xtal) ====================================
     
    24542510                if PP:
    24552511                    WriteCIFitem(self.fp, '_pd_proc_ls_profile_function',PP)
     2512                self.ShowHstrainCells(phasenam,datablockidDict)
    24562513
    24572514            #============================================================
Note: See TracChangeset for help on using the changeset viewer.