00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifdef HAVE_CONFIG_H
00023 #include <config.h>
00024 #endif
00025
00026
00027
00028
00029 #include <muse.h>
00030 #include "muse_scipost_make_cube_z.h"
00031
00032
00033
00034
00035
00036
00043
00044 int
00045 muse_scipost_make_cube_compute(muse_processing *aProcessing,
00046 muse_scipost_make_cube_params_t *aParams)
00047 {
00048 cpl_frameset *inframes = muse_frameset_find_tags(aProcessing->inframes,
00049 aProcessing->intags, 0,
00050 CPL_FALSE);
00051 cpl_frame *frame = cpl_frameset_get_position(inframes, 0);
00052 char *fn = cpl_strdup(cpl_frame_get_filename(frame));
00053 muse_pixtable *pixtable = muse_pixtable_load_restricted_wavelength(fn,
00054 aParams->lambdamin,
00055 aParams->lambdamax);
00056 muse_processing_append_used(aProcessing, frame, CPL_FRAME_GROUP_RAW, 1);
00057 cpl_frameset_delete(inframes);
00058 if (!pixtable) {
00059 cpl_msg_error(__func__, "NULL pixel table for %s", fn);
00060 cpl_free(fn);
00061 return -1;
00062 }
00063 cpl_free(fn);
00064
00065 cpl_propertylist_erase_regexp(pixtable->header, "ESO QC ", 0);
00066 muse_pixtable_wcs wcstype = muse_pixtable_wcs_check(pixtable);
00067 if (wcstype == MUSE_PIXTABLE_WCS_NATSPH) {
00068 muse_wcs_position_celestial(pixtable,
00069 muse_pfits_get_ra(pixtable->header),
00070 muse_pfits_get_dec(pixtable->header));
00071 }
00072 muse_resampling_type resample
00073 = muse_postproc_get_resampling_type(aParams->resample_s);
00074 muse_resampling_params *rp = muse_resampling_params_new(resample);
00075 rp->dx = aParams->dx;
00076 rp->dy = aParams->dy;
00077 rp->dlambda = aParams->dlambda;
00078 rp->crtype = muse_postproc_get_cr_type(aParams->crtype_s);
00079 rp->crsigma = aParams->crsigma;
00080 rp->ld = aParams->ld;
00081 rp->rc = aParams->rc;
00082 rp->pfx = aParams->pixfrac;
00083 rp->pfy = aParams->pixfrac;
00084 rp->pfl = aParams->pixfrac;
00085 cpl_propertylist *outwcs = muse_postproc_cube_load_output_wcs(aProcessing);
00086 muse_resampling_params_set_wcs(rp, outwcs);
00087 cpl_propertylist_delete(outwcs);
00088 muse_cube_type format = muse_postproc_get_cube_format(aParams->format_s);
00089 cpl_error_code rc = muse_postproc_cube_resample_and_collapse(aProcessing,
00090 pixtable,
00091 format, rp,
00092 aParams->filter);
00093 muse_resampling_params_delete(rp);
00094 if (aParams->stacked) {
00095 cpl_msg_debug(__func__, "additional output as column-stacked image");
00096 muse_image *img = muse_resampling_image(pixtable,
00097 MUSE_RESAMPLE_WEIGHTED_RENKA,
00098 aParams->dx, aParams->dlambda);
00099 muse_processing_save_image(aProcessing, -1, img, MUSE_TAG_OBJECT_RESAMPLED);
00100 muse_image_delete(img);
00101 }
00102 muse_pixtable_delete(pixtable);
00103 return rc == CPL_ERROR_NONE ? 0 : -1;
00104 }