[2] | 1 | ;------------------------------------------------------------ |
---|
| 2 | ;------------------------------------------------------------ |
---|
| 3 | ;------------------------------------------------------------ |
---|
| 4 | ;+ |
---|
| 5 | ; |
---|
[142] | 6 | ; @file_comments |
---|
| 7 | ; Overprint vectors in a field traced by plt. |
---|
[2] | 8 | ; |
---|
[142] | 9 | ; @categories |
---|
[157] | 10 | ; Graphics |
---|
[2] | 11 | ; |
---|
[142] | 12 | ; @param VECTEUR {in}{required} |
---|
| 13 | ; It is a structure with 2 elements containing we 2 matrixes U and V of |
---|
| 14 | ; values of the zonal and meridian component of the fiel of vectors to |
---|
| 15 | ; be traced. |
---|
| 16 | ; For ex: |
---|
[2] | 17 | ; vecteur={matriceu:lec('unsurface'),matricev:lec('vnsurface')} |
---|
[142] | 18 | ; rq:the name of elements of vector does not have any importance. |
---|
| 19 | ; vecteur={u:lec('unsurface'),v:lec('vnsurface')} goes well too. |
---|
[2] | 20 | ; |
---|
[142] | 21 | ; @keyword UNVECTSUR |
---|
| 22 | ; It is a scalar n or an array with 2 elements [n1,n2]. |
---|
| 23 | ; In the first case, we will trace a vector on n following x and y. |
---|
| 24 | ; In the second case, we will trace a vector on n1 following x and a |
---|
| 25 | ; vector n2 following n2 |
---|
| 26 | ; Comments: To trace all vectors following y and one vector on two |
---|
| 27 | ; following x, put unvectsur=[2,1] |
---|
[2] | 28 | ; |
---|
[142] | 29 | ; @keyword VECTMIN {in}{required} |
---|
| 30 | ; Minimum norme of vectors to be traced |
---|
[2] | 31 | ; |
---|
[142] | 32 | ; @keyword VECTMAX {in}{required} |
---|
| 33 | ; Maximum norme of vectors to be traced |
---|
[2] | 34 | ; |
---|
[142] | 35 | ; @keyword _EXTRA |
---|
| 36 | ; Used to pass your keywords |
---|
| 37 | ; |
---|
| 38 | ; @uses |
---|
| 39 | ; common.pro |
---|
[2] | 40 | ; |
---|
[142] | 41 | ; @history |
---|
[157] | 42 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
[2] | 43 | ; 10/3/1999 |
---|
| 44 | ; 11/6/1999 compatibilite avec NAN et la lecture |
---|
| 45 | ; des structures. |
---|
[142] | 46 | ; |
---|
| 47 | ; @version |
---|
| 48 | ; $Id$ |
---|
| 49 | ; |
---|
[2] | 50 | ;- |
---|
| 51 | ;------------------------------------------------------------ |
---|
| 52 | ;------------------------------------------------------------ |
---|
| 53 | ;------------------------------------------------------------ |
---|
| 54 | pro ajoutvect,vecteur, vectlegende, UNVECTSUR=unvectsur,VECTMIN=vectmin, VECTMAX=vectmax, _EXTRA = ex |
---|
[114] | 55 | ; |
---|
| 56 | compile_opt idl2, strictarrsubs |
---|
| 57 | ; |
---|
[2] | 58 | @common |
---|
[142] | 59 | tempsun = systime(1) ; For key_performance |
---|
[2] | 60 | ;---------------------------------------------------------------------------- |
---|
| 61 | ; |
---|
| 62 | u = litchamp(vecteur.(0)) |
---|
| 63 | u = checkfield(u, 'plt', TYPE = 'xy', /NOQUESTION) |
---|
| 64 | v = litchamp(vecteur.(1)) |
---|
| 65 | v = checkfield(v, 'plt', TYPE = 'xy', /NOQUESTION) |
---|
| 66 | ;----------------------------------------------------------- |
---|
[142] | 67 | ;----------------------------------------------------------- |
---|
| 68 | ; We recuperate possible informations on fields |
---|
| 69 | ;----------------------------------------------------------- |
---|
[2] | 70 | grilleu = litchamp(vecteur.(0), /grid) |
---|
| 71 | if grilleu EQ '' then grilleu = 'U' |
---|
| 72 | grillev = litchamp(vecteur.(1), /grid) |
---|
| 73 | if grillev EQ '' then grillev = 'V' |
---|
[41] | 74 | |
---|
[2] | 75 | IF grilleu EQ 'V' AND grillev EQ 'U' THEN inverse = 1 |
---|
| 76 | IF grilleu EQ grillev THEN interpolle = 0 ELSE interpolle = 1 |
---|
| 77 | if keyword_set(inverse) then begin |
---|
| 78 | rien = u |
---|
| 79 | u = v |
---|
| 80 | v = rien |
---|
| 81 | endif |
---|
| 82 | ;------------------------------------------------------------ |
---|
[142] | 83 | ; We find common points between u and v |
---|
[2] | 84 | ;------------------------------------------------------------ |
---|
| 85 | if interpolle then begin |
---|
[41] | 86 | indicexu = (lindgen(jpi))[firstxu:firstxu+nxu-1] |
---|
| 87 | indicexv = (lindgen(jpi))[firstxv:firstxv+nxv-1] |
---|
[2] | 88 | indicex = inter(indicexu, indicexv) |
---|
[41] | 89 | indiceyu = (lindgen(jpj))[firstyu:firstyu+nyu-1] |
---|
| 90 | indiceyv = (lindgen(jpj))[firstyv:firstyv+nyv-1] |
---|
[2] | 91 | indicey = inter(indiceyu, indiceyv) |
---|
| 92 | nx = n_elements(indicex) |
---|
| 93 | ny = n_elements(indicey) |
---|
| 94 | indice2d = lindgen(jpi, jpj) |
---|
| 95 | indice2d = indice2d[indicex[0]:indicex[0]+nx-1,indicey[0]:indicey[0]+ny-1] |
---|
| 96 | ;------------------------------------------------------------ |
---|
[142] | 97 | ; extraction of u and v on the appropriated domain |
---|
[2] | 98 | ;------------------------------------------------------------ |
---|
| 99 | case 1 of |
---|
| 100 | (size(u))[0] NE 2 OR (size(v))[0] NE 2: return |
---|
| 101 | (size(u))[1] EQ nxu AND (size(u))[2] EQ nyu AND $ |
---|
| 102 | (size(v))[1] EQ nxv AND (size(v))[2] EQ nyv:BEGIN |
---|
| 103 | if nxu NE nx then $ |
---|
[41] | 104 | if indicex[0] EQ firstxu then u = u[0:nx-1, *] ELSE u = u[1: nx, *] |
---|
[2] | 105 | IF nxv NE nx THEN $ |
---|
[41] | 106 | if indicex[0] EQ firstxv then v = v[0:nx-1, *] ELSE v = v[1: nx, *] |
---|
[2] | 107 | IF nyu NE ny THEN $ |
---|
[41] | 108 | if indicey[0] EQ firstyu then u = u[*, 0:ny-1] ELSE u = u[*, 1: ny] |
---|
[2] | 109 | IF nyv NE ny THEN $ |
---|
[41] | 110 | if indicey[0] EQ firstyv then v = v[*, 0:ny-1] ELSE v = v[*, 1: ny] |
---|
[2] | 111 | END |
---|
| 112 | (size(u))[1] EQ jpi AND (size(u))[2] EQ jpj AND $ |
---|
| 113 | (size(v))[1] EQ jpi AND (size(v))[2] EQ jpj:BEGIN |
---|
| 114 | u = u[indice2d] |
---|
| 115 | v = v[indice2d] |
---|
| 116 | END |
---|
| 117 | ELSE:BEGIN |
---|
| 118 | ras = report('problemes d''adequation entre la taille du domaine et la taille des matrices necessaires a tracer des vecteurs') |
---|
| 119 | return |
---|
| 120 | end |
---|
| 121 | endcase |
---|
| 122 | ;------------------------------------------------------------------ |
---|
[142] | 123 | ; We reshape u and v to make sure that none dimension has been erased. |
---|
[2] | 124 | ;------------------------------------------------------------------ |
---|
| 125 | if ny EQ 1 then begin |
---|
| 126 | u = reform(u, nx, ny) |
---|
| 127 | v = reform(v, nx, ny) |
---|
| 128 | endif |
---|
| 129 | ;------------------------------------------------------------------ |
---|
[142] | 130 | ; construction of u and v at points T |
---|
[2] | 131 | ;----------------------------------------------------------- |
---|
[114] | 132 | a=u[0,*] |
---|
[2] | 133 | u=(u+shift(u,1,0))/2. |
---|
[114] | 134 | if NOT keyword_set(key_periodic) OR nx NE jpi then u[0,*]=a |
---|
| 135 | a=v[*,0] |
---|
[2] | 136 | v=(v+shift(v,0,1))/2. |
---|
[114] | 137 | if NOT keyword_set(key_periodic) OR nx NE jpi then v[*,0]=a |
---|
[2] | 138 | ;---------------------------------------------------------------------------- |
---|
[142] | 139 | ; attribution of the mask and of longitude and latitude arrays. |
---|
| 140 | ; We recuperate the complete grid to establish a big mask extensive |
---|
| 141 | ; in the four directions to cover points for which a land point has |
---|
| 142 | ; been considerated (do a small drawing) |
---|
[2] | 143 | ;---------------------------------------------------------------------------- |
---|
| 144 | vargrid='T' |
---|
[41] | 145 | msku = (umask())[indice2d+jpi*jpj*firstzt] |
---|
| 146 | mskv = (vmask())[indice2d+jpi*jpj*firstzt] |
---|
[2] | 147 | glam = glamt[indice2d] |
---|
| 148 | gphi = gphit[indice2d] |
---|
| 149 | if ny EQ 1 then begin |
---|
| 150 | msku = reform(msku, nx, ny) |
---|
| 151 | mskv = reform(mskv, nx, ny) |
---|
| 152 | ; glam = reform(glam, nx, ny) |
---|
| 153 | ; gphi = reform(gphi, nx, ny) |
---|
| 154 | endif |
---|
| 155 | ;----------------------------------------------------------- |
---|
[142] | 156 | ; We mask u and v et v the long of coasts (the place where we |
---|
| 157 | ; can not calculate the average) |
---|
| 158 | ;----------------------------------------------------------- |
---|
| 159 | ; extention of the mask |
---|
[2] | 160 | u = u*msku*shift(msku,1,0) |
---|
| 161 | v = v*mskv*shift(mskv,0,1) |
---|
| 162 | ENDIF ELSE BEGIN |
---|
[41] | 163 | u = u*tmask[firstxt:lastxt,firstyt:lastyt,firstzt] |
---|
| 164 | v = v*tmask[firstxt:lastxt,firstyt:lastyt,firstzt] |
---|
[2] | 165 | indice2d = lindgen(jpi, jpj) |
---|
[41] | 166 | indice2d = indice2d[firstxt:lastxt, firstyt:lastyt] |
---|
[2] | 167 | nx = nxt |
---|
| 168 | ny = nyt |
---|
| 169 | endelse |
---|
| 170 | tabnorme=sqrt(u^2+v^2) |
---|
| 171 | nan = where(finite(u, /nan) EQ 1) |
---|
| 172 | if nan[0] NE -1 then u[nan] = 1e5 |
---|
| 173 | nan = where(finite(v, /nan) EQ 1) |
---|
| 174 | if nan[0] NE -1 then v[nan] = 1e5 |
---|
| 175 | if keyword_set(vectmin) then BEGIN |
---|
[41] | 176 | toosmall=where(tabnorme lt vectmin) |
---|
| 177 | if toosmall[0] NE -1 then begin |
---|
| 178 | u[toosmall] = 1e5 |
---|
| 179 | v[toosmall] = 1e5 |
---|
[2] | 180 | ENDIF |
---|
| 181 | endif |
---|
| 182 | if keyword_set(vectmax) then BEGIN |
---|
[41] | 183 | toobig=where(tabnorme gt vectmax) |
---|
| 184 | if toobig[0] NE -1 then begin |
---|
| 185 | u[toobig] = 1e5 |
---|
| 186 | v[toobig] = 1e5 |
---|
[2] | 187 | ENDIF |
---|
| 188 | ENDIF |
---|
| 189 | ;----------------------------------------------------------- |
---|
[142] | 190 | ; Put back of a big value on all points for which we can do the calculation. |
---|
[2] | 191 | ;----------------------------------------------------------- |
---|
| 192 | if interpolle then t2 = msku*shift(msku,1,0)*mskv*shift(mskv,0,1) $ |
---|
[41] | 193 | ELSE t2 = tmask[firstxt:lastxt,firstyt:lastyt,firstzt] |
---|
[114] | 194 | if NOT keyword_set(key_periodic) OR nx NE jpi then t2[0, *]=0. |
---|
| 195 | t2[*,0]=0. |
---|
[2] | 196 | terre=where(t2 eq 0) |
---|
| 197 | if terre[0] ne -1 then begin |
---|
[114] | 198 | u[terre]=1e5 |
---|
| 199 | v[terre]=1e5 |
---|
[2] | 200 | ENDIF |
---|
| 201 | ;----------------------------------------------------------- |
---|
[142] | 202 | ; trace only one vector one two |
---|
[2] | 203 | ;----------------------------------------------------------- |
---|
| 204 | if keyword_set(unvectsur) then BEGIN ; |
---|
[142] | 205 | ; indx is a vector containing number of columns to be selected. |
---|
| 206 | ; indy is a vector containing number of lines to be selected. |
---|
[2] | 207 | if n_elements(unvectsur) EQ 1 then begin |
---|
| 208 | indx = where((lindgen(nx) MOD unvectsur[0]) eq 0) |
---|
| 209 | indy = where((lindgen(ny) MOD unvectsur[0]) eq 0) |
---|
| 210 | ENDIF ELSE BEGIN |
---|
| 211 | indx = where((lindgen(nx) MOD unvectsur[0]) eq 0) |
---|
| 212 | indy = where((lindgen(ny) MOD unvectsur[1]) eq 0) |
---|
[142] | 213 | ENDELSE |
---|
| 214 | ; From indx and indy, we will construct an array which will give indexes |
---|
| 215 | ; of intersections points of columns specified by indx. |
---|
[2] | 216 | indicereduit = indx#replicate(1,n_elements(indy))+nx*replicate(1,n_elements(indx))#indy |
---|
[142] | 217 | ; We reduce arrays which will be passed to vecteur. |
---|
[2] | 218 | u = u[indicereduit] |
---|
| 219 | v = v[indicereduit] |
---|
| 220 | tabnorme = tabnorme[indicereduit] |
---|
| 221 | ; |
---|
| 222 | endif |
---|
| 223 | ;----------------------------------------------------------- |
---|
| 224 | ; |
---|
| 225 | ;----------------------------------------------------------- |
---|
| 226 | if keyword_set(inverse) then begin |
---|
| 227 | rien = u |
---|
| 228 | u = v |
---|
| 229 | v = rien |
---|
| 230 | endif |
---|
| 231 | ;----------------------------------------------------------- |
---|
[142] | 232 | ; Drawing of vectors. |
---|
[2] | 233 | ;---------------------------------------------------------- |
---|
| 234 | vecteur, u, v, tabnorme, indice2d, indicereduit, missing=1e5, _extra = ex |
---|
| 235 | ;----------------------------------------------------------- |
---|
[142] | 236 | ; We complete the caption. |
---|
[2] | 237 | ;----------------------------------------------------------- |
---|
| 238 | if terre[0] ne -1 then mini = min(tabnorme[where(t2 eq 1)], max = maxi, /nan) $ |
---|
| 239 | ELSE mini = min(tabnorme, max = maxi, /nan) |
---|
| 240 | |
---|
| 241 | if litchamp(vecteur.(0), /u) NE '' then $ |
---|
| 242 | vectlegende = {minmax:[mini, maxi], unite:litchamp(vecteur.(0), /u)} $ |
---|
| 243 | ELSE vectlegende = {minmax:[mini, maxi], unite:varunit} |
---|
| 244 | |
---|
| 245 | |
---|
| 246 | sortie: |
---|
| 247 | if keyword_set(key_performance) NE 0 THEN print, 'temps ajoutvect', systime(1)-tempsun |
---|
| 248 | return |
---|
| 249 | end |
---|
| 250 | |
---|
| 251 | |
---|