1 | function [lon_value, lat_value, datejul_value, datestr_value, lai_value]=simul_lai_2d(index_simulation) |
---|
2 | |
---|
3 | %SIMUL_LAI_2D fill array LAI 2d array and associated arrays lat, lon, date |
---|
4 | % with simulated data |
---|
5 | |
---|
6 | % |
---|
7 | %+ |
---|
8 | % |
---|
9 | % ============== |
---|
10 | % simul_lai_2d.m |
---|
11 | % ============== |
---|
12 | % |
---|
13 | % .. function:: simul_lai_2d(index_simulation) |
---|
14 | % |
---|
15 | % DESCRIPTION |
---|
16 | % =========== |
---|
17 | % |
---|
18 | % :param index_simulation: 1 or 2 |
---|
19 | % :type index_simulation: int8 |
---|
20 | % :raise index_simulation: required |
---|
21 | % |
---|
22 | % Charge en mémoire un tableau 2D simulé **lai_value** de LAI dans : |
---|
23 | % |
---|
24 | % Simulation #1 |
---|
25 | % la zone géographique [20°E,10°E] [10°N,20°N] avec un point tous les 2° en |
---|
26 | % latitude et 5° en longitude et dans la zone temporelle 20010101-20011231 |
---|
27 | % avec un point ts les 30 jours. ++ en biais avec un décalage de .5 degré en longitude |
---|
28 | % |
---|
29 | % Simulation #2 |
---|
30 | % la zone géographique [++°E,++°E] [++°N,++°N] avec 860 points en latitude |
---|
31 | % et 874 points en longitude dans la zone temporelle 20010101-20011231 |
---|
32 | % avec un point ts les 8 jours. ++ en biais avec un décalage de .5 degré en longitude |
---|
33 | % |
---|
34 | % Les longitudes sont stockées dans le tableau **lon_value**. |
---|
35 | % |
---|
36 | % Les latitudes sont stockées dans le tableau **lat_value**. |
---|
37 | % |
---|
38 | % Les dates au format `yyyymmdd` sont stockés dans le tableau **datestr_value**. |
---|
39 | % |
---|
40 | % EXAMPLES |
---|
41 | % ======== |
---|
42 | % |
---|
43 | % From scratch to create short array of LAI and associated arrays lat, long |
---|
44 | % and datestr: |
---|
45 | % |
---|
46 | % see demo 1 |
---|
47 | % |
---|
48 | % To plot the grid:: |
---|
49 | % |
---|
50 | % octave> showgrid(lon_value, lat_value); |
---|
51 | % |
---|
52 | % To write these arrays in |
---|
53 | % file:`${PROJECT_OD}/LAI/laisen2001_write_lai_2d_float.txt`:: |
---|
54 | % |
---|
55 | % octave> result=write_lai_2d(lon_value, lat_value, datestr_value, lai_value); |
---|
56 | % |
---|
57 | % From scratch to create long array of LAI and associated arrays lat, long |
---|
58 | % and datestr: |
---|
59 | % |
---|
60 | % see demo 2 |
---|
61 | % |
---|
62 | % To plot the grid:: |
---|
63 | % |
---|
64 | % octave> result=showgrid(lon_value, lat_value); |
---|
65 | % |
---|
66 | % To write these arrays in |
---|
67 | % file:`${PROJECT_OD}/LAI/laisen2001_write_lai_2d_float.txt`:: |
---|
68 | % |
---|
69 | % octave> result=write_lai_2d(lon_value, lat_value, datejul_value, datestr_value, lai_value); |
---|
70 | % |
---|
71 | % SEE ALSO |
---|
72 | % ======== |
---|
73 | % |
---|
74 | % :ref:`guide data LAI <data_lai>` |
---|
75 | % |
---|
76 | % :func:`simul_lai_2d` |
---|
77 | % :func:`write_lai_2d` |
---|
78 | % |
---|
79 | % TODO |
---|
80 | % ==== |
---|
81 | % |
---|
82 | % des valeurs de LAI plus réalistes y compris des NaN |
---|
83 | % |
---|
84 | % returned values when error |
---|
85 | % |
---|
86 | % EVOLUTIONS |
---|
87 | % ========== |
---|
88 | % |
---|
89 | % $Id$ |
---|
90 | % |
---|
91 | % $URL$ |
---|
92 | % |
---|
93 | % |
---|
94 | % - fplod 20110708T164042Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
95 | % |
---|
96 | % * add datejul_value output |
---|
97 | % |
---|
98 | % - fplod 20110302T153846Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
99 | % |
---|
100 | % * examples moved to demo |
---|
101 | % |
---|
102 | % - fplod 20101208T103329Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
103 | % |
---|
104 | % * check argument |
---|
105 | % |
---|
106 | % - fplod 20101206T152338Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
107 | % |
---|
108 | % * check argument |
---|
109 | % |
---|
110 | % - fplod 20101206T105346Z adonis.locean-ipsl.upmc.fr (Linux) |
---|
111 | % |
---|
112 | % * cleanning thanks to mlint |
---|
113 | % |
---|
114 | % - fplod 20101203T105554Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
115 | % |
---|
116 | % * time step in simulation #1 set to 30 days |
---|
117 | % (50 days give 8 steps which is confused with 8 digits of yyyymmdd) |
---|
118 | % |
---|
119 | % - fplod 20101202T142356Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
120 | % |
---|
121 | % * add parameter information in header |
---|
122 | % |
---|
123 | % - fplod 20100923T141616Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
124 | % |
---|
125 | % * creation from simul_lai.m because impossible to define |
---|
126 | % lai_values(46,839041,839041) - too big |
---|
127 | % and better reproduction of longitude values |
---|
128 | %- |
---|
129 | % |
---|
130 | result=-1; |
---|
131 | % |
---|
132 | usage='lon_value, lat_value, datejul_value, datestr_value, lai_value]=simul_lai_2d(index_simulaion)'; |
---|
133 | if nargin~=1 |
---|
134 | disp(['Incorrect number of arguments']); |
---|
135 | error(usage); |
---|
136 | end |
---|
137 | % |
---|
138 | arg_info=whos('index_simulation'); |
---|
139 | if ~strcmp(arg_info.class,'int8') |
---|
140 | disp(['Incorrect type of arg index_simulation']); |
---|
141 | whos index_simulation |
---|
142 | error(usage); |
---|
143 | end |
---|
144 | clear arg_info |
---|
145 | % |
---|
146 | % définition de la zone géographique : les coins en degré et les résolutions |
---|
147 | if (index_simulation == 1) |
---|
148 | % ici une boite [20°E,10°E] [10°N,20°N] et un point tous les 2° en latitude |
---|
149 | % et 5° en longitude |
---|
150 | lonmin_value=-20.; |
---|
151 | lonmax_value=-10.; |
---|
152 | latmin_value=10.; |
---|
153 | latmax_value=20.; |
---|
154 | lat_delta = 2.; |
---|
155 | lon_delta = 5.; |
---|
156 | elseif (index_simulation == 2 ) |
---|
157 | lonmin_value=-18.168; |
---|
158 | lonmax_value=-10.518; |
---|
159 | latmin_value=10.004; |
---|
160 | latmax_value=17.996; |
---|
161 | lat_delta = 0.0092930; |
---|
162 | lon_delta = 0.0087529; |
---|
163 | else |
---|
164 | error(['eee : unknow simulation ' num2str(index_simulation)]); |
---|
165 | end |
---|
166 | % |
---|
167 | % définition de la zone temporelle : l'année et la résolution |
---|
168 | if (index_simulation == 1) |
---|
169 | % ici une valeur tous les 30 jours pour 2001 |
---|
170 | yyyy_value=2001; |
---|
171 | datestr_delta=30; |
---|
172 | elseif (index_simulation == 2 ) |
---|
173 | % ici une valeur tous les 8 jours pour 2001 |
---|
174 | yyyy_value=2001; |
---|
175 | datestr_delta=8; |
---|
176 | else |
---|
177 | error(['eee : unknow simulation ' num2str(index_simulation)]); |
---|
178 | end |
---|
179 | clear index_simulation |
---|
180 | % création du tableau des longitudes |
---|
181 | lon_basevalue=transpose(lonmin_value:lon_delta:lonmax_value); |
---|
182 | clear lonmin_value |
---|
183 | clear lonmax_value |
---|
184 | clear lon_delta |
---|
185 | % |
---|
186 | % création du tableau des latitudes |
---|
187 | lat_basevalue=transpose(latmin_value:lat_delta:latmax_value); |
---|
188 | clear latmin_value |
---|
189 | clear latmax_value |
---|
190 | clear lat_delta |
---|
191 | % |
---|
192 | nb_line=size(lat_basevalue,1)*size(lon_basevalue,1); |
---|
193 | % |
---|
194 | lon_orthovalue=repmat(lon_basevalue,size(lat_basevalue,1),1); |
---|
195 | lon_value=zeros(nb_line,1); |
---|
196 | lon_value(:)=NaN; |
---|
197 | for index_line=1:nb_line |
---|
198 | offset=ceil(index_line/size(lon_basevalue,1))*0.5; |
---|
199 | lon_value(index_line)=lon_orthovalue(index_line)-offset; |
---|
200 | end |
---|
201 | clear offset |
---|
202 | lat_value=zeros(nb_line,1); |
---|
203 | lat_value(:)=NaN; |
---|
204 | for index_line=1:nb_line |
---|
205 | index_lat=ceil(index_line/size(lon_basevalue,1)); |
---|
206 | lat_value(index_line)=lat_basevalue(index_lat); |
---|
207 | end |
---|
208 | clear index_lat |
---|
209 | clear lat_basevalue |
---|
210 | clear lon_basevalue |
---|
211 | clear lon_orthovalue |
---|
212 | % |
---|
213 | datejul_value=datenum(yyyy_value,1,1):datestr_delta:datenum(yyyy_value,12,eomday(yyyy_value,12)); |
---|
214 | clear yyyy_value |
---|
215 | clear datestr_delta |
---|
216 | % |
---|
217 | % conversion datenum (unité octave/matlab) en format "yyyymmdd" |
---|
218 | datestr_value=datestr(datejul_value,'yyyymmdd'); |
---|
219 | nb_datestr=size(datestr_value,1); |
---|
220 | % |
---|
221 | % création de tableau LAI |
---|
222 | lai_value=zeros(nb_line,nb_datestr); |
---|
223 | lai_value(:,:)=NaN; |
---|
224 | for index_line=1:nb_line |
---|
225 | for index_datestr=1:nb_datestr |
---|
226 | lai_value(index_line,index_datestr)=(index_datestr+index_line)/100.; |
---|
227 | end |
---|
228 | end |
---|
229 | clear nb_line |
---|
230 | clear index_line |
---|
231 | clear nb_datestr |
---|
232 | clear index_datestr |
---|
233 | % |
---|
234 | % |
---|
235 | result=0; |
---|
236 | % |
---|
237 | end |
---|
238 | |
---|
239 | %!demo |
---|
240 | %! % From scratch to create short array of LAI and associated arrays lat, long |
---|
241 | %! % and datestr:: |
---|
242 | %! clear all |
---|
243 | %! close all |
---|
244 | %! varamma_startup |
---|
245 | %! more off |
---|
246 | %! index_simulation=int8(1); |
---|
247 | %! [lon_value, lat_value, datejul_value, datestr_value, lai_value]=simul_lai_2d(index_simulation); |
---|
248 | |
---|
249 | %!demo |
---|
250 | %! % From scratch to create long array of LAI and associated arrays lat, long |
---|
251 | %! % and datestr:: |
---|
252 | %! clear all |
---|
253 | %! close all |
---|
254 | %! varamma_startup |
---|
255 | %! more off |
---|
256 | %! index_simulation=int8(2); |
---|
257 | %! [lon_value, lat_value, datejul_value, datestr_value, lai_value]=simul_lai_2d(index_simulation); |
---|