#!/usr/bin/env /usr/bin/python3 ################################################ import pandas as pd # the API webpage # https://www-nds.iaea.org/relnsd/vcharthtml/api_v0_guide.html#examples # the service URL livechart = "https://nds.iaea.org/relnsd/v0/data?" import urllib.request def lc_read_csv(url): req = urllib.request.Request(url) req.add_header('User-Agent', 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:77.0) Gecko/20100101 Firefox/77.0') return pd.read_csv(urllib.request.urlopen(req)) mp = 938.27208816; #MeV/c^2 mn = 939.56542052; ''' haha = lc_read_csv(livechart + 'fields=ground_states&nuclides=all') def FindZ(AZ): query = livechart + "fields=ground_states&nuclides=" + AZ temp = lc_read_csv(query); try : return temp['z'] except : return 'na' def FindSym(Z): try: return (haha['symbol'][haha['z']==Z]).iloc[0] except: return 'na' def Mass(A, Z): try : BEA = float(haha['binding'][haha['z']==Z][haha['n']==(A-Z)])/1000 return (A-Z)*mn + Z*mp - A * BEA except : return -404 def MassSym(AZ): query = livechart + "fields=ground_states&nuclides=" + AZ temp = lc_read_csv(query); Z = temp['z'] N = temp['n'] try : return Z*mp + N*mn - (Z+N)*temp['binding']/1000 except: return -404 def Sp(A,Z,a,z): mA = Mass(A,Z) mB = Mass(A-a, Z-z) if z == 0 : mb = a * mn elif a == z : mb = a * mp else : mb = Mass(a,z) if (mB == -404 or mb == -404 or mA == -404) : return -404 else: return mB + mb - mA def Ex(AZ, maxMeV): query = livechart + "fields=levels&nuclides=" + AZ tempEx = lc_read_csv(query); try : return tempEx[['energy', 'jp']][tempEx['energy']<= maxMeV * 1000] except: return -404 ''' #=================================================== import cgi, cgitb form = cgi.FieldStorage() AZ = form.getvalue('isotopes_name') maxEx = form.getvalue('maxEx') if maxEx == "can be omitted" : maxEx = -1 query = livechart + "fields=ground_states&nuclides=" + AZ temp = lc_read_csv(query); print( "Content-type:text/html\r\n\r\n") print("") print("") print("
") print("%9.3f | %s |