[2] | 1 | ;+ |
---|
| 2 | ; |
---|
[142] | 3 | ; @file_comments |
---|
| 4 | ; Draw the grid |
---|
[2] | 5 | ; |
---|
[142] | 6 | ; @categories |
---|
[268] | 7 | ; Grid |
---|
[231] | 8 | ; |
---|
[254] | 9 | ; @param GLAMIN {in}{optional}{type=1d or 2d array}{default=glam specified by vargrid, on the domain defined by <pro>domdef</pro>} |
---|
[248] | 10 | ; Longitude of points of the grid. |
---|
[2] | 11 | ; |
---|
[254] | 12 | ; @param GPHIIN {in}{optional}{type=1d or 2d array}{default=gphi specified by vargrid, on the domain defined by <pro>domdef</pro>} |
---|
[248] | 13 | ; Latitude of points of the grid. |
---|
[2] | 14 | ; |
---|
[248] | 15 | ; @keyword XSTRIDE {type=integer}{default=1} |
---|
[231] | 16 | ; It specify that we want to trace only one line of |
---|
[142] | 17 | ; constant i every xstride points |
---|
[2] | 18 | ; |
---|
[248] | 19 | ; @keyword YSTRIDE {type=integer}{default=1} |
---|
[231] | 20 | ; It specify that we want to trace only one line of |
---|
[142] | 21 | ; constant j every xstride points |
---|
[2] | 22 | ; |
---|
[231] | 23 | ; @keyword OCEAN |
---|
[142] | 24 | ; To trace the grid only on ocean points. |
---|
[231] | 25 | ; |
---|
[142] | 26 | ; @keyword EARTH |
---|
[163] | 27 | ; To trace the grid only on land points. |
---|
[2] | 28 | ; |
---|
[142] | 29 | ; @keyword RMOUT |
---|
| 30 | ; Select to remove all cell having one corner out of the |
---|
| 31 | ; plot boundaries (!x.range, !y.range) |
---|
[13] | 32 | ; |
---|
[142] | 33 | ; @keyword _EXTRA |
---|
[231] | 34 | ; Used to pass keywords |
---|
| 35 | ; |
---|
[142] | 36 | ; @uses |
---|
| 37 | ; common.pro |
---|
[231] | 38 | ; |
---|
[142] | 39 | ; @examples |
---|
[2] | 40 | ; |
---|
[13] | 41 | ; IDL> plt,indgen(jpi,jpj),/nocontour,/nofill |
---|
| 42 | ; IDL> vargrid='T' |
---|
[2] | 43 | ; IDL> tracegrille,/ocean,color=20 |
---|
| 44 | ; IDL> tracegrille,/earth,color=80 |
---|
| 45 | ; |
---|
| 46 | ; |
---|
[142] | 47 | ; @history |
---|
[157] | 48 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
[142] | 49 | ; |
---|
| 50 | ; @version |
---|
| 51 | ; $Id$ |
---|
[231] | 52 | ; |
---|
[2] | 53 | ;- |
---|
[327] | 54 | PRO tracegrille, glamin, gphiin, OCEAN=ocean, EARTH=earth $ |
---|
| 55 | , XSTRIDE=xstride, YSTRIDE=ystride, RMOUT=rmout $ |
---|
| 56 | , _EXTRA=extra |
---|
[114] | 57 | ; |
---|
| 58 | compile_opt idl2, strictarrsubs |
---|
| 59 | ; |
---|
[13] | 60 | @cm_4mesh |
---|
| 61 | @cm_4data |
---|
| 62 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
| 63 | @updatenew |
---|
| 64 | ENDIF |
---|
| 65 | ;--------------------------------------------------------- |
---|
[142] | 66 | tempsun = systime(1) ; For key_performance |
---|
[13] | 67 | ; to avoid warning message |
---|
| 68 | oldexcept = !except |
---|
| 69 | !except = 0 |
---|
| 70 | if n_elements(key_gridtype) EQ 0 then key_gridtype = 'c' |
---|
| 71 | ; |
---|
| 72 | if n_elements(glamin) * n_elements(gphiin) EQ 0 then BEGIN |
---|
| 73 | grille, mask, glam, gphi, gdep, nx, ny, nz, firstx, firsty, firstz, lastx, lasty, lastz |
---|
[209] | 74 | IF keyword_set(ocean) AND strmid(key_gridtype, 0, 1) EQ 'c' THEN BEGIN |
---|
[13] | 75 | ; we reduce the mask to take into account the point located ON the coastline. |
---|
| 76 | CASE vargrid OF |
---|
| 77 | 'U':BEGIN |
---|
| 78 | mask = tmask[firstx:lastx, firsty:lasty] |
---|
| 79 | IF NOT keyword_set(key_periodic) OR nx NE jpi $ |
---|
| 80 | THEN tmpx = mask[nx-1, *] |
---|
| 81 | mask = (mask+shift(mask, -1, 0)) < 1 |
---|
| 82 | IF NOT keyword_set(key_periodic) OR nx NE jpi $ |
---|
| 83 | THEN mask[nx-1, *] = temporary(tmpx) |
---|
| 84 | END |
---|
| 85 | 'V':BEGIN |
---|
| 86 | mask = tmask[firstx:lastx, firsty:lasty] |
---|
| 87 | tmpy = mask[*, ny-1] |
---|
| 88 | mask = (mask+shift(mask, 0, -1)) < 1 |
---|
| 89 | mask[*, ny-1] = temporary(tmpy) |
---|
| 90 | END |
---|
| 91 | 'F':BEGIN |
---|
| 92 | mask = tmask[firstx:lastx, firsty:lasty] |
---|
| 93 | IF NOT keyword_set(key_periodic) OR nx NE jpi $ |
---|
| 94 | THEN tmpx = mask[nx-1, *] |
---|
| 95 | tmpy = mask[*, ny-1] |
---|
| 96 | mask = (mask+shift(mask, -1, 0)+shift(mask, 0, -1)+shift(mask, -1, -1)) < 1 |
---|
| 97 | mask[*, ny-1] = temporary(tmpy) |
---|
| 98 | IF NOT keyword_set(key_periodic) OR nx NE jpi $ |
---|
| 99 | THEN mask[nx-1, *] = temporary(tmpx) |
---|
| 100 | END |
---|
| 101 | ELSE: |
---|
| 102 | ENDCASE |
---|
| 103 | ENDIF |
---|
| 104 | ENDIF ELSE BEGIN |
---|
| 105 | glam = glamin |
---|
| 106 | gphi = gphiin |
---|
| 107 | IF (size(glam))[0] EQ 1 AND (size(gphi))[0] EQ 1 THEN BEGIN |
---|
[231] | 108 | nx = n_elements(glam) |
---|
| 109 | ny = n_elements(gphi) |
---|
[13] | 110 | glam = glam#replicate(1, ny) |
---|
| 111 | gphi = replicate(1, nx)#gphi |
---|
| 112 | ENDIF ELSE BEGIN |
---|
| 113 | nx = (size(glam))[1] |
---|
| 114 | ny = (size(glam))[2] |
---|
| 115 | ENDELSE |
---|
| 116 | ENDELSE |
---|
| 117 | if n_elements(mask) EQ 0 then mask = replicate(1b, nx, ny) |
---|
| 118 | if (size(mask))[0] EQ 3 then mask = mask[*, *, 0] |
---|
| 119 | ; |
---|
| 120 | IF keyword_set(RMOUT) THEN BEGIN |
---|
| 121 | out = where(glam GT max(!x.range) OR glam LT min(!x.range) $ |
---|
| 122 | OR gphi GT max(!y.range) OR gphi LT min(!y.range)) |
---|
| 123 | IF out[0] NE -1 THEN BEGIN |
---|
| 124 | glam[out] = !values.f_nan |
---|
| 125 | gphi[out] = !values.f_nan |
---|
| 126 | ENDIF |
---|
| 127 | ENDIF |
---|
| 128 | ; |
---|
| 129 | IF keyword_set(ocean) then BEGIN |
---|
| 130 | earth = where(mask EQ 0) |
---|
| 131 | if earth[0] NE -1 then begin |
---|
| 132 | glam[earth] = !values.f_nan |
---|
| 133 | gphi[earth] = !values.f_nan |
---|
| 134 | ENDIF |
---|
| 135 | earth = 0 |
---|
| 136 | ENDIF |
---|
| 137 | ; |
---|
| 138 | IF keyword_set(earth) THEN BEGIN |
---|
| 139 | ocean = where(mask EQ 1) |
---|
| 140 | if ocean[0] NE -1 then begin |
---|
| 141 | glam[ocean] = !values.f_nan |
---|
| 142 | gphi[ocean] = !values.f_nan |
---|
| 143 | ENDIF |
---|
| 144 | ocean = 0 |
---|
| 145 | ENDIF |
---|
| 146 | ; |
---|
| 147 | if NOT keyword_set(xstride) then xstride = 1 |
---|
| 148 | if NOT keyword_set(ystride) then ystride = 1 |
---|
[209] | 149 | case strmid(key_gridtype, 0, 1) of |
---|
[13] | 150 | 'c':BEGIN |
---|
| 151 | for i = 0, ny-1, ystride do begin |
---|
| 152 | plots, glam[*, i], gphi[*, i], _extra = extra |
---|
| 153 | endfor |
---|
| 154 | for i = 0, nx-1, xstride do begin |
---|
| 155 | plots, glam[i, *], gphi[i, *], _extra = extra |
---|
| 156 | endfor |
---|
| 157 | END |
---|
| 158 | 'e':BEGIN |
---|
| 159 | shifted = glam[0, 0] LT glam[0, 1] |
---|
| 160 | glam2 = glam+(glam[1]-glam[0])/2. |
---|
| 161 | if shifted then begin |
---|
| 162 | for i = 0, ny-2 do BEGIN |
---|
| 163 | xx = (transpose([[glam[*, i]], [glam2[*, i]]]))[*] |
---|
| 164 | yy = (transpose([[gphi[*, i]], [gphi[*, i+1]]]))[*] |
---|
| 165 | plots, xx[0:2*nx-2], yy[0:2*nx-2], _extra = extra |
---|
| 166 | ENDFOR |
---|
| 167 | ENDIF ELSE BEGIN |
---|
| 168 | for i = 1, ny-1 do BEGIN |
---|
| 169 | xx = (transpose([[glam[*, i]], [glam2[*, i]]]))[*] |
---|
| 170 | yy = (transpose([[gphi[*, i]], [gphi[*, i-1]]]))[*] |
---|
| 171 | plots, xx[0:2*nx-2], yy[0:2*nx-2], _extra = extra |
---|
| 172 | ENDFOR |
---|
| 173 | ENDELSE |
---|
| 174 | for i = 1, (ny-1)/2 do $ |
---|
| 175 | plots, [glam[0, 2*i-1], glam[0, 2*i]] $ |
---|
| 176 | , [gphi[0, 2*i-1], gphi[0, 2*i]], _extra = extra |
---|
| 177 | for i = 0, (ny-2)/2 do $ |
---|
| 178 | plots, [glam[nx-1, 2*i], glam[nx-1, 2*i+1]] $ |
---|
| 179 | , [gphi[nx-1, 2*i], gphi[nx-1, 2*i+1]], _extra = extra |
---|
| 180 | END |
---|
| 181 | endcase |
---|
[2] | 182 | |
---|
[231] | 183 | if keyword_set(key_performance) THEN print, 'temps trace grille', systime(1)-tempsun |
---|
[13] | 184 | !except = oldexcept |
---|
[2] | 185 | |
---|
[13] | 186 | return |
---|
[2] | 187 | end |
---|