[SCM] Sample data reduction pipeline branch, debian, updated. 18bd2af5aae85b7f488b472309c7ed8d6546e7d6

Ole Streicher debian at liska.ath.cx
Fri Jun 29 13:20:58 UTC 2012


The following commit has been merged in the debian branch:
commit 4c4e8ffc52ab4ce87c434521087c72c84806bc49
Author: Ole Streicher <debian at liska.ath.cx>
Date:   Fri Jun 29 14:33:19 2012 +0200

    Add framework test recipe

diff --git a/debian/patches/add_test_recipe.patch b/debian/patches/add_test_recipe.patch
new file mode 100644
index 0000000..8d4811b
--- /dev/null
+++ b/debian/patches/add_test_recipe.patch
@@ -0,0 +1,443 @@
+--- /dev/null
++++ b/recipes/rtest.c
+@@ -0,0 +1,422 @@
++/* $Id: rtest.c,v 1.28 2007/07/30 07:08:59 llundin Exp $
++ *
++ * This file is part of the IIINSTRUMENT Pipeline
++ * Copyright (C) 2002,2003 European Southern Observatory
++ * Copyright (C) 2011,2012 Ole Streicher
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
++ */
++
++#ifdef HAVE_CONFIG_H
++#include <config.h>
++#endif
++#ifdef HAVE_STRING_H
++#include <string.h>
++#endif
++#ifdef HAVE_UNISTD_H
++#include <unistd.h>
++#endif
++
++/*-----------------------------------------------------------------------------
++				Includes
++ -----------------------------------------------------------------------------*/
++
++#include <cpl.h>
++
++#include "iiinstrument_utils.h"
++#include "iiinstrument_pfits.h"
++#include "iiinstrument_dfs.h"
++
++/*-----------------------------------------------------------------------------
++			    Private function prototypes
++ -----------------------------------------------------------------------------*/
++
++static int rtest_create(cpl_plugin *);
++static int rtest_exec(cpl_plugin *);
++static int rtest_destroy(cpl_plugin *);
++static int rtest(cpl_frameset *, const cpl_parameterlist *);
++
++/*-----------------------------------------------------------------------------
++			    Static variables
++ -----------------------------------------------------------------------------*/
++
++static char rtest_description[] =
++"Recipe to test CPL frameworks like esorex or python-cpl.\n";
++
++/*-----------------------------------------------------------------------------
++				Function code
++ -----------------------------------------------------------------------------*/
++
++/*----------------------------------------------------------------------------*/
++/**
++  @brief    Build the list of available plugins, for this module.
++  @param    list    the plugin list
++  @return   0 if everything is ok, 1 otherwise
++  @note     Only this function is exported
++
++  Create the recipe instance and make it available to the application using the
++  interface.
++ */
++/*----------------------------------------------------------------------------*/
++int cpl_plugin_get_info(cpl_pluginlist * list)
++{
++    cpl_recipe  *   recipe = cpl_calloc(1, sizeof *recipe );
++    cpl_plugin  *   plugin = &recipe->interface;
++
++    if (cpl_plugin_init(plugin,
++		    CPL_PLUGIN_API,
++		    IIINSTRUMENT_BINARY_VERSION,
++		    CPL_PLUGIN_TYPE_RECIPE,
++		    "rtest",
++		    "Framework test recipe",
++		    rtest_description,
++		    "Ole Streicher",
++		    "python-cpl at liska.ath.cx",
++		    iiinstrument_get_license(),
++		    rtest_create,
++		    rtest_exec,
++		    rtest_destroy)) {
++	cpl_msg_error(cpl_func, "Plugin initialization failed");
++	(void)cpl_error_set_where(cpl_func);
++	return 1;
++    }
++
++    if (cpl_pluginlist_append(list, plugin)) {
++	cpl_msg_error(cpl_func, "Error adding plugin to list");
++	(void)cpl_error_set_where(cpl_func);
++	return 1;
++    }
++
++    return 0;
++}
++
++/*----------------------------------------------------------------------------*/
++/**
++  @brief    Setup the recipe options
++  @param    plugin  the plugin
++  @return   0 if everything is ok
++
++  Defining the command-line/configuration parameters for the recipe.
++ */
++/*----------------------------------------------------------------------------*/
++static int rtest_create(cpl_plugin * plugin)
++{
++    cpl_ensure_code((plugin != NULL), CPL_ERROR_NULL_INPUT);
++    cpl_ensure_code((cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE),
++		    CPL_ERROR_TYPE_MISMATCH);
++
++    cpl_recipe *recipe = (cpl_recipe *)plugin;
++
++    /* Create the parameters list in the cpl_recipe object */
++    recipe->parameters = cpl_parameterlist_new();
++    if (recipe->parameters == NULL) {
++	cpl_msg_error(cpl_func, "Parameter list allocation failed");
++	cpl_ensure_code(0, (int)CPL_ERROR_ILLEGAL_OUTPUT);
++    }
++
++    /* Fill the parameters list */
++    cpl_parameter * p;
++    /* --stropt */
++    p = cpl_parameter_new_value("iiinstrument.rtest.string_option",
++	    CPL_TYPE_STRING,
++	    "A string option; saved as ESO QC STROPT",
++	    "iiinstrument.rtest",NULL);
++    cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "stropt");
++    cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
++    cpl_parameterlist_append(recipe->parameters, p);
++
++    /* --boolopt */
++    p = cpl_parameter_new_value("iiinstrument.rtest.bool_option",
++	    CPL_TYPE_BOOL,
++	    "A flag; saved as ESO QC BOOLOPT",
++	    "iiinstrument.rtest", TRUE);
++    cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "boolopt");
++    cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
++    cpl_parameterlist_append(recipe->parameters, p);
++
++    /* --floatopt */
++    p = cpl_parameter_new_value("iiinstrument.rtest.float_option",
++	    CPL_TYPE_DOUBLE,
++	    "A double option; saved as ESO QC FLOATOPT",
++	    "iiinstrument.rtest", 0.1);
++    cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "floatopt");
++    cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
++    cpl_parameterlist_append(recipe->parameters, p);
++
++    /* --inttopt */
++    p = cpl_parameter_new_value("iiinstrument.rtest.int_option",
++	    CPL_TYPE_INT,
++	    "An interger; saved as ESO QC INTOPT",
++	    "iiinstrument.rtest", 2);
++    cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "intopt");
++    cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
++    cpl_parameterlist_append(recipe->parameters, p);
++
++    /* --enumopt */
++    p = cpl_parameter_new_enum("iiinstrument.rtest.enum_option",
++	    CPL_TYPE_STRING,
++	    "An enumeration option, saved as ESO QC ENUMOPT",
++	    "iiinstrument.rtest", "first", 3, "first", "second", "third");
++    cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "enumopt");
++    cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
++    cpl_parameterlist_append(recipe->parameters, p);
++
++    /* --rangeopt */
++    p = cpl_parameter_new_range("iiinstrument.rtest.range_option",
++	    CPL_TYPE_DOUBLE,
++	    "A double option with a range, saved as ESO QC RANGEOPT",
++	    "iiinstrument.rtest", 0.1, -0.5, 0.5);
++    cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "rangeopt");
++    cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
++    cpl_parameterlist_append(recipe->parameters, p);
++
++    /* --dot.opt */
++    p = cpl_parameter_new_value("iiinstrument.rtest.dotted.opt",
++	    CPL_TYPE_INT,
++	    "An (integer) option with a dot in its name",
++	    "iiinstrument.rtest", 0);
++    cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "dot.opt");
++    cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
++    cpl_parameterlist_append(recipe->parameters, p);
++
++    /* --crashing */
++    p = cpl_parameter_new_enum("iiinstrument.rtest.crashing",
++	  CPL_TYPE_STRING, "Crash the recipe?", "iiinstrument.rtest",
++			       "no", 3, "no", "free", "segfault");
++    cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "crashing");
++    cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
++    cpl_parameterlist_append(recipe->parameters, p);
++
++    /* --sleep */
++    p = cpl_parameter_new_value("iiinstrument.rtest.sleep",
++	    CPL_TYPE_DOUBLE,
++	    "Simulate some computing by sleeping for specified time [seconds]",
++	    "iiinstrument.rtest", 0.1);
++    cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "sleep");
++    cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
++    cpl_parameterlist_append(recipe->parameters, p);
++
++    return 0;
++}
++
++/*----------------------------------------------------------------------------*/
++/**
++  @brief    Execute the plugin instance given by the interface
++  @param    plugin  the plugin
++  @return   0 if everything is ok
++ */
++/*----------------------------------------------------------------------------*/
++static int rtest_exec(cpl_plugin * plugin)
++{
++    cpl_ensure_code((plugin != NULL), CPL_ERROR_NULL_INPUT);
++    cpl_ensure_code((cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE),
++		    CPL_ERROR_TYPE_MISMATCH);
++
++    cpl_recipe *recipe = (cpl_recipe *)plugin;
++
++    cpl_ensure_code((recipe->parameters != NULL), (int)CPL_ERROR_NULL_INPUT);
++    cpl_ensure_code((recipe->frames != NULL), (int)CPL_ERROR_NULL_INPUT);
++
++    int recipe_status = rtest(recipe->frames, recipe->parameters);
++
++    /* Ensure DFS-compliance of the products */
++    if (cpl_dfs_update_product_header(recipe->frames)) {
++	if (!recipe_status) recipe_status = (int)cpl_error_get_code();
++    }
++
++    return recipe_status;
++}
++
++/*----------------------------------------------------------------------------*/
++/**
++  @brief    Destroy what has been created by the 'create' function
++  @param    plugin  the plugin
++  @return   0 if everything is ok
++ */
++/*----------------------------------------------------------------------------*/
++static int rtest_destroy(cpl_plugin * plugin)
++{
++    cpl_ensure_code((plugin != NULL), CPL_ERROR_NULL_INPUT);
++    cpl_ensure_code((cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE),
++		    CPL_ERROR_TYPE_MISMATCH);
++
++    cpl_recipe *recipe = (cpl_recipe *)plugin;
++    cpl_parameterlist_delete(recipe->parameters);
++
++    return 0;
++}
++
++/*----------------------------------------------------------------------------*/
++/**
++  @brief    Interpret the command line options and execute the data processing
++  @param    frameset   the frames list
++  @param    parlist    the parameters list
++  @return   0 if everything is ok
++ */
++/*----------------------------------------------------------------------------*/
++static int rtest(cpl_frameset            * frameset,
++		    const cpl_parameterlist * parlist)
++{
++    /* Use the errorstate to detect an error in a function that does not
++       return an error code. */
++    cpl_errorstate prestate = cpl_errorstate_get();
++
++    const cpl_parameter *param;
++    /* --stropt */
++    param = cpl_parameterlist_find_const(parlist,
++					 "iiinstrument.rtest.string_option");
++    const char *str_option = cpl_parameter_get_string(param);
++    cpl_ensure_code(str_option != NULL, CPL_ERROR_NULL_INPUT);
++
++    /* --boolopt */
++    param = cpl_parameterlist_find_const(parlist,
++					 "iiinstrument.rtest.bool_option");
++    int bool_option = cpl_parameter_get_bool(param);
++
++    /* --floatopt */
++    param = cpl_parameterlist_find_const(parlist,
++					 "iiinstrument.rtest.float_option");
++    double float_option = cpl_parameter_get_double(param);
++
++    /* --intopt */
++    param = cpl_parameterlist_find_const(parlist,
++					 "iiinstrument.rtest.int_option");
++    int int_option = cpl_parameter_get_int(param);
++
++    /* --enumopt */
++    param = cpl_parameterlist_find_const(parlist,
++					 "iiinstrument.rtest.enum_option");
++    const char *enum_option = cpl_parameter_get_string(param);
++
++    /* --rangeopt */
++    param = cpl_parameterlist_find_const(parlist,
++					 "iiinstrument.rtest.range_option");
++    double range_option = cpl_parameter_get_double(param);
++
++    /* --crashing */
++    param = cpl_parameterlist_find_const(parlist,
++					 "iiinstrument.rtest.crashing");
++    const char *crashing = cpl_parameter_get_string(param);
++
++    /* --sleep */
++    param = cpl_parameterlist_find_const(parlist,
++					 "iiinstrument.rtest.sleep");
++    double sleep_secs = cpl_parameter_get_double(param);
++
++    if (!cpl_errorstate_is_equal(prestate)) {
++	return (int)cpl_error_set_message(cpl_func, cpl_error_get_code(),
++					  "Could not retrieve the input "
++					  "parameters");
++    }
++
++    /* Identify the RAW and CALIB frames in the input frameset */
++    cpl_ensure_code(iiinstrument_dfs_set_groups(frameset) == CPL_ERROR_NONE,
++		    cpl_error_get_code());
++
++    /*  - raw input file */
++    const cpl_frame *rawframe = cpl_frameset_find_const(frameset, "RTEST_DOCATG_RAW");
++    if (rawframe == NULL) {
++	/* cpl_frameset_find_const() does not set an error code, when a frame
++	   is not found, so we will set one here. */
++	return (int)cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
++					  "No file tagged with %s", "RTEST_DOCATG_RAW");
++    }
++
++    cpl_propertylist *plist
++	= cpl_propertylist_load_regexp(cpl_frame_get_filename(rawframe),
++				       0, "ESO DET ", 0);
++    if (plist == NULL) {
++	/* In this case an error message is added to the error propagation */
++	return (int)cpl_error_set_message(cpl_func, cpl_error_get_code(),
++					  "Could not read the FITS header");
++    }
++
++    double qc_param = iiinstrument_pfits_get_dit(plist);
++    cpl_propertylist_delete(plist);
++
++    /* - calibration input file */
++    const cpl_frame *flat = cpl_frameset_find(frameset,IIINSTRUMENT_CALIB_FLAT);
++    if (flat == NULL) {
++	cpl_msg_warning(cpl_func, "No file tagged with %s",
++			IIINSTRUMENT_CALIB_FLAT);
++    }
++
++    /* Check for a change in the CPL error state */
++    /* - if it did change then propagate the error and return */
++    cpl_ensure_code(cpl_errorstate_is_equal(prestate), cpl_error_get_code());
++
++    /* Load raw image */
++    cpl_image *image = cpl_image_load(cpl_frame_get_filename(rawframe),
++				      CPL_TYPE_FLOAT, 0, 0);
++    if (image == NULL) {
++	return (int)cpl_error_set_message(cpl_func, cpl_error_get_code(),
++				     "Could not load the image");
++    }
++
++    /* Do some fake processing */
++    usleep((unsigned int)(1e6*sleep_secs));
++
++    /* Add QC parameters  */
++    cpl_propertylist *qclist = cpl_propertylist_new();
++
++    cpl_propertylist_append_double(qclist, "ESO QC QCPARAM", qc_param);
++    cpl_propertylist_append_string(qclist, "ESO PRO CATG",
++				   "THE_PRO_CATG_VALUE");
++    if (str_option != NULL) {
++	cpl_propertylist_append_string(qclist, "ESO QC STROPT", str_option);
++    } else {
++	cpl_propertylist_append_string(qclist, "ESO QC STROPT", "(null)");
++    }
++
++    cpl_propertylist_append_bool(qclist, "ESO QC BOOLOPT", bool_option);
++    cpl_propertylist_append_double(qclist, "ESO QC FLOATOPT", float_option);
++    cpl_propertylist_append_int(qclist, "ESO QC INTOPT", int_option);
++    if (enum_option != NULL) {
++	cpl_propertylist_append_string(qclist, "ESO QC ENUMOPT", enum_option);
++    } else {
++	cpl_propertylist_append_string(qclist, "ESO QC ENUMOPT", "(null)");
++    }
++    cpl_propertylist_append_double(qclist, "ESO QC RANGEOPT", range_option);
++
++    prestate = cpl_errorstate_get();
++
++    if (cpl_dfs_save_image(frameset, NULL, parlist, frameset, NULL, image,
++			   CPL_BPP_IEEE_FLOAT,
++			   "rtest", qclist, NULL,
++			   PACKAGE "/" PACKAGE_VERSION,
++			   "rtest.fits")) {
++	/* Propagate the error */
++	(void)cpl_error_set_where(cpl_func);
++    }
++
++    if (!cpl_errorstate_is_equal(prestate)) {
++	cpl_msg_error(__func__, "in cpl_dfs_save_image()");
++    }
++
++    cpl_image_delete(image);
++    cpl_propertylist_delete(qclist);
++
++    /* Let's see if we can crash the machine by some random code */
++    if (strcmp(crashing, "free") == 0) {
++	cpl_image_delete(image);
++	cpl_propertylist_delete(qclist);
++    }
++    if (strcmp(crashing, "segfault") == 0) {
++	double *crashvar = NULL;
++	*crashvar = 1.99;
++    }
++
++    return (int)cpl_error_get_code();
++}
+--- a/recipes/Makefile.am
++++ b/recipes/Makefile.am
+@@ -33,9 +33,14 @@
+ 
+ noinst_HEADERS = 
+ 
+-plugin_LTLIBRARIES = rrrecipe.la 
++plugin_LTLIBRARIES = rrrecipe.la rtest.la
+ 
+ rrrecipe_la_SOURCES = rrrecipe.c 
+ rrrecipe_la_LIBADD = $(LIBIIINSTRUMENT) -lcplcore -lcpldfs -lcplui
+ rrrecipe_la_LDFLAGS = -module -avoid-version
+ rrrecipe_la_DEPENDENCIES = $(LIBIIINSTRUMENT)
++
++rtest_la_SOURCES = rtest.c
++rtest_la_LIBADD = $(LIBIIINSTRUMENT) -lcplcore -lcpldfs -lcplui
++rtest_la_LDFLAGS = -module -avoid-version
++rtest_la_DEPENDENCIES = $(LIBIIINSTRUMENT)
diff --git a/debian/patches/series b/debian/patches/series
index e2c2220..3bfdc8d 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,3 +1,4 @@
 libadd_cpl.patch
 set_plugindir.patch
 use-std-paths-for-cpl.patch
+add_test_recipe.patch

-- 
Sample data reduction pipeline



More information about the debian-science-commits mailing list