getcefvar.pro
1.47 KB
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
function getCefVar, files, paramName, dims, StartDouble, IntDouble, Time, Data
; CEF_UNDEF, CEF_INT, CEF_FLOAT, CEF_DOUBLE, CEF_CHAR, CEF_ISO_TIME, CEF_ISO_TIME_RANGE,
Size = N_elements(Time);
TIMESHIFT = 378691200.D0 ; secs 1970 - 1958
startIndex = 0L;
datapath = getenv("USER_DATA_PATH") eq '' ? '../DATA/' : getenv("USER_DATA_PATH");
for i = 0, n_elements(files) - 1 do begin
fileName = datapath + files[i];
nrec = CEF_READ(fileName);
if (nrec LE 0) then continue;
if (i EQ 0) then begin
dataType = "UNKNOWN"
timeId = 0L;
vars = CEF_VARNAMES();
while (dataType ne "ISO_TIME") do begin
dataType = CEF_VATTR(vars[timeId],"VALUE_TYPE");
timeId += 1L;
endwhile
timeId -= 1L;
endif
Time1 = CEF_VAR(vars[timeId])/1000.D0 - TIMESHIFT;
num = where(Time1 GE StartDouble AND Time1 LT StartDouble+IntDouble, Index);
if ((Index eq 0 AND startIndex eq 0) OR (startIndex + Index gt Size)) then return, 0
if (Index gt 0) then begin
Time[startIndex:startIndex+Index-1] = Time1[num];
Data1 = CEF_VAR(paramName);
; dims = CEF_VATTR(paramName, "SIZES")
dims = n_elements(Data1)/n_elements(Time1);
if (dims eq 1) then Data[startIndex:startIndex+Index-1] = Data1[num] $
else Data[*, startIndex:startIndex+Index-1] = Data1[*, num]
endif
CEF_CLOSE
startIndex += Index;
endfor
return,startIndex;
end