GeostatisticalModelSpherical.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/sa/core/GeostatisticalModelSpherical.cpp
22 
23  \brief This file contains a class that represents the geostatistical spherical model.
24 
25  \reference Adapted from TerraLib4.
26 */
27 
28 // Terralib Includes
30 
32 {
34 }
35 
37 
38 boost::numeric::ublas::matrix<double> te::sa::GeostatisticalModelSpherical::calculate(boost::numeric::ublas::matrix<double> matrix)
39 {
40  //get the number of lags used
41  std::size_t nLags = matrix.size1();
42 
43  //create the model matrix
44  boost::numeric::ublas::matrix<double> m(nLags, 2);
45 
46  //fill matrix
47  std::vector<double> sphericalValues;
48 
49  for(std::size_t t= 0; t < nLags; ++t)
50  {
51  if(matrix(t, 0) == 0.)
52  {
53  sphericalValues.push_back(m_nugget);
54  }
55  else
56  {
57  sphericalValues.push_back(m_nugget + (m_sill - m_nugget) * (1.5 * (std::abs(matrix(t, 0)) / m_range)) - 0.5 * (std::pow(std::abs(matrix(t, 0)) / m_range, 3)));
58  }
59  m(t, 0) = matrix(t, 0);
60  m(t, 1) = sphericalValues[t];
61  }
62 
63  return m;
64 }
double m_nugget
The height of the jump of the semivariogram at the discontinuity at the origin.
double m_sill
Limit of the variogram tending to infinity lag distances.
virtual boost::numeric::ublas::matrix< double > calculate(boost::numeric::ublas::matrix< double > matrix)
Function to calculate the geostatistical information from model.
This file contains a class that represents the geostatistical spherical model.
virtual ~GeostatisticalModelSpherical()
Virtual destructor.
te::sa::GeostatisticalModelType m_type
Attribute used to define the model type used.
double m_range
The distance in which the difference of the variogram from the sill becomes negligible.