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_netcdf.h 00022 \brief Netcdf user implementation of the stochastic observer interface. 00023 */ 00024 00025 #ifndef CTA_SOBS_NETCDF_H 00026 #define CTA_SOBS_NETCDF_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_sobs.h" 00033 #include "cta_obsdescr.h" 00034 #if HAVE_LIBNETCDF 00035 //#include <netcdf.h> 00036 #endif 00037 00038 typedef struct { 00039 int nusers; 00040 int ncid; 00041 char *dbname; 00042 } CTAI_OMI_database; 00043 00044 typedef struct { 00045 CTAI_OMI_database *database; 00046 int nstations; 00047 double timeoffset; 00048 int nmeasr; 00049 int nmeasr_orig; //number of observations in the netcdf-file 00050 CTA_RelTable selectionReltab; 00051 CTA_Time tspan; 00052 float bb_lon[2]; 00053 float bb_lat[2]; 00054 } CTAI_SObs_netcdf; 00055 00056 00057 #ifdef __cplusplus 00058 extern "C" { 00059 #endif 00060 00061 /** \brief Initialization function for defining the SObs_netcdf class. 00062 * 00063 * \return no return value 00064 */ 00065 void CTA_SObs_netcdf_initialise(); 00066 00067 00068 /** \brief Implementation function that is part of object create process 00069 * 00070 * \param memsize O receives size of new CTAI_SObs_netcdf object 00071 * \param retval O receives return value 00072 * \return no return value 00073 */ 00074 void CTAI_SObs_netcdf_Create_Size( int *memsize,int *retval ); 00075 00076 00077 /** \brief Implementation function that is part of object create process. 00078 * 00079 * \note userdata must contain handle of COSTA string giving the NETCDF database name.\n 00080 * 00081 * \param x IO pointer to object data of stochastic observer 00082 * \param userdata I pointer to user data 00083 * \param retval O receives return value 00084 * \return no return value 00085 */ 00086 void CTAI_SObs_netcdf_Create_Init(CTAI_SObs_netcdf *x, 00087 CTA_Handle userdata, int *retval); 00088 00089 00090 /** \brief Create a new stochastic observer that is subset of existing stochastic observer. 00091 * 00092 * \note userdata must contain handle of COSTA string giving the selection condition.\n 00093 * \note This function fills in the object data of the new stochastic observer. The handle is created by CTA_SObs_CreateSel(). 00094 * 00095 * \param obsin I pointer to object data of the existing stochastic observer 00096 * \param userdata I pointer to userdata 00097 * \param obsout O pointer to object data of the new COSTA-stochastic observer, must exist before calling 00098 * \param retval I receives return value 00099 * \return no return value 00100 */ 00101 void CTAI_SObs_netcdf_CreateSel( CTAI_SObs_netcdf *obsin, 00102 CTA_Handle *userdata, CTAI_SObs_netcdf *obsout, int *retval); 00103 00104 00105 /** \brief Count the number of measurements 00106 * 00107 * \param x I pointer to object data of stochastic observer 00108 * \param nmeasr O receives number of measurements 00109 * \param retval O receives the return value 00110 * \return no return value 00111 */ 00112 void CTAI_SObs_netcdf_Count( CTAI_SObs_netcdf *x, int *nmeasr, 00113 int *retval); 00114 00115 00116 /** \brief Get a vector 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 measurements, must exist before calling 00120 * \param retval O receives the return value 00121 * \return no return value 00122 */ 00123 void CTAI_SObs_netcdf_GetVals( CTAI_SObs_netcdf *x, CTA_Vector *hvec, 00124 int *retval); 00125 00126 00127 /** \brief Get times associated with the measurements. 00128 * 00129 * \param x I pointer to object data of stochastic observer 00130 * \param hvec O handle of vector that receives the associated times, must exist before calling 00131 * \param retval O receives the return value 00132 * \return no return value 00133 */ 00134 void CTAI_SObs_netcdf_GetTimes( CTAI_SObs_netcdf *x, CTA_Vector *hvec, 00135 int *retval); 00136 00137 00138 /** \brief Get variance of probability density function of the mesurements. 00139 * 00140 * \param x I pointer to object data of stochastic observer 00141 * \param hvec I handle of the vector that receives the variances, must exist before calling 00142 * \param returnvar O flag: TRUE for getting variance, FALSE for getting standard deviation 00143 * \param retval O receives return value 00144 * \return no return value 00145 */ 00146 void CTAI_SObs_netcdf_GetVariances( CTAI_SObs_netcdf *x, 00147 CTA_Vector *hvec, int *returnvar, int *retval); 00148 00149 00150 /** \brief Draw random values (measurements) according to the probability density 00151 * function of the mesurements. 00152 * 00153 * \param x I pointer to object data of stochastic observer 00154 * \param hvec O handle of vector that receives the draw (measurements); must exist before calling 00155 * \param retval O receives return value 00156 * \return no return value 00157 */ 00158 void CTAI_SObs_netcdf_GetRealisation( CTAI_SObs_netcdf *x, 00159 CTA_Vector *hvec, int *retval); 00160 00161 00162 /** \brief Get covariance matrix of probability density function of the measurements. 00163 * 00164 * \param x I pointer to object data of stochastic observer 00165 * \param hmat O handle of matrix that receives the covariance matrix; must exist before calling 00166 * \param retval O receives return value 00167 * \return no return value 00168 */ 00169 void CTAI_SObs_netcdf_GetCovMat( CTAI_SObs_netcdf *x, CTA_Matrix *hmat, 00170 int *retval); 00171 00172 00173 /** \brief Export a CTAI_SObs object to file or standard output. 00174 * 00175 * \note Supported:\n 00176 * output to file (userdata must contain handle of COSTA file)\n 00177 * 00178 * \param x I pointer to object data of stochastic observer 00179 * \param userdata I user data 00180 * \param retval O receives return value 00181 * \return no return value 00182 */ 00183 void CTAI_SObs_netcdf_export( CTAI_SObs_netcdf *x, CTA_Handle *userdata, 00184 int *retval); 00185 00186 00187 /** \brief Free the object data and associated resources. 00188 * 00189 * \param x I pointer to object data of stochastic observer 00190 * \param retval O receives return value 00191 * \return no return value 00192 */ 00193 void CTAI_SObs_netcdf_Free( CTAI_SObs_netcdf *x, int *retval); 00194 00195 #ifdef __cplusplus 00196 extern } 00197 #endif 00198 00199 #endif 00200