slimTpxo.h 2.53 KB
Newer Older
lambrechts's avatar
lambrechts committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#ifndef _SLIM_TPXO_H_
#define _SLIM_TPXO_H_
#include "slimStructData.h"
#include "dgDofContainer.h"
#include "dgGroupOfElements.h"
template < class t > inline t pow2(t x)
{
  return x * x;
}
#ifdef HAVE_NETCDF
void astrol( double time, double &s, double &h, double &p, double &N);
void astronomical_argument_and_nodal_correction(double time1, double *arg, double *f);


/**Reconstruct tidal signal from the global ocean tidal model tpxo in the netcdf format*/

class slimFunctionTpxo: public function {
	public:
	double *o,*d;
	int *n;
	std::vector<slimStructDataContainerSimple*> containerAmp, containerPha;
	slimStructDataContainerSimple *containerAmpTest;
	slimStructDataContainerSimple **containerAmpBis;
	std::vector<double*> dataAmp, dataPha;
	std::vector<std::string> compList; //list of the tidal constituents
	std::vector<double> freq,astro0; //frequencies of the tide and initial astronomical argument
	std::vector<int> indiceNodal; //indice giving the location of the tidal constituant in the argument routine
  std::vector<dgDofContainer*> ampDofContainers, phaDofContainers;
  std::vector<fullMatrix<double> > ampFullMatrices, phaFullMatrices;
30
  const functor *_coordFunction;
lambrechts's avatar
lambrechts committed
31
32
33
	slimStructDataInterpolatorMultilinear *interpAmp,*interpPha;
  fullMatrix<double> coordF,timeF;

thomas's avatar
thomas committed
34
	size_t NC; //number of constituants
lambrechts's avatar
lambrechts committed
35
36
37
38
	double *astro,*nodal;
  time_t relTime1992;
	bool lon_0_360, _useDofContainers;
/**fileName to a netcdf file containing tidal harmonical downloaded at http://volkov.oce.orst.edu/tides/, amplitudeName/phaseName/lonName/latName are the names of the variable refering the real amplitude/real phase/longitude name/latitude name in the netcdf file (see ncdump -h fileName) */
39
	slimFunctionTpxo(std::string fileName,std::string amplitudeName, std::string phaseName, std::string lonName, std::string latName, const functor *coordFunction = NULL, const functor *timeFunction = NULL);
lambrechts's avatar
lambrechts committed
40
41
  void call(dataCacheMap *m,fullMatrix<double> &val);
/**coordFunction is a function returning the coordinate vector (lonLatDegrees for example) and timeFunction is a function returning the absolute time */
vallaeys's avatar
vallaeys committed
42
  void setCoordAndTimeFunctions(const functor *coordFunction,const functor *timeFunction){
lambrechts's avatar
lambrechts committed
43
44
45
46
47
48
49
50
51
52
53
    setArgument(coordF,coordFunction);
    setArgument(timeF,timeFunction);
    _coordFunction=coordFunction;
  }
	void addMask(double *dataNoMask, double *dataMask, int nlon, int nlat);
  //interpolate the amplitude and phase on dofs that are used instead of the interpolation at each time step
  void useDofContainers(dgGroupCollection *groups);
	~slimFunctionTpxo();
};
#endif
#endif