def test_easyopen_idfopen(): """py.test for easyopen""" ver = idd_helpers.latestidd() txt, result = (" Version,{};".format(ver), "{}".format(ver)) fhandle1 = StringIO(txt) fhandle2 = StringIO(txt) reload(eppy) reload(modeleditor) reload(easyopen) idf1, idf2 = easyopen.easyopen(fhandle1), eppy.openidf(fhandle2) for idf in [idf1, idf2]: versions = idf.idfobjects["version"] version = versions[0] ver = version.Version_Identifier assert result == ver # test with epw=weatherfile fhandle1 = StringIO(txt) fhandle2 = StringIO(txt) epwname = "weatherfile.epw" idf1, idf2 = ( easyopen.easyopen(fhandle1, epw=epwname), eppy.openidf(fhandle2, epw=epwname), ) for idf in [idf1, idf2]: assert idf.epw == epwname
def test_easyopen_withidd(): """py.test for easyopen""" ver = idd_helpers.latestidd() iddfile = easyopen.getiddfile(ver) txt, result = (" Version,{};".format(ver), '{}'.format(ver)) fhandle1 = StringIO(txt) fhandle2 = StringIO(txt) reload(eppy) reload(modeleditor) reload(easyopen) idf1, idf2 = easyopen.easyopen(fhandle1, idd=iddfile), eppy.openidf(fhandle2, idd=iddfile) for idf in [idf1, idf2]: versions = idf.idfobjects['version'.upper()] version = versions[0] ver = version.Version_Identifier assert result == ver # test with epw=weatherfile fhandle1 = StringIO(txt) fhandle2 = StringIO(txt) epwname = 'weatherfile.epw' idf1, idf2 = easyopen.easyopen(fhandle1, idd=iddfile, epw=epwname), eppy.openidf(fhandle2, idd=iddfile, epw=epwname) for idf in [idf1, idf2]: assert idf.epw == epwname
def openidf(fname, idd=None, epw=None): """automatically set idd and open idf file. Uses version from idf to set correct idd It will work under the following circumstances: - the IDF file should have the VERSION object. - Needs the version of EnergyPlus installed that matches the IDF version. - Energyplus should be installed in the default location. Parameters ---------- fname : str, StringIO or IOBase Filepath IDF file, File handle of IDF file open to read StringIO with IDF contents within idd : str, StringIO or IOBase This is an optional argument. easyopen will find the IDD without this arg Filepath IDD file, File handle of IDD file open to read StringIO with IDD contents within epw : str path name to the weather file. This arg is needed to run EneryPlus from eppy. """ import eppy.easyopen as easyopen return easyopen.easyopen(fname, idd=idd, epw=epw)
def test_easyopen(): """py.test for easyopen""" ver = latestidd() txt, result = (" Version,{};".format(ver), '{}'.format(ver)) fhandle = StringIO(txt) reload(modeleditor) reload(easyopen) idf = easyopen.easyopen(fhandle) versions = idf.idfobjects['version'.upper()] version = versions[0] ver = version.Version_Identifier assert result == ver # test with epw=weatherfile fhandle = StringIO(txt) epwname = 'weatherfile.epw' idf = easyopen.easyopen(fhandle, epw=epwname) assert idf.epw == epwname
def constant_schedule(cls, hourly_value=1, Name="AlwaysOn", idf=None, **kwargs): """Create a schedule with a constant value for the whole year. Defaults to a schedule with a value of 1, named 'AlwaysOn'. Args: hourly_value (float, optional): The value for the constant schedule. Defaults to 1. Name (str, optional): The name of the schedule. Defaults to Always On. idf: **kwargs: """ if idf: # Add the schedule to the existing idf idf.add_object(ep_object="Schedule:Constant".upper(), **dict(Name=Name, Schedule_Type_Limits_Name="", Hourly_Value=hourly_value), save=False) return cls(Name=Name, idf=idf, **kwargs) else: # Create a new idf object and add the schedule to it. idftxt = "VERSION, {};".format( settings.ep_version.replace( "-", ".")[0:3]) # Not an empty string. has just the # version number # we can make a file handle of a string if not Path(settings.cache_folder).exists(): Path(settings.cache_folder).mkdir_p() with tempfile.NamedTemporaryFile( mode="w", suffix="_schedule.idf", prefix="temp_", dir=settings.cache_folder, delete=False, ) as file: file.write(idftxt) # initialize the IDF object with the file handle from eppy.easyopen import easyopen idf_scratch = easyopen(file.name) idf_scratch.__class__ = archetypal.IDF idf_scratch.add_object(ep_object="Schedule:Constant".upper(), **dict(Name=Name, Schedule_Type_Limits_Name="", Hourly_Value=hourly_value), save=False) sched = cls(Name=Name, idf=idf_scratch, **kwargs) return sched
def test_easyopen_idfopen(): """py.test for easyopen""" ver = idd_helpers.latestidd() txt, result = (" Version,{};".format(ver), '{}'.format(ver)) fhandle1 = StringIO(txt) fhandle2 = StringIO(txt) reload(eppy) reload(modeleditor) reload(easyopen) idf1, idf2 = easyopen.easyopen(fhandle1), eppy.openidf(fhandle2) for idf in [idf1, idf2]: versions = idf.idfobjects['version'.upper()] version = versions[0] ver = version.Version_Identifier assert result == ver # test with epw=weatherfile fhandle1 = StringIO(txt) fhandle2 = StringIO(txt) epwname = 'weatherfile.epw' idf1, idf2 = easyopen.easyopen(fhandle1, epw=epwname), eppy.openidf(fhandle2, epw=epwname) for idf in [idf1, idf2]: assert idf.epw == epwname
def servicehw_main(idf, idd=None, baseline=None): """Replace proposed Service Hot Water with Appendix-G System""" click.echo('IDD file is %s' % idd) click.echo('IDF file is %s' % idf) proposedidf = easyopen(idf, idd) # - window reduction happens here baselineidf = reducewindows(proposedidf) # - window reduction happens here if baseline: baselineidf.saveas(baseline) click.echo('saved baseline file as %s' % baseline) else: baselineidf.printidf()
def selfshadeoff_main(idf, idd=None, baseline=None): """Turn off self shading in the building""" click.echo('IDD file is %s' % idd) click.echo('IDF file is %s' % idf) proposedidf = easyopen(idf, idd) # - window reduction happens here baselineidf = selfshadeoff(proposedidf) # - window reduction happens here if baseline: baselineidf.saveas(baseline) click.echo('saved baseline file as %s' % baseline) else: baselineidf.printidf()
def reducewindows_main(idf, idd=None, baseline=None): """Reduce the window sizes as per ASHRAE Appendix-G rules""" click.echo('IDD file is %s' % idd) click.echo('IDF file is %s' % idf) proposedidf = easyopen(idf, idd) # - window reduction happens here baselineidf = reducewindows(proposedidf) # - window reduction happens here if baseline: baselineidf.saveas(baseline) click.echo('saved baseline file as %s' % baseline) else: baselineidf.printidf()
def systemselector_main(idf, idd=None, baseline=None): """Select the baseline mechanical system based on Table G3.1.1-3""" click.echo('IDD file is %s' % idd) click.echo('IDF file is %s' % idf) proposedidf = easyopen(idf, idd) # - window reduction happens here baselineidf = systemselector(proposedidf) # - window reduction happens here if baseline: baselineidf.saveas(baseline) click.echo('saved baseline file as %s' % baseline) else: baselineidf.printidf()
def shaderemover_main(idf, idd=None, baseline=None): """Remove the exterior shades of the building""" click.echo('IDD file is %s' % idd) click.echo('IDF file is %s' % idf) proposedidf = easyopen(idf, idd) # - window reduction happens here baselineidf = shaderemover(proposedidf) # - window reduction happens here if baseline: baselineidf.saveas(baseline) click.echo('saved baseline file as %s' % baseline) else: baselineidf.printidf()
def lightingpower_main(idf, idd=None, baseline=None): """Put in ASHRAE lighting power density based on building type""" click.echo('IDD file is %s' % idd) click.echo('IDF file is %s' % idf) proposedidf = easyopen(idf, idd) # - window reduction happens here baselineidf = lightingpower(proposedidf) # - window reduction happens here if baseline: baselineidf.saveas(baseline) click.echo('saved baseline file as %s' % baseline) else: baselineidf.printidf()
def baselinesystem_main(idf, idd=None, baseline=None): """Remove proposed mechanical system and insert baseline mechanical system""" click.echo('IDD file is %s' % idd) click.echo('IDF file is %s' % idf) proposedidf = easyopen(idf, idd) # - window reduction happens here baselineidf = baselinesystem(proposedidf) # - window reduction happens here if baseline: baselineidf.saveas(baseline) click.echo('saved baseline file as %s' % baseline) else: baselineidf.printidf()
def py90dot1(idf, idd, baseline): """Generates the ASHRAE baseline IDF file""" click.echo('IDD file is %s' % idd) click.echo('IDF file is %s' % idf) proposedidf = easyopen(idf, idd) # - All the ASHRAE basline functions happen here # this is just a stub # so do nothing # - All the ASHRAE basline functions happen here if baseline: proposedidf.saveas(baseline) click.echo('saved baseline file as %s' % baseline) else: proposedidf.printidf()
def setconstruction_main(idd, idf, climatezone, baseline): """Set the ASHRAE constructions for the envelope""" click.echo('IDD file is %s' % idd) click.echo('IDF file is %s' % idf) click.echo('Climate Zone is %s' % climatezone) climatezone = "climatezone{}".format(climatezone) idffname = idf # we are calling the eppy idf object as 'idf'. Avoids name clash proposedidf = easyopen(idffname, idd) # - setting of ASHRAE constructions happens here baselineidf = setconstruction(proposedidf, climatezone) # - setting of ASHRAE constructions happens here if baseline: proposedidf.saveas(baseline) click.echo('saved baseline file as %s' % baseline) else: proposedidf.printidf()
def newidf(version=None): """open a new idf file easy way to open a new idf file for particular version. Works only id 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 ------- idf file of type eppy.modelmake.IDF """ # noqa: E501 if not version: version = "8.9" import eppy.easyopen as easyopen idfstring = " Version,{};".format(str(version)) fhandle = StringIO(idfstring) return easyopen.easyopen(fhandle)
help='location of second with idf files = ./somewhere/f2.idf') parser.add_argument("--idd", action='store', help='location of idd file = ./somewhere/eplusv8-0-1.idd') # parser.add_argument( # 'idd', action='store', # help='location of idd file = ./somewhere/eplusv8-0-1.idd') group = parser.add_mutually_exclusive_group(required=True) group.add_argument('--csv', action='store_true') group.add_argument('--html', action='store_true') nspace = parser.parse_args() fname1 = nspace.file1 fname2 = nspace.file2 iddfile = nspace.idd print(iddfile, fname1, fname2) # IDF.setiddname(iddfile) idf1 = easyopen(fname1, idd=iddfile) try: idf2 = easyopen(fname2, idd=iddfile) except IDDAlreadySetError as e: astr = "The two files have different version numners" raise IDDMismatchError(astr) # TODO What id they have different idd files ? dtls = idf1.model.dtls # undocumented variable thediffs = idfdiffs(idf1, idf2) csvdiffs = makecsvdiffs(thediffs, dtls, idf1.idfname, idf2.idfname) if nspace.csv: printcsv(csvdiffs) elif nspace.html: printhtml(csvdiffs)
"--idd", action='store', help='location of idd file = ./somewhere/eplusv8-0-1.idd') # parser.add_argument( # 'idd', action='store', # help='location of idd file = ./somewhere/eplusv8-0-1.idd') group = parser.add_mutually_exclusive_group(required=True) group.add_argument('--csv', action='store_true') group.add_argument('--html', action='store_true') nspace = parser.parse_args() fname1 = nspace.file1 fname2 = nspace.file2 iddfile = nspace.idd print(iddfile, fname1, fname2) # IDF.setiddname(iddfile) idf1 = easyopen(fname1, idd=iddfile) try: idf2 = easyopen(fname2, idd=iddfile) except IDDAlreadySetError as e: astr = "The two files have different version numners" raise IDDMismatchError(astr) # TODO What id they have different idd files ? dtls = idf1.model.dtls # undocumented variable thediffs = idfdiffs(idf1, idf2) csvdiffs = makecsvdiffs(thediffs, dtls, idf1.idfname, idf2.idfname) if nspace.csv: printcsv(csvdiffs) elif nspace.html: printhtml(csvdiffs)