Useful Scripts ============== Location of the scripts ----------------------- Here are some scripts that you may find useful. They are in the folder "./eppy/useful\_scripts" And now for some housekeeping before we start off .. code:: python import os os.chdir("../eppy/useful_scripts") # changes directory, so we are where the scripts are located .. code:: python # 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, the following three lines are needed import sys # pathnameto_eppy = 'c:/eppy' pathnameto_eppy = '../../' sys.path.append(pathnameto_eppy) If you look in the folder "./eppy/useful\_scripts", you fill find the following scripts The scripts are: :: - eppy_version.py - idfdiff.py - loopdiagram.py - eppyreadtest_folder.py - eppyreadtest_file.py eppy\_version.py ---------------- Many scripts will print out some help information, if you use the --help option. Let us try that .. code:: python %%bash # ignore the line above. It simply lets me run a command line from ipython notebook python eppy_version.py --help .. parsed-literal:: usage: eppy_version.py [-h] I print the current version of eppy. Being polite, I also say hello ! optional arguments: -h, --help show this help message and exit That was useful ! Now let us try running the program .. code:: python %%bash # ignore the line above. It simply lets me run a command line from ipython notebook python eppy_version.py .. parsed-literal:: Hello! I am eppy version 0.4.6.4a Redirecting output to a file ---------------------------- Most scripts will print the output to a terminal. Sometimes we want to send the output to a file, so that we can save it for posterity. We can do that py using ">" with the filename after that. For eppy\_version.py, it will look like this: python eppy_version.py > save_output.txt Some of the following scripts will generate csv or html outputs. We can direct the output to a file with .html extension and open it in a browser Compare two idf files - idfdiff.py ---------------------------------- This script will compare two idf files. The results will be displayed printed in "csv" format or in "html" format. You would run the script from the command line. This would be the terminal on Mac or unix, and the dos prompt on windows. Let us look at the help for this script, by typing: .. code:: python %%bash # ignore the line above. It simply lets me run a command line from ipython notebook python idfdiff.py -h .. parsed-literal:: usage: idfdiff.py [-h] (--csv | --html) idd file1 file2 Do a diff between two idf files. Prints the diff in csv or html file format. You can redirect the output to a file and open the file using as a spreadsheet or by using a browser positional arguments: idd location of idd file = ./somewhere/eplusv8-0-1.idd file1 location of first with idf files = ./somewhere/f1.idf file2 location of second with idf files = ./somewhere/f2.idf optional arguments: -h, --help show this help message and exit --csv --html Now let us try this with two "idf" files that are slightly different. If we open them in a file comparing software, it would look like this: .. code:: python from eppy.useful_scripts import doc_images #no need to know this code, it just shows the image below for_images = doc_images for_images.display_png(for_images.filemerge) # display the image below .. image:: useful_scripts_files/useful_scripts_21_0.png There are 4 differences between the files. Let us see what idfdiff.py does with the two files. We will use the --html option to print out the diff in html format. .. code:: python %%bash # python idfdiff.py idd file1 file2 python idfdiff.py --html ../resources/iddfiles/Energy+V7_2_0.idd ../resources/idffiles/V_7_2/constructions.idf ../resources/idffiles/V_7_2/constructions_diff.idf .. parsed-literal::
file1 = ../resources/idffiles/V_7_2/constructions.idf
file2 = ../resources/idffiles/V_7_2/constructions_diff.idf
Object Key | Object Name | Field Name | file1 | file2 |
---|---|---|---|---|
MATERIAL | F08 Metal surface | is here | not here | |
MATERIAL | F08 Metal surface haha | not here | is here | |
MATERIAL | G05 25mm wood | Conductivity | 0.15 | 0.155 |
CONSTRUCTION | Exterior Door | Outside Layer | F08 Metal surface | F08 Metal surface haha |
file1 = ../resources/idffiles/V_7_2/constructions.idf
file2 = ../resources/idffiles/V_7_2/constructions_diff.idf
Object Key | Object Name | Field Name | file1 | file2 |
---|---|---|---|---|
MATERIAL | F08 Metal surface | not here | is here | |
MATERIAL | F08 Metal surface haha | is here | not here | |
MATERIAL | G05 25mm wood | Conductivity | 0.15 | 0.155 |
CONSTRUCTION | Exterior Door | Outside Layer | F08 Metal surface | F08 Metal surface haha |
file1 = ../resources/idffiles/V_7_2/constr.idf
file2 = ../resources/idffiles/V_7_2/constr_diff.idf
Object Key | Object Name | Field Name | file1 | file2 |
---|---|---|---|---|
CONSTRUCTION | CLNG-1 | Outside Layer | MAT-CLNG-1 | MAT-CLNG-8 |
CONSTRUCTION | GARAGE-SLAB-1 | is here | not here | |
CONSTRUCTION | SB-E | is here | not here | |
CONSTRUCTION | SB-U | not here | is here | |
OUTPUTCONTROL:TABLE:STYLE | Column Separator | HTML | CSV |