Commit 2cbcfe86 authored by Carlo Ferrigno's avatar Carlo Ferrigno
Browse files

v 1.3.9

Internally switch to OSA10.2 for rev < 1626 for ISGRI
Compute the delta time from a light curve
Plot also delta time in light curve.
parent fda877cd
......@@ -60,6 +60,7 @@ class INTEGRALwrapper(object):
total_scw_list = sorted(in_total_scw_list)
self.product = arguments['product']
local_arguments = arguments.copy()
if len(total_scw_list) > s_max:
ind_max = int(len(total_scw_list) / s_max)
......@@ -69,6 +70,23 @@ class INTEGRALwrapper(object):
else:
scw_lists = [total_scw_list]
def get_revs(loc_scw_list):
return np.array(sorted(list(set([int(a[0:4]) for a in loc_scw_list]))))
## I split a list that contains revolutions before and after 1626 (start of validity of OSA11.X
new_scw_lists = []
for ss in scw_lists:
revs = get_revs(ss)
if revs.min() < 1626 and revs.max() >= 1626:
s1 = [s for s in ss if int(s[0:4]) < 1626]
s2 = [s for s in ss if int(s[0:4]) >= 1626]
new_scw_lists.append(s1)
new_scw_lists.append(s2)
else:
new_scw_lists.append(ss)
scw_lists = new_scw_lists
##
self.all_data = []
tot_num = 0
......@@ -98,8 +116,14 @@ class INTEGRALwrapper(object):
if data is None or not _disp.is_failed():
if not _disp.is_submitted:
revs = get_revs(scw_list)
# Force 0SA10.2 for ISGRI before rev. 1626
if revs.min() < 1626 and 'isgri' in arguments['product']:
local_arguments['osa_version'] = 'OSA10.2'
else:
local_arguments['osa_version'] = arguments['osa_version']
scw_list_str = ",".join([s for s in sorted(set(scw_list))])
data = _disp.get_product(scw_list=scw_list_str, **arguments)
data = _disp.get_product(scw_list=scw_list_str, **local_arguments)
else:
_disp.poll()
......@@ -380,13 +404,27 @@ class INTEGRALwrapper(object):
dy = np.sqrt(dy ** 2 + (y * systematic_fraction) ** 2)
ind = np.logical_and(np.isfinite(y), np.isfinite(dy))
ind = np.logical_and(ind, dy > 0)
return x[ind], y[ind], dy[ind]
#This could only be valid for ISGRI
try:
dt_lc = hdu.data['XAX_E']
INTEGRALwrapper.__log.debug('Get time bin directly from light curve')
except:
timedel = hdu.header['TIMEDEL']
timepix = hdu.header['TIMEPIXR']
t_lc = hdu.data['TIME'] + (0.5 - timepix) * timedel
dt_lc = t_lc.copy() * 0.0 + timedel / 2
for i in range(len(t_lc) - 1):
dt_lc[i + 1] = min(timedel / 2, t_lc[i + 1] - t_lc[i] - dt_lc[i])
INTEGRALwrapper.__log.debug('Computed time bin from TIMEDEL')
return x[ind], dt_lc[ind], y[ind], dy[ind]
@staticmethod
def plot_lc(combined_lc, source_name, systematic_fraction=0, ng_sig_limit=3, find_excesses=False):
from scipy import stats
x,y,dy = INTEGRALwrapper.get_lc(combined_lc, source_name, systematic_fraction)
x,dx,y,dy = INTEGRALwrapper.get_lc(combined_lc, source_name, systematic_fraction)
meany = np.sum(y / dy ** 2) / np.sum(1. / dy ** 2)
err_mean = np.sum(1 / dy ** 2)
......@@ -394,7 +432,7 @@ class INTEGRALwrapper(object):
std_dev = np.std(y)
fig = plt.figure()
_ = plt.errorbar(x, y, yerr=dy, marker='o', capsize=0, linestyle='', label='Lightcurve')
_ = plt.errorbar(x, y, xerr=dx, yerr=dy, marker='o', capsize=0, linestyle='', label='Lightcurve')
_ = plt.axhline(meany, color='green', linewidth=3)
_ = plt.xlabel('Time [IJD]')
_ = plt.ylabel('Rate')
......
......@@ -19,7 +19,7 @@ include_package_data=True
scripts_list = glob.glob('./bin/*')
setup(name='oda_integral_wrapper',
version="1.3.8",
version="1.3.9",
description='wrapper for INTEGRAL analysis using the API plugin for CDCI online data analysis',
author='Carlo Ferrigno',
author_email='carlo.ferrigno@unige.ch',
......
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