{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# **Experimental**: Run and get results\n", "\n", "## Get results from an anonymous simulation : `anon_runandget`" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Sometimes you want to run a simulation on an idf and get a particular result. There is no single function in `eppy` which can do that. In this experimental section we are exploring functions that will achieve this objectives. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "So what does this functionality look like:\n", "\n", "(Let do some housekeeping first to run this notebook)" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# the lines in this block are needed to run the code in this notebook\n", "# you don't need them if you have eppy installed\n", "import sys\n", "# pathnameto_eppy = 'c:/eppy'\n", "pathnameto_witheppy = '../'\n", "sys.path.append(pathnameto_witheppy) " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Open the `idf` file (Your path names may be different on your machine)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "fname = \"/Applications/EnergyPlus-9-3-0/ExampleFiles/1ZoneEvapCooler.idf\"\n", "wfile = \"/Applications/EnergyPlus-9-3-0/WeatherData/USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw\"\n", "\n", "import eppy\n", "import witheppy.runandget as runandget\n", "import pprint\n", "pp = pprint.PrettyPrinter()\n", "\n", "idf = eppy.openidf(fname, epw=wfile) # this is an easy way to open the idf\n", " # if you have trouble here, go back to \n", " # the tutorial and see the longer manual \n", " # way to open the file\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Lets say you want to run a simulation and get just the `*.end` file. In reality we rarely get that file. But it is a small file, so it is easy to demonstrate using that file. \n", "\n", "The `getdict` dictionary defines what you want to extract from the results. Right now we want to extract the entire `*.end` file." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "EnergyPlus Starting\n", "EnergyPlus, Version 9.3.0-baff08990c, YMD=2022.11.29 05:08\n", "Adjusting Air System Sizing\n", "Adjusting Standard 62.1 Ventilation Sizing\n", "Initializing Simulation\n", "Reporting Surfaces\n", "Beginning Primary Simulation\n", "Initializing New Environment Parameters\n", "Warming up {1}\n", "Warming up {2}\n", "Warming up {3}\n", "Warming up {4}\n", "Warming up {5}\n", "Warming up {6}\n", "Starting Simulation at 12/21 for DENVER CENTENNIAL ANN HTG 99.6% CONDNS DB\n", "Initializing New Environment Parameters\n", "Warming up {1}\n", "Warming up {2}\n", "Warming up {3}\n", "Warming up {4}\n", "Warming up {5}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Could not find platform independent libraries \n", "Could not find platform dependent libraries \n", "Consider setting $PYTHONHOME to [:]\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Warming up {6}\n", "Warming up {7}\n", "Starting Simulation at 07/21 for DENVER CENTENNIAL ANN CLG 1% CONDNS DB=>MWB\n", "Initializing New Environment Parameters\n", "Warming up {1}\n", "Warming up {2}\n", "Warming up {3}\n", "Warming up {4}\n", "Warming up {5}\n", "Warming up {6}\n", "Starting Simulation at 01/01/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=01/21/2013\n", "Continuing Simulation at 01/21/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=02/10/2013\n", "Continuing Simulation at 02/10/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=03/02/2013\n", "Continuing Simulation at 03/02/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=03/22/2013\n", "Continuing Simulation at 03/22/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=04/11/2013\n", "Continuing Simulation at 04/11/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=05/01/2013\n", "Continuing Simulation at 05/01/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=05/21/2013\n", "Continuing Simulation at 05/21/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=06/10/2013\n", "Continuing Simulation at 06/10/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=06/30/2013\n", "Continuing Simulation at 06/30/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=07/20/2013\n", "Continuing Simulation at 07/20/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=08/09/2013\n", "Continuing Simulation at 08/09/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=08/29/2013\n", "Continuing Simulation at 08/29/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=09/18/2013\n", "Continuing Simulation at 09/18/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=10/08/2013\n", "Continuing Simulation at 10/08/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=10/28/2013\n", "Continuing Simulation at 10/28/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=11/17/2013\n", "Continuing Simulation at 11/17/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=12/07/2013\n", "Continuing Simulation at 12/07/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=12/27/2013\n", "Continuing Simulation at 12/27/2013 for RUN PERIOD 1\n", "Writing tabular output file results using tab format.\n", "Writing tabular output file results using HTML format.\n", "Writing final SQL reports\n", " ReadVarsESO program starting.\n", " ReadVars Run Time=00hr 00min 0.28sec\n", " ReadVarsESO program completed successfully.\n", " ReadVarsESO program starting.\n", " ReadVars Run Time=00hr 00min 0.01sec\n", " ReadVarsESO program completed successfully.\n", "EnergyPlus Run Time=00hr 00min 2.33sec\n", "\n", "/Applications/EnergyPlus-9-3-0/energyplus --weather /Applications/EnergyPlus-9-3-0/WeatherData/USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw --output-directory /var/folders/t2/x5h7dxhn7kb87t5xz_xjnx_m0000gn/T/tmpqot1h3dg --readvars /Users/santoshphilip/Documents/coolshadow/github/witheppy/docs/multi_runs/idf_0/in.idf\n", "\n", "{'end_file': {'entirefile': True,\n", " 'result': 'EnergyPlus Completed Successfully-- 4 Warning; 0 '\n", " 'Severe Errors; Elapsed Time=00hr 00min 2.33sec\\n',\n", " 'whichfile': 'end'}}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "EnergyPlus Completed Successfully.\n" ] } ], "source": [ "getdict = dict(\n", " end_file=dict(whichfile=\"end\", entirefile=True),\n", ")\n", "\n", "# run and get the result. anon_runandget() will run the \n", "# simulation in a temprary file that will be deleted afer you get the results\n", "fullresult = runandget.anon_runandget(idf, getdict)\n", "pp.pprint(fullresult) " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We want only the results. So" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "EnergyPlus Completed Successfully-- 4 Warning; 0 Severe Errors; Elapsed Time=00hr 00min 2.33sec\n", "\n" ] } ], "source": [ "print(fullresult['end_file']['result'])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This is great. But what if I want only part of a result file. Lets say I want I want the first table from the `html table file`. And I want it in a list format with rows and columns. Aha! Let us try this" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "EnergyPlus Starting\n", "EnergyPlus, Version 9.3.0-baff08990c, YMD=2022.11.29 05:08\n", "Adjusting Air System Sizing\n", "Adjusting Standard 62.1 Ventilation Sizing\n", "Initializing Simulation\n", "Reporting Surfaces\n", "Beginning Primary Simulation\n", "Initializing New Environment Parameters\n", "Warming up {1}\n", "Warming up {2}\n", "Warming up {3}\n", "Warming up {4}\n", "Warming up {5}\n", "Warming up {6}\n", "Starting Simulation at 12/21 for DENVER CENTENNIAL ANN HTG 99.6% CONDNS DB\n", "Initializing New Environment Parameters\n", "Warming up {1}\n", "Warming up {2}\n", "Warming up {3}\n", "Warming up {4}\n", "Warming up {5}\n", "Warming up {6}\n", "Warming up {7}\n", "Starting Simulation at 07/21 for DENVER CENTENNIAL ANN CLG 1% CONDNS DB=>MWB\n", "Initializing New Environment Parameters\n", "Warming up {1}\n", "Warming up {2}\n", "Warming up {3}\n", "Warming up {4}\n", "Warming up {5}\n", "Warming up {6}\n", "Starting Simulation at 01/01/2013 for RUN PERIOD 1\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Could not find platform independent libraries \n", "Could not find platform dependent libraries \n", "Consider setting $PYTHONHOME to [:]\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Updating Shadowing Calculations, Start Date=01/21/2013\n", "Continuing Simulation at 01/21/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=02/10/2013\n", "Continuing Simulation at 02/10/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=03/02/2013\n", "Continuing Simulation at 03/02/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=03/22/2013\n", "Continuing Simulation at 03/22/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=04/11/2013\n", "Continuing Simulation at 04/11/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=05/01/2013\n", "Continuing Simulation at 05/01/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=05/21/2013\n", "Continuing Simulation at 05/21/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=06/10/2013\n", "Continuing Simulation at 06/10/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=06/30/2013\n", "Continuing Simulation at 06/30/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=07/20/2013\n", "Continuing Simulation at 07/20/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=08/09/2013\n", "Continuing Simulation at 08/09/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=08/29/2013\n", "Continuing Simulation at 08/29/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=09/18/2013\n", "Continuing Simulation at 09/18/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=10/08/2013\n", "Continuing Simulation at 10/08/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=10/28/2013\n", "Continuing Simulation at 10/28/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=11/17/2013\n", "Continuing Simulation at 11/17/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=12/07/2013\n", "Continuing Simulation at 12/07/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=12/27/2013\n", "Continuing Simulation at 12/27/2013 for RUN PERIOD 1\n", "Writing tabular output file results using tab format.\n", "Writing tabular output file results using HTML format.\n", "Writing final SQL reports\n", " ReadVarsESO program starting.\n", " ReadVars Run Time=00hr 00min 0.26sec\n", " ReadVarsESO program completed successfully.\n", " ReadVarsESO program starting.\n", " ReadVars Run Time=00hr 00min 0.01sec\n", " ReadVarsESO program completed successfully.\n", "EnergyPlus Run Time=00hr 00min 1.45sec\n", "\n", "/Applications/EnergyPlus-9-3-0/energyplus --weather /Applications/EnergyPlus-9-3-0/WeatherData/USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw --output-directory /var/folders/t2/x5h7dxhn7kb87t5xz_xjnx_m0000gn/T/tmp6d9wq11s --readvars /Users/santoshphilip/Documents/coolshadow/github/witheppy/docs/multi_runs/idf_0/in.idf\n", "\n", "{'HTML_file': {'entirefile': None,\n", " 'result': ['Site and Source Energy',\n", " [['',\n", " 'Total Energy [GJ]',\n", " 'Energy Per Total Building Area [MJ/m2]',\n", " 'Energy Per Conditioned Building Area [MJ/m2]'],\n", " ['Total Site Energy', 18.06, 77.76, 77.76],\n", " ['Net Site Energy', 18.06, 77.76, 77.76],\n", " ['Total Source Energy', 57.2, 246.26, 246.26],\n", " ['Net Source Energy', 57.2, 246.26, 246.26]]],\n", " 'table': True,\n", " 'tableindex': 0,\n", " 'whichfile': 'htm'}}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "EnergyPlus Completed Successfully.\n" ] } ], "source": [ "getdict = dict(\n", " HTML_file=dict(whichfile=\"htm\", tableindex=0, table=True),\n", ")\n", "# run and get the result. anon_runandget() will run the \n", "# simulation in a temprary file that will be deleted afer you get the results\n", "fullresult = runandget.anon_runandget(idf, getdict)\n", "pp.pprint(fullresult) " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Sweet !! Let us print just the result." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['Site and Source Energy',\n", " [['',\n", " 'Total Energy [GJ]',\n", " 'Energy Per Total Building Area [MJ/m2]',\n", " 'Energy Per Conditioned Building Area [MJ/m2]'],\n", " ['Total Site Energy', 18.06, 77.76, 77.76],\n", " ['Net Site Energy', 18.06, 77.76, 77.76],\n", " ['Total Source Energy', 57.2, 246.26, 246.26],\n", " ['Net Source Energy', 57.2, 246.26, 246.26]]]\n" ] } ], "source": [ "pp.pprint(fullresult['HTML_file']['result'])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Ha ! this is fun. What if I want last column, but just the last two values, but lets use the table name instead of the table index" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "EnergyPlus Starting\n", "EnergyPlus, Version 9.3.0-baff08990c, YMD=2022.11.29 05:08\n", "Adjusting Air System Sizing\n", "Adjusting Standard 62.1 Ventilation Sizing\n", "Initializing Simulation\n", "Reporting Surfaces\n", "Beginning Primary Simulation\n", "Initializing New Environment Parameters\n", "Warming up {1}\n", "Warming up {2}\n", "Warming up {3}\n", "Warming up {4}\n", "Warming up {5}\n", "Warming up {6}\n", "Starting Simulation at 12/21 for DENVER CENTENNIAL ANN HTG 99.6% CONDNS DB\n", "Initializing New Environment Parameters\n", "Warming up {1}\n", "Warming up {2}\n", "Warming up {3}\n", "Warming up {4}\n", "Warming up {5}\n", "Warming up {6}\n", "Warming up {7}\n", "Starting Simulation at 07/21 for DENVER CENTENNIAL ANN CLG 1% CONDNS DB=>MWB\n", "Initializing New Environment Parameters\n", "Warming up {1}\n", "Warming up {2}\n", "Warming up {3}\n", "Warming up {4}\n", "Warming up {5}\n", "Warming up {6}\n", "Starting Simulation at 01/01/2013 for RUN PERIOD 1\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Could not find platform independent libraries \n", "Could not find platform dependent libraries \n", "Consider setting $PYTHONHOME to [:]\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Updating Shadowing Calculations, Start Date=01/21/2013\n", "Continuing Simulation at 01/21/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=02/10/2013\n", "Continuing Simulation at 02/10/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=03/02/2013\n", "Continuing Simulation at 03/02/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=03/22/2013\n", "Continuing Simulation at 03/22/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=04/11/2013\n", "Continuing Simulation at 04/11/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=05/01/2013\n", "Continuing Simulation at 05/01/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=05/21/2013\n", "Continuing Simulation at 05/21/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=06/10/2013\n", "Continuing Simulation at 06/10/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=06/30/2013\n", "Continuing Simulation at 06/30/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=07/20/2013\n", "Continuing Simulation at 07/20/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=08/09/2013\n", "Continuing Simulation at 08/09/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=08/29/2013\n", "Continuing Simulation at 08/29/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=09/18/2013\n", "Continuing Simulation at 09/18/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=10/08/2013\n", "Continuing Simulation at 10/08/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=10/28/2013\n", "Continuing Simulation at 10/28/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=11/17/2013\n", "Continuing Simulation at 11/17/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=12/07/2013\n", "Continuing Simulation at 12/07/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=12/27/2013\n", "Continuing Simulation at 12/27/2013 for RUN PERIOD 1\n", "Writing tabular output file results using tab format.\n", "Writing tabular output file results using HTML format.\n", "Writing final SQL reports\n", " ReadVarsESO program starting.\n", " ReadVars Run Time=00hr 00min 0.26sec\n", " ReadVarsESO program completed successfully.\n", " ReadVarsESO program starting.\n", " ReadVars Run Time=00hr 00min 0.01sec\n", " ReadVarsESO program completed successfully.\n", "EnergyPlus Run Time=00hr 00min 1.43sec\n", "\n", "/Applications/EnergyPlus-9-3-0/energyplus --weather /Applications/EnergyPlus-9-3-0/WeatherData/USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw --output-directory /var/folders/t2/x5h7dxhn7kb87t5xz_xjnx_m0000gn/T/tmpmurbqwf7 --readvars /Users/santoshphilip/Documents/coolshadow/github/witheppy/docs/multi_runs/idf_0/in.idf\n", "\n", "{'twocells': {'cells': [[-2, -1], [-2, -1]],\n", " 'entirefile': None,\n", " 'result': ['Site and Source Energy', [246.26, 246.26]],\n", " 'tablename': 'Site and Source Energy',\n", " 'whichfile': 'htm'}}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "EnergyPlus Completed Successfully.\n" ] } ], "source": [ "getdict = dict(\n", " twocells=dict(\n", " whichfile=\"htm\",\n", " # tableindex=0, # or tablename\n", " tablename=\"Site and Source Energy\", # tableindex takes priority if both given\n", " cells=[[-2, -1], [-2, -1]], # will return 2 cells\n", " )\n", ")\n", "# run and get the result. anon_runandget() will run the \n", "# simulation in a temprary file that will be deleted afer you get the results\n", "fullresult = runandget.anon_runandget(idf, getdict)\n", "pp.pprint(fullresult)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "What if I want the contents of `*.end` **AND** the first table from the html table file. Here you go." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "EnergyPlus Starting\n", "EnergyPlus, Version 9.3.0-baff08990c, YMD=2022.11.29 05:08\n", "Adjusting Air System Sizing\n", "Adjusting Standard 62.1 Ventilation Sizing\n", "Initializing Simulation\n", "Reporting Surfaces\n", "Beginning Primary Simulation\n", "Initializing New Environment Parameters\n", "Warming up {1}\n", "Warming up {2}\n", "Warming up {3}\n", "Warming up {4}\n", "Warming up {5}\n", "Warming up {6}\n", "Starting Simulation at 12/21 for DENVER CENTENNIAL ANN HTG 99.6% CONDNS DB\n", "Initializing New Environment Parameters\n", "Warming up {1}\n", "Warming up {2}\n", "Warming up {3}\n", "Warming up {4}\n", "Warming up {5}\n", "Warming up {6}\n", "Warming up {7}\n", "Starting Simulation at 07/21 for DENVER CENTENNIAL ANN CLG 1% CONDNS DB=>MWB\n", "Initializing New Environment Parameters\n", "Warming up {1}\n", "Warming up {2}\n", "Warming up {3}\n", "Warming up {4}\n", "Warming up {5}\n", "Warming up {6}\n", "Starting Simulation at 01/01/2013 for RUN PERIOD 1\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Could not find platform independent libraries \n", "Could not find platform dependent libraries \n", "Consider setting $PYTHONHOME to [:]\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Updating Shadowing Calculations, Start Date=01/21/2013\n", "Continuing Simulation at 01/21/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=02/10/2013\n", "Continuing Simulation at 02/10/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=03/02/2013\n", "Continuing Simulation at 03/02/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=03/22/2013\n", "Continuing Simulation at 03/22/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=04/11/2013\n", "Continuing Simulation at 04/11/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=05/01/2013\n", "Continuing Simulation at 05/01/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=05/21/2013\n", "Continuing Simulation at 05/21/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=06/10/2013\n", "Continuing Simulation at 06/10/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=06/30/2013\n", "Continuing Simulation at 06/30/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=07/20/2013\n", "Continuing Simulation at 07/20/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=08/09/2013\n", "Continuing Simulation at 08/09/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=08/29/2013\n", "Continuing Simulation at 08/29/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=09/18/2013\n", "Continuing Simulation at 09/18/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=10/08/2013\n", "Continuing Simulation at 10/08/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=10/28/2013\n", "Continuing Simulation at 10/28/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=11/17/2013\n", "Continuing Simulation at 11/17/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=12/07/2013\n", "Continuing Simulation at 12/07/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=12/27/2013\n", "Continuing Simulation at 12/27/2013 for RUN PERIOD 1\n", "Writing tabular output file results using tab format.\n", "Writing tabular output file results using HTML format.\n", "Writing final SQL reports\n", " ReadVarsESO program starting.\n", " ReadVars Run Time=00hr 00min 0.27sec\n", " ReadVarsESO program completed successfully.\n", " ReadVarsESO program starting.\n", " ReadVars Run Time=00hr 00min 0.01sec\n", " ReadVarsESO program completed successfully.\n", "EnergyPlus Run Time=00hr 00min 1.48sec\n", "\n", "/Applications/EnergyPlus-9-3-0/energyplus --weather /Applications/EnergyPlus-9-3-0/WeatherData/USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw --output-directory /var/folders/t2/x5h7dxhn7kb87t5xz_xjnx_m0000gn/T/tmp7u97h2bh --readvars /Users/santoshphilip/Documents/coolshadow/github/witheppy/docs/multi_runs/idf_0/in.idf\n", "\n", "{'HTML_file': {'entirefile': None,\n", " 'result': ['Site and Source Energy',\n", " [['',\n", " 'Total Energy [GJ]',\n", " 'Energy Per Total Building Area [MJ/m2]',\n", " 'Energy Per Conditioned Building Area [MJ/m2]'],\n", " ['Total Site Energy', 18.06, 77.76, 77.76],\n", " ['Net Site Energy', 18.06, 77.76, 77.76],\n", " ['Total Source Energy', 57.2, 246.26, 246.26],\n", " ['Net Source Energy', 57.2, 246.26, 246.26]]],\n", " 'table': True,\n", " 'tableindex': 0,\n", " 'whichfile': 'htm'},\n", " 'end_file': {'entirefile': True,\n", " 'result': 'EnergyPlus Completed Successfully-- 4 Warning; 0 '\n", " 'Severe Errors; Elapsed Time=00hr 00min 1.48sec\\n',\n", " 'whichfile': 'end'}}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "EnergyPlus Completed Successfully.\n" ] } ], "source": [ "getdict = dict(\n", " HTML_file=dict(whichfile=\"htm\", tableindex=0, table=True),\n", " end_file=dict(whichfile=\"end\", entirefile=True),\n", ")\n", "fullresult = runandget.anon_runandget(idf, getdict)\n", "pp.pprint(fullresult)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## What can `getdict` get ?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let us look at some examples. For instance you can any file generated by the simulation. So far we got the `end` file and the `htm` file. What do we call them\n", "\n", "They are known by these names." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['audit',\n", " 'bnd',\n", " 'dxf',\n", " 'eio',\n", " 'end',\n", " 'err',\n", " 'eso',\n", " 'mdd',\n", " 'mtd',\n", " 'mtr',\n", " 'rdd',\n", " 'shd',\n", " 'htm',\n", " 'tab',\n", " 'sqlerr',\n", " 'csv',\n", " 'mcsv',\n", " 'expidf',\n", " 'sql',\n", " 'rvaudit']\n" ] } ], "source": [ "pp.pprint(runandget.resulttypes)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Most of them are the actual file extendions. There are two `csv` files. so we get them by `csv` and`mcsv`, where `mcsv` will get you the `meter.csv` file and `csv` will get you the regular csv file. Some examples of getting the entire file.\n", "\n", "Whenever possible `entirefile=True` will return a text file. In the case of `htm` and `sql`, the file will be read in binary mode." ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "getdict = dict(end_file=dict(whichfile=\"end\", entirefile=True))\n", "getdict = dict(HTML_file=dict(whichfile=\"htm\", entirefile=True))\n", "getdict = dict(csv_file=dict(whichfile=\"csv\", entirefile=True))\n", "getdict = dict(eio_file=dict(whichfile=\"eio\", entirefile=True))\n", "getdict = dict(sql_file=dict(whichfile=\"sql\", entirefile=True)) " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "OK ! That gets you the whole file. \n", "\n", "What are the varaitions in getting a partial data from a file. Below is a list of all of them. Let's start with the html file" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "# get all tables -> carefull. This one is slow\n", "getdict = dict(\n", " resultname=dict(\n", " whichfile=\"htm\",\n", " as_tables=True,\n", " )\n", ")\n", "\n", "# get some rows in a html table\n", "getdict = dict(\n", " resultname=dict(\n", " whichfile=\"htm\",\n", " tableindex=1, # or tablename\n", " # tablename=\"Site and Source Energy\", # tableindex takes priority if both given\n", " rows=[0, -1, 1], # will return 3 rows as indexed\n", " )\n", ")\n", "\n", "# get some columns in a html table\n", "getdict = dict(\n", " resultname=dict(\n", " whichfile=\"htm\",\n", " tableindex=1, # or tablename\n", " # tablename=\"Site to Source Energy Conversion Factors\", # tableindex takes priority if both given\n", " cols=[0, 1, -1], # will return 3 columns as indexed\n", " )\n", ")\n", "\n", "# get some cells in a html table\n", "getdict = dict(\n", " resultname=dict(\n", " whichfile=\"htm\",\n", " tableindex=1, # or tablename\n", " tablename=\"Site and Source Energy\", # tableindex takes priority if both given\n", " cells=[[0, -1], [1, -1], [-1, -1]], # will return 3 cells\n", " ))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now let us look at the csv files (this would be `resulttypes in ['csv', 'mcsv']`)" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "# get csv file cols\n", "getdict = dict(\n", " resultname=dict(\n", " whichfile=\"csv\",\n", " cols=[1, \"Date/Time\"], # you can give the index of the column or \n", " # the heading of the column\n", " )\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "That's it ! There are no functions to read and do a partial extract of the other file types.\n", "\n", "Maybe the API should be changed so that you could send it a custom function and extract whatever you want. Worth a try in the future API" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## I want to keep my result files - `runandget()`\n", "\n", "What if I don't want to run my simulation anonymously. I want to keep the result files. Then you can use the `runandget()` function. Here is an example." ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "EnergyPlus Starting\n", "EnergyPlus, Version 9.3.0-baff08990c, YMD=2022.11.29 05:08\n", "Adjusting Air System Sizing\n", "Adjusting Standard 62.1 Ventilation Sizing\n", "Initializing Simulation\n", "Reporting Surfaces\n", "Beginning Primary Simulation\n", "Initializing New Environment Parameters\n", "Warming up {1}\n", "Warming up {2}\n", "Warming up {3}\n", "Warming up {4}\n", "Warming up {5}\n", "Warming up {6}\n", "Starting Simulation at 12/21 for DENVER CENTENNIAL ANN HTG 99.6% CONDNS DB\n", "Initializing New Environment Parameters\n", "Warming up {1}\n", "Warming up {2}\n", "Warming up {3}\n", "Warming up {4}\n", "Warming up {5}\n", "Warming up {6}\n", "Warming up {7}\n", "Starting Simulation at 07/21 for DENVER CENTENNIAL ANN CLG 1% CONDNS DB=>MWB\n", "Initializing New Environment Parameters\n", "Warming up {1}\n", "Warming up {2}\n", "Warming up {3}\n", "Warming up {4}\n", "Warming up {5}\n", "Warming up {6}\n", "Starting Simulation at 01/01/2013 for RUN PERIOD 1\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Could not find platform independent libraries \n", "Could not find platform dependent libraries \n", "Consider setting $PYTHONHOME to [:]\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Updating Shadowing Calculations, Start Date=01/21/2013\n", "Continuing Simulation at 01/21/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=02/10/2013\n", "Continuing Simulation at 02/10/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=03/02/2013\n", "Continuing Simulation at 03/02/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=03/22/2013\n", "Continuing Simulation at 03/22/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=04/11/2013\n", "Continuing Simulation at 04/11/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=05/01/2013\n", "Continuing Simulation at 05/01/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=05/21/2013\n", "Continuing Simulation at 05/21/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=06/10/2013\n", "Continuing Simulation at 06/10/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=06/30/2013\n", "Continuing Simulation at 06/30/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=07/20/2013\n", "Continuing Simulation at 07/20/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=08/09/2013\n", "Continuing Simulation at 08/09/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=08/29/2013\n", "Continuing Simulation at 08/29/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=09/18/2013\n", "Continuing Simulation at 09/18/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=10/08/2013\n", "Continuing Simulation at 10/08/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=10/28/2013\n", "Continuing Simulation at 10/28/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=11/17/2013\n", "Continuing Simulation at 11/17/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=12/07/2013\n", "Continuing Simulation at 12/07/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=12/27/2013\n", "Continuing Simulation at 12/27/2013 for RUN PERIOD 1\n", "Writing tabular output file results using tab format.\n", "Writing tabular output file results using HTML format.\n", "Writing final SQL reports\n", " ReadVarsESO program starting.\n", " ReadVars Run Time=00hr 00min 0.25sec\n", " ReadVarsESO program completed successfully.\n", " ReadVarsESO program starting.\n", " ReadVars Run Time=00hr 00min 0.01sec\n", " ReadVarsESO program completed successfully.\n", "EnergyPlus Run Time=00hr 00min 1.43sec\n", "\n", "/Applications/EnergyPlus-9-3-0/energyplus --weather /Applications/EnergyPlus-9-3-0/WeatherData/USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw --output-directory /Users/santoshphilip/Documents/coolshadow/github/witheppy/docs/deletethislater --readvars --output-prefix Yousa --output-suffix D /Users/santoshphilip/Documents/coolshadow/github/witheppy/docs/multi_runs/idf_0/in.idf\n", "\n", "{'HTML_file': {'entirefile': None,\n", " 'result': ['Site and Source Energy',\n", " [['',\n", " 'Total Energy [GJ]',\n", " 'Energy Per Total Building Area [MJ/m2]',\n", " 'Energy Per Conditioned Building Area [MJ/m2]'],\n", " ['Total Site Energy', 18.06, 77.76, 77.76],\n", " ['Net Site Energy', 18.06, 77.76, 77.76],\n", " ['Total Source Energy', 57.2, 246.26, 246.26],\n", " ['Net Source Energy', 57.2, 246.26, 246.26]]],\n", " 'table': True,\n", " 'tableindex': 0,\n", " 'whichfile': 'htm'},\n", " 'end_file': {'entirefile': True,\n", " 'result': 'EnergyPlus Completed Successfully-- 4 Warning; 0 '\n", " 'Severe Errors; Elapsed Time=00hr 00min 1.43sec\\n',\n", " 'whichfile': 'end'}}\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "EnergyPlus Completed Successfully.\n" ] } ], "source": [ "getdict = dict(\n", " HTML_file=dict(whichfile=\"htm\", tableindex=0, table=True),\n", " end_file=dict(whichfile=\"end\", entirefile=True),\n", ")\n", "runoptions = dict(\n", " output_suffix=\"D\", output_prefix=\"Yousa\", output_directory=\"./deletethislater\", \n", " readvars=True\n", ")\n", "fullresult = runandget.runandget(idf, runoptions, getdict)\n", "pp.pprint(fullresult)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The files are now in the `./deletethisfolder`. Let us check" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['Yousa.audit',\n", " 'Yousa-sqlite.err',\n", " 'Yousa.bnd',\n", " 'Yousa.mtd',\n", " 'Yousa.rvaudit',\n", " 'Yousa.eso',\n", " 'Yousa.csv',\n", " 'Yousa.dxf',\n", " 'Yousa.end',\n", " 'Yousa-table.htm',\n", " 'Yousa.eio',\n", " 'Yousa.rdd',\n", " 'Yousa.mtr',\n", " 'Yousa.err',\n", " 'Yousa-meter.csv',\n", " 'Yousa.shd',\n", " 'Yousa-table.tab',\n", " 'Yousa.mdd']" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import os\n", "os.listdir(runoptions['output_directory'])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let us clean up and remove these files" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "scrolled": true }, "outputs": [], "source": [ "for whichfile in runandget.resulttypes:\n", " fname = runandget.options2filename(whichfile, runoptions)\n", " try:\n", " os.remove(fname)\n", " except FileNotFoundError as e:\n", " pass\n", "os.rmdir(runoptions['output_directory'])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## extract resutls without running the simulation - `getrun()`\n", "\n", "What if the simulation takes a long time. I have already done the simulation. I know where the files are. I just want to extract the results. How do I do that ?\n", "\n", "Lets just do a plain vanilla `idf.run()`" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\r\n", "/Applications/EnergyPlus-9-3-0/energyplus --weather /Applications/EnergyPlus-9-3-0/WeatherData/USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw --output-directory /Users/santoshphilip/Documents/coolshadow/github/witheppy/docs/deletethislater --idd /Applications/EnergyPlus-9-3-0/Energy+.idd --readvars --output-prefix Yousa --output-suffix D /Users/santoshphilip/Documents/coolshadow/github/witheppy/docs/e2100eec644542429eeefe3ce8cd3c89.idf\r\n", "\n", "EnergyPlus Starting\n", "EnergyPlus, Version 9.3.0-baff08990c, YMD=2022.11.29 05:08\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Could not find platform independent libraries \n", "Could not find platform dependent libraries \n", "Consider setting $PYTHONHOME to [:]\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Adjusting Air System Sizing\n", "Adjusting Standard 62.1 Ventilation Sizing\n", "Initializing Simulation\n", "Reporting Surfaces\n", "Beginning Primary Simulation\n", "Initializing New Environment Parameters\n", "Warming up {1}\n", "Warming up {2}\n", "Warming up {3}\n", "Warming up {4}\n", "Warming up {5}\n", "Warming up {6}\n", "Starting Simulation at 12/21 for DENVER CENTENNIAL ANN HTG 99.6% CONDNS DB\n", "Initializing New Environment Parameters\n", "Warming up {1}\n", "Warming up {2}\n", "Warming up {3}\n", "Warming up {4}\n", "Warming up {5}\n", "Warming up {6}\n", "Warming up {7}\n", "Starting Simulation at 07/21 for DENVER CENTENNIAL ANN CLG 1% CONDNS DB=>MWB\n", "Initializing New Environment Parameters\n", "Warming up {1}\n", "Warming up {2}\n", "Warming up {3}\n", "Warming up {4}\n", "Warming up {5}\n", "Warming up {6}\n", "Starting Simulation at 01/01/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=01/21/2013\n", "Continuing Simulation at 01/21/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=02/10/2013\n", "Continuing Simulation at 02/10/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=03/02/2013\n", "Continuing Simulation at 03/02/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=03/22/2013\n", "Continuing Simulation at 03/22/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=04/11/2013\n", "Continuing Simulation at 04/11/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=05/01/2013\n", "Continuing Simulation at 05/01/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=05/21/2013\n", "Continuing Simulation at 05/21/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=06/10/2013\n", "Continuing Simulation at 06/10/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=06/30/2013\n", "Continuing Simulation at 06/30/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=07/20/2013\n", "Continuing Simulation at 07/20/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=08/09/2013\n", "Continuing Simulation at 08/09/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=08/29/2013\n", "Continuing Simulation at 08/29/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=09/18/2013\n", "Continuing Simulation at 09/18/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=10/08/2013\n", "Continuing Simulation at 10/08/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=10/28/2013\n", "Continuing Simulation at 10/28/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=11/17/2013\n", "Continuing Simulation at 11/17/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=12/07/2013\n", "Continuing Simulation at 12/07/2013 for RUN PERIOD 1\n", "Updating Shadowing Calculations, Start Date=12/27/2013\n", "Continuing Simulation at 12/27/2013 for RUN PERIOD 1\n", "Writing tabular output file results using tab format.\n", "Writing tabular output file results using HTML format.\n", "Writing final SQL reports\n", " ReadVarsESO program starting.\n", " ReadVars Run Time=00hr 00min 0.25sec\n", " ReadVarsESO program completed successfully.\n", " ReadVarsESO program starting.\n", " ReadVars Run Time=00hr 00min 0.01sec\n", " ReadVarsESO program completed successfully.\n", "EnergyPlus Run Time=00hr 00min 1.45sec\n", "None\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "EnergyPlus Completed Successfully.\n" ] } ], "source": [ "runoptions = dict(\n", " output_suffix=\"D\", output_prefix=\"Yousa\", output_directory=\"./deletethislater\", \n", " readvars=True\n", ")\n", "\n", "result = idf.run(**runoptions)\n", "print(result)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "I know the files are in the folder `./deletethislater`. I want to extract from the `*.end` file and the `*.htm` file" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'HTML_file': {'entirefile': None,\n", " 'result': ['Site and Source Energy',\n", " [['',\n", " 'Total Energy [GJ]',\n", " 'Energy Per Total Building Area [MJ/m2]',\n", " 'Energy Per Conditioned Building Area [MJ/m2]'],\n", " ['Total Site Energy', 18.06, 77.76, 77.76],\n", " ['Net Site Energy', 18.06, 77.76, 77.76],\n", " ['Total Source Energy', 57.2, 246.26, 246.26],\n", " ['Net Source Energy', 57.2, 246.26, 246.26]]],\n", " 'table': True,\n", " 'tableindex': 0,\n", " 'whichfile': 'htm'},\n", " 'end_file': {'entirefile': True,\n", " 'result': 'EnergyPlus Completed Successfully-- 4 Warning; 0 '\n", " 'Severe Errors; Elapsed Time=00hr 00min 3.70sec\\n',\n", " 'whichfile': 'end'}}\n" ] } ], "source": [ "getdict = dict(\n", " HTML_file=dict(whichfile=\"htm\", tableindex=0, table=True),\n", " end_file=dict(whichfile=\"end\", entirefile=True),\n", ")\n", "\n", "\n", "fullresult = runandget.getrun(runoptions, getdict)\n", "pp.pprint(fullresult)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "as easy as that. Now let us clean up the result directory again" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [], "source": [ "for whichfile in runandget.resulttypes:\n", " fname = runandget.options2filename(whichfile, runoptions)\n", " try:\n", " os.remove(fname)\n", " except FileNotFoundError as e:\n", " pass\n", "os.rmdir(runoptions['output_directory'])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## What else ?\n", "\n", "Well ... We can return the files in `json` format. We can also compress the `json` files\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " runandget.anon_runandget(idf, getdict, json_it=True) \n", " runandget.anon_runandget(idf, getdict, json_it=True, compress_it=True) \n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Limitations\n", "\n", "- No error checking\n", " - for missing file\n", " - for missing table\n", " - for missing column or row\n", "- Json format will work for binary files like `*.sql` or `*.htm`\n", "\n", "It will just crash and burn :-)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Motivation for this functionality\n", "\n", "The primary motivation is to develop functions that can be used for distributed simulation. EnergyPlus generates a large volume of result files. You may be interested in only some data in these results, maybe even just one number - like the total energy use. In distributed simulation, some of your simulation nodes may be scattered over the internet and transfer of large files can be expensive and time consuming. So it would be useful to have a function in eppy that would run the simulation and return some specific results. the rest of the result files may be in a temporary location will be deleted.\n", "\n", "Of cousrse to do a remote simulation, one has to send the `idf` to the node. Next step would be to make this function\n", "\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.8" } }, "nbformat": 4, "nbformat_minor": 4 }