Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue/323 add line #373

Merged
merged 7 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions java/edu/ucar/metviewer/MVPlotJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ public class MVPlotJob {
protected double eqboundHigh = -0.001;
protected Boolean isCircularBlockBootstrap = Boolean.TRUE;

protected List<LineAttributes> lines = new ArrayList<>();


/**
* Deep copy of the MVPlotJob, useful for inheritance.
Expand Down Expand Up @@ -434,6 +436,7 @@ public MVPlotJob copy() {

job.eqboundLow = eqboundLow;
job.eqboundHigh = eqboundHigh;
job.lines = new ArrayList<>(lines);
return job;
}

Expand Down Expand Up @@ -2245,6 +2248,14 @@ public void setCircularBlockBootstrap(Boolean addCircularBlockBootstrap) {
isCircularBlockBootstrap = addCircularBlockBootstrap;
}

public List<LineAttributes> getLines() {
return lines;
}

public void setLines(List<LineAttributes> lines) {
this.lines = lines;
}

public Boolean getReverseX() {
return isReverseX;
}
Expand Down
46 changes: 41 additions & 5 deletions java/edu/ucar/metviewer/MVPlotJobParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ public static StringBuilder serializeJob(MVPlotJob job, DatabaseInfo databaseInf
xmlStr.append("</plot_fix>");

// agg_stat
if ((job.getAggCtc() || job.getAggSl1l2() || job.getAggSal1l2() || job.getAggPct()|| job.getAggMctc()
if ((job.getAggCtc() || job.getAggSl1l2() || job.getAggSal1l2() || job.getAggPct() || job.getAggMctc()
|| job.getAggNbrCnt() || job.getAggSsvar()
|| job.getAggVl1l2() || job.getAggGrad() || job.getAggEcnt())
|| job.isModeRatioJob()) {
Expand Down Expand Up @@ -908,7 +908,7 @@ public static StringBuilder serializeJob(MVPlotJob job, DatabaseInfo databaseInf
if (job.getPlotTmpl().equals("ens_ss.R_tmpl")) {
xmlStr.append(
"<ensss_pts>" + job.getEnsSsPts() + "</ensss_pts>" +
"<ensss_pts_disp>" + (job.getEnsSsPtsDisp() ? "TRUE" : "FALSE")+ "</ensss_pts_disp>");
"<ensss_pts_disp>" + (job.getEnsSsPtsDisp() ? "TRUE" : "FALSE") + "</ensss_pts_disp>");
}

//taylor
Expand Down Expand Up @@ -1059,6 +1059,19 @@ public static StringBuilder serializeJob(MVPlotJob job, DatabaseInfo databaseInf
xmlStr.append("<contour_intervals>" + job.getContourIntervals() + "</contour_intervals>");
}

if (!job.getLines().isEmpty()) {
StringBuilder linesStr = new StringBuilder("<lines>");
for (LineAttributes lineAttributes : job.getLines()) {
linesStr.append("<line color=\"").append(lineAttributes.getColor()).append("\" line_pos=\"")
.append(lineAttributes.getPosition()).append("\" lty=\"").append(lineAttributes.getLty())
.append("\" lwd=\"").append(lineAttributes.getLwd()).append("\" type=\"")
.append(lineAttributes.getType()).append("\"/>");
}
linesStr.append("</lines>");
xmlStr.append(linesStr);
}


// close the plot job
xmlStr.append("</plot></plot_spec>");
return xmlStr;
Expand Down Expand Up @@ -1263,6 +1276,7 @@ else if (node.tag.equals("plot")) {
String strCompleteness = "";
boolean boolPlotRun = !node.run.equalsIgnoreCase("false");


if (job.getPlotTmpl().equals("roc.R_tmpl")) {

// ROC jobs must have an aggregation method selected
Expand Down Expand Up @@ -1376,7 +1390,7 @@ else if (node.tag.equals("indep")) {
} else {
String[][] listIndy = parseIndyNode(node, "");
int size = listIndy[0].length;
if(listIndy[2].length < size) {
if (listIndy[2].length < size) {
String[] newListIndy = new String[size];
for (int j = 0; j < size; j++) {
if (j < listIndy[2].length) {
Expand Down Expand Up @@ -1769,8 +1783,8 @@ else if (node.tag.equals("agg_stat")) {
if (nodeAggStat.tag.equals("agg_ctc")) {
job.setAggCtc(val);
} else if (nodeAggStat.tag.equals("agg_mctc")) {
job.setAggMctc(val);}
else if (nodeAggStat.tag.equals("agg_nbrctc")) {
job.setAggMctc(val);
} else if (nodeAggStat.tag.equals("agg_nbrctc")) {
job.setAggNbrCtc(val);
} else if (nodeAggStat.tag.equals("agg_sl1l2")) {
job.setAggSl1l2(val);
Expand Down Expand Up @@ -1913,6 +1927,28 @@ else if (node.tag.equals("normalized_histogram")) {
job.setNormalizedHistogram(node.value.equalsIgnoreCase("true"));

}
// <lines>
else if (node.tag.equals("lines") && node.children.length > 0) {
List<LineAttributes> lines = new ArrayList<>();
for (int j = 0; j < node.children.length; j++) {
MVNode lineNode = node.children[j];
if (lineNode.tag.equals("line")) {
LineAttributes lineAttributes = new LineAttributes();
try {
lineAttributes.setColor(lineNode.getAttribute("color"));
lineAttributes.setLty(lineNode.getAttribute("lty"));
lineAttributes.setLwd(lineNode.getAttribute("lwd"));
lineAttributes.setPosition(lineNode.getAttribute("line_pos"));
lineAttributes.setType(lineNode.getAttribute("type"));
} catch (Exception e) {
logger.error("One of the lin's attribute is invalid or missing");
}
lines.add(lineAttributes);
}
}
job.setLines(lines);

}


// boolean format settings
Expand Down
2 changes: 1 addition & 1 deletion java/edu/ucar/metviewer/jobManager/BarJobManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ public BarJobManager(MVBatch mvBatch) {
}
@Override
protected String getPythonScript() {
return "/plots/bar/bar.py";
return "/metplotpy/plots/bar/bar.py";
}
}
2 changes: 1 addition & 1 deletion java/edu/ucar/metviewer/jobManager/BoxJobManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ public BoxJobManager(MVBatch mvBatch) {
}
@Override
protected String getPythonScript() {
return "/plots/box/box.py";
return "/metplotpy/plots/box/box.py";
}
}
2 changes: 1 addition & 1 deletion java/edu/ucar/metviewer/jobManager/ContourJobManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ protected Map<String, Object> createYamlInfoMap(MVPlotJob job) throws Validation
}
@Override
protected String getPythonScript() {
return "/plots/contour/contour.py";
return "/metplotpy/plots/contour/contour.py";
}
}
2 changes: 1 addition & 1 deletion java/edu/ucar/metviewer/jobManager/EclvJobManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,6 @@ protected void run(MVPlotJob job) throws ValidationException, ParseException, IO
}
@Override
protected String getPythonScript() {
return "/plots/eclv/eclv.py";
return "/metplotpy/plots/eclv/eclv.py";
}
}
2 changes: 1 addition & 1 deletion java/edu/ucar/metviewer/jobManager/EnsSsJobManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ protected void validateNumDepSeries(MVPlotJob job, int intNumDepSeries) {
}
@Override
protected String getPythonScript() {
return "/plots/ens_ss/ens_ss.py";
return "/metplotpy/plots/ens_ss/ens_ss.py";
}
}
2 changes: 1 addition & 1 deletion java/edu/ucar/metviewer/jobManager/EtbJobManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public EtbJobManager(MVBatch mvBatch) {
}
@Override
protected String getPythonScript() {
return "/plots/equivalence_testing_bounds/equivalence_testing_bounds.py";
return "/metplotpy/plots/equivalence_testing_bounds/equivalence_testing_bounds.py";
}

@Override
Expand Down
23 changes: 15 additions & 8 deletions java/edu/ucar/metviewer/jobManager/JobManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,7 @@
import java.util.*;
import java.util.regex.Matcher;

import edu.ucar.metviewer.DatabaseException;
import edu.ucar.metviewer.MVBatch;
import edu.ucar.metviewer.MVDataTable;
import edu.ucar.metviewer.MVOrderedMap;
import edu.ucar.metviewer.MVPlotJob;
import edu.ucar.metviewer.MVUtil;
import edu.ucar.metviewer.StopWatchException;
import edu.ucar.metviewer.ValidationException;
import edu.ucar.metviewer.*;

/**
* @author : tatiana $
Expand Down Expand Up @@ -541,6 +534,20 @@ protected Map<String, Object> createYamlInfoMap(MVPlotJob job) throws Validation
yamlInfo.put("cl_step", 0.05);
yamlInfo.put("equalize_by_indep", job.getEqualizeByIndep() ? "True" : "False");

if(!job.getLines().isEmpty()){
List <Map<String, Object>> linesList = new ArrayList<>();
for (LineAttributes lineAttributes : job.getLines()){
Map<String, Object> line = new HashMap<>();
line.put("type", lineAttributes.getType());
line.put("line_style", linesRtoPython.get(lineAttributes.getLty()));
line.put("line_width", lineAttributes.getLwd());
line.put("color", lineAttributes.getColor());
line.put("position", lineAttributes.getPosition());
linesList.add(line);
}
yamlInfo.put("lines", linesList);
}

return yamlInfo;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected int getNumberPlotCurves(Map.Entry[] listDep1Plot) {

@Override
protected String getPythonScript() {
return "/plots/performance_diagram/performance_diagram.py";
return "/metplotpy/plots/performance_diagram/performance_diagram.py";
}
@Override
protected Map<String, Object> addPlotConfigs(Map<String, Object> yamlInfo, MVPlotJob job, int intNumDepSeries) throws ValidationException {
Expand Down
2 changes: 1 addition & 1 deletion java/edu/ucar/metviewer/jobManager/PhistJobManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ public PhistJobManager(MVBatch mvBatch) {
}
@Override
protected String getPythonScript() {
return "/plots/histogram/prob_hist.py";
return "/metplotpy/plots/histogram/prob_hist.py";
}
}
2 changes: 1 addition & 1 deletion java/edu/ucar/metviewer/jobManager/RelpJobManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ public RelpJobManager(MVBatch mvBatch) {
}
@Override
protected String getPythonScript() {
return "/plots/histogram/rel_hist.py";
return "/metplotpy/plots/histogram/rel_hist.py";
}
}
2 changes: 1 addition & 1 deletion java/edu/ucar/metviewer/jobManager/RelyJobManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ protected void run(MVPlotJob job) throws ParseException, ValidationException, IO

@Override
protected String getPythonScript() {
return "/plots/reliability_diagram/reliability.py";
return "/metplotpy/plots/reliability_diagram/reliability.py";
}

}
2 changes: 1 addition & 1 deletion java/edu/ucar/metviewer/jobManager/RhistJobManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ protected void run(MVPlotJob job) throws ParseException, ValidationException, IO
}
@Override
protected String getPythonScript() {
return "/plots/histogram/rank_hist.py";
return "/metplotpy/plots/histogram/rank_hist.py";
}

}
2 changes: 1 addition & 1 deletion java/edu/ucar/metviewer/jobManager/RocJobManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ protected void run(MVPlotJob job) throws ParseException, ValidationException, IO

@Override
protected String getPythonScript() {
return "/plots/roc_diagram/roc_diagram.py";
return "/metplotpy/plots/roc_diagram/roc_diagram.py";
}

}
2 changes: 1 addition & 1 deletion java/edu/ucar/metviewer/jobManager/SeriesJobManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ protected void run(MVPlotJob job) throws ParseException, ValidationException, IO

@Override
protected String getPythonScript() {
return "/plots/line/line.py";
return "/metplotpy/plots/line/line.py";
}


Expand Down
2 changes: 1 addition & 1 deletion java/edu/ucar/metviewer/jobManager/TaylorJobManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected int getNumberPlotCurves(Map.Entry[] listDep1Plot) {
}
@Override
protected String getPythonScript() {
return "/plots/taylor_diagram/taylor_diagram.py";
return "/metplotpy/plots/taylor_diagram/taylor_diagram.py";
}

@Override
Expand Down
Loading