Changeset 14049


Ignore:
Timestamp:
11/29/12 08:09:39 (12 years ago)
Author:
Mathieu Morlighem
Message:

NEW: Added minimum curvature interpolation

File:
1 edited

Legend:

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

    r14048 r14049  
    426426/*FUNCTION Observations::InterpolationV4{{{*/
    427427void Observations::InterpolationV4(IssmPDouble *pprediction,IssmPDouble x_interp,IssmPDouble y_interp,IssmPDouble radius,int mindata,int maxdata){
     428        /* Reference:  David T. Sandwell, Biharmonic spline interpolation of GEOS-3
     429         * and SEASAT altimeter data, Geophysical Research Letters, 2, 139-142,
     430         * 1987.  Describes interpolation using value or gradient of value in any
     431         * dimension.*/
    428432
    429433        /*Intermediaries*/
     
    435439        IssmPDouble *Green   = NULL;
    436440        IssmPDouble *weights = NULL;
    437         IssmPDouble *d       = NULL;
     441        IssmPDouble *g       = NULL;
    438442
    439443        /*Some checks*/
     
    455459                /*Allocate intermediary matrix and vectors*/
    456460                Green = xNew<IssmPDouble>(n_obs*n_obs);
    457                 d     = xNew<IssmPDouble>(n_obs);
     461                g     = xNew<IssmPDouble>(n_obs);
    458462
    459463                /*First: distance vector*/
    460464                for(i=0;i<n_obs;i++){
    461                         d[i] = sqrt( (x[i]-x_interp)*(x[i]-x_interp) + (y[i]-y_interp)*(y[i]-y_interp) );
     465                        h = sqrt( (x[i]-x_interp)*(x[i]-x_interp) + (y[i]-y_interp)*(y[i]-y_interp) );
     466                        if(h>0){
     467                                g[i] = h*h*(log(h)-1.);
     468                        }
     469                        else{
     470                                g[i] = 0.;
     471                        }
    462472                }
    463473
     
    483493#endif
    484494
    485                 /*ok now we can interpolate with these weights*/
    486 
    487                 _error_("Not implemented yet");
     495                /*Interpolate*/
     496                prediction = 0;
     497                for(i=0;i<n_obs;i++) prediction += weights[i]*g[i];
     498
    488499        }
    489500
     
    493504        xDelete<IssmPDouble>(y);
    494505        xDelete<IssmPDouble>(obs);
     506        xDelete<IssmPDouble>(Green);
     507        xDelete<IssmPDouble>(g);
     508        xDelete<IssmPDouble>(weights);
    495509}/*}}}*/
    496510/*FUNCTION Observations::QuadtreeColoring{{{*/
Note: See TracChangeset for help on using the changeset viewer.