(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.38 and 1.40

version 1.38, 2020/06/30 22:38:17 version 1.40, 2021/05/24 22:17:06
Line 1 
Line 1 
  
 /*=========================================== /*===========================================
  
  The following 14 functions calculate the following spaceweather indices:   The following functions calculate these spaceweather indices from the vector magnetic field data:
  
  USFLUX Total unsigned flux in Maxwells  USFLUX Total unsigned flux in Maxwells
  MEANGAM Mean inclination angle, gamma, in degrees  MEANGAM Mean inclination angle, gamma, in degrees
Line 18 
Line 18 
  MEANPOT Mean photospheric excess magnetic energy density in ergs per cubic centimeter  MEANPOT Mean photospheric excess magnetic energy density in ergs per cubic centimeter
  TOTPOT Total photospheric magnetic energy density in ergs per cubic centimeter  TOTPOT Total photospheric magnetic energy density in ergs per cubic centimeter
  MEANSHR Mean shear angle (measured using Btotal) in degrees  MEANSHR Mean shear angle (measured using Btotal) in degrees
    CMASK The total number of pixels that contributed to the calculation of all the indices listed above
   
    And these spaceweather indices from the line-of-sight magnetic field data:
    USFLUXL Total unsigned flux in Maxwells
    MEANGBL Mean value of the line-of-sight field gradient, in Gauss/Mm
    CMASKL The total number of pixels that contributed to the calculation of USFLUXL and MEANGBL
  R_VALUE Karel Schrijver's R parameter  R_VALUE Karel Schrijver's R parameter
  
  The indices are calculated on the pixels in which the conf_disambig segment is greater than 70 and  The indices are calculated on the pixels in which the conf_disambig segment is greater than 70 and
Line 1022  int computeShearAngle(float *bx_err, flo
Line 1028  int computeShearAngle(float *bx_err, flo
     }     }
     /* For mean 3D shear angle, area with shear greater than 45*/     /* For mean 3D shear angle, area with shear greater than 45*/
     *meanshear_angleptr = (sumsum)/(count);                 /* Units are degrees */     *meanshear_angleptr = (sumsum)/(count);                 /* Units are degrees */
   
       // For the error in the mean 3D shear angle:
       // If count_mask is 0, then we run into a divide by zero error. In this case, set *meanshear_angle_err_ptr to NAN
       // If count_mask is greater than zero, then compute the error.
       if (count_mask == 0)
           *meanshear_angle_err_ptr = NAN;
       else
     *meanshear_angle_err_ptr = (sqrt(err)/count_mask)*(180./PI);     *meanshear_angle_err_ptr = (sqrt(err)/count_mask)*(180./PI);
  
     /* The area here is a fractional area -- the % of the total area. This has no error associated with it. */     /* The area here is a fractional area -- the % of the total area. This has no error associated with it. */
     *area_w_shear_gt_45ptr   = (count_mask/(count))*(100.0);     *area_w_shear_gt_45ptr   = (count_mask/(count))*(100.0);
  
     //printf("MEANSHR=%f\n",*meanshear_angleptr);     //printf("MEANSHR=%f\n",*meanshear_angleptr);
     //printf("MEANSHR_err=%f\n",*meanshear_angle_err_ptr);      //printf("ERRMSHA=%f\n",*meanshear_angle_err_ptr);
     //printf("SHRGT45=%f\n",*area_w_shear_gt_45ptr);     //printf("SHRGT45=%f\n",*area_w_shear_gt_45ptr);
   
         return 0;         return 0;
 } }
  
Line 1249  int computeLorentz(float *bx, float *by
Line 1261  int computeLorentz(float *bx, float *by
 //  (Gauss/pix^2)(CDELT1)^2(RSUN_REF/RSUN_OBS)^2(100.cm/m)^2 //  (Gauss/pix^2)(CDELT1)^2(RSUN_REF/RSUN_OBS)^2(100.cm/m)^2
 //  =Gauss*cm^2 //  =Gauss*cm^2
  
 int computeAbsFlux_los(float *los, int *dims, float *absFlux,  int computeAbsFlux_los(float *los, int *dims, float *absFlux_los,
                        float *mean_vf_ptr, float *count_mask_ptr,                         float *mean_vf_los_ptr, float *count_mask_los_ptr,
                        int *bitmask, float cdelt1, double rsun_ref, double rsun_obs)                        int *bitmask, float cdelt1, double rsun_ref, double rsun_obs)
  
 { {
Line 1259  int computeAbsFlux_los(float *los, int *
Line 1271  int computeAbsFlux_los(float *los, int *
     int ny = dims[1];     int ny = dims[1];
     int i = 0;     int i = 0;
     int j = 0;     int j = 0;
     int count_mask = 0;      int count_mask_los = 0;
     double sum = 0.0;     double sum = 0.0;
     *absFlux = 0.0;      *absFlux_los = 0.0;
     *mean_vf_ptr = 0.0;      *mean_vf_los_ptr = 0.0;
  
  
     if (nx <= 0 || ny <= 0) return 1;     if (nx <= 0 || ny <= 0) return 1;
Line 1274  int computeAbsFlux_los(float *los, int *
Line 1286  int computeAbsFlux_los(float *los, int *
             if ( bitmask[j * nx + i] < 30 ) continue;             if ( bitmask[j * nx + i] < 30 ) continue;
             if isnan(los[j * nx + i]) continue;             if isnan(los[j * nx + i]) continue;
             sum += (fabs(los[j * nx + i]));             sum += (fabs(los[j * nx + i]));
             count_mask++;              count_mask_los++;
            }            }
         }         }
  
     *mean_vf_ptr     = sum*cdelt1*cdelt1*(rsun_ref/rsun_obs)*(rsun_ref/rsun_obs)*100.0*100.0;      *mean_vf_los_ptr     = sum*cdelt1*cdelt1*(rsun_ref/rsun_obs)*(rsun_ref/rsun_obs)*100.0*100.0;
     *count_mask_ptr  = count_mask;      *count_mask_los_ptr  = count_mask_los;
   
       printf("USFLUXL=%f\n",*mean_vf_los_ptr);
       printf("CMASKL=%f\n",*count_mask_los_ptr);
  
     return 0;     return 0;
 } }
Line 1365  int computeLOSderivative(float *los, int
Line 1380  int computeLOSderivative(float *los, int
     }     }
  
     *mean_derivative_los_ptr = (sum)/(count_mask); // would be divided by ((nx-2)*(ny-2)) if shape of count_mask = shape of magnetogram     *mean_derivative_los_ptr = (sum)/(count_mask); // would be divided by ((nx-2)*(ny-2)) if shape of count_mask = shape of magnetogram
     //printf("mean_derivative_los_ptr=%f\n",*mean_derivative_los_ptr);  
       printf("MEANGBL=%f\n",*mean_derivative_los_ptr);
  
         return 0;         return 0;
 } }


Legend:
Removed from v.1.38  
changed lines
  Added in v.1.40

Karen Tian
Powered by
ViewCVS 0.9.4