34 #include "muse_processing.h" 36 #include "muse_utils.h" 54 typedef struct muse_processinginfo_s {
55 struct muse_processinginfo_s *prev;
56 struct muse_processinginfo_s *next;
58 cpl_recipeconfig *recipeconfig;
60 muse_processing_prepare_header_func *prepare_header;
62 muse_processing_get_frame_level_func *get_frame_level;
64 muse_processing_get_frame_mode_func *get_frame_mode;
85 if (m->plugin == aRecipe) {
108 ( cpl_recipe *plugin,
109 cpl_recipeconfig *recipeconfig,
110 muse_processing_prepare_header_func *prepare_header,
111 muse_processing_get_frame_level_func *get_frame_level,
112 muse_processing_get_frame_mode_func *get_frame_mode) {
119 while (m->next != NULL) {
127 m->recipeconfig = recipeconfig;
128 m->prepare_header = prepare_header;
129 m->get_frame_level = get_frame_level;
130 m->get_frame_mode = get_frame_mode;
154 m->prev->next = m->next;
155 if (m->next != NULL) {
156 m->next->prev = m->prev;
159 cpl_recipeconfig_delete(m->recipeconfig);
173 const char *aFrametag,
174 cpl_propertylist *aHeader) {
176 return (m != NULL)? (* m->prepare_header)(aFrametag, aHeader): CPL_ERROR_NONE;
189 const char *aFrametag) {
191 return (m != NULL)? (* m->get_frame_level)(aFrametag): CPL_FRAME_LEVEL_NONE;
204 const char *aFrametag) {
219 return (m != NULL)?m->recipeconfig: NULL;
241 cpl_type aType,
const char *aDescription)
243 cpl_ensure_code(aHeader, CPL_ERROR_NULL_INPUT);
244 cpl_ensure_code(aName, CPL_ERROR_NULL_INPUT);
246 cpl_error_code rc = CPL_ERROR_NONE;
248 cpl_propertylist *list = cpl_propertylist_new();
249 cpl_propertylist_copy_property_regexp(list, aHeader, aName, 0);
250 if (cpl_propertylist_is_empty(list)) {
251 cpl_propertylist_delete(list);
259 if (!cpl_propertylist_has(aHeader,
"MUSE PRIVATE DOCUMENTATION") &&
260 (aDescription && !strstr(aDescription,
"(optional)"))) {
261 cpl_msg_warning(__func__,
"Property %s (%s) not used", aName,
263 return CPL_ERROR_DATA_NOT_FOUND;
272 cpl_propertylist_append_float(aHeader, aName, -99.);
274 case CPL_TYPE_DOUBLE:
275 cpl_propertylist_append_double(aHeader, aName, -999.);
277 case CPL_TYPE_STRING:
278 cpl_propertylist_append_string(aHeader, aName,
"");
281 cpl_propertylist_append_int(aHeader, aName, INT_MAX);
284 cpl_propertylist_append_long(aHeader, aName, LONG_MAX);
287 cpl_propertylist_append_bool(aHeader, aName, FALSE);
290 return CPL_ERROR_INVALID_TYPE;
295 cpl_property *
property = cpl_propertylist_get_property(aHeader, aName);
296 if (aDescription != NULL && strlen(aDescription)>0) {
297 rc = cpl_property_set_comment(property, aDescription);
299 cpl_type type = cpl_property_get_type(property);
301 cpl_msg_warning(__func__,
"Type of property %s is %s but should be %s",
302 aName, cpl_type_get_name(type), cpl_type_get_name(aType));
303 return CPL_ERROR_TYPE_MISMATCH;
305 return CPL_ERROR_NONE;
310 for (i = 0; i < cpl_propertylist_get_size(list); i++) {
311 cpl_property *prop = cpl_propertylist_get(list, i);
312 cpl_property *
property =
313 cpl_propertylist_get_property(aHeader, cpl_property_get_name(prop));
314 if (aDescription != NULL && strlen(aDescription)>0) {
315 rc = cpl_property_set_comment(property, aDescription);
317 cpl_type type = cpl_property_get_type(property);
319 cpl_msg_warning(__func__,
"Type of property %s is %s but should be %s",
320 aName, cpl_type_get_name(type), cpl_type_get_name(aType));
321 cpl_propertylist_delete(list);
322 return CPL_ERROR_TYPE_MISMATCH;
325 cpl_propertylist_delete(list);
345 cpl_msg_set_threadid_off();
346 cpl_msg_info(__func__,
"%s v%s", PACKAGE_NAME, PACKAGE_VERSION);
350 cpl_recipe *recipe = (cpl_recipe *)aPlugin;
351 cpl_errorstate state = cpl_errorstate_get();
352 cpl_size nframes = cpl_frameset_get_size(recipe->frames);
353 if (!cpl_errorstate_is_equal(state)) {
354 cpl_errorstate_set(state);
356 cpl_msg_debug(__func__,
"%"CPL_SIZE_FORMAT
" input frames:", nframes);
358 cpl_msg_indent_more();
360 for (iframe = 0; iframe < nframes; iframe++) {
361 cpl_frame *frame = cpl_frameset_get_position(recipe->frames, iframe);
362 cpl_msg_debug(__func__,
"%s\t%s", cpl_frame_get_filename(frame),
363 cpl_frame_get_tag(frame));
365 cpl_msg_indent_less();
368 cpl_msg_debug(__func__,
"non-default parameters:");
369 cpl_msg_indent_more();
371 const cpl_parameter *p = cpl_parameterlist_get_first(recipe->parameters);
372 for ( ; p; p = cpl_parameterlist_get_next(recipe->parameters)) {
375 const char *name = cpl_parameter_get_alias(p, CPL_PARAMETER_MODE_CLI);
376 cpl_type type = cpl_parameter_get_type(p);
379 case CPL_TYPE_BOOL: {
380 cpl_boolean value = cpl_parameter_get_bool(p),
381 dval = cpl_parameter_get_default_bool(p);
383 cpl_msg_debug(__func__,
"--%s=%s [%s]", name,
384 value ?
"true" :
"false", dval ?
"true" :
"false");
390 int value = cpl_parameter_get_int(p),
391 dval = cpl_parameter_get_default_int(p);
393 cpl_msg_debug(__func__,
"--%s=%d [%d]", name, value, dval);
398 case CPL_TYPE_DOUBLE: {
399 double value = cpl_parameter_get_double(p),
400 dval = cpl_parameter_get_default_double(p);
402 cpl_msg_debug(__func__,
"--%s=%g [%g]", name, value, dval);
407 case CPL_TYPE_STRING: {
408 const char *value = cpl_parameter_get_string(p),
409 *dval = cpl_parameter_get_default_string(p);
410 if (value && dval && strncmp(value, dval, strlen(dval) + 1)) {
411 cpl_msg_debug(__func__,
"--%s=\"%s\" [\"%s\"]", name, value, dval);
417 cpl_msg_debug(__func__,
"--%s: parameter of unknown type!", name);
422 cpl_msg_debug(__func__,
"none");
424 cpl_msg_indent_less();
427 cpl_msg_debug(__func__,
"relevant MUSE environment variables:");
428 cpl_msg_indent_more();
429 const char *env[] = {
"MUSE_AIT_HACK_SLICE_NUMBER",
430 "MUSE_BASICPROC_SKIP_GAIN_OVERRIDE",
431 "MUSE_BASICPROC_SKIP_NONLIN_CORR",
432 "MUSE_TWILIGHT_SCALES",
"MUSE_TWILIGHT_SKIP",
433 "MUSE_GEOMETRY_SKIP",
"MUSE_GEOMETRY_NO_INVERSION",
434 "MUSE_GEOMETRY_MASK_ROTATION",
435 "MUSE_GEOMETRY_PINHOLE_DY",
"MUSE_GEOMETRY_STD_GAP",
436 "MUSE_GEOMETRY_HORI_OFFSETS",
"MUSE_DAR_CORRECT_METHOD",
437 "MUSE_PIXTABLE_SAVE_AS_TABLE",
"MUSE_COLLAPSE_PIXTABLE",
438 "MUSE_COLLAPSE_USE_VARIANCE",
439 "MUSE_CPL_ERRORSTATE_NDUMP",
"MUSE_EXPERT_USER",
440 "MUSE_BADPIX_FROM_MASKCUBE",
"MUSE_DEBUG_QUADRANTS",
441 "MUSE_DEBUG_TRACE",
"MUSE_DEBUG_WAVECAL",
442 "MUSE_DEBUG_LSF_FIT",
"MUSE_DEBUG_SKY",
443 "MUSE_PLOT_TRACE",
"MUSE_DEBUG_DCR",
"MUSE_DEBUG_FLUX",
444 "MUSE_DEBUG_PIXTABLE_LIMITS",
445 "MUSE_DEBUG_GEO_VERIFY_DY",
"MUSE_DEBUG_GEO_VERTICAL",
446 "MUSE_DEBUG_MEMORY_PROGRAM",
"MUSE_DEBUG_WCS",
447 "MUSE_DEBUG_GRID_CONVERSION",
"MUSE_DEBUG_NEAREST",
448 "MUSE_DEBUG_WEIGHTED",
"MUSE_DEBUG_WEIGHTED_X",
449 "MUSE_DEBUG_WEIGHTED_Y",
"MUSE_DEBUG_WEIGHTED_Z",
450 "MUSE_DEBUG_WEIGHTED_GRID",
"MUSE_DEBUG_WEIGHT_CUBE",
451 "MUSE_DEBUG_CRREJECT",
"MUSE_DEBUG_CRREJECT_X",
452 "MUSE_DEBUG_CRREJECT_Y",
"MUSE_DEBUG_CRREJECT_Z",
456 char *value = getenv(env[ienv]);
458 cpl_msg_debug(__func__,
"%s=%s", env[ienv], value);
462 cpl_msg_indent_less();
465 cpl_msg_debug(__func__,
"relevant OpenMP environment variables:");
466 cpl_msg_indent_more();
469 const char *envomp[] = {
"OMP_SCHEDULE",
"OMP_NUM_THREADS",
"OMP_DYNAMIC",
470 "OMP_PROC_BIND",
"OMP_NESTED",
"OMP_STACKSIZE",
471 "OMP_WAIT_POLICY",
"OMP_MAX_ACTIVE_LEVELS",
473 "OMP_PLACES",
"OMP_CANCELLATION",
"OMP_DISPLAY_ENV",
474 "OMP_DEFAULT_DEVICE",
475 "OMP_MAX_TASK_PRIORITY", NULL };
477 while (envomp[ienv]) {
478 char *value = getenv(envomp[ienv]);
480 cpl_msg_debug(__func__,
"%s=%s", envomp[ienv], value);
484 cpl_msg_indent_less();
int muse_processing_get_frame_mode(const cpl_recipe *aRecipe, const char *aFrametag)
Get the mode for a product frame with a certain tag.
cpl_error_code muse_processing_prepare_header(const cpl_recipe *aRecipe, const char *aFrametag, cpl_propertylist *aHeader)
Prepare and check a FITS header for a certain frame tag.
struct muse_processinginfo_s muse_processinginfo_t
cpl_frame_level muse_processing_get_frame_level(const cpl_recipe *aRecipe, const char *aFrametag)
Get the level for a product frame with a certain tag.
void muse_processinginfo_delete(cpl_recipe *aRecipe)
Clear all information from the processing info and from the recipe config.
cpl_recipeconfig * muse_processing_get_recipeconfig(cpl_recipe *aRecipe)
Get the recipe (frame) configuration.
void muse_processinginfo_register(cpl_recipe *plugin, cpl_recipeconfig *recipeconfig, muse_processing_prepare_header_func *prepare_header, muse_processing_get_frame_level_func *get_frame_level, muse_processing_get_frame_mode_func *get_frame_mode)
Register extended functionalities for MUSE recipes.
static muse_processinginfo_t * muse_processinginfo_get(const cpl_recipe *aRecipe)
Get processinginfo for a certain recipe.
void muse_processing_recipeinfo(cpl_plugin *aPlugin)
Output main pipeline configuration, inputs, and parameters.
static muse_processinginfo_t * muse_processinginfo
cpl_error_code muse_processing_prepare_property(cpl_propertylist *aHeader, const char *aName, cpl_type aType, const char *aDescription)
Prepare and check the specified property.