Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def organize_cooling_data(link):
- import urllib2
- res = {'temperature': [], 'cooling_function': []}
- data = urllib2.urlopen(link)
- for line in data:
- temp = line.rstrip().split(',')
- res['temperature'].append(float(temp[1]))
- res['cooling_function'].append(float(temp[0]))
- return res
- def main():
- import numpy
- import pylab
- import pickle
- data = {'dust':organize_cooling_data('http://pastebin.com/raw.php?i=H6euHHNE'),
- 'atomic':organize_cooling_data('http://pastebin.com/raw.php?i=TtX0H7X7')}
- denser_temperature = numpy.logspace(5,9,100)
- for itm in data:
- data[itm]['fit_params'] = numpy.polyfit(numpy.log(data[itm]['temperature']),
- numpy.log(data[itm]['cooling_function']),7)
- pylab.loglog(data[itm]['temperature'], data[itm]['cooling_function'],'o',
- label=itm,linewidth=3)
- pylab.loglog(denser_temperature,
- numpy.exp(numpy.polyval(data[itm]['fit_params'],
- numpy.log(denser_temperature))),
- label=itm,linewidth=3)
- pylab.legend(loc='best')
- pylab.xlabel('Temperature [K]')
- pylab.ylabel('Cooling function [erg*cc/s]')
- pylab.ylim((1e-23,1e-20))
- pylab.tick_params(axis='both', which='major', labelsize=12)
- pickle.dump(data,open('cooling_function.pkl','wb'))
- pylab.show()
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement