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

Diff for /JSOC/proj/sharp/apps/update_sharp_keys.c between version 1.15 and 1.16

version 1.15, 2015/03/11 22:18:05 version 1.16, 2020/06/30 22:38:53
Line 1 
Line 1 
 /* /*
  *      MODULE NAME: update_sharp_keys.c  *      MODULE NAME: update_sharp_keys.c
  *  *
  *      DESCRIPTION: This module recalculates SHARP keywords. This is accomplished by   *          DESCRIPTION: This module recalculates SHARP keywords.
  *      cloning a record, recalculating keywords of choice (i.e., user input),   *      This is accomplished by cloning a record, recalculating keywords of choice
  *      and pointing to the same segments as the old record. Associated error keys   *      (i.e., user input), and pointing to the same segments as the old record.
  *      are computed by default.   *      Associated error keys are computed by default.
  *  *
  *      This module accounts for versioning by appending to the keyword CODEVER7 and HISTORY:  *      This module accounts for versioning by appending to the keyword CODEVER7 and HISTORY:
  *      CODEVER7 will contain multiple lines: the production build of sharp.c, the  *      CODEVER7 will contain multiple lines: the production build of sharp.c, the
Line 24 
Line 24 
  *                   -- DRMS SHARP CEA series  *                   -- DRMS SHARP CEA series
  *                   -- HARPNUM  *                   -- HARPNUM
  *                   -- comma separated list of keywords to recalculate  *                   -- comma separated list of keywords to recalculate
  *                   -- DEBUG flag (use like this debug=debug)   *                   -- DEBUG flag
  *  *
  *      AUTHOR     : Monica Bobra  *      AUTHOR     : Monica Bobra
  *  *
  *      Version    :   v0.0     Jun 14 2013  
  *                     v0.1     Feb 11 2014 Added different input and output series  
  *  
  *      EXAMPLE    :  *      EXAMPLE    :
  *      update_sharp_keys sharpseriesin=hmi.sharp_720s sharpceaseriesin=hmi.sharp_cea_720s //  *      update_sharp_keys sharpseriesin=hmi.sharp_720s sharpceaseriesin=hmi.sharp_cea_720s //
  *      HARPNUM=1 sharpseriesout=hmi.sharp_720s sharpceaseriesout=hmi.sharp_cea_720s keylist=USFLUX,TOTPOT debug=debug  *      HARPNUM=1 sharpseriesout=hmi.sharp_720s sharpceaseriesout=hmi.sharp_cea_720s keylist=USFLUX,TOTPOT debug=debug
Line 68 
Line 65 
 #define SHOW(msg) {printf("%s", msg); fflush(stdout);} #define SHOW(msg) {printf("%s", msg); fflush(stdout);}
  
 char *module_name = "update_sharp_keys";  /* Module name */ char *module_name = "update_sharp_keys";  /* Module name */
 char *version_id  = "2014 Feb 12";        /* Version number */  char *version_id  = "2020 Jun 29";        /* Version number */
  
 ModuleArgs_t module_args[] = ModuleArgs_t module_args[] =
 { {
Line 77  ModuleArgs_t module_args[] =
Line 74  ModuleArgs_t module_args[] =
         {ARG_STRING, "sharpseriesout",     NULL, "Output Sharp dataseries"},         {ARG_STRING, "sharpseriesout",     NULL, "Output Sharp dataseries"},
         {ARG_STRING, "sharpceaseriesout",  NULL, "Output Sharp CEA dataseries"},         {ARG_STRING, "sharpceaseriesout",  NULL, "Output Sharp CEA dataseries"},
         {ARG_INT,    "HARPNUM",            NULL, "HARP number"},         {ARG_INT,    "HARPNUM",            NULL, "HARP number"},
         {ARG_STRING, "keylist",            NULL, "comma separated list of keywords to update"},          {ARG_STRING, "keylist",            NULL, "comma separated list of keywords to update (for LOS keywords enter MEANGBZLOS or USFLUXLOS)"},
         {ARG_STRING, "debug",              NULL, "debug mode functionality. use like this: debug=debug"},         {ARG_STRING, "debug",              NULL, "debug mode functionality. use like this: debug=debug"},
         {ARG_END}         {ARG_END}
 }; };
Line 100  int DoIt(void)
Line 97  int DoIt(void)
         float mean_derivative_btotal;         float mean_derivative_btotal;
         float mean_derivative_bh;         float mean_derivative_bh;
         float mean_derivative_bz;         float mean_derivative_bz;
           float mean_derivative_los;
         float mean_jz;         float mean_jz;
         float us_i;         float us_i;
         float mean_alpha;         float mean_alpha;
Line 196  int DoIt(void)
Line 194  int DoIt(void)
         char *debug   = (char *) params_get_str(&cmdparams, "debug");         char *debug   = (char *) params_get_str(&cmdparams, "debug");
  
         // Flags to indicate which keyword will be recalculated         // Flags to indicate which keyword will be recalculated
         int meanvfflag  = (strstr(keylist,"USFLUX")  != NULL);  // generalize so that lowercase is acceptable      int meanvflosflag = (strstr(keylist,"USFLUXLOS")  != NULL);
       int meanglosflag  = (strstr(keylist,"MEANGBZLOS") != NULL);
           int meanvfflag    = (strstr(keylist,"USFLUX")  != NULL);
         int totpotflag  = (strstr(keylist,"TOTPOT")  != NULL);         int totpotflag  = (strstr(keylist,"TOTPOT")  != NULL);
         int meangamflag = (strstr(keylist,"MEANGAM") != NULL);         int meangamflag = (strstr(keylist,"MEANGAM") != NULL);
         int meangbtflag = (strstr(keylist,"MEANGBT") != NULL);         int meangbtflag = (strstr(keylist,"MEANGBT") != NULL);
Line 257  int DoIt(void)
Line 257  int DoIt(void)
         float *fx = (float *) (malloc(nxny * sizeof(float)));         float *fx = (float *) (malloc(nxny * sizeof(float)));
         float *fy = (float *) (malloc(nxny * sizeof(float)));         float *fy = (float *) (malloc(nxny * sizeof(float)));
         float *fz = (float *) (malloc(nxny * sizeof(float)));         float *fz = (float *) (malloc(nxny * sizeof(float)));
       float *derx_los  = (float *) (malloc(nxny * sizeof(float)));
           float *dery_los  = (float *) (malloc(nxny * sizeof(float)));
  
         for (irec=0;irec<nrecs;irec++)         for (irec=0;irec<nrecs;irec++)
         {         {
Line 437  int DoIt(void)
Line 439  int DoIt(void)
  
            drms_setkey_float(sharpoutrec, "R_VALUE",  Rparam);            drms_setkey_float(sharpoutrec, "R_VALUE",  Rparam);
            drms_setkey_float(sharpceaoutrec, "R_VALUE", Rparam);            drms_setkey_float(sharpceaoutrec, "R_VALUE", Rparam);
           }
  
           /***** MEANGBZ, Example Function 7 ************************************/
           if (meangbzflag)
           {
               // Compute Bz derivative
               if (computeBzderivative(bz, bz_err, dims, &mean_derivative_bz, &mean_derivative_bz_err, mask, bitmask, derx_bz, dery_bz, err_term1, err_term2))
               {
                   mean_derivative_bz     = DRMS_MISSING_FLOAT;
                   mean_derivative_bz_err = DRMS_MISSING_FLOAT;
            }            }
  
            /***** MEANPOT and TOTPOT, Example Function 13  (Requires Keiji's code) **/              // Set sharp keys
               drms_setkey_float(sharpoutrec, "MEANGBZ",  mean_derivative_bz);
               drms_setkey_float(sharpoutrec, "ERRBZ",  mean_derivative_bz_err);
   
               // Set sharp cea keys
               drms_setkey_float(sharpceaoutrec, "MEANGBZ", mean_derivative_bz);
               drms_setkey_float(sharpceaoutrec, "ERRBZ", mean_derivative_bz_err);
           }
  
           /***** MEANPOT and TOTPOT, Example Function 13  (Requires Keiji's code) **/
            if (totpotflag || meanpotflag)            if (totpotflag || meanpotflag)
            {            {
               // First compute potential field               // First compute potential field
Line 473  int DoIt(void)
Line 492  int DoIt(void)
            }            }
  
            /***** MEANGAM, Example Function 3 ************************************/            /***** MEANGAM, Example Function 3 ************************************/
   
            if (meangamflag)            if (meangamflag)
            {            {
               // First compute horizontal field               // First compute horizontal field
Line 496  int DoIt(void)
Line 514  int DoIt(void)
            }            }
  
            /***** MEANGBT, Example Function 5 (Requires Function 4) *************/            /***** MEANGBT, Example Function 5 (Requires Function 4) *************/
   
            if (meangbtflag)            if (meangbtflag)
            {            {
               // First, compute Bt               // First, compute Bt
Line 520  int DoIt(void)
Line 537  int DoIt(void)
            }            }
  
            /***** MEANGBH, Example Function 6 (Requires Function 2) *************/            /***** MEANGBH, Example Function 6 (Requires Function 2) *************/
   
            if (meangbhflag)            if (meangbhflag)
            {            {
               // First, compute Bh               // First, compute Bh
Line 542  int DoIt(void)
Line 558  int DoIt(void)
               drms_setkey_float(sharpceaoutrec, "ERRBH", mean_derivative_bh_err);               drms_setkey_float(sharpceaoutrec, "ERRBH", mean_derivative_bh_err);
            }            }
  
            /***** MEANGBZ, Example Function 7 ************************************/  
   
            if (meangbzflag)  
            {  
               // Compute Bz derivative  
               if (computeBzderivative(bz, bz_err, dims, &mean_derivative_bz, &mean_derivative_bz_err, mask, bitmask, derx_bz, dery_bz, err_term1, err_term2))  
               {  
                  mean_derivative_bz     = DRMS_MISSING_FLOAT;  
                  mean_derivative_bz_err = DRMS_MISSING_FLOAT;  
               }  
   
               // Set sharp keys  
               drms_setkey_float(sharpoutrec, "MEANGBZ",  mean_derivative_bz);  
               drms_setkey_float(sharpoutrec, "ERRBZ",  mean_derivative_bz_err);  
   
               // Set sharp cea keys  
               drms_setkey_float(sharpceaoutrec, "MEANGBZ", mean_derivative_bz);  
               drms_setkey_float(sharpceaoutrec, "ERRBZ", mean_derivative_bz_err);  
            }  
   
            /***** MEANJZD and TOTUSJZ, Example Function 9 (Requires Function 8) ***/            /***** MEANJZD and TOTUSJZ, Example Function 9 (Requires Function 8) ***/
   
            if (meanjzdflag || totusjzflag)            if (meanjzdflag || totusjzflag)
            {            {
               // First, compute Jz on all pixels               // First, compute Jz on all pixels
Line 597  int DoIt(void)
Line 592  int DoIt(void)
            }            }
  
            /***** MEANALP, Example Function 10 (Requires Function 8)*********/            /***** MEANALP, Example Function 10 (Requires Function 8)*********/
   
            if (meanalpflag)            if (meanalpflag)
            {            {
               // First, compute Jz on all pixels               // First, compute Jz on all pixels
Line 623  int DoIt(void)
Line 617  int DoIt(void)
            }            }
  
            /***** MEANJZH, TOTUSJH, ABSNJZH, Example Function 11 (Requires Function 8) ***/            /***** MEANJZH, TOTUSJH, ABSNJZH, Example Function 11 (Requires Function 8) ***/
   
            if (meanjzhflag || totusjhflag || absnjzhflag)            if (meanjzhflag || totusjhflag || absnjzhflag)
            {            {
               // First, compute Jz on all pixels               // First, compute Jz on all pixels
Line 660  int DoIt(void)
Line 653  int DoIt(void)
            }            }
  
            /***** SAVNCPP, Example Function 12 (Requires Function 8) *******************/            /***** SAVNCPP, Example Function 12 (Requires Function 8) *******************/
   
            if (savncppflag)            if (savncppflag)
            {            {
               // First, compute Jz on all pixels               // First, compute Jz on all pixels
Line 685  int DoIt(void)
Line 677  int DoIt(void)
            }            }
  
            /***** MEANSHR and SHRGT45, Example Function 14 (Requires Keiji's code) **********/            /***** MEANSHR and SHRGT45, Example Function 14 (Requires Keiji's code) **********/
   
            if (meanshrflag || shrgt45flag)            if (meanshrflag || shrgt45flag)
            {            {
               // First compute potential field               // First compute potential field
Line 714  int DoIt(void)
Line 705  int DoIt(void)
            }            }
  
           /***** TOTFX, TOTFY, TOTFX, TOTBSQ, EPSX, EPSY, EPSZ , Example Function 16 (Lorentz forces) **********/           /***** TOTFX, TOTFY, TOTFX, TOTBSQ, EPSX, EPSY, EPSZ , Example Function 16 (Lorentz forces) **********/
   
            if (totfxflag || totfyflag || totfzflag || totbsqflag || epsxflag || epsyflag || epszflag)            if (totfxflag || totfyflag || totfzflag || totbsqflag || epsxflag || epsyflag || epszflag)
            {            {
   
                 // Compute Lorentz forces                 // Compute Lorentz forces
                 if (computeLorentz(bx, by, bz, fx, fy, fz, dims, &totfx, &totfy, &totfz, &totbsq,                 if (computeLorentz(bx, by, bz, fx, fy, fz, dims, &totfx, &totfy, &totfz, &totbsq,
                     &epsx, &epsy, &epsz, mask, bitmask, cdelt1, rsun_ref, rsun_obs))                     &epsx, &epsy, &epsz, mask, bitmask, cdelt1, rsun_ref, rsun_obs))
Line 751  int DoIt(void)
Line 740  int DoIt(void)
  
            }            }
  
           /***** USFLUX, Example Function 17 *************************************/
               if (meanvflosflag)
               {
               // Compute unsigned flux
               if (computeAbsFlux_los(los, dims, &absFlux, &mean_vf,
                                  &count_mask, bitmask, cdelt1, rsun_ref, rsun_obs))
               {
                   mean_vf = DRMS_MISSING_FLOAT;
                   count_mask = DRMS_MISSING_INT;
               }
   
               drms_setkey_float(sharpoutrec, "USFLUX",  mean_vf);
               drms_setkey_float(sharpoutrec, "CMASK",   count_mask);
   
               drms_setkey_float(sharpceaoutrec, "USFLUX",  mean_vf);
               drms_setkey_float(sharpceaoutrec, "CMASK",   count_mask);
           }
   
           /***** MEANGBZ, Example Function 18 ************************************/
           if (meanglosflag)
           {
               // Compute Bz derivative
               if (computeLOSderivative(los, dims, &mean_derivative_los,
                                        bitmask, derx_los, dery_los))
               {
                   mean_derivative_los     = DRMS_MISSING_FLOAT;
               }
   
               // Set sharp keys
               drms_setkey_float(sharpoutrec, "MEANGBZ",  mean_derivative_los);
   
               // Set sharp cea keys
               drms_setkey_float(sharpceaoutrec, "MEANGBZ", mean_derivative_los);
           }
   
            /******************************* END FLAGS **********************************/            /******************************* END FLAGS **********************************/
  
         drms_free_array(bitmaskArray);         drms_free_array(bitmaskArray);
Line 776  int DoIt(void)
Line 800  int DoIt(void)
  
         } //endfor         } //endfor
  
       // free all the arrays
         free(fx); free(fy); free(fz);         free(fx); free(fy); free(fz);
         free(bh); free(bt); free(jz);         free(bh); free(bt); free(jz);
         free(bpx); free(bpy); free(bpz);         free(bpx); free(bpy); free(bpz);
         free(derx); free(dery);         free(derx); free(dery);
         free(derx_bt); free(dery_bt);         free(derx_bt); free(dery_bt);
           free(derx_los); free(dery_los);
         free(derx_bz); free(dery_bz);         free(derx_bz); free(dery_bz);
         free(derx_bh); free(dery_bh);         free(derx_bh); free(dery_bh);
         free(bt_err); free(bh_err);  free(jz_err);         free(bt_err); free(bh_err);  free(jz_err);
Line 789  int DoIt(void)
Line 815  int DoIt(void)
         free(jz_smooth);         free(jz_smooth);
         free(err_term2);         free(err_term2);
         free(err_term1);         free(err_term1);
   
       // Close all the records
         drms_close_records(sharpinrecset, DRMS_FREE_RECORD);         drms_close_records(sharpinrecset, DRMS_FREE_RECORD);
         drms_close_records(sharpceainrecset, DRMS_FREE_RECORD);         drms_close_records(sharpceainrecset, DRMS_FREE_RECORD);
  


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

Karen Tian
Powered by
ViewCVS 0.9.4