00001 /* 00002 COSTA: Problem solving environment for data assimilation 00003 Copyright (C) 2005 Nils van Velzen 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 */ 00019 00020 /** 00021 \file cta_stoch_observer.h 00022 \brief Interface description of the COSTA default stochastic observer component. For user implementation see cta_usr_stoch_observer.h. 00023 */ 00024 00025 #ifndef CTA_SOBS_H 00026 #define CTA_SOBS_H 00027 #include "cta_system.h" 00028 #include "cta_handles.h" 00029 #include "cta_datatypes.h" 00030 #include "cta_functions.h" 00031 #include "cta_vector.h" 00032 #include "cta_matrix.h" 00033 #include "cta_time.h" 00034 00035 /* StochObs and Decription Handles */ 00036 typedef CTA_Handle CTA_StochObs; 00037 typedef CTA_Handle CTA_SObsClass; 00038 00039 #include "cta_obsdescr.h" 00040 00041 /* parameters for different functions */ 00042 #define CTA_SOBS_CREATE_SIZE ( 1) 00043 #define CTA_SOBS_CREATE_INIT ( 2) 00044 #define CTA_SOBS_FREE ( 3) 00045 #define CTA_SOBS_CREATE_SELECTION ( 4) 00046 #define CTA_SOBS_COUNT ( 5) 00047 #define CTA_SOBS_GET_OBS_DESCRIPTION ( 6) 00048 #define CTA_SOBS_GET_VALUES ( 7) 00049 #define CTA_SOBS_GET_REALISATION ( 8) 00050 #define CTA_SOBS_GET_EXPECTATION ( 9) 00051 #define CTA_SOBS_EVALUATE_PDF (10) 00052 #define CTA_SOBS_GET_COV_MATRIX (11) 00053 #define CTA_SOBS_GET_VARIANCE (12) 00054 #define CTA_SOBS_EXPORT (13) 00055 #define CTA_SOBS_GET_TIMES (14) 00056 #define CTA_SOBS_NUMFUNC (15) 00057 00058 #ifdef __cplusplus 00059 extern "C" { 00060 #endif 00061 00062 /** \brief Create a new class (=implementation) of a COSTA stochastic observer component. 00063 * 00064 * \param name I name of the new stochastic observer class 00065 * \param h_func I COSTA function handles for functions that implement class, 00066 * missing functions must have value CTA_NULL 00067 * \param descrcl I class of the observation description that is created by stochastic observer 00068 * \param hstochobscl O handle of new stochastic observer class 00069 * \return error status: CTA_OK if successful 00070 */ 00071 CTAEXPORT int CTA_SObs_DefineClass(const char *name, const CTA_Func h_func[CTA_SOBS_NUMFUNC], 00072 CTA_ObsDescrClass descrcl, CTA_SObsClass *hstochobscl); 00073 00074 /** \brief Create an instance of a stocastic observer 00075 * 00076 * \param hstochobscl I stochastic observer class of new stochastic observer 00077 * \param userdata IO userdata for creation (depends on class) 00078 * \param hstochobs O receives handle of new stochastic observer object 00079 * \return error status: CTA_OK if successful 00080 */ 00081 CTAEXPORT int CTA_SObs_Create(CTA_SObsClass hstochobscl, CTA_Handle userdata, 00082 CTA_StochObs *hstochobs); 00083 00084 /** \brief Create a new stochastic observer that is subset of existing stochastic observer. 00085 * 00086 * \param hsobsin I handle of the existing stochastic observer of 00087 * which a selection is to be made 00088 * \param userdata IO inputs necessary for making a selection (depends on user implementation) 00089 * \param hsobsout O receives handle of the new COSTA-stochastic observer, empty before calling, caller responsible for freeing after use 00090 * \return error status: CTA_OK if successful 00091 */ 00092 CTAEXPORT int CTA_SObs_CreateSel(CTA_StochObs hsobsin, CTA_Handle userdata, 00093 CTA_StochObs *hsobsout); 00094 00095 /** \brief Create a new stoch observer that is subset in time of existing stochastic observer. 00096 * 00097 * All observations in the closed interval [t1,t2] of the time span are selected. 00098 * 00099 * \param hsobsin I handle of the stochastic observer of 00100 * which a selection is to be made 00101 * \param timespan I time span over which selection has to be made 00102 * \param hsobsout O receives handle of the new COSTA-stochastic observer, empty before calling 00103 * \return error states: CTA_OK if successful 00104 */ 00105 CTAEXPORT int CTA_SObs_CreateTimSel(CTA_StochObs hsobsin, CTA_Time timespan, 00106 CTA_StochObs *hsobsout); 00107 00108 00109 /** \brief Count the number of elements in stochastic observer. 00110 * \param hsobs I handle of the stochastic observer 00111 * \param nmeasr O receives number of measurements in this observer 00112 * \return error status: CTA_OK if successful 00113 */ 00114 CTAEXPORT int CTA_SObs_Count(CTA_StochObs hsobs, int *nmeasr); 00115 00116 00117 /** \brief Get a vector with the measurements. 00118 * 00119 * \param hsobs I handle of the stochastic observer 00120 * \param hvec IO handle of vector that receives the measurements; must exist before calling 00121 * \return error status: CTA_OK if successful 00122 */ 00123 CTAEXPORT int CTA_SObs_GetVal(CTA_StochObs hsobs,CTA_Vector hvec); 00124 00125 00126 /** \brief Count the times associated to the measurements. 00127 * 00128 * \param hsobs I handle of the stochastic observer 00129 * \param hvec IO handle to vector that receives the times; must exist before calling 00130 * \return error status: CTA_OK if successful 00131 */ 00132 CTAEXPORT int CTA_SObs_GetTimes( CTA_StochObs hsobs,CTA_Vector hvec); 00133 00134 00135 /** \brief Draw random values (measurements) according to the probability density 00136 * function of the mesurements. 00137 * 00138 * \param hsobs I handle of the stochastic observer 00139 * \param hvec IO handle of vector that receives the draw (measurements); must exist before calling 00140 * \return error status: CTA_OK if successful 00141 */ 00142 CTAEXPORT int CTA_SObs_GetRealisation(CTA_StochObs hsobs, CTA_Vector hvec); 00143 00144 00145 /** \brief Get expectation of the probability density function of the mesurements. 00146 * 00147 * \param hsobs I handle of the stochastic observer 00148 * \param hvec IO handle of vector that receives the expectation values; must exist before calling 00149 * \return error status: CTA_OK if successful 00150 */ 00151 CTAEXPORT int CTA_SObs_GetExpectation(CTA_StochObs hsobs, CTA_Vector hvec); 00152 00153 00154 /** \brief Get the value of the probability density function of the mesurements at given location. 00155 * 00156 * \param hsobs I handle of the stochastic observer 00157 * \param hvecx I handle of vector with location for evaluating pdf 00158 * \param hvecy IO handle of vector that is to contain the pdf-value; must exist before calling 00159 * \return error status: CTA_OK if successful 00160 */ 00161 CTAEXPORT int CTA_SObs_EvalPDF(CTA_StochObs hsobs, CTA_Vector hvecx, CTA_Vector hvecy); 00162 00163 00164 /** \brief Get covariance matrix of probability density function of the measurements. 00165 * 00166 * \param hsobs I handle of the stochastic observer 00167 * \param hmat IO handle of matrix that receives the covariance matrix; must exist before calling 00168 * \return error status: CTA_OK if successful 00169 */ 00170 CTAEXPORT int CTA_SObs_GetCovMat(CTA_StochObs hsobs, CTA_Matrix hmat); 00171 00172 00173 /** \brief Get variance of probability density function of the mesurements. 00174 * 00175 * \param hsobs I handle of the stochastic observer 00176 * \param hvec IO handle of vector that receives the variance; must exist before calling 00177 * \return error status: CTA_OK if successful 00178 */ 00179 CTAEXPORT int CTA_SObs_GetVar( CTA_StochObs hsobs, CTA_Vector hvec); 00180 00181 00182 /** \brief Get standard deviation of probability density function of the measurements. 00183 * 00184 * \param hsobs I handle of the stochastic observer 00185 * \param hvec IO handle of vector that is to contain the standard deviation 00186 * \return error status: CTA_OK if successful 00187 */ 00188 CTAEXPORT int CTA_SObs_GetStd( CTA_StochObs hsobs, CTA_Vector hvec); 00189 00190 00191 /** \brief Create the observation description corresponding to the stochastic observer. 00192 * 00193 * \note Caller is responsible for freeing the here created observation description 00194 * 00195 * \param hsobs I handle of the stochastic observer 00196 * \param hobsdescr O receives handle of newly created observation description class, empty before calling 00197 * \return error status: CTA_OK if successful 00198 */ 00199 CTAEXPORT int CTA_SObs_GetDescription(CTA_StochObs hsobs, CTA_ObsDescr *hobsdescr); 00200 00201 00202 /** \brief Export the stochastic observer. 00203 * 00204 * \note Supported by CTA_DEFAULT_SOBS:\n 00205 * output to file (userdata must contain handle of COSTA file)\n 00206 * 00207 * \param hsobs I handle of the stochastic observer 00208 * \param userdata I configuration of output 00209 * \return error status: CTA_OK if successful 00210 */ 00211 CTAEXPORT int CTA_SObs_Export(CTA_StochObs hsobs, CTA_Handle userdata); 00212 00213 /** \brief Free the stochastic observer 00214 * 00215 * \Note hsobs=CTA_NULL is allowed 00216 * 00217 * \param hsobs IO handle of the stochastic observer, replaced by CTA_NULL on return 00218 * \return error status: CTA_OK if successful 00219 */ 00220 CTAEXPORT int CTA_SObs_Free( 00221 CTA_StochObs *hsobs /* Handle of stochastic observer */ 00222 ); 00223 00224 #ifdef __cplusplus 00225 } 00226 #endif 00227 00228 #endif