Code Monkey home page Code Monkey logo

epw's Introduction

epw

Lightweight Python package for editing EnergyPlus Weather (epw) files

Overview

EnergyPlus weather files or .epw files are comma separated variable (csv) files which contain weather and location information. They are used to provide climate data for the energy simulations of the EnergyPlus simulation software.

This package provides a epw class for reading, modifying and saving .epw files.

Installation

pip install git+https://github.com/building-energy/epw.git@master

Or save the entire package locally, and do a local pip install.

Usage

Reading a .epw file:

>>> from epw import epw
>>> a=epw()
>>> a.read(r'C:\EnergyPlusV8-9-0\WeatherData\USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw')
>>> print(a)
<epw.epw.epw object at 0x00000155BBAB99E8>

Viewing the header information:

>>> d=a.headers # this is a dictionary of the header information
>>> print(d) 
{'LOCATION': ['San Francisco Intl Ap', 'CA', 'USA', 'TMY3', '724940', '37.62', '-122.40', '-8.0', '2.0'], 
 'DESIGN CONDITIONS': ['1', 'Climate Design Data 2009 ASHRAE Handbook', '', 'Heating', '1', '3.8', '4.9', '-3.7', '2.8', '10.7', '-1.2', '3.4', '11.2', '12.9', '12.1', '11.6', '12.2', '2.2', '150', 'Cooling', '8', '8.5', '28.3', '17.2', '25.7', '16.7', '23.6', '16.2', '18.6', '25.7', '17.8', '23.9', '17', '22.4', '5.9', '310', '16.1', '11.5', '19.9', '15.3', '10.9', '19.2', '14.7', '10.4', '18.7', '52.4', '25.8', '49.8', '23.8', '47.6', '22.4', '2038', 'Extremes', '12.8', '11.5', '10.6', '22.3', '1.8', '34.6', '1.5', '2.3', '0.8', '36.2', '-0.1', '37.5', '-0.9', '38.8', '-1.9', '40.5'],
 'TYPICAL/EXTREME PERIODS': ['6', 'Summer - Week Nearest Max Temperature For Period', 'Extreme', '8/ 1', '8/ 7', 'Summer - Week Nearest Average Temperature For Period', 'Typical', '9/ 5', '9/11', 'Winter - Week Nearest Min Temperature For Period', 'Extreme', '2/ 1', '2/ 7', 'Winter - Week Nearest Average Temperature For Period', 'Typical', '2/15', '2/21', 'Autumn - Week Nearest Average Temperature For Period', 'Typical', '12/ 6', '12/12', 'Spring - Week Nearest Average Temperature For Period', 'Typical', '5/29', '6/ 4'], 
 'GROUND TEMPERATURES': ['3', '.5', '', '', '', '10.86', '10.57', '11.08', '11.88', '13.97', '15.58', '16.67', '17.00', '16.44', '15.19', '13.51', '11.96', '2', '', '', '', '11.92', '11.41', '11.51', '11.93', '13.33', '14.60', '15.61', '16.15', '16.03', '15.32', '14.17', '12.95', '4', '', '', '', '12.79', '12.27', '12.15', '12.31', '13.10', '13.96', '14.74', '15.28', '15.41', '15.10', '14.42', '13.60'], 
 'HOLIDAYS/DAYLIGHT SAVINGS': ['No', '0', '0', '0'], 
 'COMMENTS 1': ['Custom/User Format -- WMO#724940; NREL TMY Data Set (2008); Period of Record 1973-2005 (Generally)'], 
 'COMMENTS 2': [' -- Ground temps produced with a standard soil diffusivity of 2.3225760E-03 {m**2/day}'], 
 'DATA PERIODS': ['1', '1', 'Data', 'Sunday', ' 1/ 1', '12/31']}

Viewing the climate data

>>> df=a.dataframe  # this is pandas dataframe
>>> df1=df[['Year', 'Month', 'Day', 'Hour', 'Minute','Dry Bulb Temperature']]
>>> print(df1.head())
   Year  Month  Day  Hour  Minute  Dry Bulb Temperature
0  1999      1    1     1       0                   7.2
1  1999      1    1     2       0                   7.2
2  1999      1    1     3       0                   6.7
3  1999      1    1     4       0                   6.1
4  1999      1    1     5       0                   4.4

Modifying the header information:

>>> a.headers['LOCATION'][0]='New_location' # modifies the location city
>>> print(a.headers['LOCATION'])
['New_location', 'CA', 'USA', 'TMY3', '724940', '37.62', '-122.40', '-8.0', '2.0']

Modifying the climate data:

>>> a.dataframe['Dry Bulb Temperature']=a.dataframe['Dry Bulb Temperature']+1.0 # increases dry bulb temperature by 1 degree C
>>> print(a.dataframe[['Year', 'Month', 'Day', 'Hour', 'Minute','Dry Bulb Temperature']].head())
   Year  Month  Day  Hour  Minute  Dry Bulb Temperature
0  1999      1    1     1       0                   8.2
1  1999      1    1     2       0                   8.2
2  1999      1    1     3       0                   7.7
3  1999      1    1     4       0                   7.1
4  1999      1    1     5       0                   5.4

Saving the modified .epw file:

>>> a.write('new_epw_file.epw')

epw's People

Contributors

kastnerp avatar stevenkfirth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

epw's Issues

'newline' is an invalid keyword argument for this function on Ubuntu

Hi, I have tried to open a wheater file with this tool on an Ubuntu machine but I get the following error.

from epw import epw

w=epw()
w.read('ARG_Buenos.Aires.875760_IWEC.epw')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-d02902a44dea> in <module>()
----> 1 w.read('ARG_Buenos.Aires.875760_IWEC.epw')

/usr/local/lib/python2.7/dist-packages/epw-0.0.0-py2.7.egg/epw/epw.pyc in read(self, fp)
     23         """
     24 
---> 25         self.headers=self._read_headers(fp)
     26         self.dataframe=self._read_data(fp)
     27 

/usr/local/lib/python2.7/dist-packages/epw-0.0.0-py2.7.egg/epw/epw.pyc in _read_headers(self, fp)
     39 
     40         d={}
---> 41         with open(fp, newline='') as csvfile:
     42             csvreader = csv.reader(csvfile, delimiter=',', quotechar='"')
     43             for row in csvreader:

TypeError: 'newline' is an invalid keyword argument for this function

What is the problem?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.