1 | function [datestr_value, precip_value]=simul_precip(station,index_simulation) |
---|
2 | |
---|
3 | %SIMUL_PRECIP fill array precipitation 2D array and associated arrays datestr |
---|
4 | %with simulated data |
---|
5 | |
---|
6 | % |
---|
7 | %+ |
---|
8 | % |
---|
9 | % ============== |
---|
10 | % simul_precip.m |
---|
11 | % ============== |
---|
12 | % |
---|
13 | % .. function:: simul_precip(station,index_simulation) |
---|
14 | % |
---|
15 | % DESCRIPTION |
---|
16 | % =========== |
---|
17 | % |
---|
18 | % :param index_simulation: 1 |
---|
19 | % :type index_simulation: int8 |
---|
20 | % :raise index_simulation: required |
---|
21 | % |
---|
22 | % :param station: station |
---|
23 | % :type station: string |
---|
24 | % :raise station: required |
---|
25 | % |
---|
26 | % |
---|
27 | % Charge en mémoire un tableau 2D simulé **precip_value** de précipitation dans : |
---|
28 | % |
---|
29 | % Simulation #1 |
---|
30 | % données pendant la mousson de 2006 |
---|
31 | % |
---|
32 | % Les dates au format `yyyymmdd` sont stockés dans le tableau **datestr_value**. |
---|
33 | % |
---|
34 | % EXAMPLES |
---|
35 | % ======== |
---|
36 | % |
---|
37 | % From scratch to create short array of precipitation and associated array datestr: |
---|
38 | % |
---|
39 | % see demo 1 |
---|
40 | % |
---|
41 | % To write these arrays in |
---|
42 | % file:`${VARAMMA_OD}/PRECIP/barkedji_pluie_2006_write_precip.csv`:: |
---|
43 | % |
---|
44 | % octave> result=write_precip(datestr_value, precip_value); |
---|
45 | % |
---|
46 | % From scratch to create long array of precipitation and associated array datestr: |
---|
47 | % |
---|
48 | % see demo 2 |
---|
49 | % |
---|
50 | % To write these arrays in |
---|
51 | % file:`${VARAMMA_OD}/PRECIP/barkedji_pluie_2006_write_precip.csv`:: |
---|
52 | % |
---|
53 | % octave> result=write_precip(datestr_value, precip_value); |
---|
54 | % |
---|
55 | % SEE ALSO |
---|
56 | % ======== |
---|
57 | % |
---|
58 | % :ref:`guide data precipitation <data_precipitation_insitu>` |
---|
59 | % |
---|
60 | % :func:`write_precip` |
---|
61 | % |
---|
62 | % TODO |
---|
63 | % ==== |
---|
64 | % |
---|
65 | % des valeurs de precipitation plus réalistes y compris des NaN |
---|
66 | % |
---|
67 | % returned values when error |
---|
68 | % |
---|
69 | % pb with demo 2 |
---|
70 | % |
---|
71 | % EVOLUTIONS |
---|
72 | % ========== |
---|
73 | % |
---|
74 | % $Id$ |
---|
75 | % |
---|
76 | % $URL$ |
---|
77 | % |
---|
78 | % - fplod 20110228T115056Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
79 | % |
---|
80 | % * examples moved in demo |
---|
81 | % * use int2str instead of num2str |
---|
82 | % |
---|
83 | % - fplod 20110221T155750Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
84 | % |
---|
85 | % * remove simulated geolocation |
---|
86 | % |
---|
87 | % - fplod 20110112T110544Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
88 | % |
---|
89 | % * creation |
---|
90 | % |
---|
91 | %- |
---|
92 | % |
---|
93 | result=-1; |
---|
94 | % |
---|
95 | usage='[datestr_value, precip_value]=simul_precip(station,index_simulaion)'; |
---|
96 | if nargin~=2 |
---|
97 | disp(['Incorrect number of arguments ' num2str(nargin) ]); |
---|
98 | error(usage) |
---|
99 | end |
---|
100 | % |
---|
101 | arg_info=whos('index_simulation'); |
---|
102 | if ~strcmp(arg_info.class,'int8') |
---|
103 | disp(['Incorrect type of arg index_simulation ' arg_info.class]); |
---|
104 | whos index_simulation |
---|
105 | error(usage); |
---|
106 | end |
---|
107 | clear arg_info |
---|
108 | % |
---|
109 | % |
---|
110 | arg_info=whos('station'); |
---|
111 | if ~strcmp(arg_info.class,'char') |
---|
112 | disp(['Incorrect type of arg station ' arg_info.class]); |
---|
113 | whos station |
---|
114 | error(usage); |
---|
115 | end |
---|
116 | clear arg_info |
---|
117 | % |
---|
118 | % définition de la zone géographique |
---|
119 | % définition de la zone temporelle |
---|
120 | if (index_simulation == 1) |
---|
121 | yyyy=2006; |
---|
122 | datenum_value=datenum(yyyy,6,1):1:datenum(yyyy,11,eomday(yyyy,11)); |
---|
123 | datestr_value=datestr(datenum_value,'yyyymmdd'); |
---|
124 | clear yyyy |
---|
125 | clear datenum_value |
---|
126 | else |
---|
127 | error(['eee : unknow simulation ' int2str(index_simulation)]); |
---|
128 | end |
---|
129 | % |
---|
130 | nb_geolocation=1; |
---|
131 | % |
---|
132 | nb_datestr=size(datestr_value,1); |
---|
133 | % |
---|
134 | % création de tableau precipitation |
---|
135 | precip_value=zeros(nb_geolocation,nb_datestr,'double'); |
---|
136 | for index_geolocation=1:nb_geolocation |
---|
137 | for index_datestr=1:nb_datestr |
---|
138 | precip_value(index_geolocation,index_datestr)=index_datestr/10.; |
---|
139 | end |
---|
140 | end |
---|
141 | clear nb_geolocation |
---|
142 | clear index_geolocation |
---|
143 | clear nb_datestr |
---|
144 | clear index_datestr |
---|
145 | % |
---|
146 | whos; |
---|
147 | % |
---|
148 | result=0; |
---|
149 | % |
---|
150 | end |
---|
151 | |
---|
152 | %!demo |
---|
153 | %! % From scratch to create short array of precipitation and associated array datestr:: |
---|
154 | %! varamma_startup |
---|
155 | %! more off |
---|
156 | %! index_simulation=int8(1); |
---|
157 | %! station='barkedji'; |
---|
158 | %! [datestr_value, precip_value]=simul_precip(station,index_simulation) |
---|
159 | |
---|
160 | %!demo |
---|
161 | %! % From scratch to create long array of precipitation and associated array datestr:: |
---|
162 | % |
---|
163 | %! varamma_startup |
---|
164 | %! more off |
---|
165 | %! echo on |
---|
166 | %! index_simulation=int8(2); |
---|
167 | %! station='barkedji'; |
---|
168 | %! [datestr_value, precip_value]=simul_precip(station,index_simulation) |
---|