- Timestamp:
- 03/14/07 18:13:39 (17 years ago)
- Location:
- trunk/SRC
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/Matrix/make_selection.pro
r163 r223 1 1 ;+ 2 2 ; 3 ; file_comments3 ; @file_comments 4 4 ; Convert an array of selected values to an index 5 ; array that identifies the selected values in a list 6 ; or data array. 5 ; array that identifies the selected values in a list or data array. 7 6 ; 8 ; categories tools 9 ; 10 ; @param NAMES {in}{required} A list or array of values to choose from 7 ; @categories 8 ; tools 11 9 ; 12 ; @param SELNAMES {in}{required} A list of selected values 10 ; @param NAMES {in}{required} 11 ; A list or array of values to choose from 13 12 ; 14 ; @keyword ONLY_VALID Return only indexes of found values. Values not 15 ; found are skipped. Default is to return 1 index value for 16 ; each SELNAME, which is -1 if SELNAME is not contained in 17 ; NAMES. If ONLY_VALID is set, the -1 values will be deleted, 18 ; and a value of -1 indicates that no SELNAME has been found 19 ; at all. 13 ; @param SELNAMES {in}{required} 14 ; A list of selected values 20 15 ; 21 ; @keyword REQUIRED Normally, MAKE_SELECTION will return indexes for 22 ; all values that are found, simply ignoring the selected 23 ; values that are not in the NAMES array (although an error 24 ; message is displayed). Set this keyword to return with 25 ; -1 as soon as a selected value is not found. 16 ; @keyword ONLY_VALID 17 ; Return only indexes of found values. Values not 18 ; found are skipped. Default is to return 1 index value for 19 ; each SELNAME, which is -1 if SELNAME is not contained in 20 ; NAMES. If ONLY_VALID is set, the -1 values will be deleted, 21 ; and a value of -1 indicates that no SELNAME has been found 22 ; at all. 26 23 ; 27 ; @keyword QUIET Suppress printing of the error message if a 28 ; selected value is not found (the error condition will 29 ; still be set). 24 ; @keyword REQUIRED 25 ; Normally, MAKE_SELECTION will return indexes for 26 ; all values that are found, simply ignoring the selected 27 ; values that are not in the NAMES array (although an error 28 ; message is displayed). Set this keyword to return with 29 ; -1 as soon as a selected value is not found. 30 30 ; 31 ; @returns A (long) array with indexes to reference the selected values 32 ; in the NAMES array. 31 ; @keyword QUIET 32 ; Suppress printing of the error message if a 33 ; selected value is not found (the error condition will 34 ; still be set). 33 35 ; 34 ; @restrictions If the NAMES array contains multiple entries of the same value, 35 ; only the index to the first entry will be returned. 36 ; @returns 37 ; A (long) array with indexes to reference the selected values 38 ; in the NAMES array. 36 39 ; 37 ; A selection can contain multiple instances of the same value.38 ; The index array will contain one entry per selected item39 ; (See example below)40 ; @restrictions 41 ; If the NAMES array contains multiple entries of the same value, 42 ; only the index to the first entry will be returned. 40 43 ; 41 ; @examples names = [ 'Alfred','Anton','Peter','John','Mary'] 44 ; A selection can contain multiple instances of the same value. 45 ; The index array will contain one entry per selected item 46 ; (See example below) 47 ; 48 ; @examples 49 ; names = [ 'Alfred','Anton','Peter','John','Mary'] 42 50 ; index = MAKE_SELECTION(names,['Peter','Mary']) 43 51 ; print,index … … 57 65 ; ; prints -1 58 66 ; 59 ; @history mgs, 28 Aug 1998: VERSION 1.00 60 ; mgs, 29 Aug 1998: - changed behavior and added ONLY_VALID keyword 67 ; @history 68 ; mgs, 28 Aug 1998: VERSION 1.00 69 ; mgs, 29 Aug 1998: - changed behavior and added ONLY_VALID keyword 61 70 ; 62 ; @version $Id$ 71 ; @version 72 ; $Id$ 63 73 ; 64 74 ;- … … 81 91 compile_opt idl2, strictarrsubs 82 92 ; 83 84 85 86 ; return an index array with a number for each element in 93 ; return an index array with a number for each element in 87 94 ; selnames that is found in names. 88 95 ; Set the REQUIRED keyword to return -1 if one element is 89 ; not found, otherwise -1 will only be returned, if no 96 ; not found, otherwise -1 will only be returned, if no 90 97 ; element is found. 91 98 92 99 ; reset error state to 0 93 100 message,/reset 94 101 95 102 quiet = keyword_set(quiet) 96 103 result = -1L 97 104 98 105 for i=0,n_elements(selnames)-1 do begin 99 106 test = where(names eq selnames[i]) 100 result = [ result, test[0] ] 107 result = [ result, test[0] ] 101 108 if (test[0] lt 0) then begin 102 109 if (keyword_set(ONLY_VALID) OR keyword_set(REQUIRED)) then $ … … 106 113 endif 107 114 endfor 108 115 109 116 if (n_elements(result) gt 1) then result = result[1:*] 110 117 … … 114 121 else result = -1L 115 122 endif 116 123 117 124 return,result 118 125 119 126 end -
trunk/SRC/Postscript/printps.pro
r220 r223 16 16 ; that any of the existing ps file). 17 17 ; 18 ; @categories 18 ; @categories 19 19 ; Postscripts 20 20 ; … … 193 193 ; postscript visualisation/archiving/printing 194 194 ; 195 ; @categories 195 ; @categories 196 196 ; Postscripts 197 197 ; 198 ; @param psfilename {in}{optional} 198 ; @param psfilename {in}{optional} 199 199 ; The name of the postscript file we want to 200 200 ; visualize and/or print and/or archive. It can also refer … … 244 244 nameps = file_search(psdir+'*.ps', /test_regular, /nosort) 245 245 IF nameps[0] EQ '' THEN BEGIN 246 ras = report('no posts rcipt file (ending with .ps) found in : ' + psdir)246 ras = report('no postscript file (ending with .ps) found in : ' + psdir) 247 247 RETURN 248 248 ENDIF -
trunk/SRC/ReadWrite/read_grads.pro
r163 r223 7 7 ; from the grads control file even if there is multiple data files. 8 8 ; 9 ; @categories 9 ; @categories 10 10 ; Reading 11 11 ; … … 44 44 ; an array 45 45 ; 46 ; @uses 46 ; @uses 47 47 ; common 48 48 ; 49 ; @restriction 49 ; @restrictions 50 50 ; define all the grid parameters (defined in common.pro) 51 51 ; associated to the data. 52 52 ; 53 ; @restrictions54 53 ; this function call the procedure scanfile that use the 55 54 ; unix commands grep and sed … … 59 58 ; IDL> plt, a 60 59 ; 61 ; @history 60 ; @history 62 61 ; Sebastien Masson (smasson\@lodyc.jussieu.fr) 63 62 ; -
trunk/SRC/ToBeReviewed/CALCULS/determ2.pro
r157 r223 1 1 ;+ 2 2 ; 3 ; file_comments 4 ; computes the determinant of n 2 by 2 arrays 5 ; Z2DS is an 2*2*n array 3 ; @file_comments 4 ; computes the determinant of n 2 by 2 arrays Z2DS is an 2*2*n array 6 5 ; 7 ; @categories 6 ; @categories 8 7 ; Without loop 9 ; 8 ; 10 9 ; @param A {in}{required} 11 10 ; n element array … … 24 23 ; Defined as z2ds[1, 1, *] = z1d11 25 24 ; 26 ; @returns 25 ; @returns 27 26 ; n elements array, the determinent of each 2*2 arrrays 28 27 ; 29 28 ; @examples 30 ; a=findgen(2,2,5)31 ; print, determ2(a)32 ; FOR i=0,4 DO print, determ(a[*,*,i]) ; IDL solution29 ; IDL> a=findgen(2,2,5) 30 ; IDL> print, determ2(a) 31 ; IDL> FOR i=0,4 DO print, determ(a[*,*,i]) ; IDL solution 33 32 ; 34 33 ; @history 35 ; 36 ; 34 ; S. Masson (smasson\@lodyc.jussieu.fr) 35 ; July 11th, 2002 37 36 ; 38 37 ; @version -
trunk/SRC/ToBeReviewed/CALCULS/grossemoyenne.pro
r163 r223 4 4 ;+ 5 5 ; 6 ; @file_comments 6 ; @file_comments 7 7 ; averages a 3- or 4-d time series field over a selected 8 8 ; geographical area or along the time axis. For one ore more … … 16 16 ; @param DIREC {in}{required} 17 17 ; 'x' 'y' 'z' 't' 'xy' 'xz' 'yz' 'xyz' 'xt' 'yt' 'zt' 18 ; 'xyt' 'xzt' 'yzt' or 'xyzt' 19 ; 20 ; @keyword BOXZOOM 18 ; 'xyt' 'xzt' 'yzt' or 'xyzt' 19 ; 20 ; @keyword BOXZOOM 21 21 ; [xmin,xmax,ymin,ymax (,(zmin,)zmax)] to more details, see domdef 22 ; boxzoom can have 5 forms: 23 ; [vert2], [vert1, vert2],[lon1, lon2, lat1, lat2], 22 ; boxzoom can have 5 forms: 23 ; [vert2], [vert1, vert2],[lon1, lon2, lat1, lat2], 24 24 ; [lon1, lon2, lat1, lat2, vert2],[lon1, lon2, lat1, lat2, vert1,vert2] 25 ; 26 ; @keyword NAN 27 ; not a number, we activate it if we want to average without considerate some masked values of TAB. 28 ; If masked values of TAB are values consecrated by IDL(!values.f_nan), wr just have to put NAN. 29 ; If masked values of TAB are valued a (a must be different of 1, corresponding to nan = 30 ; !values.f_nan and of 0, which desactivate nan). We have to put NAN=a. 31 ; Comment: In output, rsult points which are NAN will be valued a or !values.f_nan. 32 ; 25 ; 26 ; @keyword NAN 27 ; not a number, we activate it if we want to average without considerate some 28 ; masked values of TAB. 29 ; If masked values of TAB are values consecrated by IDL(!values.f_nan), we 30 ; just have to put NAN. 31 ; If masked values of TAB are valued a (a must be different of 1, 32 ; corresponding to nan = !values.f_nan and of 0, which desactivate nan). 33 ; We have to put NAN=a. 34 ; Comment: In output, rsult points which are NAN will be valued a or 35 ; !values.f_nan. 36 ; 33 37 ; @keyword NODOMDEF 34 ; We activate it if we do not want to pass in domdef even if the keyword boxzoom35 ; is present (like when grossemoyenne is called via checkfield)36 ; 37 ; @keyword INTEGRATION 38 ; We activate it if we do not want to pass in domdef even if the keyword 39 ; boxzoom is present (like when grossemoyenne is called via checkfield) 40 ; 41 ; @keyword INTEGRATION 38 42 ; To make an integral rather than an average 39 43 ; 40 ; @keyword SPATIALFIRST 44 ; @keyword SPATIALFIRST 41 45 ; when performing at the same time 42 46 ; spatial and temporal mean, grossemoyenne is assuming … … 48 52 ; SPATIALFIRST is activated automatically. 49 53 ; 50 ; @keyword TEMPORALFIRST 54 ; @keyword TEMPORALFIRST 51 55 ; to force to perform first temporal 52 ; mean even if nan is activated (see SPATIALFIRST 53 ; explanations...) 54 ; 55 ; 56 ; @keyword WDEPTH 57 ; to specify that the field is at W depth instead of T 58 ; depth (automatically activated if vargrid eq 'W') 56 ; mean even if nan is activated (see SPATIALFIRST explanations...) 57 ; 58 ; @keyword WDEPTH 59 ; to specify that the field is at W depth instead of T 60 ; depth (automatically activated if vargrid eq 'W') 59 61 ; 60 62 ; @uses 61 ; result:un tableau 63 ; result:un tableau 62 64 ; common 63 65 ; domdef 64 66 ; 65 ; @restrictions Put values corresponding to land at 1.e20 66 ; 67 ; @history 67 ; @restrictions 68 ; Put values corresponding to land at 1.e20 69 ; 70 ; @history 68 71 ; Jerome Vialard (jv\@lodyc.jussieu.fr) 69 72 ; 2/7/98 70 73 ; Sebastien Masson (smasson\@lodyc.jussieu.fr) 71 ; adaptation array containing a temporal dimension 74 ; adaptation array containing a temporal dimension 72 75 ; 14/8/98 73 76 ; 15/1/98 … … 118 121 taille = size(tab) 119 122 case 1 of 120 taille[0] eq 1 :return, report(' Le tableau n''a qu''une dimension, cas non traite!')121 taille[0] eq 2 :return, report(' Le tableau n''a qu''deux dimension, cas non traite!')122 taille[0] eq 3 :BEGIN 123 taille[0] eq 1 :return, report('array has only one dimension, not implemented!') 124 taille[0] eq 2 :return, report('array has only two dimensions, not implemented!') 125 taille[0] eq 3 :BEGIN 123 126 dim = '3d' 124 127 if dirx eq 0 and diry eq 0 and dirt eq 0 then return, tab 125 128 END 126 taille[0] eq 4 :BEGIN 129 taille[0] eq 4 :BEGIN 127 130 dim = '4d' 128 131 if dirx eq 0 and diry eq 0 and dirz eq 0 and dirt eq 0 then return, tab 129 132 END 130 else : return, report(' Le tableau d entree doit etre a 3 ou 4 dimensions s''il ne contient pas de dim temporelle utilisermoyenne')133 else : return, report('array must have 3 or 4 dimensions if there is not time dimension use moyenne') 131 134 endcase 132 135 ;------------------------------------------------------------ … … 134 137 ; Redefinition of the domain ajusted at boxzoom (at 6 elements) 135 138 ; This will allowed us to calculate only in the domain concerned by the average. 136 ; Domdef, followed by grid give us all arrays of the grid on the subdomain 137 ;------------------------------------------------------------ 138 if keyword_set(boxzoom) then BEGIN 139 ; Domdef, followed by grid give us all arrays of the grid on the subdomain 140 ;------------------------------------------------------------ 141 if keyword_set(boxzoom) then BEGIN 139 142 Case 1 Of 140 143 N_Elements(Boxzoom) Eq 1: bte = [lon1, lon2, lat1, lat2, 0., boxzoom[0]] … … 145 148 Else: return, report('Wrong Definition of Boxzoom') 146 149 endcase 147 if NOT keyword_set(nodomdef) then BEGIN 150 if NOT keyword_set(nodomdef) then BEGIN 148 151 savedbox = 1b 149 152 saveboxparam, 'boxparam4grmoyenne.dat' 150 153 domdef, bte, GRIDTYPE = vargrid, _extra = ex 151 ENDIF 152 ENDIF 154 ENDIF 155 ENDIF 153 156 ;--------------------------------------------------------------- 154 157 ; attribution of the mask and of longitude and latitude arrays... … … 159 162 ;------------------------------------------------------------ 160 163 if dirt EQ 1 AND NOT keyword_set(spatialfirst) then begin 161 if dim EQ 3d then BEGIN 164 if dim EQ 3d then BEGIN 162 165 case 1 of 163 166 taille[1] eq jpi and taille[2] eq jpj and taille[3] eq jpt: $ … … 165 168 , firsty:firsty+ny-1, *] 166 169 taille[1] EQ nx and taille[2] eq ny and taille[3] eq jpt:res = tab 167 else:BEGIN 170 else:BEGIN 168 171 if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4grmoyenne.dat' 169 172 return, report('Probleme d''adequation entre les tailles du domaine nx*ny*jpt '+strtrim(nx, 1)+'*'+strtrim(ny, 1)+'*'+strtrim(jpt, 1)+' et du tableau '+strtrim(taille[1], 1)+'*'+strtrim(taille[2], 1)+'*'+strtrim(taille[3], 1)) … … 179 182 res = total(res, 3, nan = keyword_set(nan))/ (1 > divi) 180 183 if notanum[0] NE -1 then res[temporary(notanum)] = !values.f_nan 181 ENDIF ELSE res = total(res, 3)/(1.*taille[3]) 184 ENDIF ELSE res = total(res, 3)/(1.*taille[3]) 182 185 ENDELSE 183 186 ENDIF ELSE BEGIN … … 190 193 taille[1] EQ nx and taille[2] eq ny and taille[3] eq jpk and taille[4] eq jpt: $ 191 194 res = tab[*, *, firstz:lastz, *] 192 else:BEGIN 195 else:BEGIN 193 196 if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4grmoyenne.dat' 194 197 return, report('Probleme d''adequation entre les tailles du domaine nx*ny*nz*jpt ' $ … … 211 214 ENDELSE 212 215 ENDELSE 213 if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4grmoyenne.dat' 216 if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4grmoyenne.dat' 214 217 return, moyenne(temporary(res), direc, BOXZOOM = boxzoom, NAN = nan, INTEGRATION = integration, NODOMDEF = nodomdef, WDEPTH = wdepth, _extra = ex) 215 218 ENDIF ELSE res = tab 216 219 IF jpt EQ 1 THEN BEGIN 217 if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4grmoyenne.dat' 220 if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4grmoyenne.dat' 218 221 return, moyenne(reform(res, /over), direc, BOXZOOM = boxzoom, NAN = nan, INTEGRATION = integration, NODOMDEF = nodomdef, WDEPTH = wdepth, _extra = ex) 219 222 END … … 227 230 ; II.1) verification of the coherence of the array's size to average 228 231 ; Verification of the coherence between the array's size and the domain defined by domdef 229 ; The input array must have either the total domain's size (jpi,jpj,jpt) or this230 ; one of the reduced domain (nx,ny,jpt)232 ; The input array must have either the total domain's size (jpi,jpj,jpt) or 233 ; this one of the reduced domain (nx,ny,jpt) 231 234 ;--------------------------------------------------------------- 232 235 case 1 of … … 235 238 , firsty:firsty+ny-1, *] 236 239 taille[1] EQ nx and taille[2] eq ny and taille[3] eq jpt:res = tab 237 else:BEGIN 240 else:BEGIN 238 241 if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4grmoyenne.dat' 239 242 return, report('Probleme d''adequation entre les tailles du domaine nx*ny*jpt '+strtrim(nx, 1)+'*'+strtrim(ny, 1)+'*'+strtrim(jpt, 1)+' et du tableau '+strtrim(taille[1], 1)+'*'+strtrim(taille[2], 1)+'*'+strtrim(taille[3], 1)) 240 243 enD 241 244 endcase 242 if keyword_set(nan) NE 0 then BEGIN 243 if nan NE 1 then BEGIN ; If nan is not !values.f_nan 245 if keyword_set(nan) NE 0 then BEGIN 246 if nan NE 1 then BEGIN ; If nan is not !values.f_nan 244 247 ; we put it at !values.f_nan 245 248 if abs(nan) LT 1e6 then notanumber = where(res EQ nan) $ … … 249 252 ENDIF 250 253 ;--------------------------------------------------------------- 251 ; Comment : WE HAVE TO BE CAREFUL ABOUT CASES WHERE THE DIMENSION TO AVERAGE = 1,252 ; A ND MAKE SURE THAT IT EXIST. THAT IS WHY WE USE reform(...,nx,ny,...) WHICH CAN253 ; LOOK USELESS AT THE BEGINNING254 ;--------------------------------------------------------------- 255 if nx EQ 1 OR ny EQ 1 then BEGIN 254 ; Comment : WE HAVE TO BE CAREFUL ABOUT CASES WHERE THE DIMENSION TO 255 ; AVERAGE = 1, AND MAKE SURE THAT IT EXIST. THAT IS WHY WE USE 256 ; reform(...,nx,ny,...) WHICH CAN LOOK USELESS AT THE BEGINNING 257 ;--------------------------------------------------------------- 258 if nx EQ 1 OR ny EQ 1 then BEGIN 256 259 res = reform(res, nx, ny, jpt, /over) 257 260 e1 = reform(e1, nx, ny, /over) … … 270 273 echelle = (temporary(e))[*]#replicate(1, jpt) 271 274 echelle = reform(echelle, nx, ny, jpt, /over) 272 if keyword_set(integration) then divi = 1 ELSE BEGIN 275 if keyword_set(integration) then divi = 1 ELSE BEGIN 273 276 IF msknan[0] NE -1 THEN divi = total(echelle*msknan, 1) $ 274 277 ELSE divi = total(echelle, 1) … … 287 290 echelle = (temporary(e))[*]#replicate(1, jpt) 288 291 echelle = reform(echelle, nx, ny, jpt, /over) 289 if keyword_set(integration) then divi = 1 ELSE BEGIN 292 if keyword_set(integration) then divi = 1 ELSE BEGIN 290 293 IF msknan[0] NE -1 THEN divi = total(echelle*msknan, 2) $ 291 294 ELSE divi = total(echelle, 2) 292 ENDELSE 295 ENDELSE 293 296 res = total(temporary(res)*echelle, 2, nan = nan)/(divi > 1.) 294 297 if msknan[0] NE -1 then begin … … 302 305 echelle = (temporary(e1)*temporary(e2)*temporary(mask))[*]#replicate(1, jpt) 303 306 echelle = reform(echelle, nx, ny, jpt, /over) 304 if keyword_set(integration) then divi = 1 ELSE BEGIN 307 if keyword_set(integration) then divi = 1 ELSE BEGIN 305 308 IF msknan[0] NE -1 THEN divi = total(total(echelle*msknan, 1), 1) $ 306 309 ELSE divi = total(total(echelle, 1), 1) … … 322 325 if (dim eq '4d') then begin 323 326 ;--------------------------------------------------------------- 324 ; III.1) Verification of the coherence of the array to average size 325 ; Verification of the coherence between the array's size and the domain 326 ; defind by domdef 327 ; The input array must have either the total domain size (jpi,jpj,jpk,jpt) 327 ; III.1) Verification of the coherence of the array to average size 328 ; Verification of the coherence between the array's size and the domain 329 ; defind by domdef 330 ; The input array must have either the total domain size (jpi,jpj,jpk,jpt) 328 331 ; or this one of the reduced domain (nx,ny,ny,jpt) 329 332 ;--------------------------------------------------------------- … … 336 339 taille[1] EQ nx and taille[2] eq ny and taille[3] eq jpk and taille[4] eq jpt: $ 337 340 res = tab[*, *, firstz:lastz, *] 338 else:BEGIN 341 else:BEGIN 339 342 if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4grmoyenne.dat' 340 343 return, report('Probleme d''adequation entre les tailles du domaine nx*ny*nz*jpt ' $ … … 346 349 endcase 347 350 if nx EQ 1 OR ny EQ 1 OR nz EQ 1 OR jpt EQ 1 then res = reform(res, nx, ny, nz, jpt, /over) 348 if keyword_set(nan) NE 0 then BEGIN 349 if nan NE 1 then BEGIN ; if nan is not !values.f_nan 351 if keyword_set(nan) NE 0 then BEGIN 352 if nan NE 1 then BEGIN ; if nan is not !values.f_nan 350 353 ; we put it at !values.f_nan 351 354 if abs(nan) LT 1e6 then notanumber = where(res EQ nan) $ … … 355 358 ENDIF 356 359 ;--------------------------------------------------------------- 357 ; Comment : WE HAVE TO BE CAREFUL ABOUT CASES WHERE THE DIMENSION TO AVERAGE = 1,358 ; A ND MAKE SURE THAT IT EXIST. THAT IS WHY WE USE reform(...,nx,ny,...) WHICH CAN359 ; LOOK USELESS AT THE BEGINNING360 ;--------------------------------------------------------------- 361 if nx EQ 1 OR ny EQ 1 OR nz EQ 1 then BEGIN 360 ; Comment : WE HAVE TO BE CAREFUL ABOUT CASES WHERE THE DIMENSION TO 361 ; AVERAGE = 1, AND MAKE SURE THAT IT EXIST. THAT IS WHY WE USE 362 ; reform(...,nx,ny,...) WHICH CAN LOOK USELESS AT THE BEGINNING 363 ;--------------------------------------------------------------- 364 if nx EQ 1 OR ny EQ 1 OR nz EQ 1 then BEGIN 362 365 res = reform(res, nx, ny, nz, jpt, /over) 363 366 mask = reform(mask, nx, ny, nz, /over) … … 366 369 ; the top of the ocean floor is 367 370 IF vargrid EQ 'T' OR vargrid EQ 'W' THEN bottom = total(mask, 3) $ 368 ELSE bottom = total(tmask[firstx:lastx, firsty:lasty, firstz:lastz], 3) 369 ; we suppress columns with only ocean or land 371 ELSE bottom = total(tmask[firstx:lastx, firsty:lasty, firstz:lastz], 3) 372 ; we suppress columns with only ocean or land 370 373 good = where(bottom NE 0 AND bottom NE nz) 371 374 ; the bottom of the ocean in 3D index is: … … 386 389 IF keyword_set(key_partialstep) AND bottom[0] NE -1 $ 387 390 AND nx NE 1 THEN BEGIN 388 IF msknan[0] EQ -1 THEN BEGIN 391 IF msknan[0] EQ -1 THEN BEGIN 389 392 msknan = replicate(1b, nx, ny, nz, jpt) 390 393 nan = 1 … … 395 398 res[temporary(bottom)] = !values.f_nan 396 399 ENDIF 397 if keyword_set(integration) then divi = 1 ELSE begin 400 if keyword_set(integration) then divi = 1 ELSE begin 398 401 IF msknan[0] NE -1 THEN divi = total(echelle*msknan, 1) $ 399 402 ELSE divi = total(echelle, 1) … … 415 418 IF keyword_set(key_partialstep) AND bottom[0] NE -1 $ 416 419 AND ny NE 1 THEN BEGIN 417 IF msknan[0] EQ -1 THEN BEGIN 420 IF msknan[0] EQ -1 THEN BEGIN 418 421 msknan = replicate(1b, nx, ny, nz) 419 422 nan = 1 … … 424 427 res[temporary(bottom)] = !values.f_nan 425 428 ENDIF 426 if keyword_set(integration) then divi = 1 ELSE begin 429 if keyword_set(integration) then divi = 1 ELSE begin 427 430 IF msknan[0] NE -1 THEN divi = total(echelle*msknan, 2) $ 428 431 ELSE divi = total(echelle, 2) … … 446 449 echelle = (temporary(e33)*temporary(mask))[*]#replicate(1, jpt) 447 450 echelle = reform(echelle, nx, ny, nz, jpt, /over) 448 if keyword_set(integration) then divi = 1 ELSE begin 451 if keyword_set(integration) then divi = 1 ELSE begin 449 452 IF msknan[0] NE -1 THEN divi = total(echelle*msknan, 3) $ 450 453 ELSE divi = total(echelle, 3) … … 467 470 IF keyword_set(key_partialstep) AND bottom[0] NE -1 $ 468 471 AND nx*ny NE 1 THEN BEGIN 469 IF msknan[0] EQ -1 THEN BEGIN 472 IF msknan[0] EQ -1 THEN BEGIN 470 473 msknan = replicate(1b, nx, ny, nz) 471 474 nan = 1 … … 476 479 res[temporary(bottom)] = !values.f_nan 477 480 ENDIF 478 if keyword_set(integration) then divi = 1 ELSE begin 481 if keyword_set(integration) then divi = 1 ELSE begin 479 482 IF msknan[0] NE -1 THEN divi = total(total(echelle*msknan, 1), 1) $ 480 483 ELSE divi = total(total(echelle, 1), 1) … … 497 500 echelle = (temporary(e133[*])*temporary(mask[*]))#replicate(1, jpt) 498 501 echelle = reform(echelle, nx, ny, nz, jpt, /over) 499 if keyword_set(integration) then divi = 1 ELSE begin 502 if keyword_set(integration) then divi = 1 ELSE begin 500 503 IF msknan[0] NE -1 THEN divi = total(total(echelle*msknan, 1), 2) $ 501 504 ELSE divi = total(total(echelle, 1), 2) … … 518 521 echelle = (temporary(e233[*])*temporary(mask[*]))#replicate(1, jpt) 519 522 echelle = reform(echelle, nx, ny, nz, jpt, /over) 520 if keyword_set(integration) then divi = 1 ELSE begin 523 if keyword_set(integration) then divi = 1 ELSE begin 521 524 IF msknan[0] NE -1 THEN divi = total(total(echelle*msknan, 2), 2) $ 522 525 ELSE divi = total(total(echelle, 2), 2) … … 539 542 echelle = (temporary(e1233[*])*temporary(mask[*]))#replicate(1, jpt) 540 543 echelle = reform(echelle, nx, ny, nz, jpt, /over) 541 if keyword_set(integration) then divi = 1 ELSE begin 544 if keyword_set(integration) then divi = 1 ELSE begin 542 545 IF msknan[0] NE -1 THEN divi = total(total(total(echelle*msknan, 1), 1), 1) $ 543 546 ELSE divi = total(total(total(echelle, 1), 1), 1) … … 562 565 tdim = size(res, /n_dimensions) 563 566 if keyword_set(integration) then res = total(res, tdim, nan = nan) $ 564 ELSE BEGIN 565 if keyword_set(nan) then BEGIN 567 ELSE BEGIN 568 if keyword_set(nan) then BEGIN 566 569 testnan = testnan < 1 567 570 testnan = total(temporary(testnan), tdim) … … 569 572 ENDIF ELSE divi = jpt 570 573 res = total(res, tdim, nan = nan)/(1 > divi) 571 ENDELSE 574 ENDELSE 572 575 ENDIF 573 576 ;------------------------------------------------------------ … … 580 583 valmask = 1e+20 581 584 terre = where(divi EQ 0) 582 IF terre[0] NE -1 THEN BEGIN 585 IF terre[0] NE -1 THEN BEGIN 583 586 res[temporary(terre)] = 1e+20 584 ENDIF 587 ENDIF 585 588 ;------------------------------------------------------------ 586 589 ; IV.2) We replace, when nan equal 1, !values.f_nan by nan 587 590 ;------------------------------------------------------------ 588 if keyword_set(nan) NE 0 then BEGIN 591 if keyword_set(nan) NE 0 then BEGIN 589 592 puttonan = where(temporary(testnan) EQ 0) 590 593 if puttonan[0] NE -1 then res[temporary(puttonan)] = !values.f_nan 591 if nan NE 1 then BEGIN 594 if nan NE 1 then BEGIN 592 595 notanumber = where(finite(res) eq 0) 593 596 if notanumber[0] NE -1 then res[temporary(notanumber)] = nan … … 599 602 if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4grmoyenne.dat' 600 603 ;------------------------------------------------------------ 601 if keyword_set(key_performance) THEN print, 'temps grossemoyenne', systime(1)-tempsun 604 if keyword_set(key_performance) THEN print, 'temps grossemoyenne', systime(1)-tempsun 602 605 return, res 603 606 ;------------------------------------------------------------ -
trunk/SRC/ToBeReviewed/CALCULS/moyenne.pro
r163 r223 4 4 ;+ 5 5 ; 6 ; @file_comments 6 ; @file_comments 7 7 ; averages a 2- or 3-d field over a selected 8 8 ; geographical area and along one ore more … … 17 17 ; 'x' 'y' 'z' 'xy' 'xz' 'yz' or 'xyz' 18 18 ; 19 ; @keyword BOXZOOM 19 ; @keyword BOXZOOM 20 20 ; [xmin,xmax,ymin,ymax (,(zmin,)zmax)] to more details, see domdef 21 ; boxzoom can have 5 forms: 21 ; boxzoom can have 5 forms: 22 22 ; [vert2], 23 23 ; [vert1, vert2], 24 ; [lon1, lon2, lat1, lat2], 24 ; [lon1, lon2, lat1, lat2], 25 25 ; [lon1, lon2, lat1, lat2, vert2], 26 26 ; [lon1, lon2, lat1, lat2, vert1,vert2] 27 27 ; 28 ; @keyword NAN 28 ; @keyword NAN 29 29 ; not a number, we activate it if we want to average without considerate some masked values of TAB. 30 30 ; If masked values of TAB are values consecrated by IDL(!values.f_nan), we just have to put NAN. 31 31 ; If masked values of TAB are valued a (a must be different of 1, corresponding to nan = 32 ; !values.f_nan and of 0, which desactivate nan). We have to put NAN=a. 32 ; !values.f_nan and of 0, which desactivate nan). We have to put NAN=a. 33 33 ; Comment: In output, result points which are NAN will be valued a or !values.f_nan. 34 ; 34 ; 35 35 ; @keyword NODOMDEF 36 ; We activate it if we do not want to pass in domdef even if the keyword boxzoom 36 ; We activate it if we do not want to pass in domdef even if the keyword boxzoom 37 37 ; is present (like when grossemoyenne is called via checkfield) 38 38 ; 39 ; @keyword INTEGRATION 39 ; @keyword INTEGRATION 40 40 ; To make an integral rather than an average 41 ; 42 ; @keyword WDEPTH 43 ; to specify that the field is at W depth instead of T 44 ; depth (automatically activated if vargrid eq 'W') 45 ; 41 ; 42 ; @keyword WDEPTH 43 ; to specify that the field is at W depth instead of T 44 ; depth (automatically activated if vargrid eq 'W') 45 ; 46 46 ; @returns 47 ; An array 47 ; An array 48 48 ; 49 49 ; @uses … … 51 51 ; domdef 52 52 ; 53 ; @restrictions Put values corresponding to land at 1.e20 53 ; @restrictions 54 ; Put values corresponding to land at 1.e20 54 55 ; 55 56 ; @history … … 112 113 if dirx eq 0 and diry eq 0 and dirz eq 0 then return, tab 113 114 END 114 else : return, report(' Le tableau d''entree doit etre a 2 ou 3 dimensions s''il contient une dim temporelle utilisergrossemoyenne')115 else : return, report('Array must have 2 or 3 dimensions if there is a time dimension use grossemoyenne') 115 116 endcase 116 117 ;------------------------------------------------------------ … … 118 119 ; Redefinition of the domain ajusted at boxzoom (at 6 elements) 119 120 ; This will allowed us to calculate only in the domain concerned by the average. 120 ; Domdef, followed by grid give us all arrays of the grid on the subdomain 121 ;------------------------------------------------------------ 122 if keyword_set(boxzoom) then BEGIN 121 ; Domdef, followed by grid give us all arrays of the grid on the subdomain 122 ;------------------------------------------------------------ 123 if keyword_set(boxzoom) then BEGIN 123 124 Case 1 Of 124 125 N_Elements(Boxzoom) Eq 1:bte = [lon1, lon2, lat1, lat2, 0., boxzoom[0]] … … 127 128 N_Elements(Boxzoom) Eq 5:bte = [Boxzoom[0:3], 0, Boxzoom[4]] 128 129 N_Elements(Boxzoom) Eq 6:bte = Boxzoom 129 Else: return, report(' Mauvaise Definition deBoxzoom')130 Else: return, report('Bad definition of Boxzoom') 130 131 endcase 131 if NOT keyword_set(nodomdef) then BEGIN 132 if NOT keyword_set(nodomdef) then BEGIN 132 133 savedbox = 1b 133 134 saveboxparam, 'boxparam4moyenne.dat' 134 135 domdef, bte, GRIDTYPE = vargrid, _extra = ex 135 ENDIF 136 ENDIF 136 ENDIF 137 ENDIF 137 138 ;--------------------------------------------------------------- 138 139 ; attribution of the mask and of longitude and latitude arrays... … … 155 156 jpk:res = tab[firstz:lastz] 156 157 nz:res = tab 157 ELSE:BEGIN 158 ELSE:BEGIN 158 159 if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4moyenne.dat' 159 160 return, report('Probleme d''adequation entre les tailles du domaine et de la boxzoom.') 160 161 END 161 162 ENDCASE 162 if dirz EQ 1 then BEGIN 163 dim = '3d' 163 if dirz EQ 1 then BEGIN 164 dim = '3d' 164 165 taille = size(reform(res, nx, ny, nz)) 165 166 ENDIF ELSE BEGIN 166 167 if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4moyenne.dat' 167 168 return, res 168 ENDELSE 169 ENDELSE 169 170 END 170 171 ny EQ 1:BEGIN ;vector following x … … 172 173 jpi:res = tab[firstx:lastx] 173 174 nx:res = tab 174 ELSE:BEGIN 175 ELSE:BEGIN 175 176 if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4moyenne.dat' 176 177 return, report('Probleme d''adequation entre les tailles du domaine et de la boxzoom.') 177 178 END 178 179 ENDCASE 179 if dirx EQ 1 then BEGIN 180 dim = '2d' 180 if dirx EQ 1 then BEGIN 181 dim = '2d' 181 182 taille = size(reform(res, nx, ny)) 182 ENDIF ELSE BEGIN 183 ENDIF ELSE BEGIN 183 184 if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4moyenne.dat' 184 185 return, res … … 189 190 jpj:res = tab[firsty:lasty] 190 191 ny:res = tab 191 ELSE:BEGIN 192 ELSE:BEGIN 192 193 if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4moyenne.dat' 193 194 return, report('Probleme d''adequation entre les tailles du domaine et de la boxzoom.') … … 197 198 dim = '2d' 198 199 taille = size(reform(res, nx, ny)) 199 ENDIF ELSE BEGIN 200 ENDIF ELSE BEGIN 200 201 if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4moyenne.dat' 201 202 return, res 202 ENDELSE 203 ENDELSE 203 204 END 204 205 endcase … … 213 214 ; II.1) verification of the coherence of the array's size to average 214 215 ; Verification of the coherence between the array's size and the domain defined by domdef 215 ; The input array must have either the total domain's size (jpi,jpj) or this 216 ; The input array must have either the total domain's size (jpi,jpj) or this 216 217 ; one of the reduced domain (nx,ny) 217 218 ;--------------------------------------------------------------- … … 220 221 res = tab[firstx:lastx, firsty:lasty] 221 222 taille[1] eq nx and taille[2] eq ny:res = tab 222 else:BEGIN 223 else:BEGIN 223 224 if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4moyenne.dat' 224 225 return, report('Probleme d''adequation entre les tailles du domaine nx*ny '+strtrim(nx, 1)+'*'+strtrim(ny, 1)+' et du tableau '+strtrim(taille[1], 1)+'*'+strtrim(taille[2], 1)) 225 226 END 226 227 ENDCASE 227 if keyword_set(nan) NE 0 then BEGIN 228 if nan NE 1 then BEGIN ; If nan is not !values.f_nan 228 if keyword_set(nan) NE 0 then BEGIN 229 if nan NE 1 then BEGIN ; If nan is not !values.f_nan 229 230 ; we put it at !values.f_nan 230 231 if abs(nan) LT 1e6 then notanumber = where(res EQ nan) $ … … 234 235 ENDIF 235 236 ;--------------------------------------------------------------- 236 ; Comment : WE HAVE TO BE CAREFUL ABOUT CASES WHERE THE DIMENSION TO AVERAGE = 1, 237 ; AND MAKE SURE THAT IT EXIST. THAT IS WHY WE USE reform(...,nx,ny,...) WHICH CAN 237 ; Comment : WE HAVE TO BE CAREFUL ABOUT CASES WHERE THE DIMENSION TO AVERAGE = 1, 238 ; AND MAKE SURE THAT IT EXIST. THAT IS WHY WE USE reform(...,nx,ny,...) WHICH CAN 238 239 ; LOOK USELESS AT THE BEGINNING 239 240 ;--------------------------------------------------------------- 240 if nx EQ 1 OR ny EQ 1 then BEGIN 241 if nx EQ 1 OR ny EQ 1 then BEGIN 241 242 res = reform(res, nx, ny, /over) 242 243 e1 = reform(e1, nx, ny, /over) … … 254 255 e = e1*mask 255 256 if keyword_set(integration) then divi = 1 $ 256 else begin 257 else begin 257 258 divi = e 258 259 IF msknan[0] NE -1 THEN divi = temporary(divi)*msknan … … 272 273 e = e2*mask 273 274 if keyword_set(integration) then divi = 1 $ 274 else begin 275 else begin 275 276 divi = e 276 277 IF msknan[0] NE -1 THEN divi = temporary(divi)*msknan … … 288 289 end 289 290 (dirx eq 1) and (diry eq 1) : begin 290 if keyword_set(integration) then divi = 1 else BEGIN 291 if keyword_set(integration) then divi = 1 else BEGIN 291 292 IF msknan[0] NE -1 THEN divi = total(e1*e2*mask*msknan) $ 292 293 ELSE divi = total(e1*e2*mask) 293 ENDELSE 294 ENDELSE 294 295 res = total(res*e1*e2*mask, nan = nan)/(divi > 1.) 295 296 if msknan[0] NE -1 then begin … … 307 308 if (dim eq '3d') then begin 308 309 ;--------------------------------------------------------------- 309 ; III.1) Verification of the coherence of the array to average size 310 ; Verification of the coherence between the array's size and the domain 311 ; defind by domdef 312 ; The input array must have either the total domain size (jpi,jpj,jpk) 310 ; III.1) Verification of the coherence of the array to average size 311 ; Verification of the coherence between the array's size and the domain 312 ; defind by domdef 313 ; The input array must have either the total domain size (jpi,jpj,jpk) 313 314 ; or this one of the reduced domain (nx,ny,ny) 314 315 ;--------------------------------------------------------------- … … 321 322 taille[1] EQ nx and taille[2] eq ny and taille[3] eq jpk : $ 322 323 res = tab[*, *, firstz:lastz] 323 else:BEGIN 324 else:BEGIN 324 325 if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4moyenne.dat' 325 326 return, report('Probleme d''adequation entre les tailles du domaine nx*ny*nz '+strtrim(nx, 1)+'*'+strtrim(ny, 1)+'*'+strtrim(nz, 1)+' et du tableau '+strtrim(taille[1], 1)+'*'+strtrim(taille[2], 1)+'*'+strtrim(taille[3], 1)) 326 327 END 327 328 endcase 328 if keyword_set(nan) NE 0 then BEGIN 329 if nan NE 1 then BEGIN ; if nan is not !values.f_nan 329 if keyword_set(nan) NE 0 then BEGIN 330 if nan NE 1 then BEGIN ; if nan is not !values.f_nan 330 331 ; we put it at !values.f_nan 331 332 if abs(nan) LT 1e6 then notanumber = where(res EQ nan) $ … … 335 336 ENDIF 336 337 ;--------------------------------------------------------------- 337 ; Comment : WE HAVE TO BE CAREFUL ABOUT CASES WHERE THE DIMENSION TO AVERAGE = 1, 338 ; AND MAKE SURE THAT IT EXIST. THAT IS WHY WE USE reform(...,nx,ny,...) WHICH CAN 338 ; Comment : WE HAVE TO BE CAREFUL ABOUT CASES WHERE THE DIMENSION TO AVERAGE = 1, 339 ; AND MAKE SURE THAT IT EXIST. THAT IS WHY WE USE reform(...,nx,ny,...) WHICH CAN 339 340 ; LOOK USELESS AT THE BEGINNING 340 341 ;--------------------------------------------------------------- 341 if nx EQ 1 OR ny EQ 1 OR nz EQ 1 then BEGIN 342 if nx EQ 1 OR ny EQ 1 OR nz EQ 1 then BEGIN 342 343 res = reform(res, nx, ny, nz, /over) 343 344 e1 = reform(e1, nx, ny, /over) … … 349 350 ; the top of the ocean floor is 350 351 IF vargrid EQ 'T' OR vargrid EQ 'W' THEN bottom = total(mask, 3) $ 351 ELSE bottom = total(tmask[firstx:lastx, firsty:lasty, firstz:lastz], 3) 352 ; we suppress columns with only ocean or land 352 ELSE bottom = total(tmask[firstx:lastx, firsty:lasty, firstz:lastz], 3) 353 ; we suppress columns with only ocean or land 353 354 good = where(bottom NE 0 AND bottom NE nz) 354 355 ; the bottom of the ocean in 3D index is: … … 367 368 IF keyword_set(key_partialstep) AND bottom[0] NE -1 $ 368 369 AND nx NE 1 THEN BEGIN 369 IF msknan[0] EQ -1 THEN BEGIN 370 IF msknan[0] EQ -1 THEN BEGIN 370 371 msknan = replicate(1b, nx, ny, nz) 371 372 nan = 1 … … 395 396 IF keyword_set(key_partialstep) AND bottom[0] NE -1 $ 396 397 AND ny NE 1 THEN BEGIN 397 IF msknan[0] EQ -1 THEN BEGIN 398 IF msknan[0] EQ -1 THEN BEGIN 398 399 msknan = replicate(1b, nx, ny, nz) 399 400 nan = 1 … … 447 448 IF keyword_set(key_partialstep) AND bottom[0] NE -1 $ 448 449 AND nx*ny NE 1 THEN BEGIN 449 IF msknan[0] EQ -1 THEN BEGIN 450 IF msknan[0] EQ -1 THEN BEGIN 450 451 msknan = replicate(1b, nx, ny, nz) 451 452 nan = 1 … … 454 455 res[bottom] = !values.f_nan 455 456 ENDIF 456 if keyword_set(integration) then divi = 1 else BEGIN 457 if keyword_set(integration) then divi = 1 else BEGIN 457 458 divi = e123*mask 458 459 IF msknan[0] NE -1 THEN divi = temporary(divi)*msknan … … 478 479 ELSE e133[bottom] = (e1*e3t_ps[firstx:lastx, firsty:lasty])[temporary(good)] 479 480 ENDIF 480 if keyword_set(integration) then divi = 1 else BEGIN 481 if keyword_set(integration) then divi = 1 else BEGIN 481 482 divi = e133*mask 482 483 if msknan[0] NE -1 then divi = temporary(divi)*msknan … … 502 503 ELSE e233[bottom] = (e2*e3t_ps[firstx:lastx, firsty:lasty])[temporary(good)] 503 504 ENDIF 504 if keyword_set(integration) then divi = 1 else BEGIN 505 if keyword_set(integration) then divi = 1 else BEGIN 505 506 divi = e233*mask 506 507 if msknan[0] NE -1 then divi = temporary(divi)*msknan … … 526 527 ELSE e1233[bottom] = (e1*e2*e3t_ps[firstx:lastx, firsty:lasty])[temporary(good)] 527 528 ENDIF 528 if keyword_set(integration) then divi = 1 else BEGIN 529 if keyword_set(integration) then divi = 1 else BEGIN 529 530 if msknan[0] NE -1 then divi = total(e1233*mask*msknan) $ 530 531 ELSE divi = total(e1233*mask) … … 550 551 IF terre[0] NE -1 THEN BEGIN 551 552 res[terre] = 1e+20 552 ENDIF 553 ENDIF 553 554 ;------------------------------------------------------------ 554 555 ; IV.2) We replace, when nan equal 1, !values.f_nan by nan 555 556 ;------------------------------------------------------------ 556 if keyword_set(nan) NE 0 then BEGIN 557 if keyword_set(nan) NE 0 then BEGIN 557 558 puttonan = where(testnan EQ 0) 558 559 if puttonan[0] NE -1 then res[puttonan] = !values.f_nan 559 if nan NE 1 then BEGIN 560 if nan NE 1 then BEGIN 560 561 notanumber = where(finite(res) eq 0) 561 562 if notanumber[0] NE -1 then res[notanumber] = nan … … 567 568 if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4moyenne.dat' 568 569 ;------------------------------------------------------------ 569 if keyword_set(key_performance) THEN print, 'temps moyenne', systime(1)-tempsun 570 if keyword_set(key_performance) THEN print, 'temps moyenne', systime(1)-tempsun 570 571 return, res 571 572 ;------------------------------------------------------------ -
trunk/SRC/ToBeReviewed/LECTURE/binary.pro
r142 r223 2 2 ; @file_comments 3 3 ; Returns the binary representation of a number of any numerical type. 4 ; 4 ; 5 5 ; @param NUMBER {in}{required} 6 6 ; scalar or array of numbers (any numerical type) 7 ; 8 ; @ Returns7 ; 8 ; @returns 9 9 ; Byte array with binary representation of numbers. 10 ; 11 ; @ Examples10 ; 11 ; @examples 12 12 ; Binary representation of 11b: 13 13 ; IDL> print, binary(11b) … … 26 26 ; alpha vms 0fda4149 68c0a221 49 41 da 0f 21 a2 c0 68 27 27 ; (Beginning with IDL 5.1, Alpha VMS uses IEEE representation as well.) 28 ; 29 ; @history :28 ; 29 ; @history 30 30 ; 19 Dec 1997 Originally a news posting by David Fanning. 31 31 ; (Re: bits from bytes) -
trunk/SRC/ToBeReviewed/PLOTS/DESSINE/scontour.pro
r163 r223 4 4 ;+ 5 5 ; 6 ; @ File_comments6 ; @file_comments 7 7 ; Same thing that contour but compatible with the whole environment (common.pro included) 8 8 ; 9 ; @categories 9 ; @categories 10 10 ; Graphics 11 11 ; 12 12 ; @keyword NOREINITPLT 13 ; We active it if we do not want environment variables !p, !x, !y, !z 13 ; We active it if we do not want environment variables !p, !x, !y, !z 14 14 ; to be reinitilalizated by the procedure reinitplt 15 ; 15 ; 16 16 ; @keyword _EXTRA 17 17 ; used to pass your keywords … … 21 21 ; 22 22 ; @examples 23 ; IDL> z = dist(100) 23 ; IDL> z = dist(100) 24 24 ; IDL> scontour, z, nlevels=10,small=[1,2,1],xstyle=1,ystyle=1 25 25 ; IDL> \@ps 26 26 ; 27 ; @history Sebastien Masson (smasson\@lodyc.jussieu.fr) 28 ; 10/10/1999 29 ; 27 ; @history 28 ; Sebastien Masson (smasson\@lodyc.jussieu.fr) 29 ; 10/10/1999 30 ; 30 31 ; @version 31 32 ; $Id$ … … 40 41 ; 41 42 @common 42 ; 1) I reinitializate the graphic environment (variables !x, !y et !p): 43 if NOT keyword_set(NOREINITPLT) then reinitplt, _extra = ex 44 ; 2) i put the drawing on the screen like on the postcript 43 ; 1) I reinitializate the graphic environment (variables !x, !y et !p): 44 if NOT keyword_set(NOREINITPLT) then reinitplt, _extra = ex 45 ; 2) i put the drawing on the screen like on the postcript 45 46 ; if ex contains norease and c_orientation keywords we force ex.noerase = 0 46 47 IF chkstru(ex, 'overplot') EQ 0 THEN placedessin, 'autre', _extra = ex … … 53 54 dummy = where(alltags EQ 'noerase', count1) 54 55 dummy = where(alltags EQ 'c_orientation', count2) 55 IF count1*count2 NE 0 THEN BEGIN 56 IF count1*count2 NE 0 THEN BEGIN 56 57 case n_params() OF 57 58 1:contour, x, /nodata, _EXTRA = ex … … 62 63 ex = get_extra(/overplot, _extra = ex) 63 64 noerase_orientation = 1 64 ENDIF 65 ENDIF 66 ; 3) je fais mon joli dessin 65 ENDIF 66 ENDIF 67 ; 3) je fais mon joli dessin 67 68 case n_params() OF 68 69 1:contour, x, xstyle = 1, ystyle = 1, _EXTRA = ex … … 81 82 ENDIF 82 83 ; 4) End of drawing 83 terminedessin, _extra = ex 84 terminedessin, _extra = ex 84 85 85 86 return -
trunk/SRC/ToBeReviewed/PLOTS/DESSINE/splot.pro
r163 r223 4 4 ;+ 5 5 ; 6 ; file_comments7 ; Same thing tha tplot but compatible with the whole environment (common.pro included)6 ; @file_comments 7 ; Same thing than plot but compatible with the whole environment (common.pro included) 8 8 ; 9 ; @categories 9 ; @categories 10 10 ; Graphics 11 11 ; 12 12 ; @keyword NOREINITPLT 13 ; We active it if we do not want environment variables !p, !x, !y, !z 13 ; We active it if we do not want environment variables !p, !x, !y, !z 14 14 ; to be reinitilalizated by the procedure reinitplt 15 ; 15 ; 16 16 ; @keyword _EXTRA 17 17 ; used to pass your keywords … … 20 20 ; common.pro 21 21 ; 22 ; @restrictions 23 ; If NOREINITPLT is not activated, all environment 22 ; @restrictions 23 ; If NOREINITPLT is not activated, all environment 24 24 ; variables !p, !x, !y, !z are reinitializted by the procedure reinitplt 25 25 ; … … 40 40 ;------------------------------------------------------------ 41 41 ;------------------------------------------------------------ 42 PRO splot, 42 PRO splot, x, y, NOREINITPLT = noreinitplt, _EXTRA = ex 43 43 ; 44 44 compile_opt idl2, strictarrsubs 45 45 ; 46 46 @common 47 ; 1) I reinitializate the graphic environment (les variables !x, !y et !p): 48 if NOT keyword_set(NOREINITPLT) then reinitplt, _extra = ex 49 ; 2) i put the drawing on the screen like on the postcript 47 ; 1) I reinitializate the graphic environment (les variables !x, !y et !p): 48 if NOT keyword_set(NOREINITPLT) then reinitplt, _extra = ex 49 ; 2) i put the drawing on the screen like on the postcript 50 50 placedessin, 'autre', _extra = ex 51 51 ; 3) Drawing 52 52 if n_elements(y) EQ 0 then plot, x, xstyle = 1, ystyle = 1, _EXTRA = ex $ 53 53 ELSE plot, x, y, xstyle = 1, ystyle = 1, _EXTRA = ex 54 ; 4) End of drawing 55 terminedessin, _extra=ex 54 ; 4) End of drawing 55 terminedessin, _extra=ex 56 56 ; 57 57 return -
trunk/SRC/ToBeReviewed/PLOTS/plotsym.pro
r163 r223 3 3 ; @file_comments 4 4 ; function to make plotting symbols much easier. 5 ; 5 ; 6 6 ; @categories 7 7 ; Graphics 8 8 ; 9 ; @ Keyword circle9 ; @keyword circle 10 10 ; circle symbol 11 ; 12 ; @ Keyword TRIANGLE11 ; 12 ; @keyword TRIANGLE 13 13 ; triangle symbol 14 ; 15 ; @ Keyword DIAMOND14 ; 15 ; @keyword DIAMOND 16 16 ; diamond symbol 17 ; 18 ; @ Keyword BOX17 ; 18 ; @keyword BOX 19 19 ; box symbol 20 ; 21 ; @ Keyword LINE20 ; 21 ; @keyword LINE 22 22 ; line symbol 23 24 ; @ Keyword SCALE23 ; 24 ; @keyword SCALE 25 25 ; scales the symbol 26 ; 27 ; @ Keyword ANGLE26 ; 27 ; @keyword ANGLE 28 28 ; angle the symbol should be rotated 29 ; 30 ; @ Keyword _EXTRA29 ; 30 ; @keyword _EXTRA 31 31 ; extra keywords for usersym. These are thick, color and fill 32 32 ; … … 42 42 ; @version 43 43 ; $Id$ 44 ; 44 ; 45 45 ;- 46 46 -
trunk/SRC/ToBeReviewed/STRING/getfile.pro
r192 r223 7 7 ; @param filein {in}{required} 8 8 ; text file name. 9 ; 10 ; @ Keyword ERROR9 ; 10 ; @keyword ERROR 11 11 ; =err error flag: 0=ok, 1=file not opened, 12 12 ; 2=no lines in file. 13 ; 14 ; @keyword QUIET 13 ; 14 ; @keyword QUIET 15 15 ; means give no error message. 16 ; 16 ; 17 17 ; @keyword LINES 18 18 ; =n Number of lines to read (def=all). 19 19 ; Much faster if number of lines is known. 20 20 ; Automatic for IDL 5.6 or later. 21 ; 22 ; @keyword FIND 21 ; 22 ; @keyword FIND 23 23 ; search the file in the all !path directories (use 24 24 ; find.pro) 25 25 ; 26 26 ; @keyword HELP 27 ; 27 ; 28 28 ; @returns 29 ; 29 ; 30 30 ; @history 31 31 ; R. Sterner, 20 Mar, 1990 … … 52 52 ;- 53 53 ;------------------------------------------------------------- 54 54 55 55 function getfile, filein, error=err, help=hlp, quiet=quiet, lines=lines, find = find 56 56 ; 57 57 compile_opt idl2, strictarrsubs 58 58 ; 59 59 60 60 if (n_params(0) lt 1) or keyword_set(hlp) then begin 61 61 print,' Read a text file into a string array.' … … 81 81 endif 82 82 ENDIF ELSE file = filein 83 83 84 84 if (!version.release+0. ge 5.5) then begin 85 85 f = call_function('file_search', file, count = c) … … 91 91 return,'' 92 92 endif 93 93 94 94 if n_elements(line) eq 0 and (!version.release+0. ge 5.6) then begin 95 95 lines = file_lines(file) … … 101 101 minlines = 0 102 102 endif else minlines=1 103 103 104 104 get_lun, lun 105 105 on_ioerror, err 106 106 openr, lun, file 107 107 108 108 if n_elements(lines) ne 0 then begin 109 109 s = strarr(lines) … … 117 117 endwhile 118 118 endelse 119 119 120 120 close, lun 121 121 free_lun, lun … … 126 126 endif 127 127 if minlines eq 1 then s=s[1:*] 128 128 129 129 err = 0 130 130 return, s 131 131 132 132 err: if !err eq -168 then begin 133 133 if not keyword_set(quiet) then print,' Non-standard text file format.' … … 140 140 err = 1 141 141 return, -1 142 142 143 143 end -
trunk/SRC/ToBeReviewed/STRING/string2struct.pro
r157 r223 1 1 ;+ 2 2 ; @file_comments 3 ; This is a really, really cool way to turn keywords into 4 ; a structure. 5 ; 3 ; This is a really, really cool way to turn keywords into a structure. 4 ; 6 5 ; @categories 7 6 ; … … 12 11 ; @returns 13 12 ; 14 ;15 13 ; @restrictions 16 ;17 14 ; 18 15 ; @examples … … 20 17 ; 21 18 ; @history 22 ;23 19 ; 24 20 ; @version … … 46 42 ; plot,findgen(100),_extra=stringToStructure('title="testing"') 47 43 ; 48 ; @ RETURNS44 ; @returns 49 45 ; This function returns the string as an anonymous structure. If an 50 46 ; error was found then this function returns a structure with a null field. -
trunk/SRC/Utilities/protype.pro
r163 r223 6 6 ; test is a ".pro" file corresponds to an IDL procedure, function or batch file. 7 7 ; 8 ; @categories 8 ; @categories 9 9 ; Utilities 10 10 ; 11 ; @param FILE {in} 12 ; A scalar of string type, the name of the ".pro" file to be tested11 ; @param FILE {in}{required}{type=string} 12 ; the name of the ".pro" file to be tested. 13 13 ; if necessary, the input name is completed with '.pro' 14 14 ; and its path found in !path 15 15 ; 16 ; @returns 16 ; @returns 17 ; -1 if not found 17 18 ; A scalar of string type: 'proc', 'func' or 'batch' 18 19 ; … … 54 55 ELSE:RETURN, 'batch' 55 56 ENDCASE 56 57 57 58 RETURN, -1 58 59 END -
trunk/SRC/Utilities/xfile.pro
r163 r223 4 4 ;+ 5 5 ; 6 ; @file_comments 6 ; @file_comments 7 7 ; display in a widget an ASCII file. 8 ; It is the same thing that xdisplayfile but here, we use it 9 ; to display the content of a procedure or of a function, 8 ; It is the same thing that xdisplayfile but here, we use it 9 ; to display the content of a procedure or of a function, 10 10 ; even if it is not in the current directory (thanks to the path). 11 11 ; 12 ; @categories 12 ; @categories 13 13 ; Utilities 14 14 ; 15 ; @param FILENAME {in}{required} 16 ; It is the name of the procedure or of the function 15 ; @param FILENAME {in}{required} 16 ; It is the name of the procedure or of the function 17 17 ; we want to display (with or without .pro at the end). 18 18 ; 19 ; @keyword _EXTRA 19 ; @keyword _EXTRA 20 20 ; used to pass your keywords 21 21 ; 22 ; @examples xfile,'plt' 22 ; @examples 23 ; IDL> xfile,'plt' 23 24 ; 24 ; @history Sebastien Masson (smasson\@lodyc.jussieu.fr) 25 ; 7/1/99 26 ; 6/7/1999: compatibility mac and windows 25 ; @history 26 ; Sebastien Masson (smasson\@lodyc.jussieu.fr) 27 ; 7/1/99 28 ; 6/7/1999: compatibility mac and windows 27 29 ; 28 ; @version $Id$ 30 ; @version 31 ; $Id$ 29 32 ; 30 33 ;- … … 38 41 pfile = strlowcase(filename) 39 42 ; 40 ; we have to find the full name. 43 ; we have to find the full name. 41 44 ; 42 if strpos(pfile,".pro") lt 0 then pfile=pfile+".pro" 45 if strpos(pfile,".pro") lt 0 then pfile=pfile+".pro" 43 46 thisOS = strupcase(strmid(!version.os_family, 0, 3)) 44 47 CASE thisOS of … … 56 59 i = 0 57 60 repeat begin 58 res = findfile(pfile[i]) 61 res = findfile(pfile[i]) 59 62 i = i+1 60 endrep until res[0] NE '' OR i EQ n_elements(pfile) 63 endrep until res[0] NE '' OR i EQ n_elements(pfile) 61 64 if res[0] NE '' then BEGIN 62 65 ; we open the file in a widget 63 66 xdisplayfile, pfile[i-1], _extra = ex 64 ENDIF ELSE ras = report(' le fichier demande n''existe pas...')67 ENDIF ELSE ras = report('file does not exist ...') 65 68 ; 66 69 ; -
trunk/SRC/Utilities/xhelp.pro
r163 r223 1 1 ;+ 2 2 ; 3 ; @file_comments 3 ; @file_comments 4 4 ; Display an IDL procedure header using widgets and the widget manager. 5 5 ; … … 7 7 ; Widget 8 8 ; 9 ; @param FILENAME {in}{required} 10 ; A scalar string that contains the filename of the file to display. 11 ; If FILENAME does not include a complete path specification, xhelp will 9 ; @param FILENAME {in}{required} 10 ; A scalar string that contains the filename of the file to display. 11 ; If FILENAME does not include a complete path specification, xhelp will 12 12 ; search for the file in the current working directory and then each of the 13 13 ; directories listed in !PATH environment variable. The 14 14 ; ".pro" file suffix will be appended if it is not supplied. 15 15 ; 16 ; @keyword _EXTRA 16 ; @keyword _EXTRA 17 17 ; used to pass your keywords 18 18 ; 19 ; @restrictions 19 ; @restrictions 20 20 ; Triggers the XMANAGER if it is not already in use. 21 21 ; 22 ; @examples 23 ; Open a file and create a widget to display its contents.22 ; @examples 23 ; IDL> xhelp,'plt' 24 24 ; 25 ; @history Written By Steve Richards, December 1990 25 ; @history 26 ; Written By Steve Richards, December 1990 26 27 ; Graceful error recovery, DMS, Feb, 1992. 27 28 ; Modified to extract .pro documentation headers, PJR/ESRG mar94 … … 33 34 ; 6/7/1999: compatibility mac and windows 34 35 ; 35 ; @version $Id$ 36 ; @version 37 ; $Id$ 36 38 ; 37 39 ;- … … 47 49 return 48 50 endif 49 ; We have to find the full name 51 ; We have to find the full name 50 52 pfile=FILENAME 51 if strpos(pfile,".pro") lt 0 then pfile=pfile+".pro" 53 if strpos(pfile,".pro") lt 0 then pfile=pfile+".pro" 52 54 thisOS = strupcase(strmid(!version.os_family, 0, 3)) 53 55 CASE thisOS of … … 67 69 n = 0 68 70 repeat begin 69 res = findfile(pfile[n]) 71 res = findfile(pfile[n]) 70 72 n = n+1 71 endrep until res[0] NE '' OR n EQ n_elements(pfile) 73 endrep until res[0] NE '' OR n EQ n_elements(pfile) 72 74 if res[0] NE '' then BEGIN 73 75 openr, unit,pfile[n-1], /get_lun ; opening of the file 74 ; we select the heading piece 76 ; we select the heading piece 75 77 a = strarr(1000) ;Maximum # of lines 76 78 xsize=0 … … 90 92 endwhile 91 93 if i EQ 0 then $ 92 ras = report('le programme a etait mal ecrit, il n''y a pas d''en-tete... utiliser xfile.pro.') ELSE BEGIN 94 ras = report('le programme a etait mal ecrit, il n''y a pas d''en-tete... utiliser xfile.pro.') ELSE BEGIN 93 95 a = a[0:i-1] 94 96 ; we wrote the a's content in a widget 95 97 xdisplayfile,'toto',text = a,title=pfile[n-1], _extra = ex 96 ENDELSE 98 ENDELSE 97 99 FREE_LUN, unit ;free the file unit. 98 100 ENDIF ELSE ras = report('le fichier demande n''existe pas...') -
trunk/SRC/buildinit.pro
r163 r223 74 74 ; @returns 75 75 ; 76 ;77 76 ; @uses 78 77 ; 79 ; 80 ; @restrictions: 81 ; 78 ; @restrictions 82 79 ; 83 80 ; @examples … … 85 82 ; 86 83 ; @history 87 ;88 84 ; 89 85 ; @version
Note: See TracChangeset
for help on using the changeset viewer.