source: trunk/ToBeReviewed/LECTURE/GRIB/read_grib_bds.pro @ 67

Last change on this file since 67 was 67, checked in by pinsard, 18 years ago

miscellaneous modifications according to cerbere.lodyc.jussieu.fr: /usr/home/smasson/SAXO_RD/

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