source: trunk/SRC/ToBeReviewed/LECTURE/GRIB/read_grib_bds.pro @ 134

Last change on this file since 134 was 134, checked in by navarro, 18 years ago

change *.pro file properties (del eof-style, del executable, set keywords Id

  • Property svn:keywords set to Id
File size: 2.3 KB
Line 
1FUNCTION read_grib_bds, num, recstart, ni, nj
2;
3;
4  compile_opt idl2, strictarrsubs
5;
6  offset = recstart+8
7  a = assoc(num, bytarr(1, /nozero), offset-1)
8  sizepds = bit2int([binary(a[1]), binary(a[2]), binary(a[3])])
9  flag = binary(a[8])
10  gdsnotomitted = flag[0]
11  bmsnotomitted = flag[1]
12  ddd =  bit2int([binary(a[27]), binary(a[28])], /checkneg)
13;
14  offset = offset+sizepds
15;
16  IF gdsnotomitted THEN BEGIN
17    a = assoc(num, bytarr(1, /nozero), offset-1)
18    sizedds = bit2int([binary(a[1]), binary(a[2]), binary(a[3])])
19    offset = offset+sizedds
20  ENDIF
21;
22  IF bmsnotomitted THEN BEGIN
23    a = assoc(num, bytarr(1, /nozero), offset-1)
24    sizebms = bit2int([binary(a[1]), binary(a[2]), binary(a[3])])
25    offset = offset+sizebms
26  ENDIF
27;
28  a = assoc(num, bytarr(1, /nozero), offset-1)
29;
30  sizebds = bit2int([binary(a[1]), binary(a[2]), binary(a[3])])
31                                ;
32  flags = binary(a[4])
33; BIT VALUE MEANING
34; 1   0     Grid point data
35;     1     Spherical Harmonic Coefficients
36; 2   0     Simple packing
37;     1     Second order ("Complex") Packing
38; 3   0     Original data were floating point values
39;     1     Original data were integer values
40; 4   0     No additional flags at octet 14
41;     1     Octet 14 contains flag bits 5 - 12
42; 5         Reserved (set to 0)
43; 6   0     Single datum at each grid point
44;     1     Matrix of values at each grid point
45; 7   0     No secondary bit maps
46;     1     Secondary bit maps present
47; 8   0     Second order values have constant width
48;     1     Second order values have different widths
49; 9-12      Reserved (set to 0)
50;
51  eee = bit2int([binary(a[5]), binary(a[6])], /checkneg)
52;
53  aaa = bit2int(binary(a[7]), /checkneg)
54  bbb = bit2int([binary(a[8]), binary(a[9]), binary(a[10])])
55  IF aaa LT 0 THEN rrr = -2.^(-24) * bbb * 16.^(-aaa-64) $
56  ELSE rrr = 2.^(-24) * bbb * 16.^(aaa-64)
57;
58  nbits = (a[11])[0]
59  CASE 1 OF
60    flags[0] EQ 0 AND flags[1] EQ 0:BEGIN
61      CASE nbits OF
62        8 :a = assoc(num, bytarr(ni, nj, /nozero), offset-1+12)
63        16:a = assoc(num, uintarr(ni, nj, /nozero), offset-1+12)
64        32:a = assoc(num, ulonarr(ni, nj, /nozero), offset-1+12)
65        64:a = assoc(num, ulon64arr(ni, nj, /nozero), offset-1+12)
66        ELSE:
67      ENDCASE
68    END
69  ENDCASE
70
71  RETURN, (rrr+(a[0]*2.^(eee)))*10.^(-ddd)
72END
Note: See TracBrowser for help on using the repository browser.