11# -*- coding: utf-8 -*-
2+ '''
3+ Module SUBGROUPS
4+ ========================
5+
6+ Routines that access the Bilbao Crystallographic Server.
7+
8+ Note that there is a test for some of these routines in
9+ file ``tests/run_bilbao.py``.
10+ '''
11+
212from __future__ import division , print_function
313import re
414import copy
2232def postpostURL (page ):
2333 '''warn on Bilbao down
2434 '''
35+ if page is None : return
2536 if "currently down" in page :
2637 # Bilbao is down. Tell user
2738 import re
@@ -263,7 +274,6 @@ def subBilbaoCheckLattice(spgNum,cell,tol=5):
263274 cellstr = '+' .join (['{:.5f}' .format (i ) for i in cell ])
264275 datastr = "sgr={:}&cell={:}&tol={:}&submit=Show" .format (
265276 str (int (spgNum )),cellstr ,str (int (tol )))
266- # self-tested?
267277 page = GSASIIpath .postURL (psSite ,datastr ,timeout = timeout )
268278 if postpostURL (page ): return None
269279 if not page :
@@ -368,7 +378,6 @@ def GetSupergroup(SGnum,dlg=None):
368378 import re
369379 Site = bilbaoSite + 'nph-minsup'
370380 if dlg : dlg .Update (0 ,newmsg = 'Waiting for initial web response' )
371- # self-tested?
372381 out = GSASIIpath .postURL (Site ,{'gnum' :f'{ SGnum :} ' },timeout = timeout )
373382 if postpostURL (out ): return None
374383 if not out : return None
@@ -396,7 +405,6 @@ def GetSupergroup(SGnum,dlg=None):
396405 for i ,line in enumerate (xforms ):
397406 click = line [- 1 ]
398407 print (SGnum ,click )
399- # self-tested?
400408 out1 = GSASIIpath .postURL (Site ,{'gnum' :SGnum ,'show' :'show' ,'click' :click }
401409 ,timeout = timeout )
402410 if postpostURL (out1 ): return None
@@ -572,7 +580,6 @@ def BilbaoSymSearch1(sgnum, phase, maxdelta=2, angtol=None,
572580 postdict ["stru" ] += f"{ el :4s} { i } - { atom [cx ]:.5f} { atom [cx + 1 ]:.5f} { atom [cx + 2 ]:.5f} \n "
573581# if GSASIIpath.GetConfigValue('debug'): print(postdict["stru"])
574582 savedcookies = {}
575- # self-tested?
576583 page0 = GSASIIpath .postURL (bilbaoSite + pseudosym ,postdict ,
577584 getcookie = savedcookies ,timeout = timeout )
578585 if postpostURL (page0 ): return None
@@ -666,7 +673,6 @@ def BilbaoLowSymSea1(valsdict,row,savedcookies,pagelist=None):
666673 num = row [0 ]
667674 if GSASIIpath .GetConfigValue ('debug' ): print (f"processing cell #{ num } " )
668675 postdict ['lattice' ] = num
669- # self-tested?
670676 page1 = GSASIIpath .postURL (bilbaoSite + pseudosym ,postdict ,
671677 usecookie = savedcookies ,timeout = timeout )
672678 if postpostURL (page1 ) or not page1 : return None ,None ,None ,None
@@ -703,7 +709,6 @@ def BilbaoLowSymSea2(num,valsdict,row,savedcookies,pagelist=None):
703709 postdict .update (valsdict )
704710 postdict ['super_numind' ] = row [1 ]
705711 if GSASIIpath .GetConfigValue ('debug' ): print (f"processing cell #{ num } supergroup { row [1 ]} " )
706- # self-tested?
707712 page1 = GSASIIpath .postURL (bilbaoSite + pseudosym ,postdict ,
708713 usecookie = savedcookies ,timeout = timeout )
709714 if postpostURL (page1 ) or page1 is None : return '' ,None
@@ -734,7 +739,6 @@ def BilbaoSymSearch2(valsdict,csdict,rowdict,savedcookies,
734739 postdict = {}
735740 postdict .update (valsdict )
736741 postdict ['cs' ] = num
737- # self-tested?
738742 page1 = GSASIIpath .postURL (bilbaoSite + pseudosym ,postdict ,
739743 usecookie = savedcookies ,timeout = timeout )
740744 if postpostURL (page1 ) or pagelist is not None :
@@ -797,7 +801,6 @@ def BilbaoReSymSearch(key,postdict,pagelist=None):
797801
798802 '''
799803 savedcookies = {}
800- # self-tested?
801804 page1 = GSASIIpath .postURL (bilbaoSite + pseudosym ,postdict
802805 ,getcookie = savedcookies ,timeout = timeout )
803806 if postpostURL (page1 ) or pagelist is not None :
@@ -810,7 +813,10 @@ def BilbaoReSymSearch(key,postdict,pagelist=None):
810813def createStdSetting (cifFile ,rd ):
811814 '''Use the Bilbao "CIF to Standard Setting" web service to obtain a
812815 structure in a standard setting. Then update the reader object with
813- the space group, cell and atom positions from this.
816+ the space group, cell and atom positions from this. This is called
817+ from the CIF importer in :mod:`G2phase_CIF` when a structure is
818+ encountered that has different symmetry operators from what GSAS-II
819+ generates.
814820 '''
815821 try :
816822 import requests # delay this until now, since rarely needed
@@ -854,61 +860,5 @@ def createStdSetting(cifFile,rd):
854860 if i == int (natom )- 1 : break
855861 del rd .SymOps ['xyz' ] # as-read sym ops now obsolete
856862
857- def test ():
858- '''This tests that routines in Bilbao Crystallographic Server
859- are accessible and produce output that we can parse. The output
860- is displayed but not checked to see that it agrees with what
861- has been provided previously.
862-
863-
864- The list of routines that access the Bilbao site and are tested here are:
865- * GetNonStdSubgroupsmag (uses subgrmag1_general_GSAS.pl)
866- * GetNonStdSubgroups (subgrmag1_general_GSAS.pl)
867- * GetStdSGset (checkgr.pl)
868-
869- The other routines are not yet tested that access the Bilbao site are:
870-
871- * subBilbaoCheckLattice
872- * GetSupergroup
873- * BilbaoSymSearch1
874- * BilbaoSymSearch2
875- * BilbaoReSymSearch
876- * createStdSetting
877-
878- '''
879- SGData = G2spc .SpcGroup ('f d -3 m' )[1 ]
880-
881- print ('test SUBGROUPSMAG' )
882- results ,baseList = GetNonStdSubgroupsmag (SGData ,('0' ,'0' ,'0' ,' ' ,' ' ,' ' ,' ' ,' ' ,' ' ,' ' ))
883- print (results )
884- if results :
885- for [spgp ,bns ,mv ,gid ,altList ,supList ] in results :
886- if gid in baseList :
887- print ('Space group: %d %s BNS: %s' % (gid ,spgp ,bns ))
888- print ('MV' ,mv )
889- print ('altList:' ,altList )
890- print ('superList: ' ,supList )
891-
892- print ('\n \n test SUBGROUPS' )
893- results ,baseList = GetNonStdSubgroups (SGData ,('1/3' ,'1/3' ,'1/2' ,' ' ,' ' ,' ' ,' ' ,' ' ,' ' ,' ' ))
894- print (results )
895- if results :
896- for [spgp ,mv ,gid ,altList ,supList ] in results :
897- if gid in baseList :
898- print ('Space group: %d %s' % (gid ,spgp ))
899- print ('MV' ,mv )
900- print ('altList:' ,altList )
901- print ('superList: ' ,supList )
902-
903- print ('\n \n test Bilbao IDENTIFY GROUP' )
904- sgnum ,sgsym ,xmat ,xoff = GetStdSGset (G2spc .SpcGroup ('R 3 C r' )[1 ])
905- if sgnum :
906- print (f'Space group R3c (rhomb) transforms to std setting: { sgsym } (#{ sgnum } )' )
907- print (' xform matrix' ,xmat )
908- print (' coord offset:' ,xoff )
909-
910- if __name__ == '__main__' :
911- # run self-tests
912- selftestquiet = False
913- test ()
914- print ("OK" )
863+ #if __name__ == '__main__':
864+ # Note that self-tests have been moved to file ``tests/run_bilbao.py``.
0 commit comments