santoshphilip / eppy

scripting language for E+, Energyplus
MIT License
155 stars 67 forks source link

idf.run(weather=wfile) fails if weather file was not set when idf file was opened #236

Open santoshphilip opened 5 years ago

santoshphilip commented 5 years ago

The following code does not work:

idd = "/Applications/EnergyPlus-8-5-0/Energy+.idd"
fname = "eppy/resources/idffiles/V8_5/smallfile.idf"
weatherfile = "/Applications/EnergyPlus-8-5-0/WeatherData/USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw"

from eppy import modeleditor
from eppy.modeleditor import IDF
IDF.setiddname(idd)

# this code works
idf1 = IDF(fname, epw=weatherfile)
idf1.run()
idf1.run(weather=weatherfile)

# this does not work
idf = IDF(fname)
idf.run(weather=weatherfile)

The error message is:

AttributeError                            Traceback (most recent call last)
<ipython-input-10-9e25985615b6> in <module>()
----> 1 idf.run(weather=weatherfile)

/Users/santoshphilip/Documents/coolshadow/github/eppy/eppy/modeleditor.pyc in run(self, **kwargs)
   1010         # if `idd` is not passed explicitly, use the IDF.iddname
   1011         idd = kwargs.pop('idd', self.iddname)
-> 1012         epw = kwargs.pop('weather', self.epw)
   1013         try:
   1014             run(self, weather=epw, idd=idd, **kwargs)

AttributeError: 'IDF' object has no attribute 'epw'
santoshphilip commented 5 years ago

The bug fix is easy

in eppy.modeleditor.py change lines 551 and 552

from

    if epw != None:
        self.epw = epw

to

   #  if epw != None:
    self.epw = epw

What is need here is unit test to confirm that its is working

yahyasheikhnejad commented 5 years ago

The bug fix is easy

in eppy.modeleditor.py change lines 551 and 552

from

    if epw != None:
        self.epw = epw

to

   #  if epw != None:
    self.epw = epw

What is need here is unit test to confirm that its is working

Windows 10 will not allow us to save the changes that have been made on the .py files corresponding to installed eppy program! I tried and got an error: Access is denied.