Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question
5

script for weather files

asked 2015-05-18 17:55:11 -0600

Alex Vlachokostas gravatar image

updated 2017-04-16 14:58:54 -0600

I want to create a script in order to take an epw file, process it, and then convert it back to epw. The reason for writing a script is because I want to process the epw file 500 times and as a result create 500 new epw files. Until now I was 'brewing on a small scale' using the weather converter program to convert the epw to csv, then process it in excel, and at the end convert it back to epw. Any suggestions on scaling up?

edit retag flag offensive close merge delete

Comments

Can you add a bit more about what you need to do in the processing step, and what experience you have with scripting languages? That would let us know whether ideas based around python, ruby, bash, etc would be most useful. Personally I'd recommend python but that's my own bias...

Jamie Bull gravatar imageJamie Bull ( 2015-05-19 09:04:55 -0600 )edit
2

I second python.

__AmirRoth__ gravatar image__AmirRoth__ ( 2015-05-19 10:35:54 -0600 )edit

Python, with Pandas <3

Julien Marrec gravatar imageJulien Marrec ( 2015-05-19 11:59:00 -0600 )edit

3 Answers

Sort by ยป oldest newest most voted
5

answered 2015-05-19 11:18:51 -0600

I recommend using Python for this. There are many tools that are good for text processing. Since the EPW is a quasi-csv format you can use some of the CSV tools to speed things up. You have to be creative by splitting the header and body into two datasets, though.

One option is to use the csv module to read the data and process by row.

import csv
with open('some.csv', 'rb') as f:
    reader = csv.reader(f)
    for row in reader:
        print row

You will have to determine which rows are the header data and process that data differently. You might choose to skip that data in a loop for each row. The hourly data can be extracted by column and put into your preferred data type (e.g. numpy arrays).

Another option is to use the numpy module genfromtxt.

data = np.genfromtxt(s, names = ['var1','var2', 'var3'], skip_header=num_to_skip, delimiter=",")

genfromtxt is a more powerful tool that turns the data into a numpy array. It allows you to skip headers, skip footers, pass in the header names and delimiter types. You can access the numpy array column by the column name that you pass in, which is very useful for processing.

The EnergyPlus EPW format is described in the Auxiliary Programs Documentation, so you can use that to figure out what the variables are for each column.

To write the data it may be easiest to combine the whole data set into a single string variable with comma delimiters and newline characters and then write that with the standard Python file I/O

with open('file.epw', 'w') as f:
    f.write(data_string)
edit flag offensive delete link more
1

answered 2015-05-19 15:39:13 -0600

I would prefer CRAN R language to do that. Once you have figured out the format of epw files, you can directly read in epw files (csv files anyway) , separating header and data table. With the data table you can do all sorts of data transformations with vector operations in R (instead of using Excel). After processing the data, it is easy to save the results in csv or epw format.

edit flag offensive delete link more
0

answered 2018-05-31 16:43:49 -0600

mfath gravatar image

I can also suggest the Elemensts software which is a free software provided by bigladder:

https://bigladdersoftware.com/project...

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

 

Question Tools

4 followers

Stats

Asked: 2015-05-18 17:55:11 -0600

Seen: 662 times

Last updated: May 31