Changeset 12230


Ignore:
Timestamp:
05/10/12 14:19:39 (13 years ago)
Author:
Mathieu Morlighem
Message:

Added power variogram

Location:
issm/trunk-jpl/src/c
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/Container/Observations.cpp

    r12229 r12230  
    150150
    151151}/*}}}*/
     152/*FUNCTION Observations::Variomap{{{*/
     153void Observations::Variomap(double* gamma,double *x,int n){
     154
     155        /*Output and Intermediaries*/
     156        int          nobs,i,j,k;
     157        double       range;
     158        Observation *observation1 = NULL;
     159        Observation *observation2 = NULL;
     160        int         *indices      = NULL;
     161
     162        int *counter= (int*)xmalloc(n*sizeof(int));
     163        for(j=0;j<n;j++) counter[j] = 0;
     164        for(j=0;j<n;j++) gamma[j]   = 0.0;
     165
     166        for(i=0;i<this->Size();i++){
     167                observation1=(Observation*)this->GetObjectByOffset(i);
     168
     169                for(j=0;j<n;j++){
     170                        range=x[j]; _assert_(range>=0.);
     171
     172                        /*Find all observations that are in range*/
     173                        this->quadtree->RangeSearch(&indices,&nobs,observation1->x,observation1->y,range);
     174
     175                        for (k=0;k<nobs;k++){
     176                                observation2 = (Observation*)this->GetObjectByOffset(indices[k]);
     177                                gamma[j]    += 1./2.*pow(observation1->value - observation2->value,2.);
     178                        }
     179
     180                        counter[j] += nobs;
     181                        xfree((void**)&indices);
     182                }
     183        }
     184
     185        /*Normalize semivariogram*/
     186        for(j=0;j<n;j++){
     187                if(counter[j]) gamma[j] = gamma[j]/double(counter[j]);
     188        }
     189
     190        /*Assign output pointer*/
     191        xfree((void**)&counter);
     192}/*}}}*/
  • issm/trunk-jpl/src/c/Container/Observations.h

    r12229 r12230  
    2525                void ObservationList(double **px,double **py,double **pobs,int* pnobs,double x_interp,double y_interp,double range);
    2626                void QuadtreeColoring(double* A,double *x,double *y,int n);
     27                void Variomap(double* gamma,double *x,int n);
    2728
    2829};
  • issm/trunk-jpl/src/c/Makefile.am

    r12221 r12230  
    619619                                                ./objects/Kriging/SphericalVariogram.h\
    620620                                                ./objects/Kriging/SphericalVariogram.cpp\
     621                                                ./objects/Kriging/PowerVariogram.h\
     622                                                ./objects/Kriging/PowerVariogram.cpp\
    621623                                                ./objects/Kriging/Quadtree.h\
    622624                                                ./objects/Kriging/Quadtree.cpp\
  • issm/trunk-jpl/src/c/modules/Krigingx/Krigingx.cpp

    r12229 r12230  
    5454        if(strcmp(output,"quadtree")==0){
    5555                observations->QuadtreeColoring(predictions,x_interp,y_interp,n_interp);
     56                *ppredictions=predictions;
     57                return 1;
     58        }
     59        if(strcmp(output,"variomap")==0){
     60                observations->Variomap(predictions,x_interp,n_interp);
    5661                *ppredictions=predictions;
    5762                return 1;
     
    129134                else if(strcmp(model,"exponential")==0) variogram = new ExponentialVariogram(options);
    130135                else if(strcmp(model,"spherical")==0)   variogram = new SphericalVariogram(options);
    131                 else _error_("variogram %s not supported yet (list of supported variogram: gaussian, exponential and spherical)",model);
     136                else if(strcmp(model,"power")==0)       variogram = new PowerVariogram(options);
     137                else _error_("variogram %s not supported yet (list of supported variogram: gaussian, exponential, spherical and power)",model);
    132138        }
    133139        else variogram = new GaussianVariogram(options);
  • issm/trunk-jpl/src/c/objects/Kriging/Quadtree.cpp

    r12229 r12230  
    433433
    434434        /*Return 2 if the this box is included in the range*/
    435         if(
    436                                 this->xcenter+this->length/2 <= x+range &&
    437                                 this->ycenter+this->length/2 <= y+range &&
    438                                 this->xcenter-this->length/2 >= x-range &&
    439                                 this->ycenter-this->length/2 >= y-range
    440           ) return 2;
     435        if(this->xcenter+this->length/2 <= x+range &&
     436                this->ycenter+this->length/2 <= y+range &&
     437                this->xcenter-this->length/2 >= x-range &&
     438                this->ycenter-this->length/2 >= y-range) return 2;
    441439
    442440        /*This is a simple overlap*/
  • issm/trunk-jpl/src/c/objects/objects.h

    r12218 r12230  
    178178#include "./Kriging/ExponentialVariogram.h"
    179179#include "./Kriging/SphericalVariogram.h"
     180#include "./Kriging/PowerVariogram.h"
    180181#include "./Kriging/Quadtree.h"
    181182#include "./Kriging/Observation.h"
Note: See TracChangeset for help on using the changeset viewer.