1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
| procedure TWeather.Load(var f_temp:text; pheno: TRPhenoInfos; tempfit: integer);
var
i, j : integer;
doy1, year1, codestation : integer;
temp1,temp2,temp3,lat1:double;
nb_days:integer;
wd : TRWeatherDay;
y_idx : integer;
a_arr : vectdays;
t : TDateTime;
vec : array[1..50] of ^TRWeatherDay;
begin
LogIt('START Reading...'); t := Now;
reset(f_temp);
readln(f_temp); //skip header
Self.SetSize(pheno.nb_obs);
for j:=1 to pheno.nb_obs do
begin
y_idx := j-1;
repeat readln(f_temp, codestation, lat1, year1, doy1, temp1,temp2,temp3)
until (((codestation = pheno.Tabpheno[j].station) and (year1 >= pheno.Tabpheno[j].year)) or (codestation = 0));
if (codestation = 0) then
raise Exception.create('Station not found or stations in wrong order!');
Self.year[y_idx] := TWeatherYear.Create(year1, y_idx, Self.selfPtr);
wd := CreateWeatherDay(codestation, lat1, year1, doy1, temp1, temp2, temp3);
if (tempfit = 1) then wd._tmu := wd._tmp
else if (tempfit = 2) then wd._tmu := wd._tmn
else if (tempfit = 3) then wd._tmu := wd._tmx;
Self.year[y_idx].SetDay(doy1, wd);
nb_days := Self.year[y_idx].numDays; //GetNbDays(v._yea);
for i:=2 to nb_days do
begin
readln(f_temp, codestation, lat1, year1, doy1, temp1, temp2, temp3);
if (codestation = 0) then
raise Exception.create('Unexpected EOF found > the year could not be read entirely !');
wd := CreateWeatherDay(codestation, lat1, year1, doy1, temp1, temp2, temp3);
if (tempfit = 1) then wd._tmu := wd._tmp
else if (tempfit = 2) then wd._tmu := wd._tmn
else if (tempfit = 3) then wd._tmu := wd._tmx;
Self.year[y_idx].SetDay(doy1, wd);
end;
end;
LogIt('END Reading...' + FormatDateTime('ss.zzz', Now - t));
new (vec[1]);
end; |
Partager