File: test_grib.pro

package info (click to toggle)
gnudatalanguage 0.9.2-4
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 15,212 kB
  • sloc: cpp: 114,857; sh: 11,170; makefile: 362; awk: 18; python: 6; ansic: 4
file content (52 lines) | stat: -rw-r--r-- 1,646 bytes parent folder | download | duplicates (8)
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
pro test_grib


  file = 'example.grib'

  has_grib = ~ (execute("a=gribapi_open_file(file)") eq 0)
  if ~has_grib then exit, status=77

  message, /info, "opening " + file + "..."
  grib_f = gribapi_open_file(file)

  message, /info, "number of messages in file: " + string(gribapi_count_in_file(grib_f))

  message, /info, "getting message from file..."
  grib_m = gribapi_new_from_file(grib_f)

  message, /info, "closing file..."
  gribapi_close_file, grib_f

  message, /info, "size of ,,numberOfPointsAlongAParallel'' array: " + string(gribapi_get_size(grib_m, 'numberOfPointsAlongAParallel'))
  message, /info, "size of ,,values'' array: " + string(gribapi_get_size(grib_m, 'values'))

  message, /info, "trying to get a string key ,,discipline''..."
  gribapi_get, grib_m, 'discipline', disc
  help, disc

  message, /info, "retrieving ,,values''..."
  gribapi_get, grib_m, 'values', data
  help, data

  message, /info, "retrieving ,,numberOfPointsAlongAParallel''..."
  gribapi_get, grib_m, 'numberOfPointsAlongAParallel', data
  help, data

  message, /info, "retrieving data together with lat/lon arrays using gribapi_get_data..."
  gribapi_get_data, grib_m, lats, lons, data
  help, lats, lons, data

  data = reform(data, 21, 21, /over) 
  lons = (temporary(lons))[0:20]
  lats = (temporary(lats))[indgen(21) * 21]

  ;map_set, limit=[min(lats), min(lons), max(lats), max(lons)]
  set_plot, 'z'
  contour, data, lons, lats;, /overplot, /fill, nlev=10
  contour, data, lons, lats;, /overplot, /follow, nlev=10
  ;map_continents, /countries, /coasts

  message, /info, "clearing message from memory..."
  gribapi_release, grib_m

end