Comments (10)
code review shows the following functions
class IDF3:
def initread
def initnew
def initreadtxt
These functions use the latest idd packaged with eppy. The is no need to do the call IDF.setiddname ()
. I wrote it to quickly set up unit testing.
It is apparent that initnew ()
has the same functionality we are considering for new()
. It also has the ease of use, that it avoids the extra step of setting the idd
at the start.
It would be good to have a getiddversion()
function as a quick step to see what version of idd is installed with eppy
from eppy.
IMHO, using IDF('non_existant_filename.idf') should create a blank file instead of raising an Exception. No new API is needed and things should just work.
If there is any concern about this silencing errors in filenames, an additional flag that raises an exception if file doesn't exist (which defaults to False) could be added.
i.e. IDF(filename, raise_missing=False)
from eppy.
pachi,
You make a good point.
My thinking is running in this direction:
idf = IDF(filename) # open an existing file
fhandle = open(filename, 'r')
idf = IDF(fhandle) # open a using a file handle
idftxt = """
Version, 8.3;
! more idf objects
"""
from StringIO import StringIO
idf = IDF(StringIO(idftxt)) # open when you have the idd text
idf = IDF() # create an empty new file, with no filename
idf.saveas(filename)
# this can to be saved with idf.saveas(filename)
# there may even be times when you don't want to save it
# should throw an exception if you try idf.save(), since it does not have a filename
# the same idf.saveas(fileame), idd.save() rule should apply with idf = IDF(StringIO(idftxt))
Right now all of the above will work except for idf = IDF()
We should think this through.
from eppy.
It would also be great if it recognised the version of an existing file and
picked the correct IDD.
On Fri, 18 Sep 2015 04:11 santoshphilip [email protected] wrote:
pachi,
You make a good point.My thinking is running in this direction:
idf = IDF(filename) # open an existing file
fhandle = open(filename, 'r')
idf = IDF(fhandle) # open a using a file handleidftxt = """
Version, 8.3;
! more idf objects
"""
from StringIO import StringIO
idf = IDF(StringIO(idftxt)) # open when you have the idd textidf = IDF() # create an empty new file, with no filename
idf.saveas(filename)
# this can to be saved with idf.saveas(filename)
# there may even be times when you don't want to save it
# should throw an exception if you try idf.save(), since it does not have a filename# the same idf.saveas(fileame), idd.save() rule should apply with idf = IDF(StringIO(idftxt))
Right now all of the above will work except for idf = IDF()
We should think this through.—
Reply to this email directly or view it on GitHub
#41 (comment).
from eppy.
Phillip, I think your idea is nice.
from eppy.
Regarding the correct IDD file
Issue #49 points to about picking up the latest IDD file automatically. This could be enhanced to select the right version of the idd file.
I like the API at the moment because everything is explicit. You have to explicitly pick the IDD file.
Having said that, it is a real pain in the neck and I feel the pain every time I use it.
I would be so nice to simply do:
import eppy # not what we do now
idf = eppy.IDF(filename)
zones = idf.idfobjects["ZONE"]
I can actually remember it and not have to open up the tutorial every time I start scripting with eppy :-(
At the same time it opens up system specific dependencies that are harder to maintain.
from eppy.
created a branch i41_idfnew for this issue
idf = IDF() # works now
idf.save() # throws an Exception
idf.saveas(filename) # will save the file if you wish to
from eppy.
playing with changing the imports. (not sure if it is a good direction to go)
The following works now:
from eppy import IDF
# seems more intuitive than - from eppy.modeleditor import IDF
iddfile = "/Applications/EnergyPlus-8-3-0/Energy+.idd"
IDF.setiddname(iddfile)
idf = IDF()
idf.save() # throws an exception
idf.saveas(filename) # will save the file if you wish to
from eppy.
With a couple of quick and dirty updates, the following works:
from eppy import IDF # simpler now
idf = IDF() # latest IDD is automatically found, new IDF created
print idf.idfobjects["ZONE"]
# will print []
Unit tests are a little sparse and unstructured in this part of the code. I am going to spend some time looking at testing here before I merge it into develop
from eppy.
Jamie,
responding to your comment
It would also be great if it recognised the version of an existing file and
picked the correct IDD.
Right now the code finds the latest IDD using Darren's code from #49
If you can think of a clean way of finding any particular IDD, I can look at implementing it, since I am mucking around in this part of the code anyways.
from eppy.
Related Issues (20)
- eppy-core -- initial conda-forge support HOT 3
- create .readthedocs.yaml file
- Get idfobjects by regex HOT 5
- idf.run() not working on a mac for EnergyPlus-23-1-0
- Error when generating diagrams of HVAC loops HOT 1
- Error when running IDF(idfname) HOT 2
- make eplus_home configurable HOT 2
- use Github Actions for continuous integration HOT 1
- explore doing CI on two versions of E+
- Minor mistake on the documentation (Getting Started) HOT 10
- self installing jupyter notebook for eppy tutorial HOT 4
- Energyplus terminated and the program iteration stopped HOT 4
- Adding feature to change actuator values
- Suggestion: Add a “Getting Started” Section in README
- Is there an option for not converting numbers to numeric types when reading idfs? HOT 10
- Parsing issues when using older IDD files/specifying IDD files for use. HOT 17
- How to cite eppy? HOT 6
- in idf.getobject(key, name) key is case-sensitive. it should be case-insensitive HOT 1
- save E+ output as IDF HOT 10
- runIDFs() method suggestion HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eppy.