Skip to content

Commit

Permalink
Started generateLaTeXMainSummaryTable().
Browse files Browse the repository at this point in the history
  • Loading branch information
DamonHD committed Nov 14, 2023
1 parent 8f370c5 commit f9ee2c3
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/bin/
/out.html
/out.tex
22 changes: 22 additions & 0 deletions Main-LaTeXtable-summary.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/TRVmodel/javasrc/org/hd/d/TRVmodel/Main.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
</listAttribute>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_EXCLUDE_TEST_CODE" value="true"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_SHOW_CODEDETAILS_IN_EXCEPTION_MESSAGES" value="true"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_CLASSPATH_ONLY_JAR" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.hd.d.TRVmodel.Main"/>
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value="TRVmodel"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-LaTeXtable summary"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="TRVmodel"/>
</launchConfiguration>
37 changes: 33 additions & 4 deletions javasrc/org/hd/d/TRVmodel/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,16 @@ private static void printOptions()
System.err.println(" -htmltable XXX");
System.err.println(" Write HTML table XXX to out.html for debugging.");
System.err.println(" XXX can be one of: summary, summarySoft, sagSoft");
}
System.err.println(" -LaTeXtable XXX");
System.err.println(" Write LaTeX table XXX to out.html for debugging.");
System.err.println(" XXX can be one of: summary, summarySoft, sagSoft");
}

/**Default name of output file for HTML table generation; non-null. */
public static final File DEFAULT_OUTPUT_NAME_HTML = new File("out.html");

/**Default name of output file for debugging HTML table generation; non-null. */
public static final File DEFAULT_OUTPUT_NAME = new File("out.html");
/**Default name of output file for LaTeX table generation; non-null. */
public static final File DEFAULT_OUTPUT_NAME_LaTeX = new File("out.tex");

/**Accepts command-line arguments.
* See {@link #printOptions()}.
Expand Down Expand Up @@ -82,12 +88,35 @@ public static void main(final String[] args)

// Write HTML bare, as UTF-8 (though should only be 7-bit ASCII).
// Expects to overwrite any existing file.
try (Writer w = new FileWriter(DEFAULT_OUTPUT_NAME, StandardCharsets.UTF_8))
try (Writer w = new FileWriter(DEFAULT_OUTPUT_NAME_HTML, StandardCharsets.UTF_8))
{ w.write(tableHTML); }

System.exit(0);
}

if("-LaTeXtable".equals(args[0]) && (args.length > 1))
{
final String tableLaTeX;

switch(args[1])
{
case "summary": tableLaTeX = ShowComputations.generateLaTeXMainSummaryTable(true); break;
// case "summarySoft": tableHTML = ShowComputations.generateHTMLMainSummaryTable(false); break;
// case "sagSoft": tableHTML = ShowComputations.generateHTMLSagTable(); break;
default:
System.err.println("unknown table: " + args[1]);
System.exit(1);
return; // Should be unreachable.
}

// Write HTML bare, as UTF-8 (though should only be 7-bit ASCII).
// Expects to overwrite any existing file.
try (Writer w = new FileWriter(DEFAULT_OUTPUT_NAME_LaTeX, StandardCharsets.UTF_8))
{ w.write(tableLaTeX); }

System.exit(0);
}

}
catch(final Throwable e)
{
Expand Down
53 changes: 53 additions & 0 deletions javasrc/org/hd/d/TRVmodel/hg/ShowComputations.java
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,59 @@ public static String generateHTMLMainSummaryTable(final boolean stiff) throws IO
return(result.toString());
}

/**Generate the main summary model results table for 7 places, 10 years, in LaTeX non-null.
* Attempts to remain at least slightly human readable.
* <p>
* Some details may need to be fixed up manually, including the label.
*/
public static String generateLaTeXMainSummaryTable(final boolean stiff) throws IOException
{
final StringBuilder result = new StringBuilder();
result.append("\\begin{table}[H]\n");
result.append(String.format("""
\\caption{\
%s mode: summary of mean power change with selected-room setback of\s\
(1) %s temperature regulation in A rooms\s\
(2) whole-home heat demand and of\s\
(3) heat-pump electrical demand in high ABAB and low AABB internal loss room setback arrangements\s\
(4) for 1- and 2- storey (bungalow and detached) archetypes, \s\
for %d UK locations.\s\
Based on hourly temperature data for the ten years 201X.\s\
When B rooms are set back overall home heat demand does fall,\s\
but in the ABAB layout that maximises internal losses,\s\
heat-pump electricity demand rises, in all scenarios,\s\
especially in the detached house cases.\
}\
""",
stiff ? "Stiff" : "Soft",
stiff ? "stiff" : "soft",
DDNTemperatureDataCSV.DESCRIPTORS_201X_DATASET.size()));
result.append("\\begin{adjustwidth}{-\\extralength}{0cm}\n"
+ " \\newcolumntype{C}{>{\\centering\\arraybackslash}X}\n"
+ " \\begin{tabularx}{\\fulllength}{CCCC}\n"
+ " \\toprule\n"
+ "");






// TODO






result.append(" \\bottomrule\n"
+ " \\end{tabularx}\n"
+ " \\end{adjustwidth}\n"
+ "");
result.append("\\end{table}");
return(result.toString());
}


/**Generate the temperature sag model results table for 7 places, 10 years, in (X)HTML5; non-null.
* Attempts to remain at least slightly human readable.
Expand Down

0 comments on commit f9ee2c3

Please sign in to comment.