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