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_sobs_sqlite3.h 00022 \brief SQLite3 user implementation of the stochastic observer interface. 00023 */ 00024 00025 #ifndef CTA_SOBS_SQLITE3_H 00026 #define CTA_SOBS_SQLITE3_H 00027 00028 #include "cta_f77blas.h" 00029 #include "cta_datatypes.h" 00030 #include "cta_handles.h" 00031 #include "cta_functions.h" 00032 #include "cta_util_sqlite3.h" 00033 #include "cta_sobs.h" 00034 #include "cta_obsdescr.h" 00035 #include <sqlite3.h> 00036 00037 typedef struct { 00038 CTAI_util_sqlite3_database *database; 00039 char* condition; 00040 int nstations; 00041 int nmeasr; 00042 int * stations; 00043 } CTAI_SObs_sqlite3; 00044 00045 00046 #ifdef __cplusplus 00047 extern "C" { 00048 #endif 00049 00050 /** \brief Initialization function for defining the SObs_sqlite3 class. 00051 * 00052 * \return no return value 00053 */ 00054 void CTA_SObs_sqlite3_initialise(); 00055 00056 00057 /** \brief Implementation function that is part of object create process 00058 * 00059 * \param memsize O receives size of new CTAI_SObs_sqlite3 object 00060 * \param retval O receives return value 00061 * \return no return value 00062 */ 00063 void CTAI_SObs_sqlite3_Create_Size( int *memsize,int *retval ); 00064 00065 00066 /** \brief Implementation function that is part of object create process. 00067 * 00068 * \note userdata must contain handle of COSTA string giving the SQLITE3 database name.\n 00069 * 00070 * \param x IO pointer to object data of stochastic observer 00071 * \param userdata I pointer to user data 00072 * \param retval O receives return value 00073 * \return no return value 00074 */ 00075 void CTAI_SObs_sqlite3_Create_Init(CTAI_SObs_sqlite3 *x, 00076 CTA_Handle userdata, int *retval); 00077 00078 00079 /** \brief Create a new stochastic observer that is subset of existing stochastic observer. 00080 * 00081 * \note userdata must contain handle of COSTA string giving the selection condition.\n 00082 * \note This function fills in the object data of the new stochastic observer. The handle is created by CTA_SObs_CreateSel(). 00083 * 00084 * \param obsin I pointer to object data of the existing stochastic observer 00085 * \param userdata I pointer to userdata 00086 * \param obsout O pointer to object data of the new COSTA-stochastic observer, must exist before calling 00087 * \param retval I receives return value 00088 * \return no return value 00089 */ 00090 void CTAI_SObs_sqlite3_CreateSel( CTAI_SObs_sqlite3 *obsin, 00091 CTA_Handle *userdata, CTAI_SObs_sqlite3 *obsout, int *retval); 00092 00093 00094 /** \brief Count the number of measurements 00095 * 00096 * \param x I pointer to object data of stochastic observer 00097 * \param nmeasr O receives number of measurements 00098 * \param retval O receives the return value 00099 * \return no return value 00100 */ 00101 void CTAI_SObs_sqlite3_Count( CTAI_SObs_sqlite3 *x, int *nmeasr, 00102 int *retval); 00103 00104 00105 /** \brief Get a vector with the measurements. 00106 * 00107 * \param x I pointer to object data of stochastic observer 00108 * \param hvec O handle of vector that receives the measurements, must exist before calling 00109 * \param retval O receives the return value 00110 * \return no return value 00111 */ 00112 void CTAI_SObs_sqlite3_GetVals( CTAI_SObs_sqlite3 *x, CTA_Vector *hvec, 00113 int *retval); 00114 00115 00116 /** \brief Get times associated with the measurements. 00117 * 00118 * \param x I pointer to object data of stochastic observer 00119 * \param hvec O handle of vector that receives the associated times, must exist before calling 00120 * \param retval O receives the return value 00121 * \return no return value 00122 */ 00123 void CTAI_SObs_sqlite3_GetTimes( CTAI_SObs_sqlite3 *x, CTA_Vector *hvec, 00124 int *retval); 00125 00126 00127 /** \brief Get variance of probability density function of the mesurements. 00128 * 00129 * \param x I pointer to object data of stochastic observer 00130 * \param hvec I handle of the vector that receives the variances, must exist before calling 00131 * \param returnvar O flag: TRUE for getting variance, FALSE for getting standard deviation 00132 * \param retval O receives return value 00133 * \return no return value 00134 */ 00135 void CTAI_SObs_sqlite3_GetVariances( CTAI_SObs_sqlite3 *x, 00136 CTA_Vector *hvec, int *returnvar, int *retval); 00137 00138 00139 /** \brief Draw random values (measurements) according to the probability density 00140 * function of the mesurements. 00141 * 00142 * \param x I pointer to object data of stochastic observer 00143 * \param hvec O handle of vector that receives the draw (measurements); must exist before calling 00144 * \param retval O receives return value 00145 * \return no return value 00146 */ 00147 void CTAI_SObs_sqlite3_GetRealisation( CTAI_SObs_sqlite3 *x, 00148 CTA_Vector *hvec, int *retval); 00149 00150 00151 /** \brief Get covariance matrix of probability density function of the measurements. 00152 * 00153 * \param x I pointer to object data of stochastic observer 00154 * \param hmat O handle of matrix that receives the covariance matrix; must exist before calling 00155 * \param retval O receives return value 00156 * \return no return value 00157 */ 00158 void CTAI_SObs_sqlite3_GetCovMat( CTAI_SObs_sqlite3 *x, CTA_Matrix *hmat, 00159 int *retval); 00160 00161 00162 /** \brief Export a CTAI_SObs object to file or standard output. 00163 * 00164 * \note Supported:\n 00165 * output to file (userdata must contain handle of COSTA file)\n 00166 * 00167 * \param x I pointer to object data of stochastic observer 00168 * \param userdata I user data 00169 * \param retval O receives return value 00170 * \return no return value 00171 */ 00172 void CTAI_SObs_sqlite3_export( CTAI_SObs_sqlite3 *x, CTA_Handle *userdata, 00173 int *retval); 00174 00175 00176 /** \brief Free the object data and associated resources. 00177 * 00178 * \param x I pointer to object data of stochastic observer 00179 * \param retval O receives return value 00180 * \return no return value 00181 */ 00182 void CTAI_SObs_sqlite3_Free( CTAI_SObs_sqlite3 *x, int *retval); 00183 00184 #ifdef __cplusplus 00185 } 00186 #endif 00187 00188 #endif