Changeset 142 for trunk/SRC/ToBeReviewed/PLOTS/VECTEUR/vecteur.pro
- Timestamp:
- 07/21/06 14:47:49 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/ToBeReviewed/PLOTS/VECTEUR/vecteur.pro
r134 r142 1 ;------------------------------------------------------------2 ;------------------------------------------------------------3 ;------------------------------------------------------------4 ;+5 ; NAME:vecteur6 ;7 ; PURPOSE: trace des vecteurs (meme situees sur une grille tordue) sur8 ; n''importe quelle projection, de telle sorte que tous les vecteurs9 ; aient une norme comparable sur le dessin (en clair, un vecteur qui10 ; doit faire 1cm le fait quelque soit la projection et sa position sur11 ; la sphere)12 ;13 ; CATEGORY:trace de vecteur14 ;15 ; CALLING SEQUENCE:vecteur, composanteu, composantev, normevecteur, indice2d, reduitindice2d16 ;17 ; INPUTS: COMPOSANTEU et COMPOSANTEV: ce sont les composantes des18 ; vecteurs a tracer. Ces tableaux 2d ont la meme dimension que19 ; reduitindice2d (cf apres).20 ; INDICE2D: indice permettant de passer d''un tableau jpi,jpj au21 ; zoom surlequel on fait le dessin.22 ; REDUITINDICE2D: indice permettant de passer d''un tableau23 ; definit par indice2d au tableau pourlequel on a reelement des24 ; vecteurs a tracer (en clair: c''est par ex qd on ne trace par exemple25 ; que un vecteur sur 2)26 ;27 ; KEYWORD PARAMETERS:28 ;29 ; CMREF: la longeur en cm sur le papier que diot faire la fleche30 ; de norme normeref. par defaut ajuste au dessin et compris entre31 ; .5 et 1.5 cm32 ;33 ; MISSING: la valeur d''une missing value. ne pas utilisder ce34 ; mot cle. fixe a 1e5 par ajoutvect.pro35 ;36 ; NORMEREF: la norme de la fleche de reference. par defaut on37 ; essaie de faire qqch qui colle pas trop mal!38 ;39 ; VECTCOLOR: la couleur de la fleche. Par defaut noir (couleur 0)40 ;41 ; VECTTHICK; l''epaissuer de la fleche. par defaut 1.42 ;43 ; VECTREFPOS: vecteur de 2 elements specifiant la position en44 ; coordonnees DATA du debut du vecteur de reference. Par defaut45 ; en bas a droite du dessin.46 ;47 ; VECTREFFORMAT: format a utiliser pour specifier la norme du48 ; vecteur de reference.49 ;50 ; /NOVECTREF: pour supprimer l'affichage du vecteur de reference.51 ;52 ; OUTPUTS:53 ;54 ; COMMON BLOCKS:common.pro55 ;56 ; SIDE EFFECTS:57 ;58 ; RESTRICTIONS:59 ;60 ; EXAMPLE:61 ;62 ; MODIFICATION HISTORY:63 ; Creation : 13/02/98 G. Roullet (grlod@lodyc.jussieu.fr)64 ; Modification : 14/01/99 realise la transformation65 ; spherique<->cartesien G. Roullet66 ; 12/03/99 verification de la routine G. Roullet67 ; 8/11/1999:68 ; G. Roullet et Sebastien Masson (smasson@lodyc.jussieu.fr)69 ; adaptation pour les zoom. reverification...traitement separe de la70 ; direction et de la norme des vecteurs. mots cles NORMEREF et CMREF.71 ;-72 ;------------------------------------------------------------73 ;------------------------------------------------------------74 ;------------------------------------------------------------75 76 1 FUNCTION cv_cm2normal, angle 77 2 ; 78 ; donne la longeur en coordonnes normales d''un trait ortiente de79 ; angle par rapport a l''axe des x et qui doit faire 1 cm sur le80 ; dessin.81 ; angle peut etre un tableau.3 ; Give the lenth in normal coordinates of a trait oriented of an angle 4 ; by rapport at the x axis and which must do 1 cm on the drawing. 5 ; Angle can be an array. 6 ; 82 7 ; 83 8 ; … … 85 10 ; 86 11 @common 87 ; quelle est la longeur en coordonnees normales d''un trait qui fera 188 ; cm sur le parier et qui est parallele ax?12 ; What is the lenth in normal coordinates of a trait which will do 1 cm 13 ; on the paper an which is parallel to x? 89 14 mipgsz = min(page_size, max = mapgsz) 90 15 sizexfeuille = mipgsz*key_portrait+mapgsz*(1-key_portrait) … … 92 17 cm_en_normal = 1./sizexfeuille 93 18 ; 94 ; si le rapport d''aspect de la fenetre n''est pas egale a 1, la95 ; longeur en coordonees normalise d''un trait de 1cm varie suivant96 ; l''angle polaire de cetrait.19 ; If the aspect rapport of the window is not equal to 1, the lenth in 20 ; normalized coordinates of a trait of 1 cm vary following the polar 21 ; angle of this trait. 97 22 ; 98 23 aspect = sizexfeuille/sizeyfeuille … … 104 29 PRO normalise, u, v, w 105 30 ; 106 ; normali se le vecteur31 ; normalize the vector 107 32 ; 108 33 ; … … 122 47 ENDELSE 123 48 END 49 ;------------------------------------------------------------ 50 ;------------------------------------------------------------ 51 ;------------------------------------------------------------ 52 ;+ 53 ; 54 ; @file_comments 55 ; Trace vectors (even if they are on a deformed grid) on any projection. 56 ; In this way, all vectors have a comparable norme on the drawing (to be 57 ; clear, a vector which measure 1 cm measure it, no matter the projection 58 ; and is position on the sphere). 59 ; 60 ; @categories 61 ; graphic 62 ; 63 ; @param COMPOSANTEU {in}{required} 64 ; It is the u component of the vector to be traced. This 2d array has the 65 ; same dimension that reduitindice2d (see further) 66 ; 67 ; @param COMPOSANTEV {in}{required} 68 ; It is the v component of the vector to be traced. This 2d array has the 69 ; same dimension that reduitindice2d (see further) 70 ; 71 ; @param INDICE2D {in}{required} 72 ; It in an index allowing to to pass from an jpi or jpj array to the zoom 73 ; on which we do the drawing 74 ; 75 ; @param REDUITINDICE2D {in}{required} 76 ; It is an index allowing to pass from an array defined by indice2d to the 77 ; array for which we really have vectors to be traced (to be clear, it is 78 ; for example when we trace only one vector on two). 79 ; 80 ; @keyword CMREF 81 ; The lenth in cm that must measure the arrow normed normeref. By default, 82 ; it is ajusted t othe drawing and included between .5 and 1.5 cm. 83 ; 84 ; @keyword MISSING 85 ; The value of a missing value. Do not use this keyword. Fixed at 1e5 by 86 ; ajoutvect.pro 87 ; 88 ; @keyword NORMEREF 89 ; The norme of the reference arrow. 90 ; 91 ; @keyword VECTCOLOR 92 ; The color of the arrow. Black by default (color 0) 93 ; 94 ; @keyword VECTTHICK 95 ; The thick of the arrow. 1 by default 96 ; 97 ; @keyword VECTREFPOS 98 ; Vector composed of 2 elements specifing the position on DATA coordinates 99 ; from de begining of the reference vector. By default at the right bottom 100 ; of the drawing. 101 ; 102 ; @keyword VECTREFFORMAT 103 ; The format to be used to specify the norme of the reference vector. 104 ; 105 ; @keyword NOVECTREF 106 ; To delete the display of the reference vector. 107 ; 108 ; @keyword _EXTRA 109 ; Used to pass your keywords 110 ; 111 ; @uses 112 ; common.pro 113 ; 114 ; @history 115 ; Creation : 13/02/98 G. Roullet (grlod@lodyc.jussieu.fr) 116 ; Modification : 14/01/99 realise la transformation 117 ; spherique<->cartesien G. Roullet 118 ; 12/03/99 verification de la routine G. Roullet 119 ; 8/11/1999: 120 ; G. Roullet et Sebastien Masson (smasson@lodyc.jussieu.fr) 121 ; adaptation pour les zoom. reverification...traitement separe de la 122 ; direction et de la norme des vecteurs. mots cles NORMEREF et CMREF. 123 ; 124 ; @version 125 ; $Id$ 126 ; 127 ;- 128 ;------------------------------------------------------------ 129 ;------------------------------------------------------------ 130 ;------------------------------------------------------------ 124 131 PRO vecteur, composanteu, composantev, normevecteur, indice2d, reduitindice2d $ 125 132 , CMREF = cmref, MISSING = missing, NORMEREF = normeref $ … … 130 137 ; 131 138 @common 132 tempsun = systime(1) ; pour key_performance139 tempsun = systime(1) ; For key_performance 133 140 ; 134 141 ; … … 153 160 ENDIF 154 161 ; 155 ; Etape 1: 156 ; 157 ; etant donne la direction et le sens que le vecteur a sur la 158 ; sphere, il faut se debrouiller pour determiner cette direction et le 159 ; sens qu'aura le vecteur sur l''ecran ou la feuille une fois qu''il 160 ; aura ete projete. 161 ; 162 ; En theorie: sur la sphere, un vecteur en un point donne a pour 163 ; direction la tangente au cercle qui passe par le centre de la terre 164 ; et par le vecteur. Donc trouver la direction une fois la projection 165 ; faite ds le plan 2d, c''est trouver la tangente a la courbe 166 ; representant la projection du cercle sur le plan 2d au point 167 ; representant la projection du point de depart de la shere sur le 168 ; plan 2d!!! 169 ; 170 ; En pratique on ne connait pas la definition de la courbe que donne 171 ; la projection d''un cercle alors trouver sa tangente en un point... 172 ; 173 ; Ce que l''on fait: 174 ; Ds un repere cartesien 3d, 175 ; a) on trouve les coordonnees du point T (debut de la fleche) 176 ; situe sur la shere. 177 ; b) pour chaque point T on determine les directions locales 178 ; definies par la grille en ce point et auxquelles se rapportent 179 ; les coordonnes (u,v) du vecteur. Ces directions locales sont 180 ; definies par les gradiants des glam et gphi. Une fois ces 181 ; directions obtenues, on les considere comme orthogonales et en 182 ; les normant on construit un repere orthonormal (nu,nv) auquel se 183 ; rapporte les coordonnes (u,v) du vecteur. Ds le repere 184 ; cartesien 3d de depart, le vecteur est definit par: 185 ; V=u*nu+v*nv (ou V, nu et nv sont des vecteurs 3d et u et v des 186 ; scalaires) 187 ; c) pour approximer la tangente au cercle par la corde definie 188 ; par le debut et la fin de la fleche, on va normaliser V puis 189 ; le diviser par 100. 190 ; d) ceci nous permet de determiner les coordonnees ds le repere 191 ; cartesien 3d des extremites de la corde, on les passe en 192 ; coordonnes sphereriques de facon a recuperer les positions en 193 ; latitude longitude de ces points sur la sphere. 194 ; e) on passe les coordonnees de ces points en coordonnees 195 ; normalise puis en corrdonnes polaire de facon a trouver 196 ; l''angle et la direction qu''ils determinent sur le dessin... 197 ; 198 ; 199 ; etape 1, a) 200 ; 201 ; 202 ; coordonnes du point T (debut de la fleche) en coordonnes sheriques 162 ; Stage 1: 163 ; 164 ; Given that the directions and the sense that the vector has on the sphere, 165 ; we have to try to determinate this direction and the sense that the vector 166 ; will have on the screen once it will have been projected. 167 ; 168 ; In theory: on the sphere, a vector in a given point has for direction the 169 ; tangent at the circle passing by the center of the Earth and by the vector. 170 ; So, find the direction once the projection is done, it is find the tangent 171 ; to the curve representing the projection of the circle on the 2d plan at the 172 ; point representing the projection of the starting point of the shere on the 173 ; 2d plan. 174 ; 175 ; In practice we do no know the definition of the curve given by the projection 176 ; of a circle so find its tangente in a point... 177 ; 178 ; What we do: 179 ; In a 3d cartesian reference, 180 ; a) We find coorinates of the point T (starting of the arrow) situed 181 ; on the sphere. 182 ; b) To each point T, we determine local directions defined by the grid 183 ; on this point and on which coordinates (u,v) of the vector refer to. 184 ; These local directions are defined by gradients of glam and gphi. Once 185 ; we have obtain these directions, we considare them like orthogonal and 186 ; by norming them, we build an orthonormal reference (nu,nv) on which 187 ; coordinates (u,v) of the vector refer to. In the starting 3d cartesian 188 ; reference, the vector is defined by: 189 ; V=u*nu+v*nv 190 ; (where V, nu and nv are 3d vectors and u and v are scalars). 191 ; c) To approximate the tangente to the circle by the chord defined by 192 ; the beginning and the ending of the arrow, we will normalize V, and 193 ; then divide it by 100. 194 ; d) This allows us to determine coordinates of extremities of the chord 195 ; in the 3d cartesian reference. We pass them in spherical coordinates in 196 ; order to recuperate latitude and longitude position of these points on 197 ; the sphere. 198 ; e) We pass coordinates of these points in normalized coordinates, then 199 ; in polar coordinates in order to find the angle and the direction they 200 ; dertermine on the drawing. 201 ; 202 ; 203 ; Stage 1, a) 204 ; 205 ; 206 ; coordinates of the point T (beginning of the arrow) in spherical coordinates. 203 207 glam = glamt[indice2d[reduitindice2d]] 204 208 gphi = gphit[indice2d[reduitindice2d]] 205 209 ; 206 ; coordonnes du point T (debut de la fleche) dans le repere cartesien207 ; on utilise comme shere, une shere de rayon1.210 ; Coordinates of the point T (beginning of the arrow) in the cartesian reference. 211 ; For the sphere, we use a sphere with a radius of 1. 208 212 ; 209 213 radius = replicate(1,nx*ny) … … 215 219 z0 = reform(r[2, *], nx, ny) 216 220 ; 217 ; etape 1, b) 218 ; 219 ; Construction du vecteur nu (resp. nv), vecteur norme porte par 220 ; l''axe des points u[i,j] et u[i-1,j] (resp v[i,j] et v[i,j-1]) 221 ; qui definissent pour chaque point sur la shere les directions locales 222 ; associee a u et v. ces vecteurs definissent un repere orthonorme 223 ; local. 224 ; ces vecteurs sont construits dans un repere cartesien (cv_coord) 225 ; on a choisit un rayon de la terre unite (unit). 226 ; 227 ; definition de nu 221 ; Stage 1, b) 222 ; 223 ; Construction of a vector nu (resp. nv), vectr normed carried by the axis of 224 ; points u[i,j] and u[i-1,j] (resp v[i,j] and v[i,j-1]) which define, for each 225 ; point on the sphere, local directions associated with u and v. These vectors 226 ; define a local orthonormal reference. 227 ; These vectors are built in a cartesian reference (cv_coord). We have choose a 228 ; unity radius of the Earth (unit). 229 ; 230 ; definition of nu 228 231 radius = replicate(1,nxgd*nygd) 229 232 IF finite(glamu[0]*gphiu[0]) NE 0 THEN $ … … 231 234 ELSE coord_sphe = transpose([ [(glamf[indice2d])[*]], [(gphit[indice2d])[*]], [radius[*]] ]) 232 235 r = cv_coord(from_sphere=coord_sphe,/to_rect,/degrees) 233 ; coord onnes de points de la grille u en cartesien236 ; coordinates of points of the grid u in cartesian. 234 237 ux = reform(r[0, *], nxgd, nygd) 235 238 uy = reform(r[1, *], nxgd, nygd) 236 239 uz = reform(r[2, *], nxgd, nygd) 237 ; calcul denu240 ; calculation of nu 238 241 nux = ux-shift(ux, 1, 0) 239 242 nuy = uy-shift(uy, 1, 0) 240 243 nuz = uz-shift(uz, 1, 0) 241 ; conditions a ux limites244 ; conditions at extremities. 242 245 if NOT keyword_set(key_periodic) OR nxgd NE jpi then begin 243 246 nux[0, *] = nux[1, *] … … 245 248 nuz[0, *] = nuz[1, *] 246 249 ENDIF 247 ; reduction de la grille250 ; reduction of the grid 248 251 nux = nux[reduitindice2d] 249 252 nuy = nuy[reduitindice2d] 250 253 nuz = nuz[reduitindice2d] 251 ; definition denv254 ; definition of nv 252 255 IF finite(glamv[0]*gphiv[0]) NE 0 THEN $ 253 256 coord_sphe = transpose([ [(glamv[indice2d])[*]], [(gphiv[indice2d])[*]], [radius[*]] ]) $ 254 257 ELSE coord_sphe = transpose([ [(glamt[indice2d])[*]], [(gphif[indice2d])[*]], [radius[*]] ]) 255 258 r = cv_coord(from_sphere=coord_sphe,/to_rect,/degrees) 256 ; coord onnes de points de la grille v en cartesien259 ; coordinates of points of the grid in cartesian. 257 260 vx = reform(r[0, *], nxgd, nygd) 258 261 vy = reform(r[1, *], nxgd, nygd) 259 262 vz = reform(r[2, *], nxgd, nygd) 260 ; calcul denv263 ; calcul of nv 261 264 nvx = vx-shift(vx, 0, 1) 262 265 nvy = vy-shift(vy, 0, 1) 263 266 nvz = vz-shift(vz, 0, 1) 264 ; conditions a ux limites267 ; conditions at extremities 265 268 nvx[*, 0] = nvx[*, 1] 266 269 nvy[*, 0] = nvy[*, 1] 267 270 nvz[*, 0] = nvz[*, 1] 268 ; reduction de la grille271 ; reduction of the grid 269 272 nvx = nvx[reduitindice2d] 270 273 nvy = nvy[reduitindice2d] 271 274 nvz = nvz[reduitindice2d] 272 275 ; 273 ; normali sation276 ; normalization 274 277 ; 275 278 normalise, nux, nuy, nuz 276 279 normalise, nvx, nvy, nvz 277 280 ; 278 ; etape 1, c)279 ; 280 ; coord onnes du vecteur V ds le repere cartesion281 ; Stage 1, c) 282 ; 283 ; coordinates of the vector V in the cartesian reference 281 284 ; 282 285 direcx = zu*nux + zv*nvx 283 286 direcy = zu*nuy + zv*nvy 284 287 direcz = zu*nuz + zv*nvz 285 ; normali sation du vecteur v288 ; normalization of the vector V 286 289 normalise, direcx, direcy, direcz 287 ; on divi se par 100.290 ; on divide by 100 288 291 direcx = direcx/100. 289 292 direcy = direcy/100. 290 293 direcz = direcz/100. 291 294 ; 292 ; etape 1, d)293 ; coord onnees de la pointe de la fleche dans le repere cartesien295 ; Stege 1, d) 296 ; coordinates of the point of the arrow in the cartesian reference. 294 297 295 298 x1 = x0 + direcx … … 297 300 z1 = z0 + direcz 298 301 299 ; coord onnees de la pointe en spherique302 ; coordinates of the point of the arrow in spherical coordinates. 300 303 301 304 coord_rect = transpose([ [x1[*]], [y1[*]], [z1[*]] ]) … … 305 308 306 309 ; 307 ; modif des glam tout se passe bien au niveau de la ligne de308 ; changement de date...attention, il ne faut pas couper les fleches309 ; qui sortent de la fenetre!310 ; test: si il sort du cadre mais qu''avec un +/- 360 il y rentre on le311 ; modifie...310 ; modification of glams. Everything take place at the level of the line 311 ; of changing of date... BEWARE, do not cut arrow which goes out of the 312 ; window! 313 ; test: If it goes out of the frame, but, thanks to +/- 360° it come in, 314 ; we modify it 312 315 ; 313 316 ind = where(glam1 LT !x.range[0] AND glam1+360. LE !x.range[1]) … … 322 325 ; 323 326 ; 324 ; etape 1, e)327 ; Stage 1, e) 325 328 ; 326 329 r = convert_coord(glam,gphi,/data,/to_normal) 327 x0 = r[0, *] ; coordonnes normales du debut de la fleche330 x0 = r[0, *] ; normal coordinates of the beginning of the array. 328 331 y0 = r[1, *] ; 329 332 330 333 r = convert_coord(glam1,gphi1,/data,/to_normal) 331 x1 = r[0, *] ; coordonnes normales de la fin de la fleche (avant scaling)334 x1 = r[0, *] ; normal coordinates of the ending of the array (Before scaling). 332 335 y1 = r[1, *] ; 333 336 ; 334 ; tests pour eviter que des fleches soient dessineees hors du domaine337 ; tests to avoid that arrows be drawing out of the domain. 335 338 ; 336 339 out = where(x0 LT !p.position[0] OR x0 GT !p.position[2] $ … … 338 341 if out[0] NE -1 THEN x0[out] = !values.f_nan 339 342 ; 340 ; suivant les projections, il peu y a voir des points a nan qd on341 ; passe en coordonnes normales. on supprime cespoints.343 ; Following projections, there may are points at NaN when we pass in normal coordinates. 344 ; We delete these points. 342 345 ; 343 346 nan = finite(x0*y0*x1*y1) … … 348 351 norme = norme[number] 349 352 ; 350 ; on definit le vecteur direction dans le repere normalise353 ; We define the vector direction in the normalize reference. 351 354 ; 352 355 dirx = x1-x0 353 356 diry = y1-y0 354 357 ; 355 ; on passe en polaire pour recuperer l''angle qui etait le but de 356 ; toute la partie 1!!! 358 ;We pass in polar coordinates to recuperate the angle which wasb the goal of all the first stage!!! 357 359 ; 358 360 … … 360 362 dirpol = msk*dirpol[0, *] 361 363 ; 362 ; 2eme etape....363 ; 364 ; maintenant on s''occupe de lanorme...365 ; 366 ; Mise a l''echelle automatique364 ; Stage 2 365 ; 366 ; Now we take care of the norme... 367 ; 368 ; Automatic putting at the scale 367 369 ; 368 370 if NOT keyword_set(cmref) then BEGIN … … 380 382 cm = 1.*normeref/cmref 381 383 ; 382 ; on modifie le tableau norme de facon a ce que un element qui a la 383 ; valeur cm soit represente par un trait de longueur 1cm sur le 384 ; papier. 385 ; norme contient la norme des vecteur que l''on veut dessiner 384 ; We modify the array norme to an element having the value cm be represented 385 ; by a trait of lenght 1 cm on the paper. Norme contain the norme of vectors 386 ; we want to draw. 386 387 ; 387 388 norme = 1/(1.*cm)*norme*cv_cm2normal(dirpol) 388 389 ; 389 390 ; 390 ; 3eme etape....391 ; maintenant qu''on a l''angle et la norme, et bien on recupere les392 ; coordonnes en rectangulaire et on dessine les fleches.391 ; Stage 3 392 ; Now that we have the angle and the norme, we recuperate coordinates in 393 ; rectangular and we draw arrows. 393 394 ; 394 395 r = cv_coord(from_polar = transpose([ [dirpol[*]], [norme[*]] ]), /to_rect) … … 399 400 y1 = y0+composantey 400 401 ; 401 ; c''est parti pour le trace !402 ; Drawing 402 403 ; 403 404 if NOT KEYWORD_SET(vectcolor) then vectcolor = 0 … … 407 408 , hsize = -.2, COLOR = vectcolor, THICK = vectthick 408 409 ; 409 ; D essine une fleche en bas a droite de la figure en guise de legende410 ; Draw an arrow at the right bottom of the drawing as a caption. 410 411 ; 411 412 if NOT keyword_set(novectref) then BEGIN 412 dx = cmref*cv_cm2normal(0) ; longuer du vecteur de reference en coordonnes normalisees.413 dx = cmref*cv_cm2normal(0) ; Lenght of the vector of reference in normalzed coordinates. 413 414 if keyword_set(vectrefformat) then $ 414 415 normelegende = strtrim(string(normeref, format = vectrefformat), 1)+' ' $
Note: See TracChangeset
for help on using the changeset viewer.