From 8f9bce97cf5de816585fad6913dd98d4d7488844 Mon Sep 17 00:00:00 2001 From: Sergio Pascual Date: Fri, 17 Nov 2017 18:29:08 +0100 Subject: [PATCH] Implement global_offset for ModelMap (fixes #145) --- megaradrp/products/modelmap.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/megaradrp/products/modelmap.py b/megaradrp/products/modelmap.py index c85567af..18530dec 100644 --- a/megaradrp/products/modelmap.py +++ b/megaradrp/products/modelmap.py @@ -161,6 +161,15 @@ def calc_matrix_cols(model_map, datashape, processes=0): array_mean[row] = params['mean'](xcol) array_std[row] = params['stddev'](xcol) + # shift array_mean according to global_offset + mask = numpy.zeros((model_map.total_fibers,), dtype='bool') + valid_r = [(f.fibid - 1) for f in model_map.contents if f.valid] + mask[valid_r] = True + + mean_at_ref = array_mean[mask, model_map.ref_column] + offset = model_map.global_offset(mean_at_ref) + array_mean[mask, :] = array_mean[mask, :] + offset[:, numpy.newaxis] + wcols = {} valid = [f.fibid for f in model_map.contents if f.valid] if processes < 2: