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 6 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
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
Loading