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

Diff for /JSOC/proj/sharp/apps/smarp.c between version 1.2 and 1.3

version 1.2, 2020/05/01 21:33:01 version 1.3, 2020/06/29 22:29:52
Line 21 
Line 21 
  *  *
  *      Notes:  *      Notes:
  *              v0.0 No explicit notes  *              v0.0 No explicit notes
    *              v0.1 Adjusted to take all bitmap values > 36
  *  *
  *      Example Call:  *      Example Call:
  *      > smarp "mharp=mdi.Mtarp[13643][2010.10.14_20:48:00_TAI]" "sharp_cea=su_mbobra.smarp_cea_96m" cont="mdi.fd_Ic_interp[2010.10.14_20:48:00_TAI]" "sharp_cut=su_mbobra.smarp_96m"  *      > smarp "mharp=mdi.Mtarp[13643][2010.10.14_20:48:00_TAI]" "sharp_cea=su_mbobra.smarp_cea_96m" cont="mdi.fd_Ic_interp[2010.10.14_20:48:00_TAI]" "sharp_cut=su_mbobra.smarp_96m"
Line 100  struct swIndex {
Line 101  struct swIndex {
     float mean_vf;     float mean_vf;
     float count_mask;     float count_mask;
     float absFlux;     float absFlux;
     float mean_derivative_bz;      float mean_derivative_los;
     float Rparam;     float Rparam;
 }; };
  
Line 1048  void computeSWIndex(struct swIndex *swKe
Line 1049  void computeSWIndex(struct swIndex *swKe
         int nxny = nx * ny;         int nxny = nx * ny;
         int dims[2] = {nx, ny};         int dims[2] = {nx, ny};
  
         // Get bx, by, bz, mask          // Get mask + use TARP bitmap as a threshold on spaceweather quantities
   
         // Use HARP (Turmon) bitmap as a threshold on spaceweather quantities  
         DRMS_Segment_t *bitmaskSeg = drms_segment_lookup(inRec, "bitmap");         DRMS_Segment_t *bitmaskSeg = drms_segment_lookup(inRec, "bitmap");
         DRMS_Array_t *bitmaskArray = drms_segment_read(bitmaskSeg, DRMS_TYPE_INT, &status);         DRMS_Array_t *bitmaskArray = drms_segment_read(bitmaskSeg, DRMS_TYPE_INT, &status);
         int *bitmask = (int *) bitmaskArray->data;              // get the previously made mask array          int *bitmask = (int *) bitmaskArray->data;              // bitmap
  
         //Use magnetogram map to compute R      // Get line-of-sight magnetogram
         DRMS_Segment_t *losSeg = drms_segment_lookup(inRec, "magnetogram");         DRMS_Segment_t *losSeg = drms_segment_lookup(inRec, "magnetogram");
         DRMS_Array_t *losArray = drms_segment_read(losSeg, DRMS_TYPE_FLOAT, &status);         DRMS_Array_t *losArray = drms_segment_read(losSeg, DRMS_TYPE_FLOAT, &status);
         float *los = (float *) losArray->data;          // los         float *los = (float *) losArray->data;          // los
Line 1074  void computeSWIndex(struct swIndex *swKe
Line 1073  void computeSWIndex(struct swIndex *swKe
         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.);
  
         // Temp arrays         // Temp arrays
         float *derx_bz = (float *) (malloc(nxny * sizeof(float)));          float *derx_los = (float *) (malloc(nxny * sizeof(float)));
         float *dery_bz = (float *) (malloc(nxny * sizeof(float)));          float *dery_los = (float *) (malloc(nxny * sizeof(float)));
  
         // define some values for the R calculation         // define some values for the R calculation
         int scale = round(2.0/cdelt1);         int scale = round(2.0/cdelt1);
Line 1093  void computeSWIndex(struct swIndex *swKe
Line 1092  void computeSWIndex(struct swIndex *swKe
         float *p1pad   = (float *)malloc(nxp*nyp*sizeof(float));         float *p1pad   = (float *)malloc(nxp*nyp*sizeof(float));
         float *pmapn   = (float *)malloc(nx1*ny1*sizeof(float));         float *pmapn   = (float *)malloc(nx1*ny1*sizeof(float));
  
           // Compute three spaceweather quantities, USFLUX, MEANGBZ, R_VALUE, on LOS data
  
         // THREE spaceweather quantities computed: USFLUX, MEANGBZ, R_VALUE          if (computeAbsFlux_los(los, dims, &(swKeys_ptr->absFlux), &(swKeys_ptr->mean_vf),
         if (computeAbsFlux(los, dims, &(swKeys_ptr->absFlux), &(swKeys_ptr->mean_vf),  
                            &(swKeys_ptr->count_mask), bitmask, cdelt1, rsun_ref, rsun_obs))                            &(swKeys_ptr->count_mask), bitmask, cdelt1, rsun_ref, rsun_obs))
         {         {
                 swKeys_ptr->absFlux = DRMS_MISSING_FLOAT;               // If fail, fill in NaN                 swKeys_ptr->absFlux = DRMS_MISSING_FLOAT;               // If fail, fill in NaN
Line 1103  void computeSWIndex(struct swIndex *swKe
Line 1102  void computeSWIndex(struct swIndex *swKe
                 swKeys_ptr->count_mask  = DRMS_MISSING_INT;                 swKeys_ptr->count_mask  = DRMS_MISSING_INT;
         }         }
  
           if (computeLOSderivative(los, dims, &(swKeys_ptr->mean_derivative_los),
         if (computeBzderivative(los, dims, &(swKeys_ptr->mean_derivative_bz),                                  bitmask, derx_los, dery_los))
                                 bitmask, derx_bz, dery_bz))  
         {         {
                 swKeys_ptr->mean_derivative_bz = DRMS_MISSING_FLOAT; // If fail, fill in NaN                  swKeys_ptr->mean_derivative_los = DRMS_MISSING_FLOAT; // If fail, fill in NaN
         }         }
  
           if (computeR_los(los, dims, &(swKeys_ptr->Rparam), cdelt1, rim, p1p0, p1n0,
         if (computeR(los, dims, &(swKeys_ptr->Rparam), cdelt1, rim, p1p0, p1n0,  
                      p1p, p1n, p1, pmap, nx1, ny1, scale, p1pad, nxp, nyp, pmapn))                      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
         }         }
  
   
         // Clean up the arrays         // Clean up the arrays
         drms_free_array(bitmaskArray);         drms_free_array(bitmaskArray);
         //drms_free_array(bzArray);  
         drms_free_array(losArray);         drms_free_array(losArray);
           // free arrays related to LOS derivative
         // free arrays related to Bz derivative              free(derx_los); free(dery_los);
         free(derx_bz); free(dery_bz);  
         // free the arrays that are related to the r calculation         // free the arrays that are related to the r calculation
         free(rim);         free(rim);
         free(p1p0);         free(p1p0);
Line 1144  void computeSWIndex(struct swIndex *swKe
Line 1138  void computeSWIndex(struct swIndex *swKe
 void setSWIndex(DRMS_Record_t *outRec, struct swIndex *swKeys_ptr) void setSWIndex(DRMS_Record_t *outRec, struct swIndex *swKeys_ptr)
 { {
     drms_setkey_float(outRec, "USFLUX",  swKeys_ptr->mean_vf);     drms_setkey_float(outRec, "USFLUX",  swKeys_ptr->mean_vf);
     drms_setkey_float(outRec, "MEANGBZ", swKeys_ptr->mean_derivative_bz);      drms_setkey_float(outRec, "MEANGBZ", swKeys_ptr->mean_derivative_los);
     drms_setkey_float(outRec, "R_VALUE", swKeys_ptr->Rparam);     drms_setkey_float(outRec, "R_VALUE", swKeys_ptr->Rparam);
     drms_setkey_float(outRec, "CMASK", swKeys_ptr->count_mask);     drms_setkey_float(outRec, "CMASK", swKeys_ptr->count_mask);
 }; };


Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

Karen Tian
Powered by
ViewCVS 0.9.4