Changeset 963 for trunk/exports


Ignore:
Timestamp:
Jun 20, 2013 5:07:33 PM (8 years ago)
Author:
toby
Message:

more CIF work, more docs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/exports/G2cif.py

    r960 r963  
    66import os.path
    77import GSASIIIO as G2IO
    8 reload(G2IO)
     8#reload(G2IO)
    99import GSASIIgrid as G2gd
    1010import GSASIIstrIO as G2stIO
     
    1313import GSASIIlattice as G2lat
    1414import GSASIIspc as G2spg
     15reload(G2spg)
    1516
    1617def getCallerDocString(): # for development
     
    6768
    6869        def WriteOverall():
    69             '''TODO: Write out overall refinement information
     70            '''Write out overall refinement information.
     71
     72            More could be done here, but this is a good start.
    7073            '''
    7174            WriteCIFitem('_pd_proc_info_datetime', self.CIFdate)
     
    8588            WriteCIFitem('_refine_ls_goodness_of_fit_all',GOF)
    8689
     90            # get restraint info
     91            # restraintDict = self.OverallParms.get('Restraints',{})
     92            # for i in  self.OverallParms['Constraints']:
     93            #     print i
     94            #     for j in self.OverallParms['Constraints'][i]:
     95            #         print j
    8796            #WriteCIFitem('_refine_ls_number_restraints',TEXT)
    8897           
     
    300309                        cia+1:'AUiso',cia+2:'AU11',cia+3:'AU22',cia+4:'AU33',
    301310                        cia+5:'AU12',cia+6:'AU13',cia+7:'AU23'}
    302             labellist = []
     311            self.labellist = []
    303312           
    304313            pfx = str(phasedict['pId'])+'::'
     
    306315            naniso = 0
    307316            for i,at in enumerate(Atoms):
    308                 s = PutInCol(MakeUniqueLabel(at[ct-1],labellist),6) # label
     317                s = PutInCol(MakeUniqueLabel(at[ct-1],self.labellist),6) # label
    309318                fval = self.parmDict.get(fpfx+str(i),at[cfrac])
    310319                if fval == 0.0: continue # ignore any atoms that have a occupancy set to 0 (exact)
     
    354363                if fval == 0.0: continue # ignore any atoms that have a occupancy set to 0 (exact)
    355364                if at[cia] == 'I': continue
    356                 s = PutInCol(labellist[i],6) # label
     365                s = PutInCol(self.labellist[i],6) # label
    357366                for j in (2,3,4,5,6,7):
    358367                    sigdig = -0.0009
     
    444453                          G2mth.ValEsd(cellmass/Z,-0.09,True))
    445454
     455        def WriteDistances(phasenam,SymOpList,offsetList,symOpList,G2oprList):
     456            '''Report bond distances and angles for the CIF
     457
     458            Note that _geom_*_symmetry_* fields are values of form
     459            n_klm where n is the symmetry operation in SymOpList (counted
     460            starting with 1) and (k-5, l-5, m-5) are translations to add
     461            to (x,y,z). See
     462            http://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Igeom_angle_site_symmetry_.html
     463
     464            TODO: need a method to select publication flags for distances/angles
     465            '''
     466            phasedict = self.Phases[phasenam] # pointer to current phase info           
     467            Atoms = phasedict['Atoms']
     468            cx,ct,cs,cia = phasedict['General']['AtomPtrs']
     469            fpfx = str(phasedict['pId'])+'::Afrac:'       
     470            cfrac = cx+3
     471            # loop over interatomic distances for this phase
     472            WriteCIFitem('\n# MOLECULAR GEOMETRY')
     473            WriteCIFitem('loop_' +
     474                         '\n\t_geom_bond_atom_site_label_1' +
     475                         '\n\t_geom_bond_atom_site_label_2' +
     476                         '\n\t_geom_bond_distance' +
     477                         '\n\t_geom_bond_site_symmetry_1' +
     478                         '\n\t_geom_bond_site_symmetry_2' +
     479                         '\n\t_geom_bond_publ_flag')
     480
     481            # Note that labels should be read from self.labellist to correspond
     482            # to the values reported in the atoms table and zero occupancy atoms
     483            # should not be included
     484            fpfx = str(phasedict['pId'])+'::Afrac:'       
     485            for i,at in enumerate(Atoms):
     486                if self.parmDict.get(fpfx+str(i),at[cfrac]) == 0.0: continue
     487                lbl = self.labellist[i]
     488
     489
     490            # loop over interatomic angles for this phase
     491            WriteCIFitem('loop_' +
     492                         '\n\t_geom_angle_atom_site_label_1' +
     493                         '\n\t_geom_angle_atom_site_label_2' +
     494                         '\n\t_geom_angle_atom_site_label_3' +
     495                         '\n\t_geom_angle' +
     496                         '\n\t_geom_angle_site_symmetry_1' +
     497                         '\n\t_geom_angle_site_symmetry_2' +
     498                         '\n\t_geom_angle_site_symmetry_3' +
     499                         '\n\t_geom_angle_publ_flag')
     500
     501
    446502        def WritePhaseInfo(phasenam):
    447             # see writepha.for
    448             print 'TODO: phase info for',phasenam,'goes here'
    449             # THINK: how to select publication flags for distances/angles?
     503            WriteCIFitem('\n# phase info for '+str(phasenam) + ' follows')
    450504            phasedict = self.Phases[phasenam] # pointer to current phase info           
    451505            WriteCIFitem('_pd_phase_name', phasenam)
     
    478532
    479533            # generate symmetry operations including centering and center of symmetry
    480             WriteCIFitem('loop_ _symmetry_equiv_pos_site_id _symmetry_equiv_pos_as_xyz')
    481             for i,op in enumerate(G2spg.AllOps(phasedict['General']['SGData']),start=1):
     534            SymOpList,offsetList,symOpList,G2oprList = G2spg.AllOps(
     535                phasedict['General']['SGData'])
     536            WriteCIFitem('loop_ _space_group_symop_id _space_group_symop_operation_xyz')
     537            for i,op in enumerate(SymOpList,start=1):
    482538                WriteCIFitem('   {:3d}  {:}'.format(i,op.lower()))
    483539
     
    512568            # report cell contents
    513569            WriteComposition(phasenam)
    514 #            if not self.quickmode:
    515                 # report distances and angles
    516 #                WriteDistances(phasenam)
     570            if not self.quickmode:      # report distances and angles
     571                WriteDistances(phasenam,SymOpList,offsetList,symOpList,G2oprList)
    517572
    518573            #raise Exception,'Testing'
    519 
    520             #C now loop over interatomic distances for this phase
    521             WriteCIFitem('\n# MOLECULAR GEOMETRY')
    522             WriteCIFitem('loop_' +
    523                          '\n\t_geom_bond_atom_site_label_1' +
    524                          '\n\t_geom_bond_atom_site_label_2' +
    525                          '\n\t_geom_bond_distance' +
    526                          '\n\t_geom_bond_site_symmetry_1' +
    527                          '\n\t_geom_bond_site_symmetry_2' +
    528                          '\n\t_geom_bond_publ_flag')
    529 
    530             #C now loop over interatomic angles for this phase
    531             WriteCIFitem('loop_' +
    532                          '\n\t_geom_angle_atom_site_label_1' +
    533                          '\n\t_geom_angle_atom_site_label_2' +
    534                          '\n\t_geom_angle_atom_site_label_3' +
    535                          '\n\t_geom_angle' +
    536                          '\n\t_geom_angle_site_symmetry_1' +
    537                          '\n\t_geom_angle_site_symmetry_2' +
    538                          '\n\t_geom_angle_site_symmetry_3' +
    539                          '\n\t_geom_angle_publ_flag')
    540574
    541575        def WritePowderData(histlbl):
     
    9681002                    WriteSingleXtalData(key1)
    9691003
    970         # TODO: how to report _pd_proc_ls_peak_cutoff?
    9711004        WriteCIFitem('#--' + 15*'eof--' + '#')
    9721005
Note: See TracChangeset for help on using the changeset viewer.