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

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

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

revision 2504 by jpye, Sat Oct 1 06:18:31 2011 UTC revision 2505 by jpye, Sat Oct 1 10:31:24 2011 UTC
# Line 158  N34; \field Liquid Precipitation Quantit Line 158  N34; \field Liquid Precipitation Quantit
158    
159  #include "parse/parse.h"  #include "parse/parse.h"
160    
161  #define EE_DEBUG 0  #define EE_DEBUG 1
162    
163  /**  /**
164      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 256  int datareader_ee_header(DataReader *d){ Line 256  int datareader_ee_header(DataReader *d){
256      d->i = 0;      d->i = 0;
257      d->ninputs = 1;      d->ninputs = 1;
258      d->ndata = 8760; // FIXME      d->ndata = 8760; // FIXME
259      d->nmaxoutputs = 5; // FIXME      d->nmaxoutputs = 7; // FIXME
260    
261      DATA(d)->rows = ASC_NEW_ARRAY(EePoint,d->ndata);      DATA(d)->rows = ASC_NEW_ARRAY(EePoint,d->ndata);
262    
263      /* set the number of inputs and outputs */      /* set the number of inputs and outputs */
264      d->ninputs = 1;      d->ninputs = 1;
265      d->noutputs = 6;      d->noutputs = 7;
266    
267      return 0;      return 0;
268  }  }
# Line 276  int datareader_ee_eof(DataReader *d){ Line 276  int datareader_ee_eof(DataReader *d){
276              ERROR_REPORTER_HERE(ASC_PROG_WARNING,"Incomplete data set found (%d rows < %d expected",d->i, d->ndata);              ERROR_REPORTER_HERE(ASC_PROG_WARNING,"Incomplete data set found (%d rows < %d expected",d->i, d->ndata);
277          }          }
278          d->ndata=d->i;          d->ndata=d->i;
279          ERROR_REPORTER_HERE(ASC_PROG_NOTE,"Read %d rows",d->ndata);          int i;double tmin = +0.5*DBL_MAX,tmax = -0.5*DBL_MAX;
280            for(i=0; i<d->ndata; ++i){
281                double t = DATA(d)->rows[i].t;
282                if(t < tmin)tmin = t;
283                if(t > tmax)tmax = t;
284            }
285            ERROR_REPORTER_HERE(ASC_PROG_NOTE,"Read %d rows, t in range [%f,%f] d",d->ndata,tmin/3600./24.,tmax/3600./24.);    
286          return 1;          return 1;
287      }      }
288    
# Line 288  int datareader_ee_eof(DataReader *d){ Line 294  int datareader_ee_eof(DataReader *d){
294      @return 0 on success      @return 0 on success
295  */  */
296  int datareader_ee_data(DataReader *d){  int datareader_ee_data(DataReader *d){
297      //CONSOLE_DEBUG("Reading data, i = %d");      CONSOLE_DEBUG("Reading data, i = %d",d->i);
298      unsigned year,month,day,hour,minute;      unsigned year,month,day,hour,minute;
299      char uncerts[101];      char uncerts[101];
300      EePoint *row = &(DATA(d)->rows[d->i]);      EePoint row;
301    
302  #define NUMFIELDS(D,X) D(T) X D(Tdew) X D(rh) X D(pres) X D(EHI) X D(EDNI) X D(HII) X D(GHI) X D(DNI) X D(DiffHI) X D(GHIll) X D(DNIll) X D(DiffHIll) X D(ZL) X D(winddir) X D(windspeed) X D(skycover) X D(opaqueskycover) X D(visibility) X D(ceilingheight) X D(weatherobs) X D(weathercodes) X D(precip) X D(aerosol) X D(snowdepth) X D(dayssincesnow) X D(albedo) X D(liquidprecipdepth) X D(liquidprecipqty)  #define NUMFIELDS(D,X) D(T) X D(Tdew) X D(rh) X D(pres) X D(EHI) X D(EDNI) X D(HII) X D(GHI) X D(DNI) X D(DiffHI) X D(GHIll) X D(DNIll) X D(DiffHIll) X D(ZL) X D(winddir) X D(windspeed) X D(skycover) X D(opaqueskycover) X D(visibility) X D(ceilingheight) X D(weatherobs) X D(weathercodes) X D(precip) X D(aerosol) X D(snowdepth) X D(dayssincesnow) X D(albedo) X D(liquidprecipdepth) X D(liquidprecipqty)
303    
# Line 332  int datareader_ee_data(DataReader *d){ Line 338  int datareader_ee_data(DataReader *d){
338  #undef ANDTHEN  #undef ANDTHEN
339  #undef PARSENUM  #undef PARSENUM
340    
341      row->t = ((day_of_year_specific(day,month,year) - 1)*24.0 + hour)*3600.0 + minute*60.;      row.t = ((day_of_year_specific(day,month,year) - 1)*24.0 + (hour - 1))*3600.0 + minute*60.;
342      row->T = T + 273.15;      row.T = T + 273.15;
343      row->p = pres;      row.p = pres;
344      row->rh = rh / 100.;      row.rh = rh / 100.;
345      row->DNI = DNI; // FIXME need to allow for difference in dt, which might be other than 1h.      row.DNI = DNI; // FIXME need to allow for difference in dt, which might be other than 1h.
346      row->Gd = DiffHI; // FIXME need to allow for difference in dt, which might be other than 1h.      row.Gd = DiffHI; // FIXME need to allow for difference in dt, which might be other than 1h.
347      row->d_wind = winddir * 2*3.141592653589 / 360; // perhaps for variable continuity we should return sin and cos of this?      row.d_wind = winddir * 2*3.141592653589 / 360; // perhaps for variable continuity we should return sin and cos of this?
348      row->v_wind = windspeed;      row.v_wind = windspeed;
349    
350        DATA(d)->rows[d->i] = row;
351    
352        CONSOLE_DEBUG("Read i = %d, t = %f d, T = %.1f°C, rh = %.1f %",d->i,row.t / 3600. / 24., T, row.rh*100);
353        
354      d->i++;      d->i++;
355      return 0;      return 0;
356  }  }
357    
358  int datareader_ee_time(DataReader *d, double *t){  int datareader_ee_time(DataReader *d, double *t){
359      //*t = DATA(d).t;      *t = DATA(d)->rows[d->i].t;
360      return 0;      return 0;
361  }  }
362    
# Line 354  int datareader_ee_time(DataReader *d, do Line 364  int datareader_ee_time(DataReader *d, do
364    
365  int datareader_ee_vals(DataReader *d, double *v){  int datareader_ee_vals(DataReader *d, double *v){
366  #if EE_DEBUG  #if EE_DEBUG
367      CONSOLE_DEBUG("At t=%f h, T = %lf, DNI = %f Wh/m2"      CONSOLE_DEBUG("At t=%f d, T = %lf, DNI = %f Wh/m2"
368          ,(ROW.t / 3600.),ROW.T, ROW.DNI          ,(ROW.t / 3600. / 24.),ROW.T, ROW.DNI
369      );      );
370  #endif  #endif
371    

Legend:
Removed from v.2504  
changed lines
  Added in v.2505

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