[2] | 1 | ;------------------------------------------------------------ |
---|
| 2 | ;------------------------------------------------------------ |
---|
| 3 | ;------------------------------------------------------------ |
---|
| 4 | ;+ |
---|
| 5 | ; |
---|
[142] | 6 | ; @file_comments |
---|
| 7 | ; Allows to pass a field refering to the grid V on the grid T, |
---|
| 8 | ; thanks to the average: |
---|
| 9 | ; res = 0.5*(res + shift(res, 1, 0)) |
---|
[2] | 10 | ; |
---|
[142] | 11 | ; @categories |
---|
[157] | 12 | ; Grid |
---|
[2] | 13 | ; |
---|
[142] | 14 | ; @param TEMP {in}{required} |
---|
| 15 | ; A 2, 3 or 4d array |
---|
[2] | 16 | ; |
---|
[142] | 17 | ; @returns |
---|
| 18 | ; res, a 2, 3 or 4d array |
---|
[2] | 19 | ; |
---|
[142] | 20 | ; @uses |
---|
| 21 | ; common.pro |
---|
[2] | 22 | ; |
---|
[142] | 23 | ; @restrictions |
---|
| 24 | ; Force parameters of the zoom on the grid V to be the same as |
---|
| 25 | ; those on the grid T. |
---|
[2] | 26 | ; |
---|
[142] | 27 | ; @restrictions |
---|
| 28 | ; Points which can not be calculated are put at the value NaN |
---|
| 29 | ; consecrated by IDL: !values.f_nan |
---|
[2] | 30 | ; |
---|
[142] | 31 | ; @history |
---|
| 32 | ; From Marina Levy's programs |
---|
[157] | 33 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr): |
---|
[142] | 34 | ; Validation. 5/6/2000 |
---|
[2] | 35 | ; |
---|
[142] | 36 | ; @version |
---|
| 37 | ; $Id$ |
---|
[2] | 38 | ; |
---|
[142] | 39 | ; @todo seb: nom du input? |
---|
[2] | 40 | ; |
---|
| 41 | ;- |
---|
| 42 | ;------------------------------------------------------------ |
---|
| 43 | ;------------------------------------------------------------ |
---|
| 44 | ;------------------------------------------------------------ |
---|
| 45 | FUNCTION v2t, temp |
---|
[13] | 46 | ;--------------------------------------------------------- |
---|
[114] | 47 | ; |
---|
| 48 | compile_opt idl2, strictarrsubs |
---|
| 49 | ; |
---|
[13] | 50 | @cm_4mesh |
---|
| 51 | @cm_4data |
---|
| 52 | @cm_4cal |
---|
| 53 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
| 54 | @updatenew |
---|
| 55 | ENDIF |
---|
| 56 | ;--------------------------------------------------------- |
---|
[2] | 57 | res = temp |
---|
[142] | 58 | ;We force nxt=nxv, etc ... |
---|
[13] | 59 | firstxt = firstxv |
---|
| 60 | lastxt = lastxv |
---|
| 61 | firstyt = firstyv |
---|
| 62 | lastyt = lastyv |
---|
[2] | 63 | nxt = nxv |
---|
| 64 | nyt = nyv |
---|
| 65 | vargrid = 'T' |
---|
| 66 | if NOT keyword_set(valmask) then valmask = 1e20 |
---|
[13] | 67 | lat1 = gphit[0, firstyt] |
---|
| 68 | lat2 = gphiv[0, lastyv] |
---|
[2] | 69 | |
---|
[142] | 70 | ; case on tha array's size and application |
---|
[2] | 71 | taille = size(temp) |
---|
| 72 | CASE taille[0] OF |
---|
| 73 | 1: res = -1 |
---|
| 74 | 2: BEGIN |
---|
| 75 | case 1 of |
---|
| 76 | taille[1] eq nxv and taille[2] eq nyv: |
---|
| 77 | taille[1] eq jpi and taille[2] eq jpj: $ |
---|
[13] | 78 | res=res[firstxv:lastxv, firstyv:lastyv] |
---|
[2] | 79 | else: $ |
---|
| 80 | return, report('Probleme d''adequation entre les tailles du domaine et de la boite.') |
---|
| 81 | endcase |
---|
[13] | 82 | mask = (vmask())[firstxv:lastxv, firstyv:lastyv, 0] |
---|
[2] | 83 | terre = where(mask EQ 0) |
---|
| 84 | IF terre[0] NE -1 THEN res[terre] = !values.f_nan |
---|
| 85 | res = 0.5*(res + shift(res, 0, +1)) |
---|
| 86 | res[*, 0] = !values.f_nan |
---|
[13] | 87 | mask = tmask[firstxv:lastxv, firstyv:lastyv, 0] |
---|
[2] | 88 | terre = where(mask EQ 0) |
---|
| 89 | IF terre[0] NE -1 THEN res[terre] = valmask |
---|
| 90 | END |
---|
| 91 | 3: BEGIN |
---|
| 92 | case 1 of |
---|
| 93 | taille[1] eq nxv and taille[2] eq nyv AND taille[3] EQ nzt: |
---|
| 94 | taille[1] eq nxv and taille[2] eq nyv AND taille[3] EQ jpk: $ |
---|
[13] | 95 | res=res[*, *, firstzt:lastzt] |
---|
[2] | 96 | taille[1] eq nxv and taille[2] eq nyv AND taille[3] EQ jpt: |
---|
| 97 | taille[1] eq jpi and taille[2] eq jpj AND taille[3] EQ jpk: $ |
---|
[13] | 98 | res=res[firstxv:lastxv, firstyv:lastyv, firstzt:lastzt] |
---|
[2] | 99 | taille[1] eq jpi and taille[2] eq jpj AND taille[3] EQ jpt: $ |
---|
[13] | 100 | res=res[firstxv:lastxv, firstyv:lastyv, *] |
---|
[2] | 101 | else: $ |
---|
| 102 | return, report('Probleme d''adequation entre les tailles du domaine et de la boite.') |
---|
| 103 | ENDCASE |
---|
| 104 | if taille[3] EQ jpt then begin |
---|
[13] | 105 | mask = (vmask())[firstxv:lastxv, firstyv:lastyv, lastzt*(nzt NE jpk)] |
---|
[2] | 106 | mask = temporary(mask[*])#replicate(1, jpt) |
---|
| 107 | mask = reform(mask, nxv, nyv, jpt, /over) |
---|
[13] | 108 | ENDIF ELSE mask = (vmask())[firstxv:lastxv, firstyv:lastyv, firstzt:lastzt] |
---|
[2] | 109 | terre = where(temporary(mask) EQ 0) |
---|
| 110 | IF terre[0] NE -1 THEN res[temporary(terre)] = !values.f_nan |
---|
| 111 | res = 0.5*(res + shift(res, 0, +1, 0)) |
---|
| 112 | res[*, 0, *] = !values.f_nan |
---|
| 113 | if taille[3] EQ jpt then BEGIN |
---|
[13] | 114 | mask = tmask[firstxv:lastxv, firstyv:lastyv, lastzt*(nzt NE jpk)] |
---|
[2] | 115 | mask = temporary(mask[*])#replicate(1, jpt) |
---|
| 116 | mask = reform(mask, nxv, nyv, jpt, /over) |
---|
[13] | 117 | ENDIF ELSE mask = tmask[firstxv:lastxv, firstyv:lastyv, firstzt:lastzt] |
---|
[2] | 118 | terre = where(temporary(mask) EQ 0) |
---|
| 119 | IF terre[0] NE -1 THEN res[temporary(terre)] = valmask |
---|
| 120 | END |
---|
| 121 | 4: BEGIN |
---|
| 122 | case 1 of |
---|
| 123 | taille[1] eq nxv and taille[2] eq nyv AND taille[3] EQ nzt AND taille[4] EQ jpt: |
---|
| 124 | taille[1] eq nxv and taille[2] eq nyv AND taille[3] EQ jpk AND taille[4] EQ jpt: $ |
---|
[13] | 125 | res=res[*, *, firstzt:lastzt, *] |
---|
[2] | 126 | taille[1] eq jpi and taille[2] eq jpj AND taille[3] EQ jpk AND taille[4] EQ jpt: $ |
---|
[13] | 127 | res=res[firstxv:lastxv, firstyv:lastyv, firstzt:lastzt, *] |
---|
[2] | 128 | else: $ |
---|
| 129 | return, report('Probleme d''adequation entre les tailles du domaine et de la boite.') |
---|
| 130 | ENDCASE |
---|
[13] | 131 | mask = (vmask())[firstxv:lastxv, firstyv:lastyv, firstzt:lastzt] |
---|
[2] | 132 | mask = temporary(mask[*])#replicate(1, jpt) |
---|
| 133 | mask = reform(mask, nxv, nyv, nzt, jpt, /over) |
---|
| 134 | terre = where(temporary(mask) EQ 0) |
---|
| 135 | IF terre[0] NE -1 THEN res[temporary(terre)] = !values.f_nan |
---|
| 136 | res = 0.5*(res + shift(res, 0, +1, 0, 0)) |
---|
| 137 | res[*, 0, *, *] = !values.f_nan |
---|
[13] | 138 | mask = tmask[firstxv:lastxv, firstyv:lastyv, firstzt:lastzt] |
---|
[2] | 139 | mask = temporary(mask[*])#replicate(1, jpt) |
---|
| 140 | mask = reform(mask, nxv, nyv, nzt, jpt, /over) |
---|
| 141 | terre = where(temporary(mask) EQ 0) |
---|
| 142 | IF terre[0] NE -1 THEN res[temporary(terre)] = valmask |
---|
| 143 | END |
---|
| 144 | endcase |
---|
| 145 | |
---|
[13] | 146 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
| 147 | @updateold |
---|
| 148 | ENDIF |
---|
| 149 | |
---|
| 150 | return, res |
---|
[2] | 151 | END |
---|
| 152 | |
---|