(file) Return to sw_functions.c CVS log (file) (dir) Up to [Development] / JSOC / proj / sharp / apps

Diff for /JSOC/proj/sharp/apps/sw_functions.c between version 1.22 and 1.23

version 1.22, 2013/11/11 23:21:21 version 1.23, 2014/02/18 19:50:19
Line 1034  int computeShearAngle(float *bx_err, flo
Line 1034  int computeShearAngle(float *bx_err, flo
         return 0;         return 0;
 } }
  
   /*===========================================*/
   int computeR(float *bz_err, float *los, int *dims, float *Rparam, float cdelt1,
                float *rim, float *p1p0, float *p1n0, float *p1p, float *p1n, float *p1,
                float *pmap, int nx1, int ny1)
   {
   
       int nx = dims[0];
       int ny = dims[1];
       int i = 0;
       int j = 0;
       int index;
       double sum = 0.0;
       double err = 0.0;
       *Rparam = 0.0;
       struct fresize_struct fresboxcar, fresgauss;
       int scale = round(2.0/cdelt1);
       float sigma = 10.0/2.3548;
   
       init_fresize_boxcar(&fresboxcar,1,1);
   
       // setup convolution kernel
       //init_fresize_gaussian(&fresgauss,sigma,4,1);
       init_fresize_gaussian(&fresgauss,sigma,20,1);
   
       if ((nx || ny) < 40.) return -1;
   
       //float *test = (float *)malloc(nx1*ny1*sizeof(float));
   
       fsample(los, rim, nx, ny, nx, nx1, ny1, nx1, scale, 0, 0, 0.0);
       for (i = 0; i < nx1; i++)
       {
         for (j = 0; j < ny1; j++)
         {
           index = j * nx1 + i;
           if (rim[index] > 150)
             p1p0[index]=1.0;
           else
             p1p0[index]=0.0;
           if (rim[index] < -150)
             p1n0[index]=1.0;
           else
             p1n0[index]=0.0;
         }
       }
   
       fresize(&fresboxcar, p1p0, p1p, nx1, ny1, nx1, nx1, ny1, nx1, 0, 0, 0.0);
       fresize(&fresboxcar, p1n0, p1n, nx1, ny1, nx1, nx1, ny1, nx1, 0, 0, 0.0);
   
       for (i = 0; i < nx1; i++)
       {
         for (j = 0; j < ny1; j++)
         {
           index = j * nx1 + i;
           if (p1p[index] > 0 && p1n[index] > 0)
             p1[index]=1.0;
           else
             p1[index]=0.0;
         }
       }
   
       fresize(&fresgauss, p1, pmap, nx1, ny1, nx1, nx1, ny1, nx1, 0, 0, 0.0);
   
       for (i = 0; i < nx1; i++)
       {
         for (j = 0; j < ny1; j++)
         {
           index = j * nx1 + i;
           sum += pmap[index]*abs(rim[index]);
         }
       }
   
       if (sum < 1.0)
         *Rparam = 0.0;
       else
         *Rparam = log10(sum);
   
   printf("Rparam=%f",*Rparam);
   
       free_fresize(&fresboxcar);
       free_fresize(&fresgauss);
   
       return 0;
   }
   
  
 /*==================KEIJI'S CODE =========================*/ /*==================KEIJI'S CODE =========================*/
  


Legend:
Removed from v.1.22  
changed lines
  Added in v.1.23

Karen Tian
Powered by
ViewCVS 0.9.4