Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.11 KB | None | 0 0
  1. import urllib, json
  2.  
  3. DEBUG = True
  4.  
  5. #Inputs
  6. symbol = 'Zr'
  7. mass_number = '87m'
  8. reaction = 't,3He'
  9.  
  10. url = "http://www.cross-section-plotter.com/array_xs_small.txt?_=1485105436306"
  11. response = urllib.urlopen(url)
  12. data = json.loads(response.read())['data']
  13.  
  14. search_result = None
  15.  
  16. for i,j in enumerate(data):
  17.     if j[1] == symbol and j[2] == mass_number and j[3] == reaction:
  18.         if DEBUG:
  19.             print 'Debug: '+j
  20.         search_result = j
  21.  
  22. if search_result == None:
  23.     print "Particle not found"
  24.     exit(1)
  25.  
  26. particle = search_result[3].split(',')[0]
  27. librarylc=search_result[5].split('<')[0].lower()
  28. mass_number_short = search_result[2]
  29.  
  30. if mass_number_short == 'Natural':
  31.     mass_number = '000'
  32. else:
  33.     mass_number =  mass_number_short
  34.  
  35. MT_number = search_result[4]
  36.  
  37. filename='data/'+particle+'/'+symbol+'/'+mass_number+'/'+librarylc+'/'+MT_number
  38.  
  39. if DEBUG:
  40.     print 'Debug: '+filename
  41.  
  42. particle_url = 'http://www.cross-section-plotter.com/'+filename
  43. particle_response = urllib.urlopen(particle_url)
  44. if DEBUG:
  45.     print '\n\n**** RESULT ***\n\n'
  46. print particle_response.read()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement