Skip to content

Instantly share code, notes, and snippets.

@saethlin
Last active January 17, 2018 07:29
Show Gist options
  • Save saethlin/392417c26a44ae5a939799e127b42fbb to your computer and use it in GitHub Desktop.
Save saethlin/392417c26a44ae5a939799e127b42fbb to your computer and use it in GitHub Desktop.
Total time: 16.4064 s
File: neufeld_plots.py
Function: main at line 1
Line # Hits Time Per Hit % Time Line Contents
==============================================================
1 @profile
2 def main():
3 1 168872.0 168872.0 1.0 import numpy as np
4 1 108349.0 108349.0 0.7 import matplotlib
5 1 16.0 16.0 0.0 matplotlib.use('Agg')
6 1 529759.0 529759.0 3.2 import matplotlib.pyplot as plt
7 1 10088.0 10088.0 0.1 from matplotlib.backends.backend_pdf import PdfPages
8
9 1 2.0 2.0 0.0 average_scatterings = []
10 1 1.0 1.0 0.0 optical_depths = []
11 1 1256.0 1256.0 0.0 with PdfPages('neufeld_plots.pdf') as pdf:
12 5 20378.0 4075.6 0.1 for filename in ['neufeld_1e5.txt', 'neufeld_1e6.txt', 'neufeld_1e7.txt', 'neufeld_1e8.txt']:
13 4 12682443.0 3170610.8 77.3 data = np.genfromtxt(filename)
14 4 259.0 64.8 0.0 freq = data[:, 0]
15 4 4927.0 1231.8 0.0 average_scatterings.append(np.median(data[:, 1]))
16 4 29.0 7.2 0.0 optical_depths.append(float(filename.split('.')[0].split('_')[1]))
17
18 4 338732.0 84683.0 2.1 plt.title(r"$\tau$ = {:.0e}".format(optical_depths[-1]))
19 4 19495.0 4873.8 0.1 plt.hist(freq, bins=100, range=(-1e3, 1e3), histtype='step')
20 4 1130407.0 282601.8 6.9 pdf.savefig()
21 4 2081.0 520.2 0.0 plt.close()
22
23
24 1 88322.0 88322.0 0.5 plt.loglog(optical_depths, average_scatterings, 'ko')
25 1 126.0 126.0 0.0 plt.xlim(1e2, 1e8)
26 1 92.0 92.0 0.0 plt.ylim(1e2, 1e8)
27 1 1321.0 1321.0 0.0 plt.plot([1e3, 1e8], [1e3, 1e8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment