Skip to content

Commit

Permalink
Issue #517 Added new columns for the VCNT, VL1L2, VAL1L2, and ECNT li… (
Browse files Browse the repository at this point in the history
#544)

* Issue #517 Added new columns for the VCNT, VL1L2, VAL1L2, and ECNT linetypes

* Issue #517 removed the VCNT boostrap variables from statsVcnt

* Issue #517 reformatted code and added columns for the VL1L2, VAL1L2, and ECNT linetypes.

* issue #517 fixed entries for VCNT, copy and paste resulted in VAL1L2 values instead of VCNT values.

* Updated the job.getAggEcnt(), job.getAggVl1l2(), and job.getAggVal1l2() to include the new columns.

* Add missing commas between entries in job.getAggEcnt, job.getAggVl1l2, and job.getAggVal1l2

* Add VERSION to statVl1l2.put to be consistent with the agg stat code in  MysqlAppDatabaseManager.java

* Revert back to previous version of statsVl1L2.put, omitting the addition of VL1L2_VERSION, this is not necessary
  • Loading branch information
bikegeek authored Aug 29, 2024
1 parent aaaf5f9 commit 0b8fda6
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 67 deletions.
57 changes: 37 additions & 20 deletions java/edu/ucar/metviewer/MVUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class MVUtil {
public static final String NBRCNT = "nbrcnt"; // Neighborhood Continuous Statistics
public static final String VL1L2 = "vl1l2"; // Vector Partial Sum
public static final String VAL1L2 = "val1l2"; // Vector Anomaly Partial Sum
public static final String VCNT = "vcnt"; // Vector Continuous Statistics
public static final String ECNT = "ecnt"; // Ensemble Continuous Statistics
public static final String RPS = "rps"; // Ranked Probability Score Statistics
public static final Map<String, String[]> statsEnscnt = new HashMap<>();
Expand Down Expand Up @@ -565,26 +566,34 @@ public class MVUtil {
}

static {
statsVcnt.put("VCNT_FBAR", new String[]{"bc", VL1L2});
statsVcnt.put("VCNT_OBAR", new String[]{"bc", VL1L2});
statsVcnt.put("VCNT_FS_RMS", new String[]{"bc", VL1L2});
statsVcnt.put("VCNT_OS_RMS", new String[]{"bc", VL1L2});
statsVcnt.put("VCNT_MSVE", new String[]{"bc", VL1L2});
statsVcnt.put("VCNT_RMSVE", new String[]{"bc", VL1L2});
statsVcnt.put("VCNT_FSTDEV", new String[]{"bc", VL1L2});
statsVcnt.put("VCNT_OSTDEV", new String[]{"bc", VL1L2});
statsVcnt.put("VCNT_FDIR", new String[]{"bc", VL1L2});
statsVcnt.put("VCNT_ODIR", new String[]{"bc", VL1L2});
statsVcnt.put("VCNT_FBAR_SPEED", new String[]{"bc", VL1L2});
statsVcnt.put("VCNT_OBAR_SPEED", new String[]{"bc", VL1L2});
statsVcnt.put("VCNT_VDIFF_SPEED", new String[]{"bc", VL1L2});
statsVcnt.put("VCNT_VDIFF_DIR", new String[]{"bc", VL1L2});
statsVcnt.put("VCNT_SPEED_ERR", new String[]{"bc", VL1L2});
statsVcnt.put("VCNT_SPEED_ABSERR", new String[]{"bc", VL1L2});
statsVcnt.put("VCNT_DIR_ERR", new String[]{"bc", VL1L2});
statsVcnt.put("VCNT_DIR_ABSERR", new String[]{"bc", VL1L2});
statsVcnt.put("VCNT_ANOM_CORR", new String[]{"nc","bc", VAL1L2});
statsVcnt.put("VCNT_ANOM_CORR_UNCNTR", new String[]{"bc", VAL1L2});
statsVcnt.put("VCNT_FBAR", new String[]{"bc", VCNT});
statsVcnt.put("VCNT_OBAR", new String[]{"bc", VCNT});
statsVcnt.put("VCNT_FS_RMS", new String[]{"bc", VCNT});
statsVcnt.put("VCNT_OS_RMS", new String[]{"bc", VCNT});
statsVcnt.put("VCNT_MSVE", new String[]{"bc", VCNT});
statsVcnt.put("VCNT_RMSVE", new String[]{"bc", VCNT});
statsVcnt.put("VCNT_FSTDEV", new String[]{"bc", VCNT});
statsVcnt.put("VCNT_OSTDEV", new String[]{"bc", VCNT});
statsVcnt.put("VCNT_FDIR", new String[]{"bc", VCNT});
statsVcnt.put("VCNT_ODIR", new String[]{"bc", VCNT});
statsVcnt.put("VCNT_FBAR_SPEED", new String[]{"bc", VCNT});
statsVcnt.put("VCNT_OBAR_SPEED", new String[]{"bc", VCNT});
statsVcnt.put("VCNT_VDIFF_SPEED", new String[]{"bc", VCNT});
statsVcnt.put("VCNT_VDIFF_DIR", new String[]{"bc", VCNT});
statsVcnt.put("VCNT_SPEED_ERR", new String[]{"bc", VCNT});
statsVcnt.put("VCNT_SPEED_ABSERR", new String[]{"bc", VCNT});
statsVcnt.put("VCNT_DIR_ERR", new String[]{"bc", VCNT});
statsVcnt.put("VCNT_DIR_ABSERR", new String[]{"bc", VCNT});
statsVcnt.put("VCNT_ANOM_CORR", new String[]{"nc","bc", VCNT});
statsVcnt.put("VCNT_ANOM_CORR_UNCNTR", new String[]{"bc", VCNT});
statsVcnt.put("VCNT_DIR_ME", new String[]{"bc", VCNT});
statsVcnt.put("VCNT_DIR_MAE", new String[]{"bc", VCNT});
statsVcnt.put("VCNT_DIR_MSE", new String[]{"bc", VCNT});
statsVcnt.put("VCNT_DIR_RMSE", new String[]{"bc", VCNT});
statsVcnt.put("VCNT_TOTAL", new String[]{"bc", VCNT});
statsVcnt.put("VCNT_TOTAL_DIR", new String[]{"bc", VCNT});


}

static {
Expand All @@ -611,6 +620,8 @@ public class MVUtil {
statsEcnt.put("ECNT_ME_GE_OBS", new String[]{ECNT});
statsEcnt.put("ECNT_N_LT_OBS", new String[]{ECNT});
statsEcnt.put("ECNT_ME_LT_OBS", new String[]{ECNT});
statsEcnt.put("ECNT_IGN_CONV_OERR", new String[]{ECNT});
statsEcnt.put("ECNT_IGN_CORR_OERR", new String[]{ECNT});

statsEcnt.put("ECNT_TOTAL", new String[]{ECNT});
}
Expand Down Expand Up @@ -750,6 +761,9 @@ public class MVUtil {

static {
statsVal1l2.put("VAL1L2_ANOM_CORR", new String[]{VAL1L2});
statsVal1l2.put("VAL1L2_DIRA_ME", new String[]{VAL1L2});
statsVal1l2.put("VAL1L2_DIRA_MAE", new String[]{VAL1L2});
statsVal1l2.put("VAL1L2_DIRA_MSE", new String[]{VAL1L2});
statsVal1l2.put("VAL1L2_TOTAL", new String[]{VAL1L2});
}

Expand All @@ -764,6 +778,9 @@ public class MVUtil {
statsVl1l2.put("VL1L2_SPEED_ERR", new String[]{VL1L2});
statsVl1l2.put("VL1L2_RMSVE", new String[]{VL1L2});
statsVl1l2.put("VL1L2_SPEED_DIFF", new String[]{VL1L2});
statsVl1l2.put("VL1L2_DIR_ME", new String[]{VL1L2});
statsVl1l2.put("VL1L2_DIR_MAE", new String[]{VL1L2});
statsVl1l2.put("VL1L2_DIR_MSE", new String[]{VL1L2});
statsVl1l2.put("VL1L2_TOTAL", new String[]{VL1L2});
}

Expand Down
10 changes: 7 additions & 3 deletions java/edu/ucar/metviewer/db/mysql/MysqlAppDatabaseManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1949,7 +1949,9 @@ public List<String> buildPlotSql(
+ "\n ld.n_ge_obs,"
+ "\n ld.me_ge_obs,"
+ "\n ld.n_lt_obs,"
+ "\n ld.me_lt_obs";
+ "\n ld.me_lt_obs,"
+ "\n ld.ign_conv_oerr,"
+ "\n ld.ign_corr_oerr";
} else if (job.getAggPct()) {

if (job.getPlotTmpl().equals("eclv.R_tmpl")) {
Expand Down Expand Up @@ -1995,11 +1997,13 @@ public List<String> buildPlotSql(
} else if (job.getAggVl1l2()) {
selectStat += ",\n 'NA' stat_value,\n ld.total,\n ld.ufbar,\n ld.vfbar,\n ld.uobar,"
+ "\n ld.vobar,\n ld.uvfobar,\n ld.uvffbar,\n ld.uvoobar,"
+ " \n ld.f_speed_bar, \n ld.o_speed_bar";
+ " \n ld.f_speed_bar, \n ld.o_speed_bar, \n ld.total_dir, \n ld.dir_me, \n ld.dir_mae,"
+ "\n ld.dir_mse, \n ld.version" ;
} else if (job.getAggVal1l2()) {
selectStat += ",\n 'NA' stat_value,\n ld.total,\n ld.ufabar,\n ld.vfabar,\n "
+ "ld.uoabar,\n ld.voabar,\n ld.uvfoabar,\n ld.uvffabar,\n"
+ " ld.uvooabar,\n ld.fa_speed_bar,\n ld.oa_speed_bar ";
+ " ld.uvooabar,\n ld.fa_speed_bar,\n ld.oa_speed_bar, "
+ "\n ld.version, \n ld.total_dir, \n ld.dira_me, \n ld.dira_mae, \n ld.dira_mse";
} else if (job.getCalcCtc()) {
selectStat += ",\n ld.total, ld.fy_oy, ld.fy_on, ld.fn_oy, ld.fn_on, "
+ "'NA' stat_value,\n"
Expand Down
90 changes: 46 additions & 44 deletions java/edu/ucar/metviewer/scorecard/db/AggDatabaseManagerMySQL.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,56 +19,58 @@
*/
public class AggDatabaseManagerMySQL extends DatabaseManagerSql {

private static final Logger logger = LogManager.getLogger("AggDatabaseManagerMySQL");
private static final Logger logger = LogManager.getLogger("AggDatabaseManagerMySQL");


public AggDatabaseManagerMySQL(final Scorecard scorecard,
final MysqlDatabaseManager databaseManager) throws SQLException {
super(scorecard, databaseManager);
aggStatDataFilePath = scorecard.getWorkingFolders().getDataDir() + scorecard.getAggStatDataFile();
public AggDatabaseManagerMySQL(final Scorecard scorecard,
final MysqlDatabaseManager databaseManager) throws SQLException {
super(scorecard, databaseManager);
aggStatDataFilePath = scorecard.getWorkingFolders().getDataDir() + scorecard.getAggStatDataFile();

}
}

@Override
protected String getSelectFields(String table, Integer thresh) {
String result = "";
if (table.endsWith(MVUtil.CTC)) {
result = "total, fy_oy,fy_on,fn_oy,fn_on";
} else if (table.endsWith(MVUtil.SL1L2)) {
result = "total,fbar,obar,fobar,ffbar,oobar,mae";
} else if (table.endsWith(MVUtil.GRAD)) {
result = "total,fgbar,ogbar,mgbar,egbar";
} else if (table.endsWith(MVUtil.SAL1L2)) {
result = "total,fabar,oabar,foabar,ffabar,ooabar,mae";
} else if (table.endsWith(MVUtil.VL1L2)) {
result = "total,ufbar,vfbar,uobar,vobar,uvfobar,uvffbar,uvoobar";
} else if (table.endsWith(MVUtil.VAL1L2)) {
result = "total,ufabar,vfabar,uoabar,voabar,uvfoabar,uvffabar,uvooabar";
} else if (table.endsWith(MVUtil.ECNT)) {
result = "total,me,rmse,crps,crpss,ign,spread,me_oerr,rmse_oerr,spread_oerr,spread_plus_oerr,crpscl,crps_emp,crpscl_emp ,crpss_emp";
} else if (table.endsWith(MVUtil.RPS)) {
result = "total,rps,rpss, rps_comp";
} else if (table.endsWith("nbrcnt")) {
result = "total,fbs,fss";
} else if (table.endsWith(MVUtil.PCT)) {
result = "total,(line_data_pct.n_thresh - 1)";
for (int i = 1; i < thresh; i++) {
result += ",";
if (i < thresh - 1) {
result += " FORMAT((ldt" + i + ".thresh_i + ldt" + (i + 1) + ".thresh_i)/2, 3),";
} else {
result += " FORMAT((ldt" + i + ".thresh_i + 1)/2, 3),";
@Override
protected String getSelectFields(String table, Integer thresh) {
String result = "";
if (table.endsWith(MVUtil.CTC)) {
result = "total, fy_oy,fy_on,fn_oy,fn_on";
} else if (table.endsWith(MVUtil.SL1L2)) {
result = "total,fbar,obar,fobar,ffbar,oobar,mae";
} else if (table.endsWith(MVUtil.GRAD)) {
result = "total,fgbar,ogbar,mgbar,egbar";
} else if (table.endsWith(MVUtil.SAL1L2)) {
result = "total,fabar,oabar,foabar,ffabar,ooabar,mae";
} else if (table.endsWith(MVUtil.VL1L2)) {
result = "total,ufbar,vfbar,uobar,vobar,uvfobar,uvffbar,uvoobar, f_speed_bar, o_speed_bar, total_dir, dir_me, dir_mae, dir_mse";
} else if (table.endsWith(MVUtil.VAL1L2)) {
result = "total,ufabar,vfabar,uoabar,voabar,uvfoabar,uvffabar,uvooabar, fa_speed_bar, oa_speed_bar, total_dir, dira_me, dira_mae, dira_mse";
} else if (table.endsWith(MVUtil.ECNT)) {
result = "total,me,rmse,crps,crpss,ign,spread,me_oerr,rmse_oerr,spread_oerr,spread_plus_oerr,crpscl," +
"crps_emp,crpscl_emp,crpss_emp,crpss_emp_fair,spread_md,mae,mae_oerr,bias_ratio,n_ge_obs, " +
"me_ge_obs,n_lt_obs,me_lt_obs,ign_conv_oerr,ign_corr_oerr";
} else if (table.endsWith(MVUtil.RPS)) {
result = "total,rps,rpss, rps_comp";
} else if (table.endsWith("nbrcnt")) {
result = "total,fbs,fss";
} else if (table.endsWith(MVUtil.PCT)) {
result = "total,(line_data_pct.n_thresh - 1)";
for (int i = 1; i < thresh; i++) {
result += ",";
if (i < thresh - 1) {
result += " FORMAT((ldt" + i + ".thresh_i + ldt" + (i + 1) + ".thresh_i)/2, 3),";
} else {
result += " FORMAT((ldt" + i + ".thresh_i + 1)/2, 3),";
}
result += " ldt" + i + ".oy_i," +
" ldt" + i + ".on_i";
}
}
result += " ldt" + i + ".oy_i," +
" ldt" + i + ".on_i";
}
return result;
}
return result;
}

@Override
protected String getStatValue(String table, String stat) {
return "";
}
@Override
protected String getStatValue(String table, String stat) {
return "";
}

}

0 comments on commit 0b8fda6

Please sign in to comment.