Changeset 4060 for trunk/SUBGROUPS.py


Ignore:
Timestamp:
Jul 14, 2019 6:11:34 PM (2 years ago)
Author:
toby
Message:

Work on Index Unit Cell display: narrower, allow dragging limits, add cell incr for spinners; Add run PSEUDOLATTICE; Add checkBox to MultiColumnSelection? (alternate to grid)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SUBGROUPS.py

    r3729 r4060  
    1717from __future__ import division, print_function
    1818import requests
     19import numpy as np
     20import numpy.linalg as nl
    1921import GSASIIspc as G2spc
    2022import GSASIIpath
     
    274276    return result,baseList
    275277
     278def subBilbaoCheckLattice(spgNum,cell,tol=5):
     279    '''submit a unit cell to  Bilbao PseudoLattice
     280    '''
     281    psSite = "http://www.cryst.ehu.es/cgi-bin/cryst/programs/pseudosym/nph-pseudolattice"
     282    cellstr = '+'.join(['{:.5f}'.format(i) for i in cell])
     283    datastr = "sgr={:}&cell={:}&tol={:}&submit=Show".format(
     284        str(int(spgNum)),cellstr,str(int(tol)))
     285    try:
     286        r = requests.post(psSite,data=datastr)
     287    except:     #ConnectionError?
     288        page = ''
     289        print('connection error - not on internet')
     290        return None
     291    if r.status_code == 200:
     292        print('request OK')
     293        page = r.text
     294        page = page.replace('<font style= "text-decoration: overline;">','<font>-')
     295    else:
     296        page = ''
     297        print('request failed. Reason=',r.reason)
     298        return None
     299    r.close()
     300    return page
     301
     302def parseBilbaoCheckLattice(page):
     303    '''find the cell options from the web page returned by Bilbao PseudoLattice
     304    '''
     305    cellopts = [i for i in page.split('<tr>') if '<td><pre>' in i]
     306    found = []
     307    for c in cellopts:
     308        cells = c.split("pre")[1].split('<')[0].replace('>','').split('\n') # list of cells, 1st is approx
     309        try:
     310            acell = [float(i) for i in cells[0].split()]
     311            xmatA = [c.split('[')[i].split(']')[0].split() for i in (1,2,3)]
     312            xmat =  np.array([[eval(i) for i in j] for j in xmatA])
     313            cellmat = nl.inv(xmat).T
     314        except:
     315            print('Error processing cell in',c)
     316            continue
     317        found.append((acell,cellmat))
     318    return found
     319
     320
    276321def test():
    277322    SGData = G2spc.SpcGroup('f d -3 m')[1]
Note: See TracChangeset for help on using the changeset viewer.