epw2wea and how it processes EPW field 'Number of Records per hour'

Hello all,

In the EPW data dictionary documentation (http://bigladdersoftware.com/
data-dictionary.html), I see the following:


N1, \field Number Number of Data Periods
N2, \field Number of Records per hour
A weather file may contain several “data periods” though this is not
required (and, in fact, may be detrimental). In addition, *a weather file
may contain multiple records per hour* BUT these must match the Number of
Time Steps In Hour for the simulation.


If I look at the program that converts EPW files to WEA files (
It seems to make use of the 'Records per hour' field. I see that the code
has a 'minute' variable that it initialises to 60, and it also has the
following chunk of logic that manipulates the minute variable:

  fprintf(WEA_FILE,"site_elevation %s\nweather_data_file_units 1\n",elevation);

  /* read in time step interval */
  if(minute==1) /* one measurement per hour equals a 60 minute time step */

  while( EOF != fscanf(EPW_FILE,"%d,%d,%d,%d",&year,&month,&day, &hour_in)){
    fprintf(WEA_FILE,"%d %d %.3f ",month,day,hour_in*1.0-minute*(0.5/60));

If we look at a sample EPW file, e.g. https://energyplus.net/we

LOCATION,New York Central Prk Obs Belv,NY,USA,TMY3,725033,40.78,
TYPICAL/EXTREME PERIODS,6,Summer - Week Nearest Max Temperature For
Period,Extreme,7/17,7/23,Summer - Week Nearest Average Temperature For
Period,Typical,6/ 5,6/11,Winter - Week Nearest Min Temperature For
Period,Extreme,1/18,1/24,Winter - Week Nearest Average Temperature For
Period,Typical,11/22,11/28,Autumn - Week Nearest Average Temperature For
Period,Typical,9/26,10/ 2,Spring - Week Nearest Average Temperature For
Period,Typical,3/29,4/ 4
GROUND TEMPERATURES,3,.5,1.45,0.37,2.28,5.28,13.13,19.19,23.27,
COMMENTS 1,Custom/User Format – WMO#725033; 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

then it seems to me that the chunk of logic is targeted at the 'Records per
hour' field. When execution reaches the logic chunk, the program has just
finished processing line 1 of the data,

LOCATION,New York Central Prk Obs Belv,NY,USA,TMY3,725033,40.78,

so it skips seven lines and gets to the following:

DATA PERIODS,1,1,Data,Sunday, 1/ 1,12/31

It then skips 'DATA PERIODS' and the first '1' and reads the second '1'
into the minute variable. It then looks at the value in the minute
variable, and if it is one, it overwrites that value with 60.
(Why overwrite in with 60 if it was already initialised to 60?)
I then goes into a loop in which it repeatedly
* reads in year, month, day and hour_in
* writes out to the WEA file the month, day and hour_in, but in doing so,
it adjusts hour_in based on the content of the minute variable:
It looks like it is adjusting say 9 (9AM) to 8.30 when minute=60 and
leaving 9 alone when minute=0.

Can someone please explain why the code is doing that?
Why does it set the value of the minute variable if the 'Records per hour'
field is 1, but not if it is other values? What other values can it be? 0,
2, 3, 15, 30, 60, other?

Thank you in advance for your help,

Philip Schwarz