MUSE Pipeline Reference Manual  2.5.2
recipes/muse_lsf.c
1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set sw=2 sts=2 et cin: */
3 /*
4  * This file is part of the MUSE Instrument Pipeline
5  * Copyright (C) 2014-2018 European Southern Observatory
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20  * 02110-1301, USA.
21  */
22 
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26 
27 /*---------------------------------------------------------------------------*
28  * Includes *
29  *---------------------------------------------------------------------------*/
30 #include <string.h>
31 #include <math.h>
32 
33 #include <muse.h>
34 #include <muse_data_format_z.h>
35 #include <muse_instrument.h>
36 #include <muse_lsf.h>
37 #include "muse_lsf_z.h"
38 
39 #ifndef USE_LSF_PARAMS
40 #ifdef MUSE_LSF_PARAM_METHOD_HERMIT
41 #error Please remove the "method" parameter from muse_lsf_params.xml
42 #endif
43 #endif
44 
45 /*---------------------------------------------------------------------------*
46  * Functions code *
47  *---------------------------------------------------------------------------*/
48 
49 /*----------------------------------------------------------------------------*/
58 /*----------------------------------------------------------------------------*/
59 static muse_lsf_cube *
60 muse_lsf_compute_slices(muse_pixtable *aPixtable, muse_lsf_params_t *aParams)
61 {
62  cpl_ensure(aPixtable, CPL_ERROR_NULL_INPUT, NULL);
63  muse_lsf_cube *lsfCube = muse_lsf_cube_new(aParams->lsf_range,
64  aParams->lsf_size,
65  aParams->lambda_size,
66  aPixtable->header);
67  muse_pixtable **slice_pixtable = muse_pixtable_extracted_get_slices(aPixtable);
68 
69  int i_slice, n_slices = muse_pixtable_extracted_get_size(slice_pixtable);
70  #pragma omp parallel for default(none) /* as req. by Ralf */ \
71  shared(lsfCube, n_slices, slice_pixtable, aParams)
72  for (i_slice = 0; i_slice < n_slices; i_slice++) {
73  cpl_image *img = cpl_imagelist_get(lsfCube->img, i_slice);
74  muse_lsf_fit_slice(slice_pixtable[i_slice], img,
75  lsfCube->wcs, aParams->lsf_regression_window);
76  }
77  muse_pixtable_extracted_delete(slice_pixtable);
78  return lsfCube;
79 } /* muse_lsf_compute_slices() */
80 
81 /*----------------------------------------------------------------------------*/
91 /*----------------------------------------------------------------------------*/
92 static cpl_error_code
93 muse_lsf_subtract_arcs(muse_lsf_cube *aLsfCube, cpl_table *aPixtable)
94 {
95  cpl_size n_rows = cpl_table_get_nrow(aPixtable);
96  cpl_size i_row;
97  for (i_row = 0; i_row < n_rows; i_row++) {
98  uint32_t origin = cpl_table_get_int(aPixtable, MUSE_PIXTABLE_ORIGIN, i_row,
99  NULL);
100  int i_slice = muse_pixtable_origin_get_slice(origin);
101  double lambda = cpl_table_get(aPixtable, "line_lambda", i_row, NULL);
102  double flux = cpl_table_get(aPixtable, "line_flux", i_row, NULL);
103  double v = cpl_table_get(aPixtable, MUSE_PIXTABLE_LAMBDA, i_row, NULL)
104  - lambda;
105  cpl_array *val = cpl_array_wrap_double(&v, 1);
106  muse_lsf_apply(cpl_imagelist_get(aLsfCube->img, i_slice - 1),
107  aLsfCube->wcs, val, lambda);
108  cpl_array_unwrap(val);
109  cpl_table_set(aPixtable, MUSE_PIXTABLE_DATA, i_row,
110  cpl_table_get(aPixtable, MUSE_PIXTABLE_DATA, i_row, NULL)
111  - v * flux);
112  }
113  return CPL_ERROR_NONE;
114 } /* muse_lsf_subtract_arcs() */
115 
116 /*----------------------------------------------------------------------------*/
132 /*----------------------------------------------------------------------------*/
133 static cpl_error_code
134 muse_lsf_qc(muse_lsf_cube *aLsfCube)
135 {
136  cpl_ensure_code(aLsfCube, CPL_ERROR_NULL_INPUT);
137 
138  cpl_size i_slice, n_slices = cpl_imagelist_get_size(aLsfCube->img);
139  for (i_slice = 0; i_slice < n_slices; i_slice++) {
140  cpl_image *img = cpl_imagelist_get(aLsfCube->img, i_slice);
141  cpl_size n_lsf = cpl_image_get_size_x(img);
142  cpl_size n_lambda = cpl_image_get_size_y(img);
143  cpl_array *fwhm = cpl_array_new(n_lambda, CPL_TYPE_DOUBLE);
144  cpl_size i_lambda;
145  for (i_lambda = 0; i_lambda < n_lambda; i_lambda++) {
146  int res;
147  double ref = cpl_image_get(img, n_lsf/2, i_lambda+1, &res);
148  cpl_size i_min;
149  for (i_min = n_lsf/2; i_min > 0; i_min--) {
150  if (cpl_image_get(img, i_min, i_lambda+1, &res) < ref/2) {
151  break;
152  }
153  }
154  double f_min = (ref/2 - cpl_image_get(img, i_min, i_lambda+1, &res))
155  / (cpl_image_get(img, i_min+1, i_lambda+1, &res)
156  - cpl_image_get(img, i_min, i_lambda+1, &res));
157 
158  cpl_size i_max;
159  for (i_max = n_lsf/2; i_max <= n_lsf; i_max++) {
160  if (cpl_image_get(img, i_max, i_lambda+1, &res) < ref/2) {
161  break;
162  }
163  }
164  double f_max = (ref/2 - cpl_image_get(img, i_max, i_lambda+1, &res))
165  / (cpl_image_get(img, i_max-1, i_lambda+1, &res)
166  - cpl_image_get(img, i_max, i_lambda+1, &res));
167 
168  double f = (i_max - f_max - i_min - f_min) * aLsfCube->wcs->cd11;
169  cpl_array_set(fwhm, i_lambda, f);
170  }
171  char keyword[KEYWORD_LENGTH];
172  snprintf(keyword, KEYWORD_LENGTH, "ESO QC LSF SLICE%i FWHM MEAN",
173  (int)i_slice+1);
174  cpl_propertylist_append_float(aLsfCube->header, keyword, cpl_array_get_mean(fwhm));
175  snprintf(keyword, KEYWORD_LENGTH, "ESO QC LSF SLICE%i FWHM STDEV",
176  (int)i_slice+1);
177  cpl_propertylist_append_float(aLsfCube->header, keyword, cpl_array_get_stdev(fwhm));
178  snprintf(keyword, KEYWORD_LENGTH, "ESO QC LSF SLICE%i FWHM MIN",
179  (int)i_slice+1);
180  cpl_propertylist_append_float(aLsfCube->header, keyword, cpl_array_get_min(fwhm));
181  snprintf(keyword, KEYWORD_LENGTH, "ESO QC LSF SLICE%i FWHM MAX",
182  (int)i_slice+1);
183  cpl_propertylist_append_float(aLsfCube->header, keyword, cpl_array_get_max(fwhm));
184  cpl_array_delete(fwhm);
185  }
186 
187  return CPL_ERROR_NONE;
188 } /* muse_lsf_qc() */
189 
190 #ifdef USE_LSF_PARAMS
191 /*----------------------------------------------------------------------------*/
199 /*----------------------------------------------------------------------------*/
201 muse_lsf_params_compute(cpl_table *aLines, muse_pixtable *aPixtable,
202  int aMaxIter)
203 {
204  muse_pixtable **slice_pixtable = muse_pixtable_extracted_get_slices(aPixtable);
205  int n_slices = muse_pixtable_extracted_get_size(slice_pixtable);
206  int i_slice;
207 
208  muse_lsf_params **lsfParams = cpl_calloc(n_slices + 1,
209  sizeof(muse_lsf_params *));
210  #pragma omp parallel for default(none) num_threads(2) /* as req. by Ralf */ \
211  shared(aLines, aMaxIter, n_slices, i_slice, lsfParams, slice_pixtable)
212  for (i_slice = 0; i_slice < n_slices; i_slice++) {
213  cpl_errorstate es = cpl_errorstate_get();
214  uint32_t origin = cpl_table_get_int(slice_pixtable[i_slice]->table,
215  MUSE_PIXTABLE_ORIGIN, 0, NULL);
216  if (!cpl_errorstate_is_equal(es)) {
217  cpl_msg_error(__func__, "While processing slice/ifu index %d:", i_slice);
218  cpl_errorstate_dump(es, CPL_FALSE, NULL);
219  cpl_errorstate_set(es);
220  continue;
221  }
222  unsigned short ifu = muse_pixtable_origin_get_ifu(origin);
223  unsigned short slice = muse_pixtable_origin_get_slice(origin);
224 
225  cpl_errorstate prestate = cpl_errorstate_get();
226  lsfParams[i_slice] = muse_lsf_params_fit(slice_pixtable[i_slice], aLines,
227  aMaxIter);
228  if (!cpl_errorstate_is_equal(prestate)) {
229  cpl_msg_error(__func__, "While processing slice %hu.%hu:", ifu, slice);
230  cpl_errorstate_dump(prestate, CPL_FALSE, NULL);
231  cpl_errorstate_set(prestate);
232  }
233  }
234  muse_pixtable_extracted_delete(slice_pixtable);
235  return lsfParams;
236 } /* muse_lsf_params_compute() */
237 
238 /*----------------------------------------------------------------------------*/
245 /*----------------------------------------------------------------------------*/
246 static cpl_error_code
247 muse_lsf_params_qc(cpl_propertylist *aHeader, const muse_lsf_params **aSlicePars)
248 {
249  cpl_ensure_code(aHeader, CPL_ERROR_NULL_INPUT);
250  cpl_ensure_code(aSlicePars, CPL_ERROR_NULL_INPUT);
251 
252  const muse_lsf_params **det;
253  for (det = aSlicePars; *det; det++) {
254  cpl_size n_lambda = 30;
255  double lambda_step = (kMuseNominalLambdaMax - kMuseNominalLambdaMin)
256  / (n_lambda - 1);
257  cpl_array *fwhm = cpl_array_new(n_lambda, CPL_TYPE_DOUBLE);
258  cpl_size i_lambda;
259  for (i_lambda = 0; i_lambda < n_lambda; i_lambda++) {
260  double lambda = kMuseNominalLambdaMin + i_lambda * lambda_step;
261  double f = muse_lsf_fwhm_lambda(*det, lambda, 0.04, 150);
262  cpl_array_set(fwhm, i_lambda, f);
263  }
264  char keyword[KEYWORD_LENGTH];
265  snprintf(keyword, KEYWORD_LENGTH, "ESO QC LSF SLICE%i FWHM MEAN",
266  (int)(*det)->slice);
267  cpl_propertylist_append_float(aHeader, keyword, cpl_array_get_mean(fwhm));
268  snprintf(keyword, KEYWORD_LENGTH, "ESO QC LSF SLICE%i FWHM STDEV",
269  (int)(*det)->slice);
270  cpl_propertylist_append_float(aHeader, keyword, cpl_array_get_stdev(fwhm));
271  snprintf(keyword, KEYWORD_LENGTH, "ESO QC LSF SLICE%i FWHM MIN",
272  (int)(*det)->slice);
273  cpl_propertylist_append_float(aHeader, keyword, cpl_array_get_min(fwhm));
274  snprintf(keyword, KEYWORD_LENGTH, "ESO QC LSF SLICE%i FWHM MAX",
275  (int)(*det)->slice);
276  cpl_propertylist_append_float(aHeader, keyword, cpl_array_get_max(fwhm));
277  cpl_array_delete(fwhm);
278  }
279 
280  return CPL_ERROR_NONE;
281 } /* muse_lsf_params_qc() */
282 
283 /*----------------------------------------------------------------------------*/
292 /*----------------------------------------------------------------------------*/
293 static cpl_error_code
294 muse_lsf_params_save_table(cpl_propertylist *aHeader,
295  const muse_lsf_params **aSlicePars,
296  muse_processing *aProcessing, int aIFU)
297 {
298  cpl_error_code r = CPL_ERROR_NONE;
299  if (aSlicePars) {
300  cpl_frame *frame = muse_processing_new_frame(aProcessing, aIFU, aHeader,
301  "LSF_PROFILE",
302  CPL_FRAME_TYPE_TABLE);
303  if (frame) {
304  const char *filename = cpl_frame_get_filename(frame);
305  cpl_msg_info(__func__, "Saving LSF table as %s", filename);
306  char *channel = cpl_sprintf("CHAN%02d", aIFU);
307  cpl_propertylist_update_string(aHeader, "EXTNAME", channel);
308  cpl_free(channel);
309  r = cpl_propertylist_save(aHeader, filename, CPL_IO_CREATE);
310  r = muse_lsf_params_save(aSlicePars, filename);
311  if (r == CPL_ERROR_NONE) {
312  #pragma omp critical(muse_processing_output_frames)
313  cpl_frameset_insert(aProcessing->outframes, frame);
314  } else {
315  cpl_frame_delete(frame);
316  }
317  }
318  }
319  return r;
320 } /* muse_lsf_params_save_table() */
321 #endif /* defined(USE_LSF_PARAMS) */
322 
323 /*----------------------------------------------------------------------------*/
330 /*----------------------------------------------------------------------------*/
331 int
332 muse_lsf_compute(muse_processing *aProcessing, muse_lsf_params_t *aParams)
333 {
335  "muse.muse_lsf");
337  aParams->nifu,
338  bpars, NULL);
340  cpl_ensure(images, cpl_error_get_code(), -1);
341 
342  cpl_table *arclines = muse_processing_load_ctable(aProcessing, MUSE_TAG_LINE_CATALOG, 0);
343  cpl_table *tracetable = muse_processing_load_ctable(aProcessing, MUSE_TAG_TRACE_TABLE,
344  aParams->nifu);
345  cpl_table *wavecaltable = muse_processing_load_ctable(aProcessing, MUSE_TAG_WAVECAL_TABLE,
346  aParams->nifu);
347  if (!arclines || !tracetable || !wavecaltable) {
348  cpl_msg_error(__func__, "Calibration could not be loaded:%s%s%s",
349  !arclines ? " " : "",
350  !tracetable ? " "MUSE_TAG_TRACE_TABLE : "",
351  !wavecaltable ? " "MUSE_TAG_WAVECAL_TABLE : "");
352  muse_imagelist_delete(images);
353  cpl_table_delete(arclines);
354  cpl_table_delete(tracetable);
355  cpl_table_delete(wavecaltable);
356  return -1;
357  }
358 
359  /* keep the error state at this point, before doing the spectral processing */
360  cpl_errorstate prestate = cpl_errorstate_get();
361 
362  if (aParams->method == MUSE_LSF_PARAM_METHOD_INTERPOLATE) {
363 
365  images, tracetable, wavecaltable, arclines,
366  aParams->line_quality,
367  aParams->lsf_range + aParams->lsf_regression_window);
368 
369  cpl_table_delete(arclines);
370  cpl_table_delete(tracetable);
371  cpl_table_delete(wavecaltable);
372  muse_imagelist_delete(images);
373  if (arcpixtable == NULL) {
374  cpl_msg_error(__func__, "Could not create pixel table of arc lines for "
375  "IFU %d", aParams->nifu);
376  return -1;
377  }
378 
379  muse_lsf_cube *lsfcube = muse_lsf_compute_slices(arcpixtable, aParams);
380  if (lsfcube == NULL) {
381  cpl_msg_error(__func__, "Could not create LSF cube for IFU %d",
382  aParams->nifu);
383  if (aParams->save_subtracted) {
384  muse_processing_save_table(aProcessing, aParams->nifu, arcpixtable, NULL,
385  MUSE_TAG_PT_SUB, MUSE_TABLE_TYPE_PIXTABLE);
386  }
387  muse_pixtable_delete(arcpixtable);
388  return -1;
389  }
390 
391  /* add QC parameters to the primary header of the LSF cube and save it */
392  muse_lsf_qc(lsfcube);
393  muse_processing_save_cube(aProcessing, aParams->nifu, lsfcube,
394  MUSE_TAG_LSF_PROFILE, MUSE_CUBE_TYPE_LSF);
395  if (aParams->save_subtracted) {
396  cpl_table_duplicate_column(arcpixtable->table, "orig", arcpixtable->table,
398  muse_lsf_subtract_arcs(lsfcube, arcpixtable->table);
399  muse_processing_save_table(aProcessing, aParams->nifu, arcpixtable, NULL,
400  MUSE_TAG_PT_SUB, MUSE_TABLE_TYPE_PIXTABLE);
401  }
402  muse_pixtable_delete(arcpixtable);
403  muse_lsf_cube_delete(lsfcube);
404 
405  }
406 #ifdef USE_LSF_PARAMS
407  else if (aParams->method == MUSE_LSF_PARAM_METHOD_HERMIT) {
408  muse_combinepar *cpars = muse_combinepar_new(aProcessing->parameters,
409  "muse.muse_lsf");
410  muse_image *masterimage = muse_combine_images(cpars, images);
411  muse_combinepar_delete(cpars);
412  muse_imagelist_delete(images);
413 
414  muse_pixtable *arcpixtable = muse_pixtable_create(masterimage, tracetable,
415  wavecaltable, NULL);
416  cpl_table_delete(tracetable);
417  cpl_table_delete(wavecaltable);
418  if (!arcpixtable) {
419  cpl_msg_error(__func__, "ARC pixel table creation failed");
420  cpl_table_delete(arclines);
421  muse_image_delete(masterimage);
422  return -1;
423  }
424 
425  /* erase unused (flux == 0.) and non-isolated (quality < 3) lines */
426  cpl_table_unselect_all(arclines);
427  cpl_table_or_selected_int(arclines, MUSE_LINE_CATALOG_QUALITY,
428  CPL_LESS_THAN, aParams->line_quality);
429  cpl_table_or_selected_float(arclines, "flux", CPL_NOT_GREATER_THAN, 0.);
430  cpl_table_erase_selected(arclines);
431  /* sort list by decreasing flux and cut it to the 40 brightest lines */
432  cpl_propertylist *flux_sort = cpl_propertylist_new();
433  cpl_propertylist_append_bool(flux_sort, "flux", CPL_TRUE);
434  cpl_table_sort(arclines, flux_sort);
435  cpl_propertylist_delete(flux_sort);
436  cpl_size nrows = 40;
437  if (nrows < cpl_table_get_nrow(arclines)) {
438  cpl_table_erase_window(arclines, nrows, cpl_table_get_nrow(arclines));
439  }
440 
441  if (aParams->save_subtracted) {
442  cpl_table_duplicate_column(arcpixtable->table, "orig", arcpixtable->table,
444  }
445  muse_lsf_params **lsf = muse_lsf_params_compute(arclines, arcpixtable, 40);
446 
447  cpl_propertylist *qc_header = cpl_propertylist_new();
448  muse_lsf_params_qc(qc_header, (const muse_lsf_params **)lsf);
449  muse_lsf_params_save_table(qc_header, (const muse_lsf_params **)lsf,
450  aProcessing, aParams->nifu);
452  cpl_propertylist_delete(qc_header);
453 
454  if (aParams->save_subtracted) {
455  muse_processing_save_table(aProcessing, aParams->nifu, arcpixtable, NULL,
456  MUSE_TAG_PT_SUB, MUSE_TABLE_TYPE_PIXTABLE);
457  }
458 
459  muse_pixtable_delete(arcpixtable);
460  cpl_table_delete(arclines);
461  muse_image_delete(masterimage);
462  }
463 #endif /* defined(USE_LSF_PARAMS) */
464  else {
465  cpl_msg_error(__func__, "Unknown LSF method %s", aParams->method_s);
466  }
467  return (cpl_errorstate_is_equal(prestate))?0:-1;
468 } /* muse_lsf_compute() */
int method
LSF generation method. Depending on this value, either an interpolated LSF cube is created...
Definition: muse_lsf_z.h:91
int lambda_size
Image size in line wavelength direction.
Definition: muse_lsf_z.h:77
Structure definition for a collection of muse_images.
muse_wcs * wcs
Common WCS information for each slice.
Definition: muse_lsf.h:55
void muse_image_delete(muse_image *aImage)
Deallocate memory associated to a muse_image object.
Definition: muse_image.c:85
void muse_pixtable_extracted_delete(muse_pixtable **aPixtables)
Delete a pixel table array.
unsigned short muse_pixtable_origin_get_slice(uint32_t aOrigin)
Get the slice number from the encoded 32bit origin number.
cpl_size muse_pixtable_extracted_get_size(muse_pixtable **aPixtables)
Get the size of an array of extracted pixel tables.
cpl_propertylist * header
Primary header used to save the LSF cube to disk.
Definition: muse_lsf.h:51
muse_imagelist * muse_basicproc_combine_images_lampwise(muse_processing *aProcessing, unsigned char aIFU, muse_basicproc_params *aBPars, cpl_frameset ***aLabeledFrames)
Combine several images into a lampwise image list.
double muse_lsf_fwhm_lambda(const muse_lsf_params *aDP, double aLambda, double aSampling, unsigned int aLength)
Measure the FWHM of an LSF at a given wavelength.
muse_pixtable ** muse_pixtable_extracted_get_slices(muse_pixtable *aPixtable)
Extract one pixel table per IFU and slice.
int nifu
IFU to handle. If set to 0, all IFUs are processed serially. If set to -1, all IFUs are processed in ...
Definition: muse_lsf_z.h:50
void muse_imagelist_delete(muse_imagelist *aList)
Free the memory of the MUSE image list.
Data cube/stacked image list containing the LSF for one IFU.
Definition: muse_lsf.h:49
muse_basicproc_params * muse_basicproc_params_new(cpl_parameterlist *aParameters, const char *aPrefix)
Create a new structure of basic processing parameters.
muse_image * muse_combine_images(muse_combinepar *aCPars, muse_imagelist *aImages)
Combine several images into one.
Definition: muse_combine.c:741
Structure definition of MUSE three extension FITS file.
Definition: muse_image.h:40
muse_lsf_cube * muse_lsf_cube_new(double aLsfHalfRange, cpl_size aNLsf, cpl_size aNLambda, const cpl_propertylist *aHeader)
Create a new LSF datacube.
cpl_table * table
The pixel table.
void muse_basicproc_params_delete(muse_basicproc_params *aBPars)
Free a structure of basic processing parameters.
void muse_lsf_params_delete_all(muse_lsf_params **aParams)
Delete an allocated array of muse_lsf_params structure.
int save_subtracted
Save the pixel table after the LSF subtraction.
Definition: muse_lsf_z.h:65
#define MUSE_PIXTABLE_DATA
Definition: muse_pixtable.h:48
void muse_combinepar_delete(muse_combinepar *aCPars)
Clear the combination parameters.
Definition: muse_combine.c:715
Structure definition of MUSE pixel table.
int lsf_size
Image size in LSF direction.
Definition: muse_lsf_z.h:74
cpl_frame * muse_processing_new_frame(muse_processing *aProcessing, int aIFU, cpl_propertylist *aHeader, const char *aTag, cpl_frame_type aType)
Create a new frame for a result file.
Structure to hold the parameters of the muse_lsf recipe.
Definition: muse_lsf_z.h:48
cpl_frameset * outframes
cpl_error_code muse_processing_save_cube(muse_processing *aProcessing, int aIFU, void *aCube, const char *aTag, muse_cube_type aType)
Save a MUSE datacube to disk.
int line_quality
Minimal quality flag in line catalog for selection.
Definition: muse_lsf_z.h:68
muse_combinepar * muse_combinepar_new(cpl_parameterlist *aParameters, const char *aPrefix)
Create a new set of combination parameters.
Definition: muse_combine.c:672
muse_lsf_params * muse_lsf_params_fit(muse_pixtable *aPixtable, cpl_table *aLines, int aMaxIter)
Fit all entries of one slice.
cpl_error_code muse_lsf_apply(const cpl_image *aLsfImage, const muse_wcs *aWCS, cpl_array *aVal, double aLambda)
Apply the LSF to a number of data points of one slice.
muse_pixtable * muse_pixtable_create(muse_image *aImage, cpl_table *aTrace, cpl_table *aWave, cpl_table *aGeoTable)
Create the pixel table for one CCD.
#define MUSE_PIXTABLE_ORIGIN
Definition: muse_pixtable.h:54
unsigned short muse_pixtable_origin_get_ifu(uint32_t aOrigin)
Get the IFU number from the encoded 32bit origin number.
cpl_table * muse_processing_load_ctable(muse_processing *aProcessing, const char *aTag, unsigned char aIFU)
Load a CPL table according to its tag and IFU/channel number.
cpl_error_code muse_lsf_params_save(const muse_lsf_params **aLsfParams, const char *aFile)
Save slice LSF parameters to the extension "slice" on disk.
#define MUSE_PIXTABLE_LAMBDA
Definition: muse_pixtable.h:53
muse_pixtable * muse_lsf_create_arcpixtable(muse_imagelist *aImages, cpl_table *aTrace, cpl_table *aWave, cpl_table *aArcLines, int aQuality, double aWindow)
Read images and combine the arc lines into one pixtable.
cpl_error_code muse_processing_save_table(muse_processing *aProcessing, int aIFU, void *aTable, cpl_propertylist *aHeader, const char *aTag, muse_table_type aType)
Save a computed table to disk.
Structure of basic processing parameters.
const char * method_s
LSF generation method. Depending on this value, either an interpolated LSF cube is created...
Definition: muse_lsf_z.h:93
void muse_lsf_cube_delete(muse_lsf_cube *aLsfCube)
Deallocate the memory for the LSF cube.
cpl_imagelist * img
Stacked image list for LSF; one per slice.
Definition: muse_lsf.h:53
Structure definition of detector (slice) parameters.
void muse_pixtable_delete(muse_pixtable *aPixtable)
Deallocate memory associated to a pixel table object.
double lsf_range
Wavelength window (half size) around each line to estimate LSF.
Definition: muse_lsf_z.h:71
cpl_parameterlist * parameters
cpl_error_code muse_lsf_fit_slice(const muse_pixtable *aPixtable, cpl_image *aLsfImage, muse_wcs *aWCS, double aLsfRegressionWindow)
Compute the LSF for all wavelengths of one slice.
cpl_propertylist * header
The FITS header.
double lsf_regression_window
Size of the regression window in LSF direction.
Definition: muse_lsf_z.h:80