generated from erosita/uds
July
This commit is contained in:
99
scripts/01_crabmodel_plot_sys.py
Executable file
99
scripts/01_crabmodel_plot_sys.py
Executable file
@@ -0,0 +1,99 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
__author__ = "Roman Krivonos"
|
||||
__copyright__ = "Space Research Institute (IKI)"
|
||||
|
||||
from astropy.table import Table, Column
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
import sys
|
||||
from scipy.stats import norm
|
||||
|
||||
from ridge.utils import *
|
||||
from ridge.config import *
|
||||
|
||||
|
||||
scale = 1e-3
|
||||
nbins=30
|
||||
|
||||
fn="detcnts.E01.crabmodel.fits"
|
||||
dat = Table.read(proddir+fn, unit_parse_strict='silent')
|
||||
df1 = dat.to_pandas().sort_values(by=['REV'])
|
||||
|
||||
fn="detcnts.E14.crabmodel.fits"
|
||||
dat = Table.read(proddir+fn, unit_parse_strict='silent')
|
||||
df2 = dat.to_pandas().sort_values(by=['REV'])
|
||||
|
||||
fn="detcnts.E13.crabmodel.fits"
|
||||
dat = Table.read(proddir+fn, unit_parse_strict='silent')
|
||||
df3 = dat.to_pandas().sort_values(by=['REV'])
|
||||
|
||||
|
||||
fig, (ax1, ax2, ax3) = plt.subplots(3, sharex=True, figsize=(9, 7), dpi=100)
|
||||
#fig.suptitle('Vertically stacked subplots')
|
||||
#plt.figure(figsize=(8, 6), dpi=80)
|
||||
|
||||
for axis in ['top','bottom','left','right']:
|
||||
ax1.spines[axis].set_linewidth(1)
|
||||
ax2.spines[axis].set_linewidth(1)
|
||||
ax3.spines[axis].set_linewidth(1)
|
||||
ax1.tick_params(axis="both", width=1, labelsize=14)
|
||||
ax2.tick_params(axis="both", width=1, labelsize=14)
|
||||
ax3.tick_params(axis="both", width=1, labelsize=14)
|
||||
|
||||
ax1.ticklabel_format(style='sci', axis='y', scilimits=(0,0))
|
||||
ax2.ticklabel_format(style='sci', axis='y', scilimits=(0,0))
|
||||
ax3.ticklabel_format(style='sci', axis='y', scilimits=(0,0))
|
||||
|
||||
data=(df1['B_EST']-df1['B_POLY'])/df1['B_POLY']*1000
|
||||
(mu, sg) = norm.fit(data)
|
||||
print(mu, sg)
|
||||
ax1.set_title("25-60 keV, $\\sigma=${:.0f} mCrab".format(sg))
|
||||
n, bins, patches = ax1.hist(data, nbins, density=True, facecolor='green', alpha=0.75)
|
||||
y = norm.pdf(bins, mu, sg)
|
||||
l = ax1.plot(bins, y, 'r--', linewidth=2)
|
||||
#plot
|
||||
ax1.axvline(mu, color="black", linewidth=2)
|
||||
ax1.axvline(mu+sg, color="blue", linestyle="dashed", linewidth=2)
|
||||
ax1.axvline(mu-sg, color="blue", linestyle="dashed", linewidth=2)
|
||||
ax1.grid(visible=True)
|
||||
|
||||
data=(df2['B_EST']-df2['B_POLY'])/df2['B_POLY']*1000
|
||||
(mu, sg) = norm.fit(data)
|
||||
print(mu, sg)
|
||||
ax2.set_title("60-80 keV, $\\sigma=${:.0f} mCrab".format(sg))
|
||||
n, bins, patches = ax2.hist(data, nbins, density=True, facecolor='green', alpha=0.75)
|
||||
y = norm.pdf(bins, mu, sg)
|
||||
l = ax2.plot(bins, y, 'r--', linewidth=2)
|
||||
#plot
|
||||
ax2.axvline(mu, color="black", linewidth=2)
|
||||
ax2.axvline(mu+sg, color="blue", linestyle="dashed", linewidth=2)
|
||||
ax2.axvline(mu-sg, color="blue", linestyle="dashed", linewidth=2)
|
||||
ax2.grid(visible=True)
|
||||
|
||||
data=(df3['B_EST']-df3['B_POLY'])/df3['B_POLY']*1000
|
||||
(mu, sg) = norm.fit(data)
|
||||
print(mu, sg)
|
||||
ax3.set_title("80-200 keV, $\\sigma=${:.0f} mCrab".format(sg))
|
||||
n, bins, patches = ax3.hist(data, nbins, density=True, facecolor='green', alpha=0.75)
|
||||
# add a 'best fit' line
|
||||
y = norm.pdf(bins, mu, sg)
|
||||
l = ax3.plot(bins, y, 'r--', linewidth=2)
|
||||
#plot
|
||||
ax3.axvline(mu, color="black", linewidth=2)
|
||||
ax3.axvline(mu+sg, color="blue", linestyle="dashed", linewidth=2)
|
||||
ax3.axvline(mu-sg, color="blue", linestyle="dashed", linewidth=2)
|
||||
ax3.grid(visible=True)
|
||||
|
||||
#x = np.arange(-10, 10, 0.001)
|
||||
#plot normal distribution with mean 0 and standard deviation 1
|
||||
#plt.plot(x, norm.pdf(x, 0, 1), color='red', linewidth=2)
|
||||
|
||||
plt.xlabel('Flux, mCrab',fontsize=14, fontweight='normal')
|
||||
#ax2.set_ylabel('No, x10$^{-3}$ cts s$^{-1}$ pix$^{-1}$',fontsize=14, fontweight='normal')
|
||||
|
||||
#plt.xscale('linear')
|
||||
#plt.yscale('linear')
|
||||
|
||||
plt.savefig(proddir+'crabmodel_sys.png', bbox_inches='tight')
|
||||
plt.close(fig)
|
Reference in New Issue
Block a user