Skip to content

Commit

Permalink
Install eppy and fetch input files online santoshphilip#431
Browse files Browse the repository at this point in the history
The `/docs/Main_Tutorial.ipynb` notebook now depends on the `eppy`
package, along with one `.idd` file and three `.idf` files. Previously,
the notebook assumed that the package was already installed and that the
files were present in local storage at specific locations.

With this commit, the `eppy` package is installed with `pip`, and the
required input files are fetched online.  The `.idd` file is obtained
from the `v23.2.0` tag of the EnergyPlus project and it comes encoded in
CP-1252. It is expected to remain stable in the future.  The `.idf`
files are now fetched from the `master` branch of this repository.
  • Loading branch information
jmrocha committed Jan 7, 2024
1 parent ac44081 commit b589d2c
Showing 1 changed file with 37 additions and 63 deletions.
100 changes: 37 additions & 63 deletions docs/Main_Tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -92,37 +92,44 @@
},
{
"cell_type": "code",
"execution_count": 82,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# you would normaly install eppy by doing\n",
"# python setup.py install\n",
"# or\n",
"# pip install eppy\n",
"# or\n",
"# easy_install eppy\n",
"!pip install eppy"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"def from_url_to_file(url, output_path):\n",
" import os\n",
" if not os.path.exists(output_path):\n",
" import urllib.request, urllib.parse\n",
" with urllib.request.urlopen(url) as response, open(output_path, mode='w') as file:\n",
" data = response.read().decode('cp1252')\n",
" file.write(data)\n",
"\n",
"# if you have not done so, uncomment the following three lines\n",
"import sys\n",
"# pathnameto_eppy = 'c:/eppy'\n",
"pathnameto_eppy = '../'\n",
"sys.path.append(pathnameto_eppy) \n",
"idd_url = 'https://raw.githubusercontent.com/NREL/EnergyPlus/v23.2.0/idd/versions/V7-2-0-Energy%2B.idd'\n",
"idf_url = 'https://raw.githubusercontent.com/santoshphilip/eppy/master/eppy/resources/idffiles/V_7_2/smallfile.idf'\n",
"\n",
"from eppy import modeleditor \n",
"from eppy.modeleditor import IDF\n",
"iddfile = \"../eppy/resources/iddfiles/Energy+V7_2_0.idd\"\n",
"fname1 = \"../eppy/resources/idffiles/V_7_2/smallfile.idf\""
"from_url_to_file(idd_url, 'in.idd')\n",
"from_url_to_file(idf_url, 'in1.idf')"
]
},
{
"cell_type": "code",
"execution_count": 83,
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"IDF.setiddname(iddfile)\n",
"idf1 = IDF(fname1)\n"
"from eppy.modeleditor import IDF\n",
"\n",
"IDF.setiddname('in.idd')\n",
"idf1 = IDF('in1.idf')"
]
},
{
Expand Down Expand Up @@ -851,28 +858,20 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Let us open a small idf file that has only \"CONSTRUCTION\" and \"MATERIAL\" objects in it. You can go into \"../idffiles/V_7_2/constructions.idf\" and take a look at the file. We are not printing it here because it is too big. \n",
"Let us open a small idf file that has only \"CONSTRUCTION\" and \"MATERIAL\" objects in it. You can open https://raw.githubusercontent.com/santoshphilip/eppy/0d99f8be881e7cf998208edb5e86c0654aaf5dc8/eppy/resources/idffiles/V_7_2/constructions.idf and take a look at the file. We are not printing it here because it is too long. \n",
"\n",
"So let us open it using the idfreader -"
]
},
{
"cell_type": "code",
"execution_count": 105,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"from eppy import modeleditor\n",
"from eppy.modeleditor import IDF\n",
"\n",
"iddfile = \"../eppy/resources/iddfiles/Energy+V7_2_0.idd\"\n",
"try:\n",
" IDF.setiddname(iddfile)\n",
"except modeleditor.IDDAlreadySetError as e:\n",
" pass\n",
"\n",
"fname1 = \"../eppy/resources/idffiles/V_7_2/constructions.idf\"\n",
"idf1 = IDF(fname1)\n"
"idf_url = 'https://raw.githubusercontent.com/santoshphilip/eppy/0d99f8be881e7cf998208edb5e86c0654aaf5dc8/eppy/resources/idffiles/V_7_2/constructions.idf'\n",
"from_url_to_file(idf_url, 'in2.idf')\n",
"idf1 = IDF('in2.idf')"
]
},
{
Expand All @@ -884,7 +883,7 @@
},
{
"cell_type": "code",
"execution_count": 106,
"execution_count": 8,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -2988,44 +2987,19 @@
},
{
"cell_type": "code",
"execution_count": 172,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"# OLD CODE, SHOULD BE DELETED\n",
"# from idfreader import idfreader\n",
"\n",
"# iddfile = \"../iddfiles/Energy+V7_0_0_036.idd\"\n",
"# fname = \"../idffiles/V_7_0/5ZoneSupRetPlenRAB.idf\"\n",
" \n",
"# model, to_print, idd_info = idfreader(fname, iddfile)\n",
"# surfaces = model['BUILDINGSURFACE:DETAILED'] # all the surfaces\n"
]
},
{
"cell_type": "code",
"execution_count": 173,
"metadata": {},
"outputs": [],
"source": [
"from eppy import modeleditor\n",
"from eppy.modeleditor import IDF\n",
"\n",
"iddfile = \"../eppy/resources/iddfiles/Energy+V7_2_0.idd\"\n",
"try:\n",
" IDF.setiddname(iddfile)\n",
"except modeleditor.IDDAlreadySetError as e:\n",
" pass\n",
"\n",
"\n",
"fname1 = \"../eppy/resources/idffiles/V_7_0/5ZoneSupRetPlenRAB.idf\"\n",
"idf1 = IDF(fname1)\n",
"idf_url = 'https://raw.githubusercontent.com/santoshphilip/eppy/master/eppy/resources/idffiles/V_7_0/5ZoneSupRetPlenRAB.idf'\n",
"from_url_to_file(idf_url, 'in3.idf')\n",
"idf1 = IDF('in3.idf')\n",
"surfaces = idf1.idfobjects['BUILDINGSURFACE:DETAILED']\n"
]
},
{
"cell_type": "code",
"execution_count": 174,
"execution_count": 10,
"metadata": {},
"outputs": [
{
Expand Down

0 comments on commit b589d2c

Please sign in to comment.