[2] | 1 | ;------------------------------------------------------------ |
---|
| 2 | ;------------------------------------------------------------ |
---|
| 3 | ;------------------------------------------------------------ |
---|
| 4 | ;+ |
---|
| 5 | ; |
---|
[142] | 6 | ; @file_comments |
---|
[163] | 7 | ; Allows to pass a field referring to the grid F on the grid V, |
---|
[142] | 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 | ; |
---|
| 39 | ;- |
---|
| 40 | ;------------------------------------------------------------ |
---|
| 41 | ;------------------------------------------------------------ |
---|
| 42 | ;------------------------------------------------------------ |
---|
| 43 | FUNCTION f2v, temp |
---|
[13] | 44 | ;--------------------------------------------------------- |
---|
[114] | 45 | ; |
---|
| 46 | compile_opt idl2, strictarrsubs |
---|
| 47 | ; |
---|
[13] | 48 | @cm_4mesh |
---|
| 49 | @cm_4data |
---|
| 50 | @cm_4cal |
---|
| 51 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
| 52 | @updatenew |
---|
| 53 | ENDIF |
---|
| 54 | ;--------------------------------------------------------- |
---|
[2] | 55 | res = temp |
---|
[142] | 56 | ;We force nxt=nxf, etc ... |
---|
[13] | 57 | firstxv = firstxf |
---|
| 58 | lastxv = lastxf |
---|
| 59 | firstyv = firstyf |
---|
| 60 | lastyv = lastyf |
---|
[2] | 61 | nxv = nxf |
---|
| 62 | nyv = nyf |
---|
| 63 | vargrid = 'V' |
---|
| 64 | if NOT keyword_set(valmask) then valmask = 1e20 |
---|
[13] | 65 | lon1 = glamv[firstxv, 0] |
---|
| 66 | lon2 = glamf[lastxf, 0] |
---|
[2] | 67 | |
---|
[142] | 68 | ; case on tha array's size and application |
---|
[2] | 69 | taille = size(temp) |
---|
| 70 | CASE taille[0] OF |
---|
| 71 | 1: res = -1 |
---|
| 72 | 2: BEGIN |
---|
| 73 | case 1 of |
---|
| 74 | taille[1] eq nxf and taille[2] eq nyf: |
---|
| 75 | taille[1] eq jpi and taille[2] eq jpj: $ |
---|
[13] | 76 | res=res[firstxf:lastxf, firstyf:lastyf] |
---|
[2] | 77 | else: $ |
---|
| 78 | return, report('Probleme d''adequation entre les tailles du domaine et de la boite.') |
---|
| 79 | endcase |
---|
[13] | 80 | mask = (fmask())[firstxf:lastxf, firstyf:lastyf, 0] |
---|
[2] | 81 | terre = where(mask EQ 0) |
---|
| 82 | IF terre[0] NE -1 THEN res[terre] = !values.f_nan |
---|
| 83 | res = 0.5*(res + shift(res, 1, 0)) |
---|
[13] | 84 | if NOT (keyword_set(key_periodic) AND nxf EQ jpi) then res[0, *] = !values.f_nan |
---|
| 85 | mask = (vmask())[firstxf:lastxf, firstyf:lastyf, 0] |
---|
[2] | 86 | terre = where(mask EQ 0) |
---|
| 87 | IF terre[0] NE -1 THEN res[terre] = valmask |
---|
| 88 | END |
---|
| 89 | 3: BEGIN |
---|
| 90 | case 1 of |
---|
| 91 | taille[1] eq nxf and taille[2] eq nyf AND taille[3] EQ nzt: |
---|
| 92 | taille[1] eq nxf and taille[2] eq nyf AND taille[3] EQ jpk: $ |
---|
[13] | 93 | res=res[*, *, firstzt:lastzt] |
---|
[2] | 94 | taille[1] eq nxf and taille[2] eq nyf AND taille[3] EQ jpt: |
---|
| 95 | taille[1] eq jpi and taille[2] eq jpj AND taille[3] EQ jpk: $ |
---|
[13] | 96 | res=res[firstxf:lastxf, firstyf:lastyf, firstzt:lastzt] |
---|
[2] | 97 | taille[1] eq jpi and taille[2] eq jpj AND taille[3] EQ jpt: $ |
---|
[13] | 98 | res=res[firstxf:lastxf, firstyf:lastyf, *] |
---|
[2] | 99 | else: $ |
---|
| 100 | return, report('Probleme d''adequation entre les tailles du domaine et de la boite.') |
---|
| 101 | ENDCASE |
---|
| 102 | if taille[3] EQ jpt then begin |
---|
[13] | 103 | mask = (fmask())[firstxf:lastxf, firstyf:lastyf, lastzt*(nzt NE jpk)] |
---|
[2] | 104 | mask = temporary(mask[*])#replicate(1, jpt) |
---|
| 105 | mask = reform(mask, nxf, nyf, jpt, /over) |
---|
[13] | 106 | ENDIF ELSE mask = (fmask())[firstxf:lastxf, firstyf:lastyf, firstzt:lastzt] |
---|
[2] | 107 | terre = where(temporary(mask) EQ 0) |
---|
| 108 | IF terre[0] NE -1 THEN res[temporary(terre)] = !values.f_nan |
---|
| 109 | res = 0.5*(res + shift(res, 1, 0, 0)) |
---|
[13] | 110 | if NOT (keyword_set(key_periodic) AND nxf EQ jpi) then res[0, *, *] = !values.f_nan |
---|
[2] | 111 | if taille[3] EQ jpt then BEGIN |
---|
[13] | 112 | mask = tmask[firstxf:lastxf, firstyf:lastyf, lastzt*(nzt NE jpk)] |
---|
[2] | 113 | mask = temporary(mask[*])#replicate(1, jpt) |
---|
| 114 | mask = reform(mask, nxf, nyf, jpt, /over) |
---|
[13] | 115 | ENDIF ELSE mask = (vmask())[firstxf:lastxf, firstyf:lastyf, firstzt:lastzt] |
---|
[2] | 116 | terre = where(temporary(mask) EQ 0) |
---|
| 117 | IF terre[0] NE -1 THEN res[temporary(terre)] = valmask |
---|
| 118 | END |
---|
| 119 | 4: BEGIN |
---|
| 120 | case 1 of |
---|
| 121 | taille[1] eq nxf and taille[2] eq nyf AND taille[3] EQ nzt AND taille[4] EQ jpt: |
---|
| 122 | taille[1] eq nxf and taille[2] eq nyf AND taille[3] EQ jpk AND taille[4] EQ jpt: $ |
---|
[13] | 123 | res=res[*, *, firstzt:lastzt, *] |
---|
[2] | 124 | taille[1] eq jpi and taille[2] eq jpj AND taille[3] EQ jpk AND taille[4] EQ jpt: $ |
---|
[13] | 125 | res=res[firstxf:lastxf, firstyf:lastyf, firstzt:lastzt, *] |
---|
[2] | 126 | else: $ |
---|
| 127 | return, report('Probleme d''adequation entre les tailles du domaine et de la boite.') |
---|
| 128 | ENDCASE |
---|
[13] | 129 | mask = (fmask())[firstxf:lastxf, firstyf:lastyf, firstzt:lastzt] |
---|
[2] | 130 | mask = temporary(mask[*])#replicate(1, jpt) |
---|
| 131 | mask = reform(mask, nxf, nyf, nzt, jpt, /over) |
---|
| 132 | terre = where(temporary(mask) EQ 0) |
---|
| 133 | IF terre[0] NE -1 THEN res[temporary(terre)] = !values.f_nan |
---|
| 134 | res = 0.5*(res + shift(res, 1, 0, 0, 0)) |
---|
[13] | 135 | if NOT (keyword_set(key_periodic) AND nxf EQ jpi) then res[0, *, *, *] = !values.f_nan |
---|
| 136 | mask = (vmask())[firstxf:lastxf, firstyf:lastyf, firstzt:lastzt] |
---|
[2] | 137 | mask = temporary(mask[*])#replicate(1, jpt) |
---|
| 138 | mask = reform(mask, nxf, nyf, nzt, jpt, /over) |
---|
| 139 | terre = where(temporary(mask) EQ 0) |
---|
| 140 | IF terre[0] NE -1 THEN res[temporary(terre)] = valmask |
---|
| 141 | END |
---|
| 142 | endcase |
---|
| 143 | |
---|
[13] | 144 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
| 145 | @updateold |
---|
| 146 | ENDIF |
---|
| 147 | |
---|
[2] | 148 | return, res |
---|
| 149 | END |
---|
| 150 | |
---|