source: trunk/procs/nc_build.pro @ 13

Last change on this file since 13 was 13, checked in by kolasinski, 16 years ago

Add some debug_w in nc_build and nc_put

File size: 3.5 KB
Line 
1FUNCTION nc_build, cmd, fld, direc, grid_type
2@com_eg
3@common
4; direc= data type (x,xy,xyzt,yt,etc...)
5; grid_type = grid type (to select right arrays)
6
7; output : cdf_description (using also common in com_eg)
8; X,Y,Z,T = structures containing attributes for each direction :
9;     x.name, x.units, x.long_name, x.data (+t.calendar for time)
10; + Global = global attributes: title and origin
11
12
13; grid
14   IF debug_w THEN print, ' '
15   IF debug_w THEN print, '  ENTER nc_build...'
16
17   IF debug_w THEN print, '    direc = ', direc
18
19   xpos = strpos(direc, 'x')
20   ypos = strpos(direc, 'y')
21   zpos = strpos(direc, 'z')
22   tpos = strpos(direc, 't')
23
24   str_x = ''
25   str_y = ''
26   str_z = ''
27   str_t = ''
28   IF xpos NE -1 THEN BEGIN
29      CASE grid_type OF
30         'T': xdata = glamt
31         'U': xdata = glamu
32         'V': xdata = glamv
33         'W': xdata = glamt
34      ENDCASE
35   ENDIF ELSE BEGIN
36       ; degenerated dimension case
37       xdata=0.
38   ENDELSE 
39   x_att = {name:'nav_lon', units:'degrees_east', long_name:'Longitude', data:xdata}
40   str_x = ',X=x_att'
41
42   IF ypos NE -1 THEN BEGIN
43       IF xpos NE -1 THEN BEGIN
44           CASE grid_type OF
45               'T': ydata = gphit
46               'U': ydata = gphiu
47               'V': ydata = gphiv
48               'W': ydata = gphit
49           ENDCASE
50       ENDIF ELSE BEGIN
51            ; degenerated dimension case
52           idx = where(gphit EQ max(gphit))
53           idx = idx MOD jpi
54           boite_pltz = [idx[0], idx[0], -90,90]
55           domdef, boite_pltz, /xindex ; indice pour x
56           ydata = reform(gphit[idx[0], firstyt:lastyt],lastyt-firstyt+1)
57           print, '  firstyt:lastyt', lastyt-firstyt+1
58       ENDELSE
59   ENDIF ELSE BEGIN
60       ; degenerated dimension case
61       ydata=0.
62   ENDELSE 
63   y_att = {name:'nav_lat', units:'degrees_north', long_name:'Latitude', data:ydata}
64   str_y = ',Y=y_att'
65
66   IF zpos NE -1 THEN BEGIN
67      CASE grid_type OF
68         'T': BEGIN & zdata = gdept & z_txt = 'Vertical T levels' & END
69         'U': BEGIN & zdata = gdept & z_txt = 'Vertical T levels' & END 
70         'V': BEGIN & zdata = gdept & z_txt = 'Vertical T levels' & END 
71         'W': BEGIN & zdata = gdepw & z_txt = 'Vertical W levels' & END 
72      ENDCASE
73   ENDIF ELSE BEGIN
74       ; degenerated dimension case
75       zdata=0.
76       z_txt = 'No vertical dimension'
77   ENDELSE 
78   z_att = {name:'deptht', units:'m', long_name:z_txt, data:zdata}
79   str_z = ',Z=z_att'
80   
81   IF tpos NE -1 THEN BEGIN
82      t_att_name = ''
83      CASE calendar_type OF
84         1: t_att_calendar = 'Gregorian'
85         0: t_att_calendar = '365 days per year'
86         ELSE: t_att_calendar =strtrim(string(calendar_type), 2)+' days per month'
87      ENDCASE
88      t_att_long_name = 'Time axis'
89      t_att_data = time
90      IF time(0) GT 1 THEN BEGIN
91         t_att_origin = '0001-JAN-01 00:00:00'
92         ENDIF ELSE t_att_origin = def_time_origin(cmd.timave, cmd.date1)
93      t_att_units = 'Days since '+t_att_origin
94      t_att = {name:t_att_name, calendar:t_att_calendar, origin:t_att_origin, units:t_att_units, long_name:t_att_long_name, data:t_att_data}
95      str_t = ',T=t_att'
96   ENDIF
97
98   ; global attributes
99
100   global_attributes = {title:'Data generated by nc_put', origin:fld.origin, conventions:'GDT 1.2', software: 'post_it'}
101
102   cdf_description = str_x+str_y+str_z+str_t+',GLOBAL=global_attributes'
103
104   IF debug_w THEN print, '    cdf_description = ', cdf_description
105   IF debug_w THEN print, '  ...EXIT nc_build'
106   return, cdf_description
107   
108END
Note: See TracBrowser for help on using the repository browser.