Ice Sheet System Model
4.18
Code documentation
src
c
classes
kriging
GaussianVariogram.cpp
Go to the documentation of this file.
1
5
#ifdef HAVE_CONFIG_H
6
#include <config.h>
7
#else
8
#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
9
#endif
10
11
#include "../classes.h"
12
#include "../../shared/shared.h"
13
14
/*GaussianVariogram constructors and destructor*/
15
GaussianVariogram::GaussianVariogram
(){
/*{{{*/
16
this->
nugget
= 0.2;
17
this->
sill
= 1;
18
this->
range
=
SQRT3
;
19
return
;
20
}
21
/*}}}*/
22
GaussianVariogram::GaussianVariogram
(
Options
* options){
/*{{{*/
23
24
/*Defaults*/
25
this->
nugget
= 0.2;
26
this->
sill
= 1;
27
this->
range
=
SQRT3
;
28
29
/*Overwrite from options*/
30
if
(options->
GetOption
(
"nugget"
)) options->
Get
(&this->
nugget
,
"nugget"
);
31
if
(options->
GetOption
(
"sill"
)) options->
Get
(&this->
sill
,
"sill"
);
32
if
(options->
GetOption
(
"range"
)) options->
Get
(&this->
range
,
"range"
);
33
34
/*Checks*/
35
if
(
nugget
==
sill
)
_error_
(
"nugget and sill cannot be equal (constant semivariogram not allowed)"
);
36
}
37
/*}}}*/
38
GaussianVariogram::~GaussianVariogram
(){
/*{{{*/
39
return
;
40
}
41
/*}}}*/
42
43
/*Object virtual functions definitions:*/
44
Object
*
GaussianVariogram::copy
(
void
){
/*{{{*/
45
return
new
GaussianVariogram
(*
this
);
46
}
47
/*}}}*/
48
void
GaussianVariogram::Echo
(
void
){
/*{{{*/
49
_printf_
(
"GaussianVariogram\n"
);
50
_printf_
(
" nugget: "
<< this->
nugget
<<
"\n"
);
51
_printf_
(
" sill : "
<< this->
sill
<<
"\n"
);
52
_printf_
(
" range : "
<< this->
range
<<
"\n"
);
53
}
54
/*}}}*/
55
56
/*Variogram function*/
57
double
GaussianVariogram::Covariance
(
double
deltax,
double
deltay){
/*{{{*/
58
/*The covariance can be deduced from the variogram from the following
59
* relationship:
60
* 2 gamma = C(x,x) + C(y,y) -2 C(x,y)
61
* so
62
* C(h) = sill - gamma */
63
double
h2,a,cova;
64
65
/*Calculate length square*/
66
h2=deltax*deltax + deltay*deltay;
67
68
/*If h is too small, return sill*/
69
if
(h2<0.0000001)
return
sill
;
70
71
/*compute covariance*/
72
a = 1./3.;
73
cova = (
sill
-
nugget
)*exp(-h2/(a*
range
*
range
));
74
75
return
cova;
76
}
77
/*}}}*/
78
double
GaussianVariogram::SemiVariogram
(
double
deltax,
double
deltay){
/*{{{*/
79
/*http://en.wikipedia.org/wiki/Variogram*/
80
double
h2,a,gamma;
81
82
/*Calculate length square*/
83
h2=deltax*deltax + deltay*deltay;
84
85
/*return semi-variogram*/
86
a = 1./3.;
87
gamma = (
sill
-
nugget
)*(1.-exp(-h2/(a*
range
*
range
))) +
nugget
;
88
89
//if(h2>1000*1000) _printf_("gamma = " << gamma << " h= " << sqrt(h2) << "\n");
90
_printf_
(
"h = "
<< sqrt(h2) <<
" gamma = "
<< gamma <<
"\n"
);
91
return
gamma;
92
}
93
/*}}}*/
Options
Definition:
Options.h:9
GaussianVariogram::Covariance
double Covariance(double deltax, double deltay)
Definition:
GaussianVariogram.cpp:57
_printf_
#define _printf_(StreamArgs)
Definition:
Print.h:22
Object
Definition:
Object.h:13
GaussianVariogram::sill
double sill
Definition:
GaussianVariogram.h:16
Options::Get
void Get(OptionType *pvalue, const char *name)
Definition:
Options.h:21
Options::GetOption
Option * GetOption(const char *name)
Definition:
Options.cpp:67
_error_
#define _error_(StreamArgs)
Definition:
exceptions.h:49
GaussianVariogram::~GaussianVariogram
~GaussianVariogram()
Definition:
GaussianVariogram.cpp:38
GaussianVariogram::SemiVariogram
double SemiVariogram(double deltax, double deltay)
Definition:
GaussianVariogram.cpp:78
GaussianVariogram::nugget
double nugget
Definition:
GaussianVariogram.h:15
GaussianVariogram::copy
Object * copy()
Definition:
GaussianVariogram.cpp:44
GaussianVariogram::GaussianVariogram
GaussianVariogram()
Definition:
GaussianVariogram.cpp:15
SQRT3
#define SQRT3
Definition:
constants.h:10
GaussianVariogram::Echo
void Echo()
Definition:
GaussianVariogram.cpp:48
GaussianVariogram::range
double range
Definition:
GaussianVariogram.h:17
Generated on Thu Jul 2 2020 08:09:17 for Ice Sheet System Model by
1.8.19