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

Diff for /JSOC/proj/sharp/apps/sharp.c between version 1.27 and 1.30

version 1.27, 2014/03/19 20:46:26 version 1.30, 2014/06/05 21:27:19
Line 180  struct swIndex {
Line 180  struct swIndex {
     float totpot_err;     float totpot_err;
     float meanshear_angle_err;     float meanshear_angle_err;
     float Rparam;     float Rparam;
       float totfx;
       float totfy;
       float totfz;
       float totbsq;
       float epsx;
       float epsy;
       float epsz;
 }; };
  
 // Mapping method // Mapping method
Line 1936  void computeSWIndex(struct swIndex *swKe
Line 1943  void computeSWIndex(struct swIndex *swKe
  
     // convert cdelt1_orig from degrees to arcsec     // convert cdelt1_orig from degrees to arcsec
     float cdelt1       = (atan((rsun_ref*cdelt1_orig*RADSINDEG)/(dsun_obs)))*(1/RADSINDEG)*(3600.);     float cdelt1       = (atan((rsun_ref*cdelt1_orig*RADSINDEG)/(dsun_obs)))*(1/RADSINDEG)*(3600.);
     int nx1 = nx*cdelt1/2;  
     int ny1 = ny*cdelt1/2;          //if (nx1 > floor((nx-1)/scale + 1) )
           //      DIE("X-dimension of output array in fsample() is too large.");
           //if (ny1 > floor((ny-1)/scale + 1) )
           //      DIE("Y-dimension of output array in fsample() is too large.");
  
         // Temp arrays         // Temp arrays
         float *bh      = (float *) (malloc(nxny * sizeof(float)));         float *bh      = (float *) (malloc(nxny * sizeof(float)));
Line 1962  void computeSWIndex(struct swIndex *swKe
Line 1972  void computeSWIndex(struct swIndex *swKe
     float *jz_err_squared_smooth = (float *) (malloc(nxny * sizeof(float)));     float *jz_err_squared_smooth = (float *) (malloc(nxny * sizeof(float)));
     float *jz_rms_err = (float *) (malloc(nxny * sizeof(float)));     float *jz_rms_err = (float *) (malloc(nxny * sizeof(float)));
  
     // malloc some arrays for the R parameter calculation          // define some values for the R calculation
           int scale = round(2.0/cdelt1);
           int nx1 = nx/scale;
           int ny1 = ny/scale;
           int nxp = nx1+40;
           int nyp = ny1+40;
     float *rim = (float *)malloc(nx1*ny1*sizeof(float));     float *rim = (float *)malloc(nx1*ny1*sizeof(float));
     float *p1p0 = (float *)malloc(nx1*ny1*sizeof(float));     float *p1p0 = (float *)malloc(nx1*ny1*sizeof(float));
     float *p1n0 = (float *)malloc(nx1*ny1*sizeof(float));     float *p1n0 = (float *)malloc(nx1*ny1*sizeof(float));
     float *p1p = (float *)malloc(nx1*ny1*sizeof(float));     float *p1p = (float *)malloc(nx1*ny1*sizeof(float));
     float *p1n = (float *)malloc(nx1*ny1*sizeof(float));     float *p1n = (float *)malloc(nx1*ny1*sizeof(float));
     float *p1 = (float *)malloc(nx1*ny1*sizeof(float));     float *p1 = (float *)malloc(nx1*ny1*sizeof(float));
     float *pmap = (float *)malloc(nx1*ny1*sizeof(float));          float *pmap    = (float *)malloc(nxp*nyp*sizeof(float));
           float *p1pad   = (float *)malloc(nxp*nyp*sizeof(float));
           float *pmapn   = (float *)malloc(nx1*ny1*sizeof(float));
   
           // define some arrays for the lorentz force calculation
           float *fx = (float *) (malloc(nxny * sizeof(float)));
           float *fy = (float *) (malloc(nxny * sizeof(float)));
           float *fz = (float *) (malloc(nxny * sizeof(float)));
   
  
         //spaceweather quantities computed         //spaceweather quantities computed
         if (computeAbsFlux(bz_err, bz , dims, &(swKeys_ptr->absFlux), &(swKeys_ptr->mean_vf),  &(swKeys_ptr->mean_vf_err),         if (computeAbsFlux(bz_err, bz , dims, &(swKeys_ptr->absFlux), &(swKeys_ptr->mean_vf),  &(swKeys_ptr->mean_vf_err),
Line 1994  void computeSWIndex(struct swIndex *swKe
Line 2017  void computeSWIndex(struct swIndex *swKe
  
         computeB_total(bx_err, by_err, bz_err, bt_err, bx, by, bz, bt, dims, mask, bitmask);         computeB_total(bx_err, by_err, bz_err, bt_err, bx, by, bz, bt, dims, mask, bitmask);
  
         if (computeBtotalderivative(bt, dims, &(swKeys_ptr->mean_derivative_btotal), mask, bitmask, derx_bt, dery_bt, bt_err, &(swKeys_ptr->mean_derivative_btotal_err)))          if (computeBtotalderivative(bt, dims, &(swKeys_ptr->mean_derivative_btotal), mask, bitmask, derx_bt,
                                       dery_bt, bt_err, &(swKeys_ptr->mean_derivative_btotal_err)))
     {     {
                 swKeys_ptr->mean_derivative_btotal = DRMS_MISSING_FLOAT;                 swKeys_ptr->mean_derivative_btotal = DRMS_MISSING_FLOAT;
                 swKeys_ptr->mean_derivative_btotal_err = DRMS_MISSING_FLOAT;                 swKeys_ptr->mean_derivative_btotal_err = DRMS_MISSING_FLOAT;
     }     }
  
         if (computeBhderivative(bh, bh_err, dims, &(swKeys_ptr->mean_derivative_bh), &(swKeys_ptr->mean_derivative_bh_err), mask, bitmask, derx_bh, dery_bh))          if (computeBhderivative(bh, bh_err, dims, &(swKeys_ptr->mean_derivative_bh),
                                   &(swKeys_ptr->mean_derivative_bh_err), mask, bitmask, derx_bh, dery_bh))
     {     {
                 swKeys_ptr->mean_derivative_bh = DRMS_MISSING_FLOAT;                 swKeys_ptr->mean_derivative_bh = DRMS_MISSING_FLOAT;
         swKeys_ptr->mean_derivative_bh_err = DRMS_MISSING_FLOAT;         swKeys_ptr->mean_derivative_bh_err = DRMS_MISSING_FLOAT;
         }         }
  
         if (computeBzderivative(bz, bz_err, dims, &(swKeys_ptr->mean_derivative_bz), &(swKeys_ptr->mean_derivative_bz_err), mask, bitmask, derx_bz, dery_bz))          if (computeBzderivative(bz, bz_err, dims, &(swKeys_ptr->mean_derivative_bz), &(swKeys_ptr->mean_derivative_bz_err),
                                   mask, bitmask, derx_bz, dery_bz))
     {     {
                 swKeys_ptr->mean_derivative_bz = DRMS_MISSING_FLOAT; // If fail, fill in NaN                 swKeys_ptr->mean_derivative_bz = DRMS_MISSING_FLOAT; // If fail, fill in NaN
         swKeys_ptr->mean_derivative_bz_err = DRMS_MISSING_FLOAT;         swKeys_ptr->mean_derivative_bz_err = DRMS_MISSING_FLOAT;
Line 2026  void computeSWIndex(struct swIndex *swKe
Line 2052  void computeSWIndex(struct swIndex *swKe
         swKeys_ptr->us_i_err           = DRMS_MISSING_FLOAT;         swKeys_ptr->us_i_err           = DRMS_MISSING_FLOAT;
         }         }
  
         if (computeAlpha(jz_err, bz_err, bz, dims, jz, jz_smooth, &(swKeys_ptr->mean_alpha), &(swKeys_ptr->mean_alpha_err), mask, bitmask, cdelt1, rsun_ref, rsun_obs))          if (computeAlpha(jz_err, bz_err, bz, dims, jz, jz_smooth, &(swKeys_ptr->mean_alpha), &(swKeys_ptr->mean_alpha_err),
                            mask, bitmask, cdelt1, rsun_ref, rsun_obs))
     {     {
                 swKeys_ptr->mean_alpha         = DRMS_MISSING_FLOAT;                 swKeys_ptr->mean_alpha         = DRMS_MISSING_FLOAT;
         swKeys_ptr->mean_alpha_err     = DRMS_MISSING_FLOAT;         swKeys_ptr->mean_alpha_err     = DRMS_MISSING_FLOAT;
     }     }
  
         if (computeHelicity(jz_err, jz_rms_err, bz_err, bz, dims, jz, &(swKeys_ptr->mean_ih), &(swKeys_ptr->mean_ih_err), &(swKeys_ptr->total_us_ih), &(swKeys_ptr->total_abs_ih),          if (computeHelicity(jz_err, jz_rms_err, bz_err, bz, dims, jz, &(swKeys_ptr->mean_ih), &(swKeys_ptr->mean_ih_err),
                               &(swKeys_ptr->total_us_ih), &(swKeys_ptr->total_abs_ih),
                         &(swKeys_ptr->total_us_ih_err), &(swKeys_ptr->total_abs_ih_err), mask, bitmask, cdelt1, rsun_ref, rsun_obs))                         &(swKeys_ptr->total_us_ih_err), &(swKeys_ptr->total_abs_ih_err), mask, bitmask, cdelt1, rsun_ref, rsun_obs))
     {     {
                 swKeys_ptr->mean_ih            = DRMS_MISSING_FLOAT;                 swKeys_ptr->mean_ih            = DRMS_MISSING_FLOAT;
Line 2063  void computeSWIndex(struct swIndex *swKe
Line 2091  void computeSWIndex(struct swIndex *swKe
  
         if (computeShearAngle(bx_err, by_err, bz_err, bx, by, bz, bpx, bpy, bpz, dims,         if (computeShearAngle(bx_err, by_err, bz_err, bx, by, bz, bpx, bpy, bpz, dims,
                                                   &(swKeys_ptr->meanshear_angle), &(swKeys_ptr->meanshear_angle_err), &(swKeys_ptr->area_w_shear_gt_45),                                                   &(swKeys_ptr->meanshear_angle), &(swKeys_ptr->meanshear_angle_err), &(swKeys_ptr->area_w_shear_gt_45),
                                                   mask, bitmask)) {                                mask, bitmask))
           {
                 swKeys_ptr->meanshear_angle    = DRMS_MISSING_FLOAT; // If fail, fill in NaN                 swKeys_ptr->meanshear_angle    = DRMS_MISSING_FLOAT; // If fail, fill in NaN
                 swKeys_ptr->area_w_shear_gt_45 = DRMS_MISSING_FLOAT;                 swKeys_ptr->area_w_shear_gt_45 = DRMS_MISSING_FLOAT;
         swKeys_ptr->meanshear_angle_err= DRMS_MISSING_FLOAT;         swKeys_ptr->meanshear_angle_err= DRMS_MISSING_FLOAT;
         }         }
  
         if (computeR(bz_err, los , dims, &(swKeys_ptr->Rparam), cdelt1, rim, p1p0, p1n0,         if (computeR(bz_err, los , dims, &(swKeys_ptr->Rparam), cdelt1, rim, p1p0, p1n0,
                  p1p, p1n, p1, pmap, nx1, ny1))                       p1p, p1n, p1, pmap, nx1, ny1, scale, p1pad, nxp, nyp, pmapn))
         {         {
                 swKeys_ptr->Rparam = DRMS_MISSING_FLOAT;                // If fail, fill in NaN                 swKeys_ptr->Rparam = DRMS_MISSING_FLOAT;                // If fail, fill in NaN
         }         }
  
  
           if (computeLorentz(bx, by, bz, fx, fy, fz, dims, &(swKeys_ptr->totfx), &(swKeys_ptr->totfy), &(swKeys_ptr->totfz), &(swKeys_ptr->totbsq),
              &(swKeys_ptr->epsx), &(swKeys_ptr->epsy), &(swKeys_ptr->epsz), mask, bitmask, cdelt1, rsun_ref, rsun_obs))
           {
                   swKeys_ptr->totfx             = DRMS_MISSING_FLOAT;
                   swKeys_ptr->totfy             = DRMS_MISSING_FLOAT;
                   swKeys_ptr->totfz             = DRMS_MISSING_FLOAT;
                   swKeys_ptr->totbsq            = DRMS_MISSING_FLOAT;
                   swKeys_ptr->epsx              = DRMS_MISSING_FLOAT;
                   swKeys_ptr->epsy              = DRMS_MISSING_FLOAT;
                   swKeys_ptr->epsz              = DRMS_MISSING_FLOAT;
   
           }
   
   
         // Clean up the arrays         // Clean up the arrays
  
         drms_free_array(bitmaskArray);          // Dec 18 2012 Xudong         drms_free_array(bitmaskArray);          // Dec 18 2012 Xudong
Line 2098  void computeSWIndex(struct swIndex *swKe
Line 2141  void computeSWIndex(struct swIndex *swKe
         free(jz_err_squared); free(jz_rms_err);         free(jz_err_squared); free(jz_rms_err);
         free(jz_err_squared_smooth);         free(jz_err_squared_smooth);
  
           // free the arrays that are related to the r calculation
         free(rim);         free(rim);
         free(p1p0);         free(p1p0);
         free(p1n0);         free(p1n0);
Line 2105  void computeSWIndex(struct swIndex *swKe
Line 2149  void computeSWIndex(struct swIndex *swKe
         free(p1n);         free(p1n);
         free(p1);         free(p1);
         free(pmap);         free(pmap);
           free(p1pad);
           free(pmapn);
  
           // free the arrays that are related to the lorentz calculation
           free(fx); free(fy); free(fz);
 } }
  
 /* /*
Line 2148  void setSWIndex(DRMS_Record_t *outRec, s
Line 2196  void setSWIndex(DRMS_Record_t *outRec, s
     drms_setkey_float(outRec, "ERRTPOT", swKeys_ptr->totpot_err);     drms_setkey_float(outRec, "ERRTPOT", swKeys_ptr->totpot_err);
     drms_setkey_float(outRec, "ERRMSHA", swKeys_ptr->meanshear_angle_err);     drms_setkey_float(outRec, "ERRMSHA", swKeys_ptr->meanshear_angle_err);
     drms_setkey_float(outRec, "R_VALUE", swKeys_ptr->Rparam);     drms_setkey_float(outRec, "R_VALUE", swKeys_ptr->Rparam);
       drms_setkey_float(outRec, "TOTFX",   swKeys_ptr->totfx);
       drms_setkey_float(outRec, "TOTFY",   swKeys_ptr->totfy);
       drms_setkey_float(outRec, "TOTFZ",   swKeys_ptr->totfz);
       drms_setkey_float(outRec, "TOTBSQ",  swKeys_ptr->totbsq);
       drms_setkey_float(outRec, "EPSX",    swKeys_ptr->epsx);
       drms_setkey_float(outRec, "EPSY",    swKeys_ptr->epsy);
       drms_setkey_float(outRec, "EPSZ",    swKeys_ptr->epsz);
 }; };
  
 /* /*
Line 2276  float nnb (float *f, int nx, int ny, dou
Line 2331  float nnb (float *f, int nx, int ny, dou
  
 } }
  
   
 /* ################## Wrapper for Jesper's rebin code ################## */ /* ################## Wrapper for Jesper's rebin code ################## */
  
 void frebin (float *image_in, float *image_out, int nx, int ny, int nbin, int gauss) void frebin (float *image_in, float *image_out, int nx, int ny, int nbin, int gauss)


Legend:
Removed from v.1.27  
changed lines
  Added in v.1.30

Karen Tian
Powered by
ViewCVS 0.9.4