generated from erosita/uds
104 lines
3.3 KiB
Python
Executable File
104 lines
3.3 KiB
Python
Executable File
#!/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, os
|
|
from scipy.stats import norm
|
|
|
|
from ridge.utils import *
|
|
from ridge.config import *
|
|
|
|
|
|
scale = 1e-3
|
|
nbins=30
|
|
|
|
fn="detcnts.A01.crabmodel.fits"
|
|
dat = Table.read(proddir+fn)
|
|
df1 = dat.to_pandas().sort_values(by=['REV'])
|
|
|
|
fn="detcnts.A02.crabmodel.fits"
|
|
dat = Table.read(proddir+fn)
|
|
df2 = dat.to_pandas().sort_values(by=['REV'])
|
|
|
|
fn="detcnts.A03.crabmodel.fits"
|
|
dat = Table.read(proddir+fn)
|
|
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')
|
|
|
|
if not os.path.exists(figdir):
|
|
os.makedirs(figdir)
|
|
filename=figdir+'crabmodel_sys.png'
|
|
plt.savefig(filename, bbox_inches='tight')
|
|
plt.close(fig)
|
|
print("Result is saved as {}".format(filename))
|