1 | FUNCTION 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 | |
---|
15 | |
---|
16 | xpos = strpos(direc, 'x') |
---|
17 | ypos = strpos(direc, 'y') |
---|
18 | zpos = strpos(direc, 'z') |
---|
19 | tpos = strpos(direc, 't') |
---|
20 | |
---|
21 | str_x = '' |
---|
22 | str_y = '' |
---|
23 | str_z = '' |
---|
24 | str_t = '' |
---|
25 | IF xpos NE -1 THEN BEGIN |
---|
26 | CASE grid_type OF |
---|
27 | 'T': xdata = glamt |
---|
28 | 'U': xdata = glamu |
---|
29 | 'V': xdata = glamv |
---|
30 | 'W': xdata = glamt |
---|
31 | ENDCASE |
---|
32 | ENDIF ELSE BEGIN |
---|
33 | ; degenerated dimension case |
---|
34 | xdata=0. |
---|
35 | ENDELSE |
---|
36 | x_att = {name:'nav_lon', units:'degrees_east', long_name:'Longitude', data:xdata} |
---|
37 | str_x = ',X=x_att' |
---|
38 | |
---|
39 | IF ypos NE -1 THEN BEGIN |
---|
40 | IF xpos NE -1 THEN BEGIN |
---|
41 | CASE grid_type OF |
---|
42 | 'T': ydata = gphit |
---|
43 | 'U': ydata = gphiu |
---|
44 | 'V': ydata = gphiv |
---|
45 | 'W': ydata = gphit |
---|
46 | ENDCASE |
---|
47 | ENDIF ELSE BEGIN |
---|
48 | ; degenerated dimension case |
---|
49 | idx = where(gphit EQ max(gphit)) |
---|
50 | idx = idx MOD jpi |
---|
51 | boite_pltz = [idx[0], idx[0], -90,90] |
---|
52 | domdef, boite_pltz, /xindex ; indice pour x |
---|
53 | ydata = reform(gphit[idx[0], firstyt:lastyt],lastyt-firstyt+1) |
---|
54 | print, ' firstyt:lastyt', lastyt-firstyt+1 |
---|
55 | ENDELSE |
---|
56 | ENDIF ELSE BEGIN |
---|
57 | ; degenerated dimension case |
---|
58 | ydata=0. |
---|
59 | ENDELSE |
---|
60 | y_att = {name:'nav_lat', units:'degrees_north', long_name:'Latitude', data:ydata} |
---|
61 | str_y = ',Y=y_att' |
---|
62 | |
---|
63 | IF zpos NE -1 THEN BEGIN |
---|
64 | CASE grid_type OF |
---|
65 | 'T': BEGIN & zdata = gdept & z_txt = 'Vertical T levels' & END |
---|
66 | 'U': BEGIN & zdata = gdept & z_txt = 'Vertical T levels' & END |
---|
67 | 'V': BEGIN & zdata = gdept & z_txt = 'Vertical T levels' & END |
---|
68 | 'W': BEGIN & zdata = gdepw & z_txt = 'Vertical W levels' & END |
---|
69 | ENDCASE |
---|
70 | ENDIF ELSE BEGIN |
---|
71 | ; degenerated dimension case |
---|
72 | zdata=0. |
---|
73 | z_txt = 'No vertical dimension' |
---|
74 | ENDELSE |
---|
75 | z_att = {name:'deptht', units:'m', long_name:z_txt, data:zdata} |
---|
76 | str_z = ',Z=z_att' |
---|
77 | |
---|
78 | IF tpos NE -1 THEN BEGIN |
---|
79 | t_att_name = '' |
---|
80 | CASE calendar_type OF |
---|
81 | 1: t_att_calendar = 'Gregorian' |
---|
82 | 0: t_att_calendar = '365 days per year' |
---|
83 | ELSE: t_att_calendar =strtrim(string(calendar_type), 2)+' days per month' |
---|
84 | ENDCASE |
---|
85 | t_att_long_name = 'Time axis' |
---|
86 | t_att_data = time |
---|
87 | IF time(0) GT 1 THEN BEGIN |
---|
88 | t_att_origin = '0001-JAN-01 00:00:00' |
---|
89 | ENDIF ELSE t_att_origin = def_time_origin(cmd.timave, cmd.date1) |
---|
90 | t_att_units = 'Days since '+t_att_origin |
---|
91 | 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} |
---|
92 | str_t = ',T=t_att' |
---|
93 | ENDIF |
---|
94 | |
---|
95 | ; global attributes |
---|
96 | |
---|
97 | global_attributes = {title:'Data generated by nc_put', origin:fld.origin, conventions:'GDT 1.2', software: 'post_it'} |
---|
98 | |
---|
99 | cdf_description = str_x+str_y+str_z+str_t+',GLOBAL=global_attributes' |
---|
100 | |
---|
101 | return, cdf_description |
---|
102 | |
---|
103 | END |
---|