@@ -829,36 +829,37 @@ def createStdSetting(cifFile,rd):
829829 if not os .path .exists (cifFile ):
830830 print (f'createStdSetting error: file { cifFile } not found' )
831831 return False
832- files = {'cifile' : open (cifFile ,'rb' )}
833- values = {'strtidy' :'' }
834- print (f'''Submitting structure to Bilbao "CIF to Standard Setting" (strtidy)
835- web service. Please cite:
836- { G2G .GetCite ('Bilbao: PSEUDOLATTICE' ,wrap = 70 ,indent = 5 )} ''' )
837- r0 = requests .post (bilbaoSite + cif2std , files = files , data = values )
838- structure = r0 .text [r0 .text .lower ().find ('<pre>' )+ 5 :r0 .text .lower ().find ('</pre>' )].strip ()
839- spnum ,celllist ,natom = structure .split ('\n ' )[:3 ]
840- #spgNam = G2spc.spgbyNum[int(spnum)]
841- cell = [float (i ) for i in celllist .split ()]
842- # replace cell, space group and atom info with info from Bilbao
843- # could try to xfer Uiso (Uij needs xform), but that would be too involved
844- rd .Phase ['General' ]['SGData' ] = SGData = G2spc .SpcGroup (G2spc .spgbyNum [int (spnum )])[1 ]
845- rd .Phase ['General' ]['Cell' ] = [False ] + list (cell ) + [G2lat .calc_V (G2lat .cell2A (cell ))]
846- rd .Phase ['Atoms' ] = []
847- for i ,line in enumerate (structure .split ('\n ' )[3 :]):
848- atomlist = ['' ,'Xe' ,'' ,0. ,0. ,0. ,1.0 ,'' ,0. ,'I' ,0.01 , 0. ,0. ,0. ,0. ,0. ,0. ,]
849- elem ,lbl ,wyc ,x ,y ,z = line .split ()
850- elem = elem .rstrip ('0123456789-+' )
851- atomlist [0 ] = elem + lbl
852- if G2elem .CheckElement (elem ):
853- atomlist [1 ] = elem
854- atomlist [3 :6 ] = [float (i ) for i in (x ,y ,z )]
855- atomlist [7 ],atomlist [8 ] = G2spc .SytSym (atomlist [3 :6 ],SGData )[:2 ]
856- atomlist [1 ] = G2elem .FixValence (atomlist [1 ])
857-
858- atomlist .append (ran .randint (0 ,sys .maxsize )) # add a random Id
859- rd .Phase ['Atoms' ].append (atomlist )
860- if i == int (natom )- 1 : break
861- del rd .SymOps ['xyz' ] # as-read sym ops now obsolete
832+ with open (cifFile ,'rb' ) as fil :
833+ files = {'cifile' : fil }
834+ values = {'strtidy' :'' }
835+ print (f'''Submitting structure to Bilbao "CIF to Standard Setting" (strtidy)
836+ web service. Please cite:
837+ { G2G .GetCite ('Bilbao: PSEUDOLATTICE' ,wrap = 70 ,indent = 5 )} ''' )
838+ r0 = requests .post (bilbaoSite + cif2std , files = files , data = values )
839+ structure = r0 .text [r0 .text .lower ().find ('<pre>' )+ 5 :r0 .text .lower ().find ('</pre>' )].strip ()
840+ spnum ,celllist ,natom = structure .split ('\n ' )[:3 ]
841+ #spgNam = G2spc.spgbyNum[int(spnum)]
842+ cell = [float (i ) for i in celllist .split ()]
843+ # replace cell, space group and atom info with info from Bilbao
844+ # could try to xfer Uiso (Uij needs xform), but that would be too involved
845+ rd .Phase ['General' ]['SGData' ] = SGData = G2spc .SpcGroup (G2spc .spgbyNum [int (spnum )])[1 ]
846+ rd .Phase ['General' ]['Cell' ] = [False ] + list (cell ) + [G2lat .calc_V (G2lat .cell2A (cell ))]
847+ rd .Phase ['Atoms' ] = []
848+ for i ,line in enumerate (structure .split ('\n ' )[3 :]):
849+ atomlist = ['' ,'Xe' ,'' ,0. ,0. ,0. ,1.0 ,'' ,0. ,'I' ,0.01 , 0. ,0. ,0. ,0. ,0. ,0. ,]
850+ elem ,lbl ,wyc ,x ,y ,z = line .split ()
851+ elem = elem .rstrip ('0123456789-+' )
852+ atomlist [0 ] = elem + lbl
853+ if G2elem .CheckElement (elem ):
854+ atomlist [1 ] = elem
855+ atomlist [3 :6 ] = [float (i ) for i in (x ,y ,z )]
856+ atomlist [7 ],atomlist [8 ] = G2spc .SytSym (atomlist [3 :6 ],SGData )[:2 ]
857+ atomlist [1 ] = G2elem .FixValence (atomlist [1 ])
858+
859+ atomlist .append (ran .randint (0 ,sys .maxsize )) # add a random Id
860+ rd .Phase ['Atoms' ].append (atomlist )
861+ if i == int (natom )- 1 : break
862+ del rd .SymOps ['xyz' ] # as-read sym ops now obsolete
862863
863864#if __name__ == '__main__':
864865 # Note that self-tests have been moved to file ``tests/run_bilbao.py``.
0 commit comments