/[ascend]/trunk/models/johnpye/datareader/tmy3.c
ViewVC logotype

Diff of /trunk/models/johnpye/datareader/tmy3.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2597 by jpye, Sat Apr 14 06:06:41 2012 UTC revision 2598 by jpye, Tue Apr 17 21:00:29 2012 UTC
# Line 66  Line 66 
66    
67  #include "parse/parse.h"  #include "parse/parse.h"
68    
69  #define TMY3_DEBUG 1  //#define TMY3_DEBUG 1
70    
71  /**  /**
72      Data extracted from the E/E data file, doesn't have to included everything,      Data extracted from the E/E data file, doesn't have to included everything,
# Line 74  Line 74 
74  */  */
75  typedef struct Tmy3Point_struct{  typedef struct Tmy3Point_struct{
76      double t;      double t;
77      float T; ///< dry bulb temperature, K.      double T; ///< dry bulb temperature, K.
78      float p; ///< atmospheric pressure, Pa.      double p; ///< atmospheric pressure, Pa.
79      float rh; /// relative humidity, fraction 0<rh<1.      double rh; /// relative humidity, fraction 0<rh<1.
80      float DNI; ///< direct normal irradiance Wh/m²      double DNI; ///< direct normal irradiance Wh/m²
81      float GHI; ///< diffuse horizontal irradiance Wh/m²      double GHI; ///< diffuse horizontal irradiance Wh/m²
82      float d_wind; ///< wind direction, rad, N = 0, E = pi/2, W = 3pi/2, S = pi. Range 0<=d<2pi      double d_wind; ///< wind direction, rad, N = 0, E = pi/2, W = 3pi/2, S = pi. Range 0<=d<2pi
83      float v_wind; ///< wind speed, m/s.      double v_wind; ///< wind speed, m/s.
84  } Tmy3Point;  } Tmy3Point;
85    
86  typedef struct Tmy3Data_struct{  typedef struct Tmy3Data_struct{
# Line 145  int datareader_tmy3_header(DataReader *d Line 145  int datareader_tmy3_header(DataReader *d
145      // set the value of some of the Data Reader parameters      // set the value of some of the Data Reader parameters
146      d->i = 0;      d->i = 0;
147      d->ninputs = 1;      d->ninputs = 1;
148      d->ndata = 8760; // FIXME      d->ndata = 8760; // FIXME -- is a variable length file possible?
149      d->nmaxoutputs = 7; // FIXME      d->nmaxoutputs = 7; // FIXME
150    
151      DATA(d)->rows = ASC_NEW_ARRAY(Tmy3Point,d->ndata);      DATA(d)->rows = ASC_NEW_ARRAY(Tmy3Point,d->ndata);
# Line 254  int datareader_tmy3_data(DataReader *d){ Line 254  int datareader_tmy3_data(DataReader *d){
254  #undef PARSEINT  #undef PARSEINT
255  #undef PARSECHAR  #undef PARSECHAR
256    
257      // TODO add check for data for Feb 29... just in case?      /* TODO add check for data for Feb 29... just in case */
258      row.t = ((day_of_year_specific(day,month,year) - 1)*24.0 + (hour - 1))*3600.0 + minute*60.;  
259      row.T = tmy3_field_32_T * 0.1;      // ignore year, so that data sampled from a leap year isn't somehow offset.
260        row.t = ((day_of_year(day,month) - 1)*24.0 + hour)*3600.0 + minute*60.;
261        row.T = tmy3_field_32_T + 273.15 /* convert to K */;
262      row.p = tmy3_field_41_P * 100.;      row.p = tmy3_field_41_P * 100.;
263      row.rh = tmy3_field_38_RH * 0.01;      row.rh = tmy3_field_38_RH * 0.01;
264      row.DNI = tmy3_field_8_DNI * 1.;      row.DNI = tmy3_field_8_DNI * 1.;
265      row.GHI = tmy3_field_5_GHI * 1.;      row.GHI = tmy3_field_5_GHI * 1.;
266      row.v_wind = tmy3_field_47_WS * 0.1;      row.v_wind = tmy3_field_47_WS * 1.;
267      row.d_wind = tmy3_field_44_WD * 3.14159265358 / 180. ;      row.d_wind = tmy3_field_44_WD * 3.14159265358 / 180.;
268    
269      DATA(d)->rows[d->i] = row;      DATA(d)->rows[d->i] = row;
270    
# Line 290  int datareader_tmy3_vals(DataReader *d, Line 292  int datareader_tmy3_vals(DataReader *d,
292      v[2]=ROW.rh;      v[2]=ROW.rh;
293      v[3]=ROW.DNI;      v[3]=ROW.DNI;
294      v[4]=ROW.GHI;      v[4]=ROW.GHI;
295      v[5]=ROW.d_wind;      v[5]=ROW.v_wind;
296      v[6]=ROW.v_wind;      v[6]=ROW.d_wind;
297      return 0;      return 0;
298  }  }
299    

Legend:
Removed from v.2597  
changed lines
  Added in v.2598

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22