Ignore:
Timestamp:
Nov 30, 2017 3:00:18 PM (5 years ago)
Author:
vondreele
Message:

fix phase data copy operations - needed copy.deepcopy in 2 places
(partial) fix on cif import - for incommensurate & magnetic structures
fix to StarFile? for latin1 encoding

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/imports/G2phase_CIF.py

    r3163 r3168  
    113113                sg = cf[blknm].get("_symmetry_space_group_name_H-M",'')
    114114                if not sg: sg = cf[blknm].get("_space_group_name_H-M_alt",'')
     115                sg = sg.replace('_','')
    115116                if sg: choice[-1] += ', (' + sg.strip() + ')'
    116             selblk = G2IO.PhaseSelector(
    117                 choice,
    118                 ParentFrame=ParentFrame,
    119                 title= 'Select a phase from one the CIF data_ blocks below',
    120                 size=(600,100)
    121                 )
     117            selblk = G2IO.PhaseSelector(choice,ParentFrame=ParentFrame,
     118                title= 'Select a phase from one the CIF data_ blocks below',size=(600,100))
    122119        self.errors = 'Error during reading of selected block'
    123120        if selblk is None:
     
    128125            E = True
    129126            Super = False
     127            if blk.get("_space_group_ssg_name",''):
     128                Super = True
    130129            magnetic = False
    131130            self.Phase['General']['Type'] = 'nuclear'
     
    138137                self.Phase['General']['Type'] = 'magnetic'
    139138                self.Phase['General']['AtomPtrs'] = [3,1,10,12]
    140             if not SpGrp:
     139            if Super:
    141140                sspgrp = blk.get("_space_group_ssg_name",'').split('(')
    142141                SpGrp = sspgrp[0]
     
    144143                Super = True
    145144                SuperVec = [[0,0,.1],False,4]
     145            SpGrp = SpGrp.replace('_','')
    146146            # try normalizing the space group, to see if we can pick the space group out of a table
    147147            SpGrpNorm = G2spc.StandardizeSpcName(SpGrp)
     
    170170            Volume = G2lat.calc_V(G2lat.cell2A(cell))
    171171            self.Phase['General']['Cell'] = [False,]+cell+[Volume,]
     172            if Super:
     173                print(blk.get('_cell_modulation_dimension',''))
     174                if int(blk.get('_cell_modulation_dimension','')) > 1:
     175                    msg = 'more than 3+1 super symmetry is not allowed in GSAS-II'
     176                    self.errors = msg
     177                    self.warnings += msg
     178                    return False
     179                waveloop = blk.GetLoop('_cell_wave_vector_seq_id')
     180                waveDict = dict(waveloop.items())
     181                SuperVec = [[float(waveDict['_cell_wave_vector_x'][0]),
     182                    float(waveDict['_cell_wave_vector_y'][0]),
     183                    float(waveDict['_cell_wave_vector_z'][0])],False,4]
    172184            # read in atoms
    173185            self.errors = 'Error during reading of atoms'
     
    235247            for aitem in atomloop:
    236248                if magnetic:
    237                     atomlist = ['','','',0.,0.,0.,1.0,0.,0.,0.,'',0.,'I',0.01,0.,0.,0.,0.,0.,0.,0.]
    238                 else:
    239                     atomlist = ['','','',0.,0.,0.,1.0,'',0.,'I',0.01,0.,0.,0.,0.,0.,0.,0.]
    240                 atomlist[-1] = ran.randint(0,sys.maxsize) # add a random Id
    241                 while atomlist[-1] in ranIdlookup:
    242                     atomlist[-1] = ran.randint(0,sys.maxsize) # make it unique
     249                    atomlist = ['','','',0.,0.,0.,1.0,0.,0.,0.,'',0.,'I',0.01,0.,0.,0.,0.,0.,0.]
     250                else:
     251                    atomlist = ['','','',0.,0.,0.,1.0,'',0.,'I',0.01,0.,0.,0.,0.,0.,0.]
    243252                for val,key in zip(aitem,atomkeys):
    244253                    col = G2AtomDict.get(key,-1)
     
    295304                    atomlist[7],atomlist[8] = G2spc.SytSym(atomlist[3:6],SGData)[:2]
    296305                atomlist[1] = G2elem.FixValence(atomlist[1])
     306                atomlist.append(ran.randint(0,sys.maxsize)) # add a random Id
    297307                self.Phase['Atoms'].append(atomlist)
    298308                ranIdlookup[atomlist[0]] = atomlist[-1]
     
    306316                    Spos = np.zeros((4,6))
    307317                    nim = -1
    308                     for i,item in enumerate(displFdict['_atom_site_displace_Fourier_atom_site_label']):
     318                    for i,item in enumerate(displFdict['_atom_site_displace_fourier_atom_site_label']):
    309319                        if item == atomlist[0]:
    310320                            waveType = 'Fourier'                               
    311                             ix = ['x','y','z'].index(displFdict['_atom_site_displace_Fourier_axis'][i])
    312                             im = int(displFdict['_atom_site_displace_Fourier_wave_vector_seq_id'][i])
     321                            ix = ['x','y','z'].index(displFdict['_atom_site_displace_fourier_axis'][i])
     322                            im = int(displFdict['_atom_site_displace_fourier_wave_vector_seq_id'][i])
    313323                            if im != nim:
    314324                                nim = im
    315                             val = displFdict['_atom_site_displace_Fourier_param_sin'][i]
     325                            val = displFdict['_atom_site_displace_fourier_param_sin'][i]
    316326                            Spos[im-1][ix] = cif.get_number_with_esd(val)[0]
    317                             val = displFdict['_atom_site_displace_Fourier_param_cos'][i]
     327                            val = displFdict['_atom_site_displace_fourier_param_cos'][i]
    318328                            Spos[im-1][ix+3] = cif.get_number_with_esd(val)[0]
    319329                    if nim >= 0:
     
    324334                        nim = -1
    325335                        Sadp = np.zeros((4,12))
    326                         for i,item in enumerate(UijFdict['_atom_site_U_Fourier_atom_site_label']):
     336                        for i,item in enumerate(UijFdict['_atom_site_U_fourier_atom_site_label']):
    327337                            if item == atomlist[0]:
    328                                 ix = ['U11','U22','U33','U12','U13','U23'].index(UijFdict['_atom_site_U_Fourier_tens_elem'][i])
    329                                 im = int(UijFdict['_atom_site_U_Fourier_wave_vector_seq_id'][i])
     338                                ix = ['U11','U22','U33','U12','U13','U23'].index(UijFdict['_atom_site_U_fourier_tens_elem'][i])
     339                                im = int(UijFdict['_atom_site_U_fourier_wave_vector_seq_id'][i])
    330340                                if im != nim:
    331341                                    nim = im
    332                                 val = UijFdict['_atom_site_U_Fourier_param_sin'][i]
     342                                val = UijFdict['_atom_site_U_fourier_param_sin'][i]
    333343                                Sadp[im-1][ix] = cif.get_number_with_esd(val)[0]
    334                                 val = UijFdict['_atom_site_U_Fourier_param_cos'][i]
     344                                val = UijFdict['_atom_site_U_fourier_param_cos'][i]
    335345                                Sadp[im-1][ix+6] = cif.get_number_with_esd(val)[0]
    336346                        if nim >= 0:
Note: See TracChangeset for help on using the changeset viewer.