Commit 50596d3a authored by Carlo Ferrigno's avatar Carlo Ferrigno
Browse files

Introduced possibility of grouping by revolutions or groups of revolutions.

v 1.3.27
parent 2b81038e
......@@ -109,7 +109,7 @@ class FitMosaicSources(object):
self.residuals[~mask] = 0
ndof = r[mask].flatten().shape[0]
residual = (r[mask]**2).sum()/ndof
# print("------------->", x, local_model.sum(), residual, ndof, residual/ndof)
#print("------------->", x, local_model.sum(), residual, ndof, residual/ndof)
return residual
x0 = []
......
......@@ -66,36 +66,57 @@ class INTEGRALwrapper(object):
def long_scw_list_call(self, in_total_scw_list, s_max=50, wait=True, sleep_time=10,
compute_fluxes=False, save_partial_products=False,
**arguments):
"""
Wraps a long list call to oda_api and sums/stitches results
:param in_total_scw_list: a list of science windows to elaborate e.g. ['084600340010.001', '084600350010.001']
:param s_max: if >1 it defines the size of each single submissions to oda_api, if it is <0, it groups by number
of revolutions
:param wait: leave it true for expected behavior
:param sleep_time: sleeping between retries
:param compute_fluxes: if fluxes are computed for the catalog, beware, very slow for many sources !
:param save_partial_products: save products of single calls (just for images, for now)
:param arguments: the actual oda_api arguments
:return:
"""
import time
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)
scw_lists = [total_scw_list[i * s_max:(i + 1) * s_max] for i in range(ind_max)]
if ind_max * s_max < len(total_scw_list):
scw_lists.append(total_scw_list[ind_max * s_max:])
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]))))
self.product = arguments['product']
local_arguments = arguments.copy()
## 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)
if s_max > 1:
if len(total_scw_list) > s_max:
ind_max = int(len(total_scw_list) / s_max)
scw_lists = [total_scw_list[i * s_max:(i + 1) * s_max] for i in range(ind_max)]
if ind_max * s_max < len(total_scw_list):
scw_lists.append(total_scw_list[ind_max * s_max:])
else:
new_scw_lists.append(ss)
scw_lists = new_scw_lists
##
scw_lists = [total_scw_list]
else:
scw_lists = []
all_revs = get_revs(total_scw_list)
for rev in all_revs:
new_scwlist = [s for s in total_scw_list if s.startswith("%04d" % rev)]
self.__log.debug(new_scwlist)
scw_lists.append(new_scwlist)
# by group of revolutions
if s_max < -1:
i = 0
new_scw_lists = []
while (i < len(scw_lists) / np.abs(s_max)):
local_lists = [ll for ll in
scw_lists[i * np.abs(s_max):min(len(scw_lists), (i + 1) * np.abs(s_max))]]
local_element = []
for ss in local_lists:
for kk in ss:
local_element.append(kk)
new_scw_lists.append(local_element)
i += 1
scw_lists = new_scw_lists
self.__log.info("There will be %s jobs" % len(scw_lists))
for i, ss in enumerate(scw_lists):
self.__log.debug(i, ss[0])
self.all_data = []
tot_num = 0
......@@ -107,6 +128,7 @@ class INTEGRALwrapper(object):
for n_call, scw_list in enumerate(scw_lists):
if n_poll == 0:
self.__log.info("At call %d we elaborate %d scw" % (n_call, len(scw_list)))
self.__log.info("FRom %s to %s" % (scw_list[0], scw_list[-1]))
tot_num += len(scw_list)
ys = "%06d" % n_call
......@@ -121,13 +143,7 @@ class INTEGRALwrapper(object):
self.__log.debug(f'\n\n\nn_call {n_call}\nData {data}\nIs failed {_disp.is_failed}')
if data is None and not _disp.is_failed:
revs = get_revs(scw_list)
# Force 0SA10.2 for ISGRI before rev. 1626
self.__log.debug(f"min rev {revs.min()}")
# if revs.min() < 1626 and 'isgri' in arguments['product']:
# self.__log.debug("Forced OSA10.2 instead of OSA11")
# self.__log.info("Forced OSA10.2 instead of OSA11")
# local_arguments['osa_version'] = 'OSA10.2'
# else:
local_arguments['osa_version'] = arguments['osa_version']
# Add Token to arguments if not present
......
......@@ -15,7 +15,7 @@ include_package_data=True
scripts_list = glob.glob('./bin/*')
setup(name='oda_integral_wrapper',
version="1.3.26",
version="1.3.27",
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