1 | pro interpol_time |
---|
2 | |
---|
3 | ; Les dimensions des fichiers |
---|
4 | nlon=720 |
---|
5 | nlat=360 |
---|
6 | nt=1032 |
---|
7 | |
---|
8 | une_annee=[31,30,29,31,30,31,30,31,31,30,31,30] |
---|
9 | |
---|
10 | jours_in = [15, 45, 74, 105, 135, 166, 196, 227, 258, 288, 319, 349, 1840, 1870, $ |
---|
11 | 1899, 1930, 1960, 1991, 2021, 2052, 2083, 2113, 2144, 2174, 5490, 5520, $ |
---|
12 | 5549, 5580, 5610, 5641, 5671, 5702, 5733, 5763, 5794, 5824, 9140, 9170, $ |
---|
13 | 9199, 9230, 9260, 9291, 9321, 9352, 9383, 9413, 9444, 9474, 12790, 12820, $ |
---|
14 | 12849, 12880, 12910, 12941, 12971, 13002, 13033, 13063, 13094, 13124, $ |
---|
15 | 16440, 16470, 16499, 16530, 16560, 16591, 16621, 16652, 16683, 16713, $ |
---|
16 | 16744, 16774, 20090, 20120, 20149, 20180, 20210, 20241, 20271, 20302, $ |
---|
17 | 20333, 20363, 20394, 20424, 23740, 23770, 23799, 23830, 23860, 23891, $ |
---|
18 | 23921, 23952, 23983, 24013, 24044, 24074, 27390, 27420, 27449, 27480, $ |
---|
19 | 27510, 27541, 27571, 27602, 27633, 27663, 27694, 27724, 31040, 31070, $ |
---|
20 | 31099, 31130, 31160, 31191, 31221, 31252, 31283, 31313, 31344, 31374] |
---|
21 | |
---|
22 | jours_out=make_array(1032) |
---|
23 | jours_out(0) = 15 |
---|
24 | for cpt=1,1031 do jours_out(cpt) = jours_out(cpt-1) + une_annee(cpt mod 12) |
---|
25 | |
---|
26 | idin = ncdf_open('/home/tlurton/Scen_EMISS_AER/REGRID/BC-em-bb_nc3.nc') |
---|
27 | varid = ncdf_varid(idin,'BC_em_openburning') |
---|
28 | lonid = ncdf_varid(idin,'lon') |
---|
29 | latid = ncdf_varid(idin,'lat') |
---|
30 | lonbndid = ncdf_varid(idin,'lon_bnds') |
---|
31 | latbndid = ncdf_varid(idin,'lat_bnds') |
---|
32 | timbndid = ncdf_varid(idin,'time_bnds') |
---|
33 | ncdf_varget, idin, varid, emiss_init |
---|
34 | ncdf_attget, idin, varid, "units", emiss_unit |
---|
35 | ncdf_attget, idin, varid, "long_name", emiss_longname |
---|
36 | ncdf_varget, idin, lonid, lon |
---|
37 | ncdf_varget, idin, latid, lat |
---|
38 | ncdf_varget, idin, lonbndid, lonbnds |
---|
39 | ncdf_varget, idin, latbndid, latbnds |
---|
40 | ncdf_varget, idin, timbndid, timbnds_in |
---|
41 | ncdf_close, idin |
---|
42 | |
---|
43 | timbnds_out = make_array(2,1032) |
---|
44 | timbnds_out(*,0) = [0,31] |
---|
45 | for cpt=1,1031 do timbnds_out(0,cpt) = timbnds_out(0,cpt-1) + une_annee(cpt mod 12) |
---|
46 | for cpt=1,1030 do timbnds_out(1,cpt) = timbnds_out(0,cpt+1) |
---|
47 | timbnds_out(1,1031) = 31390 |
---|
48 | |
---|
49 | emiss_interpol=make_array(nlon,nlat,1032,value=0.) |
---|
50 | |
---|
51 | indices_out_mois = make_array(86,12,value=0) |
---|
52 | for m=0,11 do begin |
---|
53 | for n=0,85 do indices_out_mois(n,m) = 12*n + m |
---|
54 | endfor |
---|
55 | |
---|
56 | jours_out_mois = make_array(86,12,value=0) |
---|
57 | for n=0,85 do begin |
---|
58 | for m=0,11 do jours_out_mois(n,m) = jours_out(indices_out_mois(n,m)) |
---|
59 | endfor |
---|
60 | |
---|
61 | jours_in_mois = make_array(n_elements(jours_in)/12,12,value=0) |
---|
62 | for m=0,11 do begin |
---|
63 | for n=0,n_elements(jours_in)/12-1 do jours_in_mois(n,m) = jours_in(n*12 + m) |
---|
64 | endfor |
---|
65 | |
---|
66 | indices_in_mois = make_array(n_elements(jours_in)/12,12,value=0) |
---|
67 | for m=0,11 do begin |
---|
68 | for n=0,n_elements(jours_in)/12-1 do indices_in_mois(n,m) = where(jours_in eq jours_in_mois(n,m)) |
---|
69 | endfor |
---|
70 | |
---|
71 | ; Interpolation mois par mois... |
---|
72 | for i=0,nlon-1 do begin |
---|
73 | for j=0,nlat-1 do begin |
---|
74 | for m=0,11 do begin |
---|
75 | emiss_interpol(i,j,indices_out_mois(*,m)) = interpol(emiss_init(i,j,indices_in_mois(*,m)),jours_in_mois(*,m),jours_out_mois(*,m)) |
---|
76 | endfor |
---|
77 | endfor |
---|
78 | endfor |
---|
79 | |
---|
80 | plot, jours_out, emiss_interpol(404,192,*) |
---|
81 | |
---|
82 | idout = ncdf_create('BC-em-bb_interp.nc', /clobber) |
---|
83 | dimlonid = ncdf_dimdef(idout,'lon',nlon) |
---|
84 | dimlatid = ncdf_dimdef(idout,'lat',nlat) |
---|
85 | dimtimid = ncdf_dimdef(idout,'time',1032) |
---|
86 | dimbndid = ncdf_dimdef(idout,'bound',2) |
---|
87 | varlonid = ncdf_vardef(idout, 'lon', [dimlonid], /double) |
---|
88 | varlatid = ncdf_vardef(idout, 'lat', [dimlatid], /double) |
---|
89 | vartimid = ncdf_vardef(idout, 'time', [dimtimid], /double) |
---|
90 | varlonbndsid = ncdf_vardef(idout, 'lon_bnds', [dimbndid,dimlonid], /double) |
---|
91 | varlatbndsid = ncdf_vardef(idout, 'lat_bnds', [dimbndid,dimlatid], /double) |
---|
92 | vartimbndsid = ncdf_vardef(idout, 'time_bnds', [dimbndid,dimtimid], /double) |
---|
93 | varemissid = ncdf_vardef(idout, 'BC_em_openburning', [dimlonid,dimlatid,dimtimid], /float) |
---|
94 | ncdf_control, idout, /endef |
---|
95 | ncdf_varput, idout, varlonid, lon |
---|
96 | ncdf_varput, idout, varlatid, lat |
---|
97 | ncdf_varput, idout, varlonbndsid, lonbnds |
---|
98 | ncdf_varput, idout, varlatbndsid, latbnds |
---|
99 | ncdf_varput, idout, vartimbndsid, timbnds_out |
---|
100 | ncdf_varput, idout, varemissid, emiss_interpol |
---|
101 | ncdf_varput, idout, vartimid, jours_out |
---|
102 | ncdf_control, idout, /redef |
---|
103 | ncdf_attput, idout, varlonid, "units", "degrees_east" |
---|
104 | ncdf_attput, idout, varlonid, "long_name", "longitude" |
---|
105 | ncdf_attput, idout, varlonid, "axis", "X" |
---|
106 | ncdf_attput, idout, varlonid, "bounds", "lon_bnds" |
---|
107 | ncdf_attput, idout, varlonid, "modulo", 360. |
---|
108 | ncdf_attput, idout, varlonid, "realtopology", "circular" |
---|
109 | ncdf_attput, idout, varlonid, "standard_name", "longitude" |
---|
110 | ncdf_attput, idout, varlonid, "topology", "circular" |
---|
111 | ncdf_attput, idout, varlatid, "units", "degrees_north" |
---|
112 | ncdf_attput, idout, varlatid, "long_name", "latitude" |
---|
113 | ncdf_attput, idout, varlatid, "axis", "Y" |
---|
114 | ncdf_attput, idout, varlatid, "bounds", "lat_bnds" |
---|
115 | ncdf_attput, idout, varlatid, "realtopology", "linear" |
---|
116 | ncdf_attput, idout, varlatid, "standard_name", "latitude" |
---|
117 | ncdf_attput, idout, varemissid, "units", string(emiss_unit) |
---|
118 | ncdf_attput, idout, varemissid, "_FillValue", 1.e+20 |
---|
119 | ncdf_attput, idout, varemissid, "cell_methods", "time: mean" |
---|
120 | ncdf_attput, idout, varemissid, "long_name", string(emiss_longname) |
---|
121 | ncdf_attput, idout, varemissid, "missing_value", 1.e+20 |
---|
122 | ncdf_attput, idout, vartimid, "units", "days since 2015-01-01 0:0:0" |
---|
123 | ncdf_attput, idout, vartimid, "long_name", "time" |
---|
124 | ncdf_attput, idout, vartimid, "calendar", '365_day' |
---|
125 | ncdf_attput, idout, vartimid, "axis", "T" |
---|
126 | ncdf_attput, idout, vartimid, "bounds", "time_bnds" |
---|
127 | ncdf_attput, idout, vartimid, "realtopology", "linear" |
---|
128 | ncdf_attput, idout, vartimid, "standard_name", "time" |
---|
129 | idin = ncdf_open('/home/tlurton/Scen_EMISS_AER/REGRID/BC-em-bb_nc3.nc') ; Je rouvre le fichier |
---|
130 | res = ncdf_attcopy(idin, "_NCProperties", idout, /in_global, /out_global) |
---|
131 | res = ncdf_attcopy(idin, "Conventions", idout, /in_global, /out_global) |
---|
132 | res = ncdf_attcopy(idin, "activity_id", idout, /in_global, /out_global) |
---|
133 | res = ncdf_attcopy(idin, "comment", idout, /in_global, /out_global) |
---|
134 | res = ncdf_attcopy(idin, "contact", idout, /in_global, /out_global) |
---|
135 | res = ncdf_attcopy(idin, "creation_date", idout, /in_global, /out_global) |
---|
136 | res = ncdf_attcopy(idin, "data_structure", idout, /in_global, /out_global) |
---|
137 | res = ncdf_attcopy(idin, "dataset_category", idout, /in_global, /out_global) |
---|
138 | res = ncdf_attcopy(idin, "external_variables", idout, /in_global, /out_global) |
---|
139 | res = ncdf_attcopy(idin, "frequency", idout, /in_global, /out_global) |
---|
140 | res = ncdf_attcopy(idin, "further_info_url", idout, /in_global, /out_global) |
---|
141 | ncdf_attput, idout, /global, "grid", '2.5 x 1.25 degree longitude x latitude' |
---|
142 | res = ncdf_attcopy(idin, "grid_label", idout, /in_global, /out_global) |
---|
143 | ncdf_attput, idout, /global, "nominal_resolution", '250 x 125 km longitude x latitude' |
---|
144 | res = ncdf_attcopy(idin, "institution", idout, /in_global, /out_global) |
---|
145 | res = ncdf_attcopy(idin, "institution_id", idout, /in_global, /out_global) |
---|
146 | res = ncdf_attcopy(idin, "mip_era", idout, /in_global, /out_global) |
---|
147 | res = ncdf_attcopy(idin, "product", idout, /in_global, /out_global) |
---|
148 | res = ncdf_attcopy(idin, "realm", idout, /in_global, /out_global) |
---|
149 | res = ncdf_attcopy(idin, "references", idout, /in_global, /out_global) |
---|
150 | res = ncdf_attcopy(idin, "source", idout, /in_global, /out_global) |
---|
151 | res = ncdf_attcopy(idin, "source_id", idout, /in_global, /out_global) |
---|
152 | res = ncdf_attcopy(idin, "table_id", idout, /in_global, /out_global) |
---|
153 | res = ncdf_attcopy(idin, "target_mip", idout, /in_global, /out_global) |
---|
154 | res = ncdf_attcopy(idin, "title", idout, /in_global, /out_global) |
---|
155 | res = ncdf_attcopy(idin, "variable_id", idout, /in_global, /out_global) |
---|
156 | res = ncdf_attcopy(idin, "license", idout, /in_global, /out_global) |
---|
157 | res = ncdf_attcopy(idin, "data_usage_tips", idout, /in_global, /out_global) |
---|
158 | res = ncdf_attcopy(idin, "reporting_unit", idout, /in_global, /out_global) |
---|
159 | res = ncdf_attcopy(idin, "tracking_id", idout, /in_global, /out_global) |
---|
160 | res = ncdf_attcopy(idin, "history", idout, /in_global, /out_global) |
---|
161 | res = ncdf_attcopy(idin, "NCO", idout, /in_global, /out_global) |
---|
162 | ncdf_close, idin |
---|
163 | ncdf_close, idout |
---|
164 | |
---|
165 | stop |
---|
166 | |
---|
167 | end |
---|