Commit 6b7eb5f6 authored by Carlo Ferrigno's avatar Carlo Ferrigno
Browse files

Introduce optimal_grouping as module.

(left direct command commented in scripts)
Removed commented section.
parent 65dc773c
......@@ -21,6 +21,7 @@ import xspec
from IPython.display import Image
from IPython.display import display
import shutil
from optimalgrouping.optimalgrouping import execute_binning
from glob import glob
......@@ -1890,7 +1891,7 @@ rmfgen spectrumset=PNsource_spectrum.fits rmfset=PN.rmf
arfgen spectrumset=PNsource_spectrum.fits arfset=PN.arf withrmfset=yes rmfset=PN.rmf \
badpixlocation=PNbary_clean.fits detmaptype=psf
$HOME/Soft/optimal-binning/optimal_binning.py PNsource_spectrum.fits -b PNbackground_spectrum.fits -r PN.rmf -a PN.arf -e 0.5 -E 10.5
optimal_binning.py PNsource_spectrum.fits -b PNbackground_spectrum.fits -r PN.rmf -a PN.arf -e 0.5 -E 10.5
'''
......@@ -2159,7 +2160,7 @@ class epicmos(xmmanalysis):
badpixlocation=MOS%dbary_clean.fits detmaptype=psf
$HOME/Soft/optimal-binning/optimal_binning.py MOS%dsource_%s.fits -b MOS%dbackground_%s.fits -r MOS%d_%s.rmf -a MOS%d_%s.arf -e 0.5 -E 10.0
#optimal_binning.py MOS%dsource_%s.fits -b MOS%dbackground_%s.fits -r MOS%d_%s.rmf -a MOS%d_%s.arf -e 0.5 -E 10.0
'''
......@@ -2205,6 +2206,8 @@ class epicmos(xmmanalysis):
print("extract response finished with status %d" % status)
raise RuntimeError
execute_binning('MOS%dsource_%s.fits'%(m,base_name), 'MOS%dbackground_%s.fits'%(m,base_name),
'MOS%d_%s.rmf'%(m,base_name) , 'MOS%d_%s.arf'%(m,base_name) , 0.5, 10.0)
ev_filter_expression_base = '#XMMEA_EM && (PI IN (500:12000)) && (PATTERN<=12 ) ' + \
'&& (TIME IN (%.2f:%.2f))'
......@@ -2477,7 +2480,7 @@ arfgen spectrumset=MOS%dsource_%s.fits arfset=MOS%d_%s.arf withrmfset=yes rmfset
badpixlocation=MOS%d_Timing_bary_clean.fits detmaptype=psf
$HOME/Soft/optimal-binning/optimal_binning.py MOS%dsource_%s.fits -b MOS%dbackground_%s.fits -r MOS%d_%s.rmf -a MOS%d_%s.arf -e 0.5 -E 10.0
#optimal_binning.py MOS%dsource_%s.fits -b MOS%dbackground_%s.fits -r MOS%d_%s.rmf -a MOS%d_%s.arf -e 0.5 -E 10.0
'''
sas_commands_lc_src = '''
......@@ -2503,33 +2506,6 @@ expression="#XMMEA_EM && (FLAG==0) && (PATTERN<=0) && (RAWX>=$rawx_min) && (RAWX
updateexposure=yes filterexposure=yes
'''
# def sas_extract_spectrum(self, sas_source_coord, sas_back_coord, base_name='spectrum', tmin=0, tmax=1e12,
# run_rmf=True):
#
# self.print_infos()
#
# m=self.mosunit
#
# cmd_str = sas_init + sas_source_coord + sas_back_coord \
# + self.sas_commands_spec_src_mos_timing % (m,m,base_name, tmin, tmax, m, base_name,m) \
# + self.sas_commands_spec_back_mos_timing % (m,m,base_name, tmin, tmax, m, base_name,m)
#
# if run_rmf:
# cmd_str += self.sas_commands_rsp_mos_timing % (m,base_name, m, base_name,
# m, base_name, m, base_name, m, base_name,
# m,
# m, base_name, m, base_name, m, base_name, m, base_name)
#
# status = wrap_run(self.workdir, 'mos_timing_%s' % base_name, cmd_str)
#
# if status != 0:
# print("extract spectrum finished with status %d" % status)
# raise RuntimeError
#######################################################################
class epicpn(xmmanalysis):
def __init__(self, workdir='.'):
......@@ -2614,7 +2590,7 @@ rmfgen spectrumset=PNsource_%s.fits rmfset=PN_%s.rmf
arfgen spectrumset=PNsource_%s.fits arfset=PN_%s.arf withrmfset=yes rmfset=PN_%s.rmf \
badpixlocation=PNbary_clean.fits detmaptype=psf
$HOME/Soft/optimal-binning/optimal_binning.py PNsource_%s.fits -b PNbackground_%s.fits -r PN_%s.rmf -a PN_%s.arf -e 0.5 -E 10.5
#optimal_binning.py PNsource_%s.fits -b PNbackground_%s.fits -r PN_%s.rmf -a PN_%s.arf -e 0.5 -E 10.5
'''
......@@ -2658,8 +2634,15 @@ outset=%ssrc_%s.fits bkgtslist=%sback_%s.fits withbkgset=yes applyabsolutecorrec
cmd_str+=self.sas_commands_rsp%(base_name,base_name,base_name,base_name,base_name,
base_name,base_name,base_name,base_name)
status=wrap_run(self.workdir, 'PN_%s'%base_name,cmd_str)
if run_rmf:
execute_binning('PNsource_%s.fits' % base_name, 'PNbackground_%s.fits' % base_name, 'PN_%s.rmf' % base_name,
'PN_%s.arf' % base_name, 0.5, 10.5)
if status!=0:
print("PN extract spectrum finished with status %d"%status)
raise RuntimeError
......@@ -2679,7 +2662,7 @@ outset=%ssrc_%s.fits bkgtslist=%sback_%s.fits withbkgset=yes applyabsolutecorrec
sas_command = self.sas_init + sas_source_coord
sas_command += '\nrmfgen spectrumset=PNsource_%s.fits rmfset=PN_pileup_%s.rmf correctforpileup=yes raweventfile=%s\n'%(base_name,base_name,ccd_evt_file)
sas_command += '\n$HOME/Soft/optimal-binning/optimal_binning.py PNsource_%s.fits -b PNbackground_%s.fits -r PN_pileup_%s.rmf -a PN_%s.arf -e 0.5 -E 10.5\n'%(base_name,base_name,base_name,base_name)
#sas_command += '\noptimal_binning.py PNsource_%s.fits -b PNbackground_%s.fits -r PN_pileup_%s.rmf -a PN_%s.arf -e 0.5 -E 10.5\n'%(base_name,base_name,base_name,base_name)
status = wrap_run(self.workdir, 'PN_pileup_%s' % base_name, sas_command)
......@@ -2687,7 +2670,8 @@ outset=%ssrc_%s.fits bkgtslist=%sback_%s.fits withbkgset=yes applyabsolutecorrec
print("PN extract rm for pileup finished with status %d" % status)
raise RuntimeError
execute_binning('PNsource_%s.fits' % base_name, 'PNbackground_%s.fits' % base_name, 'PN_pileup_%s.rmf' % base_name,
'PN_%s.arf' % base_name, 0.5, 10.5)
def sas_average_products(self, run_sas=False, min_psf=3, max_psf=30, default_psf=1.0,
relative_x_offset=-2, relative_y_offset=+2,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment