def tecdPerLOS(stec, intervals, mask=None, eps=1, tsps=30, polynom_list=None, zero_mean=False): tecd = np.nan * np.ones(stec.size) if mask is None: mask = np.zeros(stec.size, dtype=bool) for ir, r in enumerate(intervals): chunk = stec[r[0]+1 : r[1]-1] idf = np.isfinite(chunk) if np.sum(np.isfinite(chunk)) < (15 * (60/tsps)): err_list = np.array([]) continue if np.sum(np.isnan(chunk)) > 0: chunk = uf.cubicSplineFit(chunk, idf) res, err_list0, po = uf.detrend(chunk, polynom_list=polynom_list, eps=eps, mask=mask[r[0]+1 : r[1]-1], polynomial_order=True) if ir == 0 or len(err_list) == 0: err_list = err_list0 else: err_list = np.vstack((err_list, err_list0)) res[~idf] = np.nan if zero_mean: if abs(np.nansum(res)) < 5: tecd[r[0]+1 : r[1]-1] = res else: tecd[r[0]+1 : r[1]-1] = res return tecd
def tecdPerLOS(stec, intervals, mask, eps=1, polynom_list=None, zero_mean=False, filter='polynomial'): tecd = np.nan * np.ones(stec.size) for ir, r in enumerate(intervals): chunk = stec[r[0] + 1:r[1] - 1] idf = np.isfinite(chunk) if np.sum(np.isfinite(chunk)) < (15 * (60 / tsps)): continue if np.sum(np.isnan(chunk)) > 0: chunk = gu.cubicSplineFit(chunk, idf) if filter == 'polynomial': res, err_list0, po = gu.detrend(chunk, polynom_list=polynom_list, eps=eps, mask=mask[r[0] + 1:r[1] - 1], polynomial_order=True) polynom_orders.append([np.squeeze(np.diff(r)) / (60 / tsps), po]) delta_eps.append(abs(np.diff(err_list0)[-1])) if ir == 0 or 'err_list' not in locals(): err_list = err_list0 else: err_list = np.vstack((err_list, err_list0)) res[~idf] = np.nan if zero_mean: if abs(np.nansum(res)) < 5: tecd[r[0] + 1:r[1] - 1] = res else: tecd[r[0] + 1:r[1] - 1] = res return tecd, err_list