View EPJ in a browser

EPJ in Browser

The epj file is basically in JSON format. There are number of libraries that allow the conversion of the JSON in HTML format, which can be viewed in the browser. Here we explore some of these options with eppy3000 functionality.

This is most useful if you are using eppy3000 in the ipython notebook or jupyter notebook, since the notebook works within the browser. Let us see what the possibilities are.

Let us open a small epjson file and explore:

[1]:
# you would normaly install eppy by doing
# python setup.py install
# or
# pip install eppy
# or
# easy_install eppy

# if you have not done so, uncomment the following three lines
import sys
# pathnameto_eppy = 'c:/eppy3000'
pathnameto_eppy3000 = '../'
sys.path.append(pathnameto_eppy3000)
[2]:
pathnameto_eppy3000 = '../'
sys.path.append(pathnameto_eppy3000)

from eppy3000.modelmaker import EPJ
ep_file = "../eppy3000/resources/epJSON/V9_3/smallfile.epJSON"
[3]:
epj = EPJ(epjname=ep_file)
[4]:
from eppy3000 import epjviewer
html = epjviewer.epj2html(epj)
print(html)
<table border="1"><tr><th>Version</th><td><table border="1"><tr><th>Version 1</th><td><table border="1"><tr><th>version_identifier</th><td>9.3</td></tr><tr><th>idf_order</th><td>1</td></tr></table></td></tr></table></td></tr><tr><th>SimulationControl</th><td><table border="1"><tr><th>SimulationControl 1</th><td><table border="1"><tr><th>do_zone_sizing_calculation</th><td>Yes</td></tr><tr><th>do_system_sizing_calculation</th><td>Yes</td></tr><tr><th>do_plant_sizing_calculation</th><td>Yes</td></tr><tr><th>run_simulation_for_sizing_periods</th><td>No</td></tr><tr><th>run_simulation_for_weather_file_run_periods</th><td>Yes</td></tr><tr><th>idf_order</th><td>2</td></tr></table></td></tr></table></td></tr><tr><th>Building</th><td><table border="1"><tr><th>Empire State Building</th><td><table border="1"><tr><th>north_axis</th><td>30</td></tr><tr><th>terrain</th><td>City</td></tr><tr><th>loads_convergence_tolerance_value</th><td>0.04</td></tr><tr><th>temperature_convergence_tolerance_value</th><td>0.4</td></tr><tr><th>solar_distribution</th><td>FullExterior</td></tr><tr><th>maximum_number_of_warmup_days</th><td>25</td></tr><tr><th>minimum_number_of_warmup_days</th><td>6</td></tr><tr><th>idf_order</th><td>3</td></tr></table></td></tr></table></td></tr><tr><th>Site:Location</th><td><table border="1"><tr><th>CHICAGO_IL_USA TMY2-94846</th><td><table border="1"><tr><th>latitude</th><td>41.78</td></tr><tr><th>longitude</th><td>-87.75</td></tr><tr><th>time_zone</th><td>-6</td></tr><tr><th>elevation</th><td>190</td></tr><tr><th>idf_order</th><td>4</td></tr></table></td></tr></table></td></tr></table>

That is your HTML file. Dammit ! it is is not very useful. I see the <table> tags in it, but I want to see the actual table.

Well … You can copy that HTML text into a file and then open it in a browser. Try it. It will look like this.

[5]:
import ex_inits #no need to know this code, it just shows the image below
for_images = ex_inits
for_images.display_png(for_images.epjhtml) # display the image below
_images/epjviewer_8_0.png

But can you see it in the notebook. This document is done is written in a jupyter notebook.

[6]:
# if you are in jupyter notebook, uncomment this line below.

# epjviewer.epj2ipythonhtml(epj)

# and you will get the hTML table below it
# It save the html by default in "./eppy3000_deletethis.html" and then displays it in the notebook

Epmunch in Browser

What if you want to look at just one epobject

[7]:
version = epj.epobjects["Version"][0]
html = epjviewer.epmunch2html(version)
print(html)
<table border="1"><tr><th>Version</th><td><table border="1"><tr><th>Version 1</th><td><table border="1"><tr><th>version_identifier</th><td>9.3</td></tr><tr><th>idf_order</th><td>1</td></tr></table></td></tr></table></td></tr></table>

If you save it into a html file and open in a browser, it will look like:

[8]:
for_images.display_png(for_images.epmunchhtml) # display the image below
_images/epjviewer_15_0.png
[9]:
# if you are in jupyter notebook, uncomment this line below.

# epjviewer.epmunch2ipythonhtml(version)

# and you will get the hTML table below it
# It save the html by default in "./eppy3000_deletethis.html" and then displays it in the notebook

Epobjects in Browser

How about viewing a list of epobjects.

Let us try a complex example with mix of epobjects

[10]:
ep_file = "../eppy3000/resources/snippets/V9_0/5Zone_Unitary_HXAssistedCoil.epJSONout"
epj = EPJ(ep_file)
[11]:
surfs = epj.epobjects["BuildingSurface:Detailed"]
roofs = [surf for surf in surfs if surf.surface_type == 'Roof']
version = epj.epobjects["Version"]
epobjects = version + roofs
[12]:
html = epjviewer.epobjects2html(epobjects)
print(html)
<table border="1"><tr><th>Version</th><td><table border="1"><tr><th>Version 1</th><td><table border="1"><tr><th>idf_max_extensible_fields</th><td>0</td></tr><tr><th>idf_max_fields</th><td>1</td></tr><tr><th>idf_order</th><td>1</td></tr><tr><th>version_identifier</th><td>9.0</td></tr></table></td></tr></table></td></tr><tr><th>BuildingSurface:Detailed</th><td><table border="1"><tr><th>TOP-1</th><td><table border="1"><tr><th>construction_name</th><td>ROOF-1</td></tr><tr><th>idf_max_extensible_fields</th><td>12</td></tr><tr><th>idf_max_fields</th><td>22</td></tr><tr><th>idf_order</th><td>63</td></tr><tr><th>number_of_vertices</th><td>4</td></tr><tr><th>outside_boundary_condition</th><td>Outdoors</td></tr><tr><th>sun_exposure</th><td>SunExposed</td></tr><tr><th>surface_type</th><td>Roof</td></tr><tr><th>vertices</th><td><table border="1"><thead><tr><th>vertex_x_coordinate</th><th>vertex_y_coordinate</th><th>vertex_z_coordinate</th></tr></thead><tbody><tr><td>0.0</td><td>15.2</td><td>3.0</td></tr><tr><td>0.0</td><td>0.0</td><td>3.0</td></tr><tr><td>30.5</td><td>0.0</td><td>3.0</td></tr><tr><td>30.5</td><td>15.2</td><td>3.0</td></tr></tbody></table></td></tr><tr><th>view_factor_to_ground</th><td>0.0</td></tr><tr><th>wind_exposure</th><td>WindExposed</td></tr><tr><th>zone_name</th><td>PLENUM-1</td></tr></table></td></tr></table></td></tr></table>
[13]:
for_images.display_png(for_images.epobjectshtml) # display the image below
_images/epjviewer_22_0.png
[14]:
# if you are in jupyter notebook, uncomment this line below.

# epjviewer.epobjects2ipythonhtml(epobjects)

# and you will get the hTML table below it
# It save the html by default in "./eppy3000_deletethis.html" and then displays it in the notebook