|
[HepData-svn] r1802 - in trunk/hepdata-webapp/src/main: java/cedar/hepdata/formats java/cedar/hepdata/webapp/components resources/cedar/hepdata/webapp/pagesblackhole at projects.hepforge.org blackhole at projects.hepforge.orgWed Jun 25 13:33:34 BST 2014
Author: watt Date: Wed Jun 25 13:33:33 2014 New Revision: 1802 Log: Fix input formatter if x axis contains inequalities and focus is null. Link sample Python script from webpage. Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/InputFormatter.java trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/components/Tip.java trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/SubmittingData.tml Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/InputFormatter.java ============================================================================== --- trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/InputFormatter.java Wed May 28 13:37:43 2014 (r1801) +++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/InputFormatter.java Wed Jun 25 13:33:33 2014 (r1802) @@ -15,47 +15,48 @@ public class InputFormatter { public static String format(Collection<Dataset> ds, Paper p) { - StringBuffer s = new StringBuffer(); - if(p!=null){ - s.append("*author: " + p.getAuthors().first() + "\n"); - for (Reference ref : p.getReferences()){ - s.append("*reference: "+ref.getDescription()+" : "+ref.getDate()+"\n"); + StringBuffer s = new StringBuffer(); + if(p!=null){ + s.append("*author: " + p.getAuthors().first() + "\n"); + for (Reference ref : p.getReferences()){ + s.append("*reference: "+ref.getDescription()+" : "+ref.getDate()+"\n"); } - if (p.getDOI() != null) { - s.append("*doi: "+p.getDOI()+"\n"); - } + if (p.getDOI() != null) { + s.append("*doi: "+p.getDOI()+"\n"); + } for (Modification mod : p.getModifications()){ s.append("*status: Encoded "+mod.getComment()+" by "+mod.getModifier()+"\n"); } for (Experiment exp : p.getExperiments()){ - s.append("*experiment: "+exp.getName()+"\n"); - s.append("*detector: "+exp.getInformalName()+"\n"); + s.append("*experiment: "+exp.getName()+"\n"); + s.append("*detector: "+exp.getInformalName()+"\n"); } if(p.getSpiresId()!=null) s.append("*spiresId: " + p.getSpiresId() + "\n"); if(p.getInspireId()!=null) s.append("*inspireId: " + p.getInspireId() + "\n"); - if(p.getCdsId()!=null) s.append("*cdsId: " + p.getCdsId() + "\n"); + if(p.getCdsId()!=null) s.append("*cdsId: " + p.getCdsId() + "\n"); if(p.getRedId()!=null) s.append("*durhamId: " + p.getRedId() + "\n"); if(p.getTitle()!=null) { - s.append("*title: "+p.getTitle()+"\n"); + s.append("*title: "+p.getTitle()+"\n"); } for (String comment : p.getComments()){ comment=comment.replaceAll("\\\\n","\\\\\\\\n"); s.append("*comment: "+comment+"\n"); - } - } - for (Dataset d : ds) { + } + } + for (Dataset d : ds) { String dstr = InputFormatter.format(d); if (dstr != null) s.append(dstr); } + s.append("\n*E\n"); return s.toString(); } public static String format(Dataset ds) { - StringBuffer s = new StringBuffer(); + StringBuffer s = new StringBuffer(); s.append("\n*dataset:"+"\n"); if(ds.getTfpString() != null){ s.append(ds.getTfpString().replace("TFP = L","*l").replace(";","").replace(": ",": ") + "\n"); @@ -79,7 +80,7 @@ s.append("*dserror: " + de.getPlus()); if(de.getNormType().toSymbol().equals("%")){s.append(" PCT");} s.append(" : " + de.getComment()); - s.append("\n"); + s.append("\n"); } @@ -122,42 +123,42 @@ nyhead=1; } - for (String comm : yax.getComments()){ - if(comm.contains(":")){ - StringBuffer tempbuff = new StringBuffer(); - String left = comm.split("\\s*:\\s*")[0]; + for (String comm : yax.getComments()){ + if(comm.contains(":")){ + StringBuffer tempbuff = new StringBuffer(); + String left = comm.split("\\s*:\\s*")[0]; String right=" "; if(comm.split("\\s*:\\s*").length>1){ right = comm.split("\\s*:\\s*")[1]; } - tempbuff.append("*qual: " + left + " : " + right); - storelist.add(tempbuff.toString()); - } else{ - nycomm =- 1; - } - } - for (Property prop : yax.getProperties()){ - if(!prop.getName().startsWith("sqrts")){ - StringBuffer tempbuff = new StringBuffer(); - tempbuff.append("*qual: " + prop.getName().trim()); - if(!prop.getUnit().toString().equals("num")) { tempbuff.append(" IN " + prop.getUnit().toString().toUpperCase()); } - if(prop.getLowValue().equals(prop.getHighValue())){ - tempbuff.append(" : " + prop.getLowValue()); - } else{ - tempbuff.append(" : " + prop.getLowValue() + " TO " + prop.getHighValue()); - } - storelist.add(tempbuff.toString()); - } - } - Collections.sort(storelist); - for (int i=0; i<storelist.size(); i++){ - store[n][i]=storelist.get(i); + tempbuff.append("*qual: " + left + " : " + right); + storelist.add(tempbuff.toString()); + } else{ + nycomm =- 1; + } + } + for (Property prop : yax.getProperties()){ + if(!prop.getName().startsWith("sqrts")){ + StringBuffer tempbuff = new StringBuffer(); + tempbuff.append("*qual: " + prop.getName().trim()); + if(!prop.getUnit().toString().equals("num")) { tempbuff.append(" IN " + prop.getUnit().toString().toUpperCase()); } + if(prop.getLowValue().equals(prop.getHighValue())){ + tempbuff.append(" : " + prop.getLowValue()); + } else{ + tempbuff.append(" : " + prop.getLowValue() + " TO " + prop.getHighValue()); + } + storelist.add(tempbuff.toString()); + } + } + Collections.sort(storelist); + for (int i=0; i<storelist.size(); i++){ + store[n][i]=storelist.get(i); } } - // // now check each property etc. for repetition across yaxes (very simple case first) + // // now check each property etc. for repetition across yaxes (very simple case first) for (int i=0; i<nyprop+nycomm+nyhead; i++){ Boolean same = true; if(nyax > 1){ for (int ny=0; ny<nyax-1; ny++){ - if(!store[ny][i].equals(store[ny+1][i])) { same = false; } + if(!store[ny][i].equals(store[ny+1][i])) { same = false; } } } if(same) { @@ -166,8 +167,8 @@ else{ s.append(store[0][i]); for(int ny=1; ny<nyax; ny++){ - String right = store[ny][i].split("\\s*\\:\\s")[1]; - if(!store[0][i].startsWith("*yheader")) {right = store[ny][i].split("\\s*\\:\\s")[2];} + String right = store[ny][i].split("\\s*\\:\\s")[1]; + if(!store[0][i].startsWith("*yheader")) {right = store[ny][i].split("\\s*\\:\\s")[2];} s.append(" : "+right); } s.append("\n"); @@ -182,51 +183,56 @@ s.append("\n"); s.append("*data"); for(XAxis xax : ds.getXAxes()){ - s.append(": x "); + s.append(": x "); } for(YAxis yx : ds.getYAxes()){ - s.append(": y "); + s.append(": y "); } s.append("\n"); for (int i=0; i<numpoints; i++){ - ///////////////////////// x axes///////////////////////////////// + ///////////////////////// x axes///////////////////////////////// for( int nx=0; nx<ds.getXAxes().size(); nx++){ try{ if(ds.getXAxis(nx+1).getBin(i+1).getRelation() != Relation.EQUALS){ - s.append(" " + ds.getXAxis(nx+1).getBin(i+1).getRelation().toString()); + s.append(" " + ds.getXAxis(nx+1).getBin(i+1).getRelation().toString()); + if (ds.getXAxis(nx+1).getBin(i+1).getLowValue() != null) { + s.append(" " + ds.getXAxis(nx+1).getBin(i+1).getLowValue().toString()); + } else if (ds.getXAxis(nx+1).getBin(i+1).getHighValue() != null) { + s.append(" " + ds.getXAxis(nx+1).getBin(i+1).getHighValue().toString()); + } } - if(ds.getXAxis(nx+1).getBin(i+1).getFocus() != null){ - SignificantFigures focusx = new SignificantFigures(ds.getXAxis(nx+1).getBin(i+1).getFocus()); - int lsd = focusx.getLSD(); - int msd = focusx.getMSD(); - if(msd == 0) msd = 1; - if(ds.getXAxis(nx+1).getBin(i+1).getFocusLength() != null){ - lsd = -ds.getXAxis(nx+1).getBin(i+1).getFocusLength(); - } - String foc = Formats.forms(ds.getXAxis(nx+1).getBin(i+1).getFocus(),msd,-lsd); - boolean asymmfocus = false; - if (ds.getXAxis(nx+1).getBin(i+1).getLowValue() != null && ds.getXAxis(nx+1).getBin(i+1).getHighValue() != null && ds.getXAxis(nx+1).getBin(i+1).getFocus() != null) { - double diff = ds.getXAxis(nx+1).getBin(i+1).getFocus() - (ds.getXAxis(nx+1).getBin(i+1).getLowValue() + ds.getXAxis(nx+1).getBin(i+1).getHighValue()) / 2.0; - if (Math.abs(diff/ds.getXAxis(nx+1).getBin(i+1).getFocus()) > 1E-6) { - asymmfocus = true; - } - } - boolean haswidth = false; - if (ds.getXAxis(nx+1).getBin(i+1).getLowValue() != null && ds.getXAxis(nx+1).getBin(i+1).getHighValue() != null) { - double diff = ds.getXAxis(nx+1).getBin(i+1).getHighValue() - ds.getXAxis(nx+1).getBin(i+1).getLowValue(); - double mean = (ds.getXAxis(nx+1).getBin(i+1).getLowValue() + ds.getXAxis(nx+1).getBin(i+1).getHighValue()) / 2.0; - if((Math.abs(diff/mean) > 1E-6) || (mean == 0.0 && Math.abs(diff) > 1E-6)){ - haswidth = true; - } - } - if (asymmfocus && haswidth) { - s.append(" " + foc + " (BIN=" + ds.getXAxis(nx+1).getBin(i+1).getLowValue() + " TO " + ds.getXAxis(nx+1).getBin(i+1).getHighValue() + ")"); - } else if (!haswidth || ds.getXAxis(nx+1).getBin(i+1).getLowValue() == null || ds.getXAxis(nx+1).getBin(i+1).getHighValue() == null) { - s.append(" " + foc); - } else { - s.append(" " + ds.getXAxis(nx+1).getBin(i+1).getLowValue() + " TO " + ds.getXAxis(nx+1).getBin(i+1).getHighValue()); - } + else if(ds.getXAxis(nx+1).getBin(i+1).getFocus() != null){ + SignificantFigures focusx = new SignificantFigures(ds.getXAxis(nx+1).getBin(i+1).getFocus()); + int lsd = focusx.getLSD(); + int msd = focusx.getMSD(); + if(msd == 0) msd = 1; + if(ds.getXAxis(nx+1).getBin(i+1).getFocusLength() != null){ + lsd = -ds.getXAxis(nx+1).getBin(i+1).getFocusLength(); + } + String foc = Formats.forms(ds.getXAxis(nx+1).getBin(i+1).getFocus(),msd,-lsd); + boolean asymmfocus = false; + if (ds.getXAxis(nx+1).getBin(i+1).getLowValue() != null && ds.getXAxis(nx+1).getBin(i+1).getHighValue() != null && ds.getXAxis(nx+1).getBin(i+1).getFocus() != null) { + double diff = ds.getXAxis(nx+1).getBin(i+1).getFocus() - (ds.getXAxis(nx+1).getBin(i+1).getLowValue() + ds.getXAxis(nx+1).getBin(i+1).getHighValue()) / 2.0; + if (Math.abs(diff/ds.getXAxis(nx+1).getBin(i+1).getFocus()) > 1E-6) { + asymmfocus = true; + } + } + boolean haswidth = false; + if (ds.getXAxis(nx+1).getBin(i+1).getLowValue() != null && ds.getXAxis(nx+1).getBin(i+1).getHighValue() != null) { + double diff = ds.getXAxis(nx+1).getBin(i+1).getHighValue() - ds.getXAxis(nx+1).getBin(i+1).getLowValue(); + double mean = (ds.getXAxis(nx+1).getBin(i+1).getLowValue() + ds.getXAxis(nx+1).getBin(i+1).getHighValue()) / 2.0; + if((Math.abs(diff/mean) > 1E-6) || (mean == 0.0 && Math.abs(diff) > 1E-6)){ + haswidth = true; + } + } + if (asymmfocus && haswidth) { + s.append(" " + foc + " (BIN=" + ds.getXAxis(nx+1).getBin(i+1).getLowValue() + " TO " + ds.getXAxis(nx+1).getBin(i+1).getHighValue() + ")"); + } else if (!haswidth || ds.getXAxis(nx+1).getBin(i+1).getLowValue() == null || ds.getXAxis(nx+1).getBin(i+1).getHighValue() == null) { + s.append(" " + foc); + } else { + s.append(" " + ds.getXAxis(nx+1).getBin(i+1).getLowValue() + " TO " + ds.getXAxis(nx+1).getBin(i+1).getHighValue()); + } } else { if(ds.getXAxis(nx+1).getBin(i+1).getLowValue() != null && ds.getXAxis(nx+1).getBin(i+1).getHighValue()==null){ s.append(" " + ds.getXAxis(nx+1).getBin(i+1).getLowValue()); @@ -237,43 +243,43 @@ else{ s.append(" " + ds.getXAxis(nx+1).getBin(i+1).getDescription()); } - } + } } catch(Exception e){ - s.append(" " + ds.getXAxis(nx+1).getBin(i+1).getDescription()); + s.append(" " + ds.getXAxis(nx+1).getBin(i+1).getDescription()); } s.append(";"); } - ////////////////////////////y-axes/////////////////////////////////////////// + ////////////////////////////y-axes/////////////////////////////////////////// for (int n=0; n<nyax; n++){ YAxis yax = ds.getYAxis(n+1); try{ - if(yax.getPoint(i+1).getRelation() != Relation.EQUALS){ - s.append(" " + yax.getPoint(i+1).getRelation().toString()); - } - String f_desc = yax.getPoint(i+1).getDescription(); - String f_val = yax.getPoint(i+1).getValue().toString(); - if (f_desc != null) { - s.append(" " + f_desc); - } - else { - if(yax.getPoint(i+1).getValueLength() != null) { - int lsd = yax.getPoint(i+1).getValueLength(); - int msd = 0; - if(lsd > 0){ - msd = f_val.indexOf("."); - } else{ - msd = f_val.length() - 2; - } - if (yax.getPoint(i+1).getValue() < 0) { msd -= 1; } - f_val = Formats.forms(yax.getPoint(i+1).getValue(),msd,lsd); - } - if(f_val.contains("E-")){ - int lsd = Integer.parseInt(f_val.substring(f_val.indexOf("E")+2)); - int ldiff = f_val.length() + lsd; - f_val = Formats.forms(yax.getPoint(i+1).getValue(),1,ldiff-5); - } - s.append(" " + f_val); - } + if(yax.getPoint(i+1).getRelation() != Relation.EQUALS){ + s.append(" " + yax.getPoint(i+1).getRelation().toString()); + } + String f_desc = yax.getPoint(i+1).getDescription(); + String f_val = yax.getPoint(i+1).getValue().toString(); + if (f_desc != null) { + s.append(" " + f_desc); + } + else { + if(yax.getPoint(i+1).getValueLength() != null) { + int lsd = yax.getPoint(i+1).getValueLength(); + int msd = 0; + if(lsd > 0){ + msd = f_val.indexOf("."); + } else{ + msd = f_val.length() - 2; + } + if (yax.getPoint(i+1).getValue() < 0) { msd -= 1; } + f_val = Formats.forms(yax.getPoint(i+1).getValue(),msd,lsd); + } + if(f_val.contains("E-")){ + int lsd = Integer.parseInt(f_val.substring(f_val.indexOf("E")+2)); + int ldiff = f_val.length() + lsd; + f_val = Formats.forms(yax.getPoint(i+1).getValue(),1,ldiff-5); + } + s.append(" " + f_val); + } int nerr=0; for(Uncertainty err : yax.getPoint(i+1).getErrors()){ nerr++; @@ -284,13 +290,13 @@ int lsd = Integer.parseInt(f_plus.substring(f_plus.indexOf("E")+2)); int ldiff = f_plus.length() + lsd; f_plus = Formats.forms(err.getPlus(),1,ldiff-5); - } + } String f_minus = err.getMinus().toString(); if(f_minus.contains("E-")){ int lsd = Integer.parseInt(f_minus.substring(f_minus.indexOf("E")+2)); int ldiff = f_minus.length() + lsd; f_minus = Formats.forms(err.getMinus(),1,ldiff-5); - } + } if(nerr == 1) { if(err.isSymmetric()){ @@ -301,12 +307,12 @@ } } else if(nerr == 2) { - if (err.getSourceType() == ErrorSource.STAT) { - s.append(" (STAT="); - } - else { - s.append(" (DSYS="); - } + if (err.getSourceType() == ErrorSource.STAT) { + s.append(" (STAT="); + } + else { + s.append(" (DSYS="); + } if(err.isSymmetric()) {s.append(f_plus + norm);} else{s.append("+" + f_plus + norm + ",-" + f_minus + norm);} } @@ -316,7 +322,7 @@ else{s.append("+" + f_plus + norm + ",-" + f_minus + norm);} } if(err.getComment() != null && !err.getComment().equals("")) { - s.append(":" + err.getComment()); + s.append(":" + err.getComment()); } } if(nerr > 1) { s.append(")");} @@ -324,7 +330,7 @@ catch(Exception e){ s.append(" - "); } s.append(";"); } - s.append("\n"); + s.append("\n"); } s.append("*dataend:\n"); } Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/components/Tip.java ============================================================================== --- trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/components/Tip.java Wed May 28 13:37:43 2014 (r1801) +++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/components/Tip.java Wed Jun 25 13:33:33 2014 (r1802) @@ -60,7 +60,7 @@ writer.element("b"); writer.write("beam"); writer.end(); - writer.write(" , "); + writer.write(", "); writer.element("b"); writer.write("targ"); writer.end(); Modified: trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/SubmittingData.tml ============================================================================== --- trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/SubmittingData.tml Wed May 28 13:37:43 2014 (r1801) +++ trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/SubmittingData.tml Wed Jun 25 13:33:33 2014 (r1802) @@ -19,7 +19,7 @@ <p/> The format we accept data in is very wide and generally we require only a flat file containing the numerical values. Postscript and pdf figures are not suitable. However, supplementary files of any format (.ps, .pdf, .root, .C, .slha, etc.) can be placed in a web directory linked from the main HepData record. <p/> -Any text files you send us will be processed into a standard format, which can be seen from the "input" link on any of the existing records. Data submissions provided in text formats closer to the "input" format (<i>not</i> the "plain text" format) can therefore be entered more quickly into the database. You can start by looking at the "input" file for an existing record that is similar to your submitted data. An annotated <a href="http://hepdata.cedar.ac.uk/resource/sample.input">sample input file</a> is available, as is a <a href="http://hepdata.cedar.ac.uk/resource/6150.pl">Perl script</a> used to produce the "input" file from the <a href="http://hepdata.cedar.ac.uk/resource/zz.txt">original submission</a>. Some nomenclature that is still used in practice is defined in the historical 1970s <a href="http://hepdata.cedar.ac.uk/resource/EncodingManual.pdf">encoding manual</a> (14 MB). It is useful to provide key metadata for each table such as a caption, the process bei ng considered (initial-state and final-state particles), important kinematic cuts, and headers for the x and y columns specifying the quantity with units. Multiple x and y values can be given in the same row separated by semicolons and non-existent entries can be indicated by dashes "-". Numerical values should be given with an appropriate and not excessive number of significant figures (in general, a maximum of 4), avoiding giving more decimal places for the errors than the central values. An <a href="http://hepdata.cedar.ac.uk/resource-cgi/input">online form</a> is available to test data input. Click on "Browse..." to select your input file, followed by "Upload" and "Process", then click "Display" for the first 10 tables, or "All" for the whole record. Please note that this <a href="http://hepdata.cedar.ac.uk/resource-cgi/input">online form</a> is only for testing purposes, and the final submittal to HepData must still be done by email to hepdata(at)projects.hepforge. org. +Any text files you send us will be processed into a standard format, which can be seen from the "input" link on any of the existing records. Data submissions provided in text formats closer to the "input" format (<i>not</i> the "plain text" format) can therefore be entered more quickly into the database. You can start by looking at the "input" file for an existing record that is similar to your submitted data. An annotated <a href="http://hepdata.cedar.ac.uk/resource/sample.input">sample input file</a> is available, as is a <a href="http://hepdata.cedar.ac.uk/resource/6150.pl">Perl script</a> or <a href="http://hepdata.cedar.ac.uk/resource/6150.py">Python script</a> used to produce the "input" file from the <a href="http://hepdata.cedar.ac.uk/resource/zz.txt">original submission</a>. Some nomenclature that is still used in practice is defined in the historical 1970s <a href="http://hepdata.cedar.ac.uk/resource/EncodingManual.pdf">encoding manual</a> (14 MB). It is usefu l to provide key metadata for each table such as a caption, the process being considered (initial-state and final-state particles), important kinematic cuts, and headers for the x and y columns specifying the quantity with units. Multiple x and y values can be given in the same row separated by semicolons and non-existent entries can be indicated by dashes "-". Numerical values should be given with an appropriate and not excessive number of significant figures (in general, a maximum of 4), avoiding giving more decimal places for the errors than the central values. An <a href="http://hepdata.cedar.ac.uk/resource-cgi/input">online form</a> is available to test data input. Click on "Browse..." to select your input file, followed by "Upload" and "Process", then click "Display" for the first 10 tables, or "All" for the whole record. Please note that this <a href="http://hepdata.cedar.ac.uk/resource-cgi/input">online form</a> is only for testing purposes, and the final submit tal to HepData must still be done by email to hepdata(at)projects.hepforge.org. </td> </tr> </table>
More information about the HepData-svn mailing list |