eppy3000 package

Subpackages

Submodules

eppy3000.epMunch module

subclass Munch

class eppy3000.epMunch.EPMunch(*args, **kwargs)[source]

Bases: Munch

Subclass of Munch for eppy3000

allfieldnames()[source]
copy(newname)[source]

make a copy of this anc add it to parent dict

delete()[source]

delete this by removing it from the parent dict

epjfieldnames()[source]
schemafieldnames()[source]
exception eppy3000.epMunch.NotEPObject[source]

Bases: Exception

eppy3000.epMunch.printkey(key, indent=0, formatstr=None, func=None)[source]

Prints the key in epMunch with the right indentation

Used internally by printmunch

eppy3000.epMunch.printmunch(amunch, indent=0, index=None, func=None)[source]

This prints the epMunch object

In effect, it can print the epJSON file which may have nested epMunch objects in it. Or it can print a single epMunch object. printmunch is called recursively until all epMunch objects are exhausted. It will also print a list of epMunch objects that can occur within an epJSON file

It has been tested for epJSON files. The is no guarantee that will work on a more complex nesting of epMunch objects

An epJSON object such as:

"Heating Setpoint Schedule": {
    "data": [
        {
            "field": "Through: 12/31"
        },
        {
            "field": "For: AllDays"
        },
        {
            "field": "Until: 24:00"
        },
        {
            "field": 15.0
        }
    ],
    "idf_max_extensible_fields": 4,
    "idf_max_fields": 6,
    "idf_order": 59,
    "schedule_type_limits_name": "Any Number"
},

will print out as:

Schedule:Compact                                 !-  EP_KEY
            Heating Setpoint Schedule            !-  EPJOBJECT_NAME
                                                 !-  data
                Through: 12/31                       !-  field #1
                For: AllDays                         !-  field #2
                Until: 24:00                         !-  field #3
                15.0                                 !-  field #4
            4                                    !-  idf_max_extensible_fields
            6                                    !-  idf_max_fields
            59                                   !-  idf_order
            Any Number                           !-  schedule_type_limits_name

which is much more easy on human eyes

Parameters:
  • amunch (epMunch) – an EpMunch object that may have more nested EpMunch objects within

  • indent (int) – Used internally to indent the output

  • index (int) – used internally to give index numbers to repeating items in a list

  • func (function) –

    default func = print you can get a list by:

    lines = []
    printmunch(amunch, func=line.append)
    # lines will be a list of lines
    

Return type:

None

eppy3000.epj_mmapping module

Subclass from collections.abc.MutableMapping to get finer control over a dict like object.

epj.epobjects is a dict and is not connected to epj.epj

There are 2 dicts:

  • epj.epj is the real dict where the epJSON data is held as a dict

  • in eppy3000 one does not work directly on epj.epj

  • one works on epj.epobjects that holds the same data as epj.epj

  • this means that any operations done on epj.epobjects should make

  • equivalent changes in epj.epj

This can be done thru subclassing collections.abc.MutableMapping, rather than subclassing dict

https://stackoverflow.com/questions/3387691/how-to-perfectly-override-a-dict

# Alex Martelli describes how to use collections.MutableSequence in # <http://stackoverflow.com/questions/3487434/overriding-append-method-after-inheriting-from-a-python-list>

class eppy3000.epj_mmapping.EpjMapping(theepj)[source]

Bases: MutableMapping

simple Mutable mapping to test out some stuff

keys() a set-like object providing a view on D's keys[source]
class eppy3000.epj_mmapping.EpjSequence(adict, theepj=None)[source]

Bases: MutableSequence

simple Mutable Sequence to stes to ut some stuff

insert(i, v)[source]

S.insert(index, value) – insert value before index

eppy3000.epj_mmapping.epjsequence2dict(epjs)[source]

convert the epjsequence to a dict to compare to epj[key]

eppy3000.epj_mmapping.eppyfields(epj)[source]

put eppy fields into epj

eppy3000.epj_mmapping.main()[source]

eppy3000.epjviewer module

HTML viewer for EPJ and epMunch

exception eppy3000.epjviewer.JupyterNotInstalled[source]

Bases: Exception

eppy3000.epjviewer.epj2html(epj)[source]

convert the epj to html

eppy3000.epjviewer.epj2ipythonhtml(epj, fname='./eppy3000_deletethis.html')[source]

display the epj as HTML tables in jupyter notebook

eppy3000.epjviewer.epjhtmllines(epj)[source]

return the number of rows in all the epmunch tables that make up the epj

eppy3000.epjviewer.epmuchhtmllines(epmunch)[source]

return the rows in the html table made from epmunch

eppy3000.epjviewer.epmunch2dct(epmunch)[source]

convert epmunch to and json string

eppy3000.epjviewer.epmunch2html(epmunch)[source]

convert epmunch to an HTML table

eppy3000.epjviewer.epmunch2ipythonhtml(epmunch, fname='./eppy3000_deletethis.html')[source]

display the epmunch as HTML table in jupyter notebook

eppy3000.epjviewer.epobjects2dct(epobjects)[source]

convert epobjects to dcts for display

eppy3000.epjviewer.epobjects2html(epobjects)[source]

convert epobjects to html

eppy3000.epjviewer.epobjects2ipythonhtml(epobjects, fname='./eppy3000_deletethis.html')[source]

display the epobjects as HTML tables in jupyter notebook

eppy3000.epjviewer.epobjectslines(epobjects)[source]

return the number of rows in all the epmunch tables that make up the epobjects

eppy3000.epjviewer.removeeppykeys_inepmunch(epmunch, rkeys=None)[source]

remove the eppy keys in epmunch

eppy3000.eppy3000 module

Main module.

eppy3000.epschema module

class for the epschema file

class eppy3000.epschema.EPSchema(epschemaname)[source]

Bases: object

hold the data from the json epschema file

read()[source]

read the json file

class eppy3000.epschema.EPSchemaMunch(*args, **kwargs)[source]

Bases: Munch

Munch subcalssed to for the EPSchema json

fieldnames()[source]

field names of the EPSchema object

fieldnames_list()[source]

fieldnames that contain lists

fieldproperty(fieldname)[source]

field names of the EPSchema object

eppy3000.epschema.read_epschema_asmunch(fhandle)[source]

read the epschema json as a munch

eppy3000.idfjsonconverter module

convertion functions - to convert from JSON to IDF and in reverse.

eppy3000.idfjsonconverter.epjfile2idffile(epjpath, idfpath=None, schemapath=None)[source]

convert an EPJ file on disk to an IDF file on disk

eppy3000.idfjsonconverter.getfilepaths(folder, ext)[source]

get file paths of files in folder that have extension ext

eppy3000.idfjsonconverter.getidfversion(fhandle)[source]

get the idf version of this file

reads the Version object in the file and extract the version number

Parameters:

fhandle (io.String, io.TextIOWrapper) – can be a file open for read or a io.StringIO object

Returns:

Version number of the idf file

Return type:

str

eppy3000.idfjsonconverter.grouper(iterable, n, fillvalue=None)[source]

Collect data into fixed-length chunks or blocks

eppy3000.idfjsonconverter.idf2json(idfhandle, epschemahandle)[source]

converts the E+ file in the old IDF format to the new JSON format

Parameters:
  • jsonhandle (io.TextIOWrapper, io.StringIO) – This is the E+ file in the old IDF format

  • epschemahandle (io.TextIOWrapper, io.StringIO) – This is the epjson file (eqv. of the IDD file in the old format)

Returns:

E+ file in the new JSON format

Return type:

str

eppy3000.idfjsonconverter.idffile2epjfile(idfpath, epjpath=None, schemapath=None, epjext=None)[source]

convert an IDF file on disk to an EPJ file on disk

reads the idf file at idfpath. Converts it to epj file Writes the epj file to epjpath

Parameters:
  • idfpath (str, pathlib.Path) – idf file name or path to the idf file

  • epjpath (str, pathlib.Path) – epj file name or path to the epj file

  • schemapath (str, pathlib.Path) – path to Energy+.schema.epJSON usuallty found in the install location of EnergyPlus. If schemapah=None, the function will attempt to find the schema path in the standard install locations

Returns:

the path to the saved EPJ file

Return type:

pathlib.Path

eppy3000.idfjsonconverter.idffolder2epjfolder(idffolder, epjfolder=None, idfext=None, epjext=None, schemapath=None, verbose=False)[source]

Convert all the idf files in idffolder into epj files and save them in epjfolder

The function finds the idf files by searching for the all files in the idffolder that have the extension ‘idf’. This extension can be overridden by giving a value to idfext

Parameters:
  • idffolder (str, pathlib.Path) – This is the folder with the idf files

  • epjfolder (str, pathlib.Path) – This is the folder where you want to store the generated epj files. When epjfolder=None, the epj files are saved in the idffolder

  • idfext (str) – This is the extension of the idf files. Default value is idf

  • epjext (str) – This is the extension of the epj files. Default value is epJSON

  • schemapath (str, pathlib.Path) – path to Energy+.schema.epJSON usuallty found in the install location of EnergyPlus. If schemapah=None, the function will attempt to find the schema path in the standard install locations

  • verbose (Boolean) – When verbose=True, it will print file names on screen. The default for verbose is False

Return type:

None

eppy3000.idfjsonconverter.json2idf(jsonhandle, epschemahandle)[source]

converts the E+ file new JSON format to the old IDF format

Parameters:
  • jsonhandle (io.TextIOWrapper, io.StringIO) – This is the E+ file in the new JSON format

  • epschemahandle (io.TextIOWrapper, io.StringIO) – This is the epjson file (eqv. of the IDD file in the old format)

Returns:

E+ file in the old IDF format

Return type:

str

eppy3000.idfjsonconverter.keymapping(somekeys, allkeys)[source]

map the keys regardless of case

eppy3000.idfjsonconverter.num(s)[source]
eppy3000.idfjsonconverter.removetrailingblanks(lst)[source]

remove railing blanks in lst lst = [(a, b), (a, ‘’), (b, c), (d, ‘’), (e, ‘’)] return [(a, b), (a, ‘’), (b, c)]

eppy3000.installlocation module

functions to find the installation folder of a Energyplus version

eppy3000.installlocation.installfolder(version, platform_system=None)[source]

return the install folder of this EnergyPlus version

eppy3000.installlocation.schemapath(version, platform_system=None)[source]

return the schema path for the Energyplus version

eppy3000.installlocation.version2folder(version)[source]

foldername from version

eppy3000.modelmaker module

same as modelmaker in eppy

class eppy3000.modelmaker.EPJ(epjname=None, epw=None, epschemaname=None)[source]

Bases: object

copyepobject(key, objname, newname)[source]

copy an epj object with a new name

jsonstr(indent=4)[source]

return a json string of the file

newepobject(key, objname, defaultvalues=True, **kwargs)[source]

create a new epj object

popepobject(key, index)[source]

Pop an EPJ object from the EPJ.

Parameters:
  • key (str) – The type of EPJ object.

  • index (int) – The index of the object to pop.

Return type:

EpBunch object.

read()[source]

read the epj file

read_epschema_asmunch()[source]

Read the epschema file - will become a frozen singleton

readepschema()[source]

read the epschema file

removeallepobjects(epjkey)[source]

Remove all epobjects of a certain type from the EPJ.

Parameters:

epjkey (key of the epobjects to remove) –

removeepobject(epobject)[source]

Remove an EPJ object from the EPJ.

Parameters:

epobject (EpBunch object) – The epobject to remove.

run(**runoptions)[source]
save(filename=None, indent=4)[source]

save the file

saveas(filename, indent=4)[source]

saveas in filename

savecopy(filename=None, indent=4)[source]

save a copy of the file if filename==None: return copy in StringIO NOT unit TESTED at all. Not even use tested

eppy3000.rawidf module

read and save idf files without using eppy

eppy3000.rawidf.rawidf2str(rawdata, order=None)[source]

string rep of rawdata

eppy3000.rawidf.readrawidf(fhandle)[source]

read the idf file as a dict. Dict keys are idfobjkeys, dict values are list in list

eppy3000.rawidf.removecomment(astr, cphrase)[source]

the comment is similar to that in python. any charachter after the # is treated as a comment until the end of the line astr is the string to be de-commented cphrase is the comment phrase

eppy3000.readepj module

read epj json file and have eppy like functionality

eppy3000.readepj.addeppykeys(epmunch)[source]

adds eppykeys needed by eppy3000

The way E+ json is structured:

  • the lowest branch on the json tree is the epobject

  • once you are in the epobject:
    • the epobject will not know:
      1. Its own name

      2. the type of object it is

    • it will know only its own fields

We add two new keys to the epobject that will let it store its name and object type These names start with eppy to make it clear that eppy300 has added them

  • eppykey -> stores the E+ object type (epkey)

  • eppyname -> stores the name of the object. its key in E+ json

Parameters:

epmunch (eppy3000.epMunch.EPMunch) – This is the E+ file as seen by eppy3000

Return type:

None

eppy3000.readepj.readepjjson(fhandle)[source]

read an json epj

Parameters:

fhandle (io.String, io.TextIOWrapper) – can be a file open for read or a io.StringIO object

Return type:

eppy.EPMunch

eppy3000.readepj.removeeppykeys(epmunch, rkeys=None)[source]

remove the eppykeys

This will remove all the additional keys that eppy added in addeppykeys(). This is usually called before saving

Parameters:
  • epmunch (eppy3000.epMunch.EPMunch) – This is the E+ file as seen by eppy3000

  • rkeys (list) – These are the keys to be removed. if rkeys is None then rkeys is set to [‘eppykey’, ‘eppyname’, ‘eppy_objepschema’]

Return type:

None

Module contents

Top-level package for eppy3000.

eppy3000.newepj(version=None)[source]

open a new idf file

easy way to open a new idf file for particular version. Works only if Energyplus of that version is installed.

Parameters:

version (string) – version of the new file you want to create. Will work only if this version of Energyplus has been installed.

Returns:

file of type eppy.modelmake.IDF

Return type:

idf

eppy3000.openidf(idfpath, epjpath=None, schemapath=None, epjext=None)[source]

open and idf file as a epj file