|
[HepData-svn] r1810 - trunk/hepdata-webapp/src/main/java/cedar/hepdata/formatsblackhole at projects.hepforge.org blackhole at projects.hepforge.orgThu Jul 24 13:07:28 BST 2014
Author: watt Date: Thu Jul 24 13:07:28 2014 New Revision: 1810 Log: Be more careful with writing signs if errors are zero Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/BdmsFormatter.java trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/InputFormatter.java trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/MarcXMLFormatter.java trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/PlainFormatter.java Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/BdmsFormatter.java ============================================================================== --- trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/BdmsFormatter.java Thu Jul 24 13:05:01 2014 (r1809) +++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/BdmsFormatter.java Thu Jul 24 13:07:28 2014 (r1810) @@ -273,8 +273,19 @@ else{ s.append(" +- " + f_plus + norm);} } else{ - if(yax.getPoint(i+1).getErrors().size()==1&&err.getSourceType().toString().equals("statistical")){ s.append(" (STAT=+" + f_plus + norm + "," + f_minus + norm+")");} - else { s.append(" +" + f_plus + norm + "," + f_minus + norm);} + if(yax.getPoint(i+1).getErrors().size()==1&&err.getSourceType().toString().equals("statistical")){ + if (err.getMinus() == 0.0) { + s.append(" (STAT=+" + f_plus + norm + ",-" + f_minus + norm+")"); + } else { + s.append(" (STAT=+" + f_plus + norm + "," + f_minus + norm+")"); + } + } else { + if (err.getMinus() == 0.0) { + s.append(" +" + f_plus + norm + ",-" + f_minus + norm); + } else { + s.append(" +" + f_plus + norm + "," + f_minus + norm); + } + } } } else if(nerr == 2) { @@ -287,7 +298,8 @@ if (err.getPlus() < 0.0) { s.append("" + f_plus + norm); } else { s.append("+" + f_plus + norm); } if (err.getMinus() < 0.0) { s.append("," + f_minus + norm); } - else { s.append(",+" + f_minus + norm); } + else if (err.getMinus() > 0.0) { s.append(",+" + f_minus + norm); } + else { s.append(",-" + f_minus + norm); } } } else { @@ -299,7 +311,8 @@ if (err.getPlus() < 0.0) { s.append("" + f_plus + norm); } else { s.append("+" + f_plus + norm); } if (err.getMinus() < 0.0) { s.append("," + f_minus + norm); } - else { s.append(",+" + f_minus + norm); } + else if (err.getMinus() > 0.0) { s.append(",+" + f_minus + norm); } + else { s.append(",-" + f_minus + norm); } } } } Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/InputFormatter.java ============================================================================== --- trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/InputFormatter.java Thu Jul 24 13:05:01 2014 (r1809) +++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/InputFormatter.java Thu Jul 24 13:07:28 2014 (r1810) @@ -301,8 +301,9 @@ if(nerr == 1) { if(err.isSymmetric()){ s.append(" +- " + f_plus + norm); - } - else{ + } else if (err.getMinus() == 0.0) { + s.append(" +" + f_plus + norm + ",-" + f_minus + norm); + } else{ s.append(" +" + f_plus + norm + "," + f_minus + norm); } } @@ -318,7 +319,8 @@ if (err.getPlus() < 0.0) { s.append("" + f_plus + norm); } else { s.append("+" + f_plus + norm); } if (err.getMinus() < 0.0) { s.append("," + f_minus + norm); } - else { s.append(",+" + f_minus + norm); } + else if (err.getMinus() > 0.0) { s.append(",+" + f_minus + norm); } + else { s.append(",-" + f_minus + norm); } } } else { @@ -328,7 +330,8 @@ if (err.getPlus() < 0.0) { s.append("" + f_plus + norm); } else { s.append("+" + f_plus + norm); } if (err.getMinus() < 0.0) { s.append("," + f_minus + norm); } - else { s.append(",+" + f_minus + norm); } + else if (err.getMinus() > 0.0) { s.append(",+" + f_minus + norm); } + else { s.append(",-" + f_minus + norm); } } } if(err.getComment() != null && !err.getComment().equals("")) { Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/MarcXMLFormatter.java ============================================================================== --- trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/MarcXMLFormatter.java Thu Jul 24 13:05:01 2014 (r1809) +++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/MarcXMLFormatter.java Thu Jul 24 13:07:28 2014 (r1810) @@ -516,7 +516,7 @@ s.append(e.getNormType().toSymbol()); } else { vale = new SignificantFigures(e.getPlus()); - if (e.getPlus()<0.0) { s.append(""); } + if (e.getPlus()<0.0) { s.append(" "); } else { s.append(" +"); } if (e.getNormType() == ErrorNorm.PCT) { lsd = vale.getLSD(); } msd = vale.getMSD(); @@ -526,7 +526,8 @@ s.append(e.getNormType().toSymbol()); vale = new SignificantFigures(e.getMinus()); if (e.getMinus()<0.0) { s.append(","); } - else { s.append(",+"); } + else if (e.getMinus()>0.0) { s.append(",+"); } + else { s.append(",-"); }; if (e.getNormType() == ErrorNorm.PCT) { lsd = vale.getLSD(); } msd = vale.getMSD(); if (msd <= 0) msd = 1; Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/PlainFormatter.java ============================================================================== --- trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/PlainFormatter.java Thu Jul 24 13:05:01 2014 (r1809) +++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/PlainFormatter.java Thu Jul 24 13:07:28 2014 (r1810) @@ -261,22 +261,18 @@ for (Uncertainty e : d.getYAxis(ny).getPoint(r).getErrors()) { try { Uncertainty ae = e.getAbsoluteError(d.getYAxis(ny).getPoint(r)); - if (ae.isSymmetricReversed()) { - s.append("\t" + ae.getPlus()); - s.append("\t+" + ae.getMinus()); - } else if (ae.getPlus() < 0.0 && ae.getMinus() > 0.0) { - s.append("\t" + ae.getPlus()); - s.append("\t+" + ae.getMinus()); - } else if (ae.getPlus() < 0.0 && ae.getMinus() < 0.0) { - s.append("\t" + ae.getPlus()); - s.append("\t" + ae.getMinus()); - } else if (ae.getPlus() > 0.0 && ae.getMinus() > 0.0) { - s.append("\t+" + ae.getPlus()); - s.append("\t+" + ae.getMinus()); + if (ae.getPlus() < 0.0) { + s.append("\t" + ae.getPlus()); } else { - s.append("\t+" + ae.getPlus()); - s.append("\t" + ae.getMinus()); - } + s.append("\t+" + ae.getPlus()); + } + if (ae.getMinus() < 0.0) { + s.append("\t" + ae.getMinus()); + } else if (ae.getMinus() > 0.0) { + s.append("\t+" + ae.getMinus()); + } else { + s.append("\t-" + ae.getMinus()); + } } catch (HDException hde) { s.append("\t+?\t?"); }
More information about the HepData-svn mailing list |