Beispiel #1
0
void c_nngetaspectd(int row, int col, double *aspect, int *ier)
{
   if (asflag == 0) {
     error_status = 28;
     ErrorHnd(error_status, "c_nngetaspectd", filee, "\n");
     *ier = 28;
     *aspect = -999.;
     return;
   }
   if (iscale == 1)
   {
     sprintf(emsg,"\n\n       Current automatically computed scaling "
                  "values:\n"
                  "         magx = %f\n         magy = %f\n"
                  "         magz = %f\n\n",
                  magx_auto, magy_auto, magz_auto);
     ErrorHnd(25, "c_nngetaspectd", filee, emsg);
     *ier = 25;
     *aspect = -999.;
     return;
   }
   if (curasd.crows == 0)
   {
     ErrorHnd(22, "c_nngetaspectd", filee, "\n");
     *ier = 22;
     *aspect = -999.;
     return;
   }
   if (row >= curasd.crows || row < 0)
   {
     sprintf(emsg,"\n  Requested row = %d (indices starting with one)\n",row+1);
     ErrorHnd(20, "c_nngetaspectd", filee, emsg);
     *ier = 20;
     *aspect = -999.;
     return;
   }
   if (col >= curasd.ccols || col < 0)
   {
     sprintf(emsg,"\n  Requested column = %d (indices starting with one)\n",
               col);
     ErrorHnd(21, "c_nngetaspectd", filee, emsg);
     *ier = 21;
     *aspect = -999.;
     return;
   }
   *ier = 0;
   *aspect = (curasd.aspect_outd)[row][col];
}
Beispiel #2
0
void NGCALLF(natgridd,NATGRIDD) (int *n, double *x, double *y, double *z, 
                int *nxg, int *nyg, double *xg, double *yg, double *zg,
                int *ier)
{
   ErrorHnd(29, "natgridd", filee, "\n");
   *ier = error_status;
   return;
}
Beispiel #3
0
void c_nnpntd(double x, double y, double *point)
{
   int   idum, nxi=3, nyi=3, ierr;
   double xdum[1], ydum[1], zdum[1], xi[3], yi[3], *out;

/*
 *  Check to see if the input point is within the gridded region
 *  set up in the initialization.
 */
   if ( (x < xstart) || (x > xend) || (y < ystart) || (y > yend) )
   {
      sprintf(emsg,"\n  Coordinate = (%f, %f)\n", x, y);
      ErrorHnd(27, "c_nnpntd", filee, emsg);
      return;
   } 
 
/*
 *  Set up a 3 x 3 gridded region with the desired coordinate in
 *  the middle.
 */
   xi[0] = x-0.05*(xend-xstart);
   xi[1] = x;
   xi[2] = x+0.05*(xend-xstart);
   yi[0] = y-0.05*(yend-ystart);
   yi[1] = y;
   yi[2] = y+0.05*(yend-ystart);

   out = c_natgridd(idum, xdum, ydum, zdum, nxi, nyi, xi, yi, &ierr);
   if (ierr != 0)
   {
      ErrorHnd(28, "c_nnpntd", filee, "\n");
      error_status = ierr;
      *point = -999.;
   }
   
   *point = out[3*1 +1];
}
Beispiel #4
0
/*
 *  Set values for double parameters.
 */
void c_nnsetrd(char *pnam, double dval)
{
   if (!strncmp(pnam,"bi",2) OR !strncmp(pnam,"BI",2) OR
            !strncmp(pnam,"bI",2) OR !strncmp(pnam,"Bi",2)) {
      if (dval < 1.) {
        bI = 1.;
      }
      else if (dval > 3.) {
        bI = 3.;
      }
      else {
        bI = dval;
      }
   }
   else if (!strncmp(pnam,"bj",2) OR !strncmp(pnam,"BJ",2) OR
            !strncmp(pnam,"bJ",2) OR !strncmp(pnam,"Bj",2)) {
      if (dval < 3.) {
        bJ = 3.;
      }
      else if (dval > 9.) {
        bJ = 9.;
      }
      else {
        bJ = dval;
      }
   }
   else if (!strncmp(pnam,"magx",4) OR !strncmp(pnam,"MAGX",4)) {
      magx = dval;
   }
   else if (!strncmp(pnam,"magy",4) OR !strncmp(pnam,"MAGY",4)) {
      magy = dval;
   }
   else if (!strncmp(pnam,"magz",4) OR !strncmp(pnam,"MAGZ",4)) {
      magz = dval;
   }
   else if (!strncmp(pnam,"hor",3) OR !strncmp(pnam,"HOR",3)) {
      horilap = dval;
   }
   else if (!strncmp(pnam,"ver",3) OR !strncmp(pnam,"VER",3)) {
      vertlap = dval;
   }
   else if (!strncmp(pnam,"nul",3) OR !strncmp(pnam,"NUL",3)) {
      nuldat = dval;
   }
   else {
      sprintf(emsg,"\n  Parameter name supplied is: %s\n",pnam);
      ErrorHnd(23, "c_nnsetrd", filee, emsg);
   }
}
Beispiel #5
0
void NGCALLF(nngetwtsd,NNGETWTSD) (int *numw, int *neighs, double *wts, double *px, double *py, double *pz)
{
   int i;

   if (igrad || !single_point) {
      ErrorHnd(31, "c_nngetwtsd", stderr, emsg);
   }
   c_nngetwtsd(numw, neighs, wts, px, py, pz);

/*
 *  Adjust the indices for Fortran.
 */
   for (i = 0; i < *numw; i++) {
     neighs[i]++;
   }
}
Beispiel #6
0
/*
 *  Get values for double parameters.
 */
void c_nngetrd(char *pnam, double *dval)
{
   if (!strncmp(pnam,"bi",2) OR !strncmp(pnam,"BI",2) OR
            !strncmp(pnam,"bI",2) OR !strncmp(pnam,"Bi",2)) {
      *dval = bI;
   }
   else if (!strncmp(pnam,"bj",2) OR !strncmp(pnam,"BJ",2) OR
            !strncmp(pnam,"bJ",2) OR !strncmp(pnam,"Bj",2)) {
      *dval = bJ;
   }
   else if (!strncmp(pnam,"magx",4) OR !strncmp(pnam,"MAGX",4)) {
      *dval = magx;
   }
   else if (!strncmp(pnam,"magy",4) OR !strncmp(pnam,"MAGY",4)) {
      *dval = magy;
   }
   else if (!strncmp(pnam,"magz",4) OR !strncmp(pnam,"MAGZ",4)) {
      *dval = magz;
   }
   else if (!strncmp(pnam,"hor",3) OR !strncmp(pnam,"HOR",3)) {
      *dval = horilap;
   }
   else if (!strncmp(pnam,"ver",3) OR !strncmp(pnam,"VER",3)) {
      *dval = vertlap;
   }
   else if (!strncmp(pnam,"nul",3) OR !strncmp(pnam,"NUL",3)) {
      *dval = nuldat;
   }
   else if (!strncmp(pnam,"xas",3) OR !strncmp(pnam,"XAS",3)) {
      *dval = magx_auto;
   }
   else if (!strncmp(pnam,"yas",3) OR !strncmp(pnam,"YAS",3)) {
      *dval = magy_auto;
   }
   else if (!strncmp(pnam,"zas",3) OR !strncmp(pnam,"ZAS",3)) {
      *dval = magz_auto;
   }
   else {
      sprintf(emsg,"\n  Parameter name supplied is: %s\n",pnam);
      ErrorHnd(23, "c_nngetrd", filee, emsg);
   }
}
Beispiel #7
0
/*
 *  Initialize single point interpolation mode.  This just
 *  does the regridding initialization and initial data analysis.
 */
void c_nnpntinitd(int n, double x[], double y[], double z[])
{
#define NXI 2
#define NYI 2

   double xi[NXI], yi[NYI], wtmp;

   single_point = 1; 
   first_single = 1;
   asflag = 0;
   horilap_save = horilap;
   vertlap_save = vertlap;
   horilap = -1.;
   vertlap = -1.;

/*
 *  Establish the gridded region to contain all of the input
 *  data points plus an extra 10% space around the border.
 */
   xi[0] = armind(n, x);
   xi[1] = armaxd(n, x);
   wtmp  = xi[1] - xi[0];
   xi[0] -= 0.1*wtmp;
   xi[1] += 0.1*wtmp;

   yi[0] = armind(n, y);
   yi[1] = armaxd(n, y);
   wtmp  = yi[1] - yi[0];
   yi[0] -= 0.1*wtmp;
   yi[1] += 0.1*wtmp;

   Initialized(n, x, y, NXI, NYI, xi, yi);

   if (ReadDatad(n,x,y,z) != 0) 
   {
      ErrorHnd(error_status, "c_nnpntinitd", filee, "\n");
   }
}
Beispiel #8
0
int ReadDatad(int numdat, double *xin, double *yin, double *zin)
{  
   double temp[3], minx, maxx, miny, maxy, xtmp, ytmp, ztmp;
   double qtxy, qtyx, qtzx, qtzy;
   int i0, i1, n0;

   bigtri[0][0] = bigtri[0][1] = bigtri[1][1] = bigtri[2][0] = -1;
   bigtri[1][0] = bigtri[2][1] = 5;

   if (rootdat EQ NULL) 
   {  
      rootdat  = IMakeDatum();
      if (error_status) return (error_status);

      rootsimp = IMakeSimp();
      if (error_status) return (error_status);

      roottemp = IMakeTemp();
      if (error_status) return (error_status);

      rootneig = IMakeNeig();
      if (error_status) return (error_status);

      rootdat->values[0] = rootdat->values[1]
                         = rootdat->values[2]
                         = 0;
   }
   else 
   {  
      FreeVecti(jndx);
      FreeMatrixd(points);
      FreeMatrixd(joints);
   }
   curdat = rootdat;
   datcnt = 0;
   minx = xstart - horilap;   maxx = xend + horilap;
   miny = ystart - vertlap;   maxy = yend + vertlap;

   for (n0 = 0 ; n0 < numdat ; n0++) {
      temp[0] = xin[n0];
      temp[1] = yin[n0];
      temp[2] = zin[n0];
      if (temp[0] > minx AND temp[0] < maxx AND 
          temp[1] > miny AND temp[1] < maxy) {
          if (curdat->nextdat EQ NULL) 
          {
             curdat->nextdat = IMakeDatum();
             if (error_status) return (error_status);
          }
          curdat = curdat->nextdat;
          datcnt++;
          for (i1 = 0; i1 < 3; i1++) 
             curdat->values[i1] = temp[i1];
      }
   }

   if (datcnt > 3)
   {   
      datcnt3 = datcnt + 3;
      jndx = IntVect(datcnt3);
      if (error_status) return (error_status);
      sumx = sumy = sumz = sumx2 = sumy2 = sumxy = sumxz = sumyz = 0;
      iscale = 0;
/*
 *  Calculate minimums and maximums of the input data accounting for
 *  the scale factors.
 *
 *  For the initial calculations, we have:
 *
 *      maxxy[0][0] = maximum x input data value
 *      maxxy[1][0] = minimum x input data value
 *      maxxy[0][1] = maximum y input data value
 *      maxxy[1][1] = minimum y input data value
 *      maxxy[0][2] = maximum z input data value
 *      maxxy[1][2] = minimum z input data value
 *
 */

data_limits:

      maxxy[0][0] =  maxxy[0][1] = maxxy[0][2] = 
                   -(maxxy[1][0] = maxxy[1][1] = maxxy[1][2] = BIGNUM);
      curdat = rootdat->nextdat;
      for (i0 = 0; i0 < datcnt; i0++)
      {
         xtmp = curdat->values[0] * magx;
         if (maxxy[0][0] < xtmp) 
             maxxy[0][0] = xtmp;  
         if (maxxy[1][0] > xtmp) 
             maxxy[1][0] = xtmp;  
         ytmp = curdat->values[1] * magy;
         if (maxxy[0][1] < ytmp) 
             maxxy[0][1] = ytmp;  
         if (maxxy[1][1] > ytmp) 
             maxxy[1][1] = ytmp;  
         ztmp = curdat->values[2] * magz;
         if (maxxy[0][2] < ztmp) 
             maxxy[0][2] = ztmp; 
         if (maxxy[1][2] > ztmp) 
             maxxy[1][2] = ztmp; 
         curdat  = curdat->nextdat;
      }
/*
 *  Modify the mins and maxs based on the scale factors and overlap regions.
 *  to get the actual minimums and maximums of the data under consideration.
 */
      if (maxxy[0][0] < maxx * magx) 
          maxxy[0][0] = maxx * magx; 
      if (maxxy[1][0] > minx * magx) 
          maxxy[1][0] = minx * magx; 
      if (maxxy[0][1] < maxy * magy) 
          maxxy[0][1] = maxy * magy; 
      if (maxxy[1][1] > miny * magy) 
          maxxy[1][1] = miny * magy; 
/*
 *  Calculate the extents in x, y, and z.
 *
 *      maxxy[0][0] = maximum x extent, including overlap regions.
 *      maxxy[0][1] = maximum y extent, including overlap regions.
 *      maxxy[0][2] = maximum z extent.
 */
      for (i0 = 0 ; i0 < 3 ; i0++) 
      {
         maxxy[0][i0] -= maxxy[1][i0];
      }
      maxhoriz = maxxy[0][0]; 
      if (maxhoriz < maxxy[0][1]) 
          maxhoriz = maxxy[0][1];
      wbit   = maxhoriz * EPSILON;
/*
 *  Calculate the ratio of the x extent by the y extent (qtxy) and
 *  the y extent by the x extent (qtyx) .
 */
      qtxy   = maxxy[0][0] / maxxy[0][1];
      qtyx  = 1./qtxy;
      if ( (qtxy > (2.+EPSILON)) OR (qtyx > (2.+EPSILON)) )
      {
         if (auto_scale) 
         {
/*
 *  Readjust the scaling and recompute the data limits.
 */ 
            iscale = 1;
            if (qtxy > (2+EPSILON) )
            {
               magy *= qtxy;
            }
            else
            {
               magx *= qtyx;
            }
            magx_auto = magx;
            magy_auto = magy;
            magz_auto = magz;
            goto data_limits;
         }
         else
         {
/*
 *  Issue a warning and turn off gradient estimation.
 */
            TooNarrow();
         }
      }

      if (igrad)
      {  
         qtzx = maxxy[0][2] / maxxy[0][0];
         qtzy = maxxy[0][2] / maxxy[0][1];
         if ( (qtzx > 60) OR (qtzy > 60) )
         {
            if (auto_scale) 
            {
/*
 *  Readjust the scaling and recompute the data limits.  The X and Y
 *  scales have been appropriately adjusted by the time you get here,
 *  so dividing magz by either qtzx or qtzy will bring it in line.
 */ 
               iscale = 1;
               magz *= 1./qtzx;
               magx_auto = magx;
               magy_auto = magy;
               magz_auto = magz;
               goto data_limits;
            }
            else
            {
/*
 *  Issue a warning and turn off gradient estimation.
 */
               TooSteep();
            }
         }
         if ( (qtzx < .017) OR (qtzy < .017) )
         {
            if (auto_scale) 
            {
/*
 *  Readjust the scaling and recompute the data limits.  The X and Y
 *  scales have been appropriately adjusted by the time you get here,
 *  so dividing magz by either qtzx or qtzy will bring it in line.
 */ 
               iscale = 1;
               magz *= 1./qtzx;
               magx_auto = magx;
               magy_auto = magy;
               magz_auto = magz;
               goto data_limits;
            }
            else
            {
/*
 *  Issue a warning and turn off gradient estimation.
 */
               TooShallow();
            }
         }
      }

      if (igrad) 
      {
         points = DoubleMatrix(datcnt+4, 6);
         if (error_status) return (error_status);
      }
      else
      {
         points = DoubleMatrix(datcnt+4, 3);
         if (error_status) return (error_status);
      }
      joints = DoubleMatrix(datcnt3, 2); 
      if (error_status) return (error_status);
      curdat = rootdat->nextdat;
      rootdat->nextdat = NULL;
      for (i0 = 0; i0 < datcnt; i0++)
      {  sumx += points[i0][0] = 
            curdat->values[0] * magx;
         sumx2 += SQ(points[i0][0]);
         sumy += points[i0][1] = 
            curdat->values[1] * magy;
         sumy2 += SQ(points[i0][1]);
         sumxy += points[i0][0] * points[i0][1];
         if (densi) points[i0][2] = 1;
         else
         {  sumz += points[i0][2] = 
               curdat->values[2] * magz;
            sumxz += points[i0][0] * points[i0][2];
            sumyz += points[i0][1] * points[i0][2];
         }
         holddat = curdat;
         curdat = curdat->nextdat;
         free(holddat);
      }
      det = (datcnt * (sumx2 * sumy2 - sumxy * sumxy))
          - (sumx * (sumx * sumy2 - sumy * sumxy))
          + (sumy * (sumx * sumxy - sumy * sumx2));
      aaa = ((sumz * (sumx2 * sumy2 - sumxy * sumxy))
          - (sumxz * (sumx * sumy2 - sumy * sumxy))
          + (sumyz * (sumx * sumxy - sumy * sumx2))) / 
         det;
      bbb = 
         ((datcnt * (sumxz * sumy2 - sumyz * sumxy))
          - (sumz * (sumx * sumy2 - sumy * sumxy))
          + (sumy * (sumx * sumyz - sumy * sumxz))) / 
         det;
      ccc = 
         ((datcnt * (sumx2 * sumyz - sumxy * sumxz))
          - (sumx * (sumx * sumyz - sumy * sumxz))
          + (sumz * (sumx * sumxy - sumy * sumx2))) / 
         det;


      for (i0 = 0 ; i0 < 3 ; i0++)
      {  points[datcnt+i0][0] = maxxy[1][0] + 
            bigtri[i0][0] * maxxy[0][0] * RANGE;
         points[datcnt+i0][1] = maxxy[1][1] + 
            bigtri[i0][1] * maxxy[0][1] * RANGE;
         if (densi) 
            points[datcnt+i0][2] = 1;
         else 
            points[datcnt+i0][2] =
            aaa + bbb * points[datcnt+i0][0] + 
            ccc * points[datcnt+i0][1];
      }
      rootdat = NULL;
   }
   else
   {  
      ErrorHnd(1, "ReadData", filee, "\n");
      error_status = 1;
      return (error_status);
   }

/*
 *  Determine if any input data coordinates are duplicated.
 */
   if (nndup == 1) {
      for (i0 = 0 ; i0 < datcnt ; i0++) {
         for (i1 = i0+1 ; i1 < datcnt ; i1++) {
            if ( (points[i0][0] == points[i1][0]) &&
               (points[i0][1] == points[i1][1]) )
            {
               sprintf(emsg,"\n  Coordinates %d and %d are identical.\n",i0,i1);
               ErrorHnd(2, "ReadData", filee, emsg);
               error_status = 2;
               return (error_status);
            }
         }
      }
   }

/*
 *  Introduce a small random perturbation into the coordinate values.
 */
   srand(367);     
   for (i0 = 0 ; i0 < datcnt ; i0++)
   {
      for (i1 = 0 ; i1 < 2 ; i1++)
      {
         points[i0][i1] += wbit * (0.5 - (double)rand() / RAND_MAX);
      }
   }
   if (sdip OR igrad)
   {  
      piby2 = 2 * atan(1.0);
      nn_pi = piby2 * 2;
      piby32 = 3 * piby2;
      rad2deg = 90 / piby2;
   }
   return (0);
}
Beispiel #9
0
void NGCALLF(nnpntendd,NNPNTENDD) ()
{
   ErrorHnd(29, "nnpntendd", filee, "\n");
}
Beispiel #10
0
void NGCALLF(nnpntd,NNPNTD) (double *x, double *y, double *point)
{
   ErrorHnd(29, "nnpntd", filee, "\n");
}
Beispiel #11
0
void NGCALLF(nnpntinitd,NNPNTINITD) (int *n, double *x, double *y, double *z)
{
   ErrorHnd(29, "nnpntinitd", filee, "\n");
}
Beispiel #12
0
void NGCALLF(nngetaspectd,NNGETASPECTD) (int *row, int *col, 
             double *aspect, int *ier)
{
   ErrorHnd(29, "nngetaspectd", filee, "\n");
   *ier = error_status;
}
Beispiel #13
0
void NGCALLF(nngetsloped,NNGETSLOPED) (int *row, int *col, 
             double *slope, int *ier)
{
   ErrorHnd(29, "nngetsloped", filee, "\n");
   *ier = error_status;
}
Beispiel #14
0
void NGCALLF(nngetrd,NNGETRD) (char *pnam, double *rval)
{
   ErrorHnd(29, "nngetrd", filee, "\n");
}