<jupyter_start><jupyter_text>2_Using_Eppy  IntroEppy can be used to modify EnergyPlus idf files.It's open source and can be viewed here: https://github.com/santoshphilip/eppyThis demo uses the following idf file, which is available in the ExampleFiles in the EnergyPlus installation.<jupyter_code>with open('1ZoneUncontrolled.idf','r') as f:
    print(f.read())<jupyter_output>!-Generator IDFEditor 1.34
!-Option OriginalOrderTop UseSpecialFormat
!-NOTE: All comments with '!-' are ignored by the IDFEditor and are generated automatically.
!-      Use '!' comments if they need to be retained when using the IDFEditor.
!1ZoneUncontrolled.idf
! Basic file description:  Basic test for EnergyPlus.  Resistive Walls.  Regular (no ground contact) floor.
!                          Regular roof.  No Windows.
!
! Highlights:              Very basic test to see that EnergyPlus "works".
!
!
! Simulation Location/Run: Denver Centennial  Golden CO USA WMO=724666, 2 design days, 1 run period,
!                          Run Control executes two design days (see RUN PERIOD object)
!
! Location:                Denver, CO
!
! Design Days:             Denver Centennial  Golden CO USA Annual Heating 99%, MaxDB=-15.5Â°C
!                          Denver Centennial  Golden CO USA Annual Cooling (DB=>MWB) 1%, MaxDB=32Â°C MWB=15.5Â°C
!
! Run Period (Weather File): Full Annual Simulation[...]<jupyter_text>Setting up Eppy  Install Eppy if it isn't already available<jupyter_code>!pip install eppy
import eppy
eppy<jupyter_output><empty_output><jupyter_text>Import IDF class<jupyter_code>from eppy.modeleditor import IDF
IDF
help(IDF)
print(dir(IDF))<jupyter_output>['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'block', 'copyidfobject', 'getextensibleindex', 'getiddgroupdict', 'getiddname', 'getobject', 'idd_index', 'idd_info', 'idd_version', 'iddname', 'idfstr', 'initnew', 'initread', 'initreadtxt', 'new', 'newidfobject', 'popidfobject', 'printidf', 'read', 'removeextensibles', 'removeidfobject', 'run', 'save', 'saveas', 'savecopy', 'setidd', 'setiddname']<jupyter_text>Set 'iddfile' class attribute<jupyter_code>iddfile = r'C:\EnergyPlusV8-9-0\Energy+.idd'
IDF.setiddname(iddfile)
IDF.iddname<jupyter_output><empty_output><jupyter_text>Reading an idf file  Create an instance and read in an .idf file<jupyter_code>idf=IDF()
idf.idfname='1ZoneUncontrolled.idf'
idf.read()
idf<jupyter_output><empty_output><jupyter_text>Print the idf as a text stringThis is how the text file itself looks from within the IDF class<jupyter_code>idf.printidf()<jupyter_output>Version,
    8.9;                      !- Version Identifier

SimulationControl,
    No,                       !- Do Zone Sizing Calculation
    No,                       !- Do System Sizing Calculation
    No,                       !- Do Plant Sizing Calculation
    Yes,                      !- Run Simulation for Sizing Periods
    Yes;                      !- Run Simulation for Weather File Run Periods

Building,
    Simple One Zone (Wireframe DXF),    !- Name
    0.0,                      !- North Axis
    Suburbs,                  !- Terrain
    0.04,                     !- Loads Convergence Tolerance Value
    0.004,                    !- Temperature Convergence Tolerance Value
    MinimalShadowing,         !- Solar Distribution
    30,                       !- Maximum Number of Warmup Days
    6;                        !- Minimum Number of Warmup Days

SurfaceConvectionAlgorithm:Inside,
    TARP;                     !- Algorithm

SurfaceConvectionAlgorithm:Outside,
    DOE-2;   [...]<jupyter_text>Print the idf as a dictionary<jupyter_code>l=[1,2]
l[1]
d={'a':1,
   'b':2,
   'c':3}
d['b']
idf.idfobjects<jupyter_output><empty_output><jupyter_text>Inspect the idf object  Number of 'idfobjects'<jupyter_code>len(idf.idfobjects)
idf.idfobjects['VERSION']<jupyter_output><empty_output><jupyter_text>Count of 'idfobjects'<jupyter_code>{k:len(v) for k,v in idf.idfobjects.items()}<jupyter_output><empty_output><jupyter_text>Count of 'idfobjects' that are present<jupyter_code>{k:len(v) for k,v in idf.idfobjects.items() if len(v)>0}<jupyter_output><empty_output><jupyter_text>Print the 'BUILDING' objects<jupyter_code>idf.idfobjects['BUILDING']<jupyter_output><empty_output><jupyter_text>Print the orientation of the first 'BUILDING' object<jupyter_code>idf.idfobjects['BUILDING'][0].North_Axis<jupyter_output><empty_output><jupyter_text>Print the 'CONSTRUCTION' objects<jupyter_code>idf.idfobjects['CONSTRUCTION']<jupyter_output><empty_output><jupyter_text>epJSON formatAlternatively, it may now be possible to do some this using the epJSON format and not need to use Eppy.Using the '1ZoneUncontrolled.epJSON' file...<jupyter_code>import json
fp='1ZoneUncontrolled.epJSON'
with open(fp) as f:
    data = json.load(f)
data['Building']['Simple One Zone (Wireframe DXF)']['north_axis']
data['Building']<jupyter_output><empty_output><jupyter_text>Count of idf objects<jupyter_code>{k:len(v) for k,v in data.items() if len(v)>0}<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11739293764087153, 'fraction_numerical': 0.010330578512396695, 'mean_word_length': 4.056980056980057, 'pattern_counts': {'":': 0, '<': 58, '<?xml version=': 0, '>': 61, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '15', 'dir': 'jupyter-structured-clean-dedup', 'id': '213556', 'license': 'MIT', 'n_tokens_mistral': 1879, 'n_tokens_neox': 1795, 'n_words': 435, 'path': 'demo/2_Eppy/2_Using_Eppy.ipynb', 'repo_name': 'building-energy/energyplus_python_demo', 'size': '5324'}