Changeset 3168


Ignore:
Timestamp:
Nov 30, 2017 3:00:18 PM (6 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

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/CifFile/StarFile.py

    r3137 r3168  
    931931        if len(one_pack)!=1:
    932932            raise ValueError("Bad packet key %s = %s: returned %d packets" % (keyname,keyvalue,len(one_pack)))
    933         print("Keyed packet: %s" % one_pack[0])
     933#        print("Keyed packet: %s" % one_pack[0])
    934934        return one_pack[0]
    935935
     
    21922192        # print("Full URL is: " + my_uri)
    21932193        filestream = urlopen(my_uri)
    2194         text = filestream.read().decode('utf8')
     2194#        text = filestream.read().decode('utf8')
     2195        text = filestream.read().decode('latin1')
    21952196        filestream.close()
    21962197    else:
     
    21982199        text = filestream.read()
    21992200        if not isinstance(text,unicode):
    2200             text = text.decode('utf8')  #CIF is always ascii/utf8
     2201#            text = text.decode('utf8')  #CIF is always ascii/utf8
     2202            text = text.decode('latin1')  #CIF is always ascii/utf8
    22012203        my_uri = ""
    22022204    if not text:      # empty file, return empty block
  • trunk/GSASIIphsGUI.py

    r3148 r3168  
    22532253            if r < 0 and c < 0:
    22542254                for row in range(Atoms.GetNumberRows()):
    2255                     Atoms.SelectRow(row,True)                   
     2255                    Atoms.SelectRow(row,True)                   
     2256                wx.CallAfter(Paint)
     2257                return
    22562258            if r < 0:                          #double click on col label! Change all atoms!
    22572259                noSkip = True
     
    44714473        cx,ct,cs,cia = generalData['AtomPtrs']
    44724474        atomData = data['Atoms']
    4473         D4Map = generalData['4DmapData']
     4475        D4Map = generalData.get('4DmapData',{'rho':[]})
    44744476        if waveData.GetSizer():
    44754477            waveData.GetSizer().Clear(True)
     
    51935195                                str(int(Cell[0]))+','+str(int(Cell[1]))+','+str(int(Cell[2]))                           
    51945196                            atom[cs-1] = G2spc.StringOpsProd(atomOp,newOp,SGData)
    5195                             if cmx:
     5197                            if cmx:         #magnetic moment
    51965198                                opNum = G2spc.GetOpNum(OprNum,SGData)
    51975199                                mom = np.inner(np.array(atom[cmx:cmx+3]),Bmat)
    5198 #                                print OprNum,newOp,opNum,SpnFlp
     5200#                                print (OprNum,newOp,opNum,nl.det(M),SpnFlp)
    51995201                                atom[cmx:cmx+3] = np.inner(np.inner(mom,M),Amat)*nl.det(M)*SpnFlp[opNum-1]
    52005202                            if atom[cui] == 'A':
     
    63756377            if dlg.ShowModal() == wx.ID_OK:
    63766378                for sel in dlg.GetSelections():
    6377                     data['Histograms'][keyList[sel]].update(copyDict)
     6379                    data['Histograms'][keyList[sel]].update(copy.deepcopy(copyDict))
    63786380        finally:
    63796381            dlg.Destroy()
     
    64326434                                    data['Histograms'][item][name][2][itm][1] = copy.deepcopy(copyDict[name][itm])
    64336435                            elif name == 'Twins':
    6434                                 data['Histograms'][item]['Twins'][0][1][1] = copyDict['Twins']
     6436                                data['Histograms'][item]['Twins'][0][1][1] = copy.deepcopy(copyDict['Twins'])
    64356437                            else:
    64366438                                try:
     
    64666468            G2G.G2MessageBox(G2frame,'No histograms to copy to')
    64676469            return
    6468         copyDict = {}
    64696470        if 'HKLF' in sourceDict['Histogram']:
    64706471            copyNames = ['Scale','Extinction','Babinet','Flack','Twins','Fix FXU']
  • trunk/GSASIIspc.py

    r3136 r3168  
    698698                SGData['SGSpin'][:2] = [1,1]
    699699   
    700 def MagSGSym(SGData):
     700def MagSGSym(SGData):       #needs to use SGPtGrp not SGLaue!
    701701    SGLaue = SGData['SGLaue']
    702702    SpnFlp = SGData['SGSpin']
    703703    GenSym = SGData['GenSym']
     704    SGPtGrp = SGData['SGPtGrp']
    704705    if not len(SpnFlp):
    705         SGLaue['MagPtGp'] = SGLaue
     706        SGLaue['MagPtGp'] = SGPtGrp
    706707        return SGData['SpGrp']
    707708    magSym = SGData['SpGrp'].split()
    708709    if SGLaue in ['-1',]:
    709         SGData['MagPtGp'] = SGLaue
     710        SGData['MagPtGp'] = SGPtGrp
    710711        if SpnFlp[0] == -1:
    711712            magSym[1] += "'"
     
    714715            if SpnFlp[1] < 0:
    715716                magSym[0] += '(P)'
    716     elif SGLaue in ['mmm',]:
     717    elif SGPtGrp in ['mmm','mm2','m2m','2mm','222']:
    717718        SGData['MagPtGp'] = ''
    718719        for i in [0,1,2]:
    719             SGData['MagPtGp'] += 'm'
     720            SGData['MagPtGp'] += SGPtGrp[i]
    720721            if SpnFlp[i] < 0:
    721722                magSym[i+1] += "'"
     
    34463447    'P n a m':['(00g)','(00g)0s0','(a00)','(a00)00s','(0b0)','(0b0)00s'],
    34473448    'P m n b':['(00g)','(00g)s00','(a00)','(a00)00s','(0b0)','(0b0)s00'],
    3448     'P c m n':['(00g)','(00g)0s0','(a00)','(a00)0s0','(0b0)','(0b0)s00'],
     3449    'P c m n':['(00g)','(00g)0s0','(00g)ss0','(a00)','(a00)0s0','(0b0)','(0b0)s00'],
    34493450#63
    34503451    'C m c m':['(00g)','(00g)s00','(10g)','(10g)s00','(a00)','(a00)00s','(a00)0ss','(a00)0s0','(0b0)','(0b0)00s','(0b0)s0s','(0b0)s00',],
  • 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.