(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.15 and 1.17

version 1.15, 2013/07/08 23:02:22 version 1.17, 2013/07/24 02:35:08
Line 102  int computeAbsFlux(float *bz_err, float
Line 102  int computeAbsFlux(float *bz_err, float
      *mean_vf_ptr     = sum*cdelt1*cdelt1*(rsun_ref/rsun_obs)*(rsun_ref/rsun_obs)*100.0*100.0;      *mean_vf_ptr     = sum*cdelt1*cdelt1*(rsun_ref/rsun_obs)*(rsun_ref/rsun_obs)*100.0*100.0;
      *mean_vf_err_ptr = (sqrt(err))*fabs(cdelt1*cdelt1*(rsun_ref/rsun_obs)*(rsun_ref/rsun_obs)*100.0*100.0); // error in the unsigned flux      *mean_vf_err_ptr = (sqrt(err))*fabs(cdelt1*cdelt1*(rsun_ref/rsun_obs)*(rsun_ref/rsun_obs)*100.0*100.0); // error in the unsigned flux
      *count_mask_ptr  = count_mask;      *count_mask_ptr  = count_mask;
      printf("cdelt1=%f\n",cdelt1);       //printf("cdelt1=%f\n",cdelt1);
      printf("rsun_obs=%f\n",rsun_obs);       //printf("rsun_obs=%f\n",rsun_obs);
      printf("rsun_ref=%f\n",rsun_ref);       //printf("rsun_ref=%f\n",rsun_ref);
      printf("CMASK=%g\n",*count_mask_ptr);       //printf("CMASK=%g\n",*count_mask_ptr);
      printf("USFLUX=%g\n",*mean_vf_ptr);       //printf("USFLUX=%g\n",*mean_vf_ptr);
      printf("sum=%f\n",sum);       //printf("sum=%f\n",sum);
      printf("USFLUX_err=%g\n",*mean_vf_err_ptr);       //printf("USFLUX_err=%g\n",*mean_vf_err_ptr);
      return 0;      return 0;
 } }
  
Line 188  int computeGamma(float *bz_err, float *b
Line 188  int computeGamma(float *bz_err, float *b
  
      *mean_gamma_ptr = sum/count_mask;      *mean_gamma_ptr = sum/count_mask;
      *mean_gamma_err_ptr = (sqrt(err*err))/(count_mask*100.0); // error in the quantity (sum)/(count_mask)      *mean_gamma_err_ptr = (sqrt(err*err))/(count_mask*100.0); // error in the quantity (sum)/(count_mask)
      printf("MEANGAM=%f\n",*mean_gamma_ptr);       //printf("MEANGAM=%f\n",*mean_gamma_ptr);
      printf("MEANGAM_err=%f\n",*mean_gamma_err_ptr);       //printf("MEANGAM_err=%f\n",*mean_gamma_err_ptr);
      return 0;      return 0;
 } }
  
Line 299  int computeBtotalderivative(float *bt, i
Line 299  int computeBtotalderivative(float *bt, i
  
         *mean_derivative_btotal_ptr     = (sum)/(count_mask); // would be divided by ((nx-2)*(ny-2)) if shape of count_mask = shape of magnetogram         *mean_derivative_btotal_ptr     = (sum)/(count_mask); // would be divided by ((nx-2)*(ny-2)) if shape of count_mask = shape of magnetogram
         *mean_derivative_btotal_err_ptr = (sqrt(err))/(count_mask); // error in the quantity (sum)/(count_mask)         *mean_derivative_btotal_err_ptr = (sqrt(err))/(count_mask); // error in the quantity (sum)/(count_mask)
         printf("MEANGBT=%f\n",*mean_derivative_btotal_ptr);          //printf("MEANGBT=%f\n",*mean_derivative_btotal_ptr);
         printf("MEANGBT_err=%f\n",*mean_derivative_btotal_err_ptr);          //printf("MEANGBT_err=%f\n",*mean_derivative_btotal_err_ptr);
         return 0;         return 0;
 } }
  
Line 382  int computeBhderivative(float *bh, float
Line 382  int computeBhderivative(float *bh, float
  
         *mean_derivative_bh_ptr     = (sum)/(count_mask); // would be divided by ((nx-2)*(ny-2)) if shape of count_mask = shape of magnetogram         *mean_derivative_bh_ptr     = (sum)/(count_mask); // would be divided by ((nx-2)*(ny-2)) if shape of count_mask = shape of magnetogram
         *mean_derivative_bh_err_ptr = (sqrt(err))/(count_mask); // error in the quantity (sum)/(count_mask)         *mean_derivative_bh_err_ptr = (sqrt(err))/(count_mask); // error in the quantity (sum)/(count_mask)
         printf("MEANGBH=%f\n",*mean_derivative_bh_ptr);          //printf("MEANGBH=%f\n",*mean_derivative_bh_ptr);
         printf("MEANGBH_err=%f\n",*mean_derivative_bh_err_ptr);          //printf("MEANGBH_err=%f\n",*mean_derivative_bh_err_ptr);
  
         return 0;         return 0;
 } }
Line 474  int computeBzderivative(float *bz, float
Line 474  int computeBzderivative(float *bz, float
  
         *mean_derivative_bz_ptr = (sum)/(count_mask); // would be divided by ((nx-2)*(ny-2)) if shape of count_mask = shape of magnetogram         *mean_derivative_bz_ptr = (sum)/(count_mask); // would be divided by ((nx-2)*(ny-2)) if shape of count_mask = shape of magnetogram
         *mean_derivative_bz_err_ptr = (sqrt(err))/(count_mask); // error in the quantity (sum)/(count_mask)         *mean_derivative_bz_err_ptr = (sqrt(err))/(count_mask); // error in the quantity (sum)/(count_mask)
         printf("MEANGBZ=%f\n",*mean_derivative_bz_ptr);          //printf("MEANGBZ=%f\n",*mean_derivative_bz_ptr);
         printf("MEANGBZ_err=%f\n",*mean_derivative_bz_err_ptr);          //printf("MEANGBZ_err=%f\n",*mean_derivative_bz_err_ptr);
  
         return 0;         return 0;
 } }
Line 580  int computeJz(float *bx_err, float *by_e
Line 580  int computeJz(float *bx_err, float *by_e
              dery[j * nx + i] = ( (3*bx[j * nx + i]) + (-4*bx[(j-1) * nx + i]) - (-bx[(j-2) * nx + i]) )*0.5;              dery[j * nx + i] = ( (3*bx[j * nx + i]) + (-4*bx[(j-1) * nx + i]) - (-bx[(j-2) * nx + i]) )*0.5;
           }           }
  
           for (i = 1; i <= nx-2; i++)
         for (i = 0; i <= nx-1; i++)  
           {           {
             for (j = 0; j <= ny-1; j++)              for (j = 1; j <= ny-2; j++)
             {             {
                // calculate jz at all points                // calculate jz at all points
   
                jz[j * nx + i]            = (derx[j * nx + i]-dery[j * nx + i]);       // jz is in units of Gauss/pix                jz[j * nx + i]            = (derx[j * nx + i]-dery[j * nx + i]);       // jz is in units of Gauss/pix
   
                  // the next 7 lines can be used with a for loop that goes from i=0;i<=nx-1 and j=0;j<=ny-1.
                  //int i1, j1,i2, j2;
                  //i1 = i + 1 ; if (i1 >nx-1){i1=nx-1;}
                  //j1 = j + 1 ; if (j1 >ny-1){j1=ny-1;}
                  //i2 = i - 1; if (i2 < 0){i2 = 0;}
                  //j2 = j - 1; if (j2 < 0){i2 = 0;}
                  //jz_err[j * nx + i]        = 0.5*sqrt( (bx_err[j1 * nx + i]*bx_err[j1 * nx + i]) + (bx_err[j2 * nx + i]*bx_err[j2 * nx + i]) +
                  //                                     (by_err[j * nx + i1]*by_err[j * nx + i1]) + (by_err[j * nx + i2]*by_err[j * nx + i2]) ) ;
   
                jz_err[j * nx + i]        = 0.5*sqrt( (bx_err[(j+1) * nx + i]*bx_err[(j+1) * nx + i]) + (bx_err[(j-1) * nx + i]*bx_err[(j-1) * nx + i]) +                jz_err[j * nx + i]        = 0.5*sqrt( (bx_err[(j+1) * nx + i]*bx_err[(j+1) * nx + i]) + (bx_err[(j-1) * nx + i]*bx_err[(j-1) * nx + i]) +
                                             (by_err[j * nx + (i+1)]*by_err[j * nx + (i+1)]) + (by_err[j * nx + (i-1)]*by_err[j * nx + (i-1)]) ) ;                                             (by_err[j * nx + (i+1)]*by_err[j * nx + (i+1)]) + (by_err[j * nx + (i-1)]*by_err[j * nx + (i-1)]) ) ;
                jz_err_squared[j * nx + i]= (jz_err[j * nx + i]*jz_err[j * nx + i]);                jz_err_squared[j * nx + i]= (jz_err[j * nx + i]*jz_err[j * nx + i]);
                count_mask++;                count_mask++;
   
             }             }
           }           }
   
         return 0;         return 0;
 } }
  
Line 643  int computeJzsmooth(float *bx, float *by
Line 653  int computeJzsmooth(float *bx, float *by
         *us_i_ptr        = (us_i);                   /* us_i gets populated as TOTUSJZ */         *us_i_ptr        = (us_i);                   /* us_i gets populated as TOTUSJZ */
         *us_i_err_ptr    = (sqrt(err))*fabs((cdelt1/1)*(rsun_ref/rsun_obs)*(0.00010)*(1/MUNAUGHT)); // error in the quantity TOTUSJZ         *us_i_err_ptr    = (sqrt(err))*fabs((cdelt1/1)*(rsun_ref/rsun_obs)*(0.00010)*(1/MUNAUGHT)); // error in the quantity TOTUSJZ
  
         printf("MEANJZD=%f\n",*mean_jz_ptr);          //printf("MEANJZD=%f\n",*mean_jz_ptr);
         printf("MEANJZD_err=%f\n",*mean_jz_err_ptr);          //printf("MEANJZD_err=%f\n",*mean_jz_err_ptr);
  
         printf("TOTUSJZ=%g\n",*us_i_ptr);          //printf("TOTUSJZ=%g\n",*us_i_ptr);
         printf("TOTUSJZ_err=%g\n",*us_i_err_ptr);          //printf("TOTUSJZ_err=%g\n",*us_i_err_ptr);
  
         return 0;         return 0;
  
Line 735  int computeAlpha(float *jz_err, float *b
Line 745  int computeAlpha(float *jz_err, float *b
         *mean_alpha_ptr = sum; /* Units are 1/Mm */         *mean_alpha_ptr = sum; /* Units are 1/Mm */
         *mean_alpha_err_ptr    = (sqrt(sum_err*sum_err)) / ((a+b+c+d)*100.0); // error in the quantity (sum)/(count_mask); factor of 100 comes from converting percent         *mean_alpha_err_ptr    = (sqrt(sum_err*sum_err)) / ((a+b+c+d)*100.0); // error in the quantity (sum)/(count_mask); factor of 100 comes from converting percent
  
         printf("MEANALP=%f\n",*mean_alpha_ptr);          //printf("MEANALP=%f\n",*mean_alpha_ptr);
         printf("MEANALP_err=%f\n",*mean_alpha_err_ptr);          //printf("MEANALP_err=%f\n",*mean_alpha_err_ptr);
  
         return 0;         return 0;
 } }
Line 791  int computeHelicity(float *jz_err, float
Line 801  int computeHelicity(float *jz_err, float
         *total_us_ih_err_ptr  = (sqrt(sum_err*sum_err)) / (100.0)               ;  // error in the quantity TOTUSJH         *total_us_ih_err_ptr  = (sqrt(sum_err*sum_err)) / (100.0)               ;  // error in the quantity TOTUSJH
         *total_abs_ih_err_ptr = (sqrt(sum_err*sum_err)) / (100.0)               ;  // error in the quantity ABSNJZH         *total_abs_ih_err_ptr = (sqrt(sum_err*sum_err)) / (100.0)               ;  // error in the quantity ABSNJZH
  
         printf("MEANJZH=%f\n",*mean_ih_ptr);          //printf("MEANJZH=%f\n",*mean_ih_ptr);
         printf("MEANJZH_err=%f\n",*mean_ih_err_ptr);          //printf("MEANJZH_err=%f\n",*mean_ih_err_ptr);
  
         printf("TOTUSJH=%f\n",*total_us_ih_ptr);          //printf("TOTUSJH=%f\n",*total_us_ih_ptr);
         printf("TOTUSJH_err=%f\n",*total_us_ih_err_ptr);          //printf("TOTUSJH_err=%f\n",*total_us_ih_err_ptr);
  
         printf("ABSNJZH=%f\n",*total_abs_ih_ptr);          //printf("ABSNJZH=%f\n",*total_abs_ih_ptr);
         printf("ABSNJZH_err=%f\n",*total_abs_ih_err_ptr);          //printf("ABSNJZH_err=%f\n",*total_abs_ih_err_ptr);
  
         return 0;         return 0;
 } }
Line 845  int computeSumAbsPerPolarity(float *jz_e
Line 855  int computeSumAbsPerPolarity(float *jz_e
  
         *totaljzptr    = fabs(sum1) + fabs(sum2);  /* Units are A */         *totaljzptr    = fabs(sum1) + fabs(sum2);  /* Units are A */
         *totaljz_err_ptr = sqrt(err)*(1/cdelt1)*fabs((0.00010)*(1/MUNAUGHT)*(rsun_ref/rsun_obs));         *totaljz_err_ptr = sqrt(err)*(1/cdelt1)*fabs((0.00010)*(1/MUNAUGHT)*(rsun_ref/rsun_obs));
         printf("SAVNCPP=%g\n",*totaljzptr);          //printf("SAVNCPP=%g\n",*totaljzptr);
         printf("SAVNCPP_err=%g\n",*totaljz_err_ptr);          //printf("SAVNCPP_err=%g\n",*totaljz_err_ptr);
  
         return 0;         return 0;
 } }
Line 903  int computeFreeEnergy(float *bx_err, flo
Line 913  int computeFreeEnergy(float *bx_err, flo
         *totpotptr       = (sum)/(8.*PI);         *totpotptr       = (sum)/(8.*PI);
         *totpot_err_ptr  = (sqrt(err))*fabs(cdelt1*cdelt1*(rsun_ref/rsun_obs)*(rsun_ref/rsun_obs)*100.0*100.0*(1/(8.*PI)));         *totpot_err_ptr  = (sqrt(err))*fabs(cdelt1*cdelt1*(rsun_ref/rsun_obs)*(rsun_ref/rsun_obs)*100.0*100.0*(1/(8.*PI)));
  
         printf("MEANPOT=%g\n",*meanpotptr);          //printf("MEANPOT=%g\n",*meanpotptr);
         printf("MEANPOT_err=%g\n",*meanpot_err_ptr);          //printf("MEANPOT_err=%g\n",*meanpot_err_ptr);
  
         printf("TOTPOT=%g\n",*totpotptr);          //printf("TOTPOT=%g\n",*totpotptr);
         printf("TOTPOT_err=%g\n",*totpot_err_ptr);          //printf("TOTPOT_err=%g\n",*totpot_err_ptr);
  
         return 0;         return 0;
 } }
Line 963  int computeShearAngle(float *bx_err, flo
Line 973  int computeShearAngle(float *bx_err, flo
         *meanshear_angle_err_ptr = (sqrt(err*err))/(count);  // error in the quantity (sum)/(count_mask)         *meanshear_angle_err_ptr = (sqrt(err*err))/(count);  // error in the quantity (sum)/(count_mask)
         *area_w_shear_gt_45ptr   = (count_mask/(count))*(100.0);/* The area here is a fractional area -- the % of the total area */         *area_w_shear_gt_45ptr   = (count_mask/(count))*(100.0);/* The area here is a fractional area -- the % of the total area */
  
         printf("MEANSHR=%f\n",*meanshear_angleptr);          //printf("MEANSHR=%f\n",*meanshear_angleptr);
         printf("MEANSHR_err=%f\n",*meanshear_angle_err_ptr);          //printf("MEANSHR_err=%f\n",*meanshear_angle_err_ptr);
  
         return 0;         return 0;
 } }


Legend:
Removed from v.1.15  
changed lines
  Added in v.1.17

Karen Tian
Powered by
ViewCVS 0.9.4