ridge/scripts/03_grxe_galprof_plot.py
Roman Krivonos 5292290a35 IKI
2024-08-27 12:57:19 +03:00

85 lines
2.5 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
from ridge.utils import *
from ridge.config import *
scale = 100.0
fn="detcnts.E01.ALL.resid.galprof.fits"
dat = Table.read(profdir+fn, unit_parse_strict='silent')
df1 = dat.to_pandas().sort_values(by=['LON1'])
fn="detcnts.E14.ALL.resid.galprof.fits"
dat = Table.read(profdir+fn, unit_parse_strict='silent')
df2 = dat.to_pandas().sort_values(by=['LON1'])
fn="detcnts.E13.ALL.resid.galprof.fits"
dat = Table.read(profdir+fn, unit_parse_strict='silent')
df3 = dat.to_pandas().sort_values(by=['LON1'])
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.set_title("25-60 keV")
ax2.set_title("60-80 keV")
ax3.set_title("80-200 keV")
ax1.set_ylim(-0.3,1.8)
ax2.set_ylim(-0.3,1.8)
ax3.set_ylim(-0.3,1.8)
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))
lon=(df1['LON1']+df1['LON2'])/2
ax1.errorbar(lon, df1['GRXE_SIM_FLUX']/scale,
yerr=df1['GRXE_SIM_ERROR']/scale,
xerr=(df1['LON2']-df1['LON1'])/2,
fmt='o' )
ax1.grid(visible=True)
lon=(df2['LON1']+df2['LON2'])/2
ax2.errorbar(lon, df2['GRXE_SIM_FLUX']/scale,
yerr=df2['GRXE_SIM_ERROR']/scale,
xerr=(df2['LON2']-df2['LON1'])/2,fmt='o' )
ax2.grid(visible=True)
lon=(df3['LON1']+df3['LON2'])/2
ax3.errorbar(lon, df3['GRXE_SIM_FLUX']/scale,
yerr=df3['GRXE_SIM_ERROR']/scale,
xerr=(df3['LON2']-df3['LON1'])/2, fmt='o' )
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('Galactic Longitude',fontsize=14, fontweight='normal')
ax2.set_ylabel('GRXE flux, x100 mCrab',fontsize=14, fontweight='normal')
#plt.xscale('linear')
#plt.yscale('linear')
plt.savefig(profdir+'galprof.png', bbox_inches='tight')
plt.close(fig)