Changeset 226 for trunk/SRC/ToBeReviewed/LECTURE/read_ncdf.pro
- Timestamp:
- 03/16/07 10:22:26 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/ToBeReviewed/LECTURE/read_ncdf.pro
r216 r226 2 2 ; @file_comments 3 3 ; Reading function for the file net_cdf. 4 ; This program is less universal than ncdf_lec (it appeal to declared 4 ; This program is less universal than ncdf_lec (it appeal to declared 5 5 ; variables in common.pro) but it is very easier to be used. It considerate 6 6 ; the declaration of the different zooms which have been defined 7 7 ; (ixminmesh...premierx...), the declaration of the variable key_shift... 8 8 ; To put it in a nutshell, the result of read_ncdf can be directly used in plt... 9 ; This is also this program which is used by default in our reading widgets. 9 ; This is also this program which is used by default in our reading widgets. 10 10 ; 11 11 ; @categories 12 12 ; Reading 13 ; 13 ; 14 14 ; @param NAME {in}{required}{type=string} 15 15 ; It define the field to be read. … … 18 18 ; Relative with the time axis. 19 19 ; These can be 20 ; - 2 date of the type yyyymmdd and in this case, we select dates 20 ; - 2 date of the type yyyymmdd and in this case, we select dates 21 21 ; which are included between these two dates. 22 ; - 2 indexes which define between which and which time step we have 22 ; - 2 indexes which define between which and which time step we have 23 23 ; to extract the temporal dimension. 24 24 ; … … 26 26 ; Relative with the time axis. 27 27 ; See BEGINNING. 28 ; 28 ; 29 29 ; @param COMPATIBILITY {in}{optional} 30 30 ; Useless, defined for compatibility 31 ; 32 ; @keyword BOXZOOM 33 ; Contain the boxzoom on which we have to do the reading 34 ; 31 ; 32 ; @keyword BOXZOOM 33 ; Contain the boxzoom on which we have to do the reading 34 ; 35 35 ; @keyword CALLITSELF {default=0}{type=scalar: 0 or 1} 36 36 ; For ROMS outputs. Use by read_ncdf itself to access auxilliary data (h and zeta). 37 ; 37 ; 38 38 ; @keyword FILENAME {required}{type=string} 39 39 ; It contains he file's name. 40 ; 40 ; 41 41 ; @keyword INIT {default=0}{type=scalar: 0 or 1} 42 42 ; To call automatically initncdf, filename and thus 43 43 ; redefine all the grid parameters 44 ; 44 ; 45 45 ; @keyword GRID 46 46 ; ='[UTVWF]' to specify the type of grid. Default is (1) … … 48 48 ; GRID[._][TUVFW].NC (not case sensible) or (2) T if case (1) 49 49 ; is not found. 50 ; 50 ; 51 51 ; @keyword TIMESTEP {default=0}{type=scalar: 0 or 1} 52 52 ; Specify that BEGINNING and ENDING refer to indexes of the time axis and not to dates 53 53 ; 54 54 ; @keyword TOUT {default=0}{type=scalar: 0 or 1} 55 ; We activate it if we want to read the file on the whole domain without 56 ; considerate the sub-domain defined by the boxzoom or 55 ; We activate it if we want to read the file on the whole domain without 56 ; considerate the sub-domain defined by the boxzoom or 57 57 ; lon1,lon2,lat1,lat2,vert1,vert2. 58 ; 58 ; 59 59 ; @keyword NOSTRUCT {default=0}{type=scalar: 0 or 1} 60 ; We activate it if we do not want that read_ncdf send back a structure 60 ; We activate it if we do not want that read_ncdf send back a structure 61 61 ; but only the array referring to the field. 62 ; 62 ; 63 63 ; @keyword TIMEVAR {type=string} 64 64 ; It define the name of the variable that … … 74 74 ; 75 75 ; @keyword _EXTRA 76 ; Used to pass your keywords 76 ; Used to pass your keywords 77 77 ; 78 78 ; @returns 79 79 ; Structure readable by litchamp.pro or an array if NOSTRUCT is activated. 80 ; 80 ; 81 81 ; @uses 82 82 ; common.pro 83 ; 83 ; 84 84 ; @restrictions 85 85 ; The field must have a temporal dimension. 86 ; 86 ; 87 87 ; @history 88 88 ; Sebastien Masson (smasson\@lodyc.jussieu.fr) 89 ; 15/10/1999 90 ; 89 ; 15/10/1999 90 ; 91 91 ; @version 92 ; $Id$ 92 ; $Id$ 93 93 ;- 94 94 ;--------------------------------------------------------- … … 116 116 ; we find the filename. 117 117 ;------------------------------------------------------------ 118 ; print,filename 118 ; print,filename 119 119 ; is parent a valid widget ? 120 120 if keyword_set(parentin) then BEGIN … … 145 145 ncdf_diminq, cdfid, varcontient.dim[i], tmp, dimsize 146 146 dimnames[i] = tmp 147 ENDFOR 147 ENDFOR 148 148 ;------------------------------------------------------------ 149 149 ; shall we redefine the grid parameters … … 174 174 lasttps = where(time EQ date2) & lasttps = lasttps[0] 175 175 ENDIF ELSE BEGIN 176 IF keyword_set(timevar) THEN BEGIN 176 IF keyword_set(timevar) THEN BEGIN 177 177 timeid = ncdf_varid(cdfid, timevar) 178 178 IF timeid EQ -1 THEN BEGIN … … 183 183 timecontient = ncdf_varinq(cdfid, timeid) 184 184 contient.recdim = timecontient.dim[0] 185 ENDIF ELSE BEGIN 185 ENDIF ELSE BEGIN 186 186 ; we find the infinite dimension 187 187 timedim = contient.recdim … … 190 190 return, report('the file '+filename+' as no infinite dimension. !C Use TIMESTEP or TIMEVAR keyword') 191 191 endif 192 ; we find the FIRST time axis 192 ; we find the FIRST time axis 193 193 timeid = 0 194 194 repeat BEGIN ; As long as we have not find a variable having only one dimension: the infinite one … … 204 204 endif 205 205 timeid = timeid-1 206 ENDELSE 206 ENDELSE 207 207 ; we must found the time origin of the julian calendar used in the 208 ; time axis. 208 ; time axis. 209 209 ; does the attribut units an dcalendar exist for the variable time axis? 210 210 if timecontient.natts EQ 0 then BEGIN … … 231 231 'greg':IF n_elements(key_caltype) EQ 0 THEN key_caltype = 'greg' 232 232 ELSE:BEGIN 233 ; notused = report('Unknown calendar: '+value+', we use greg calendar.') 233 ; notused = report('Unknown calendar: '+value+', we use greg calendar.') 234 234 key_caltype = 'greg' 235 235 END 236 236 ENDCASE 237 237 ENDIF ELSE BEGIN 238 ; notused = report('Unknown calendar, we use '+key_caltype+' calendar.') 238 ; notused = report('Unknown calendar, we use '+key_caltype+' calendar.') 239 239 IF n_elements(key_caltype) EQ 0 THEN key_caltype = 'greg' 240 240 ENDELSE … … 272 272 'hour':time = julday(depart[1], depart[2], depart[0])+time/24.d 273 273 'day':time = julday(depart[1], depart[2], depart[0])+time 274 'month':BEGIN 274 'month':BEGIN 275 275 if total(fix(time) NE time) NE 0 then $ ; we switch to days with 30d/m 276 276 time = julday(depart[1], depart[2], depart[0])+round(time*30) $ … … 327 327 dimnames[0] EQ 'xi_u' AND dimnames[1] EQ 'eta_rho':vargrid = 'U' 328 328 dimnames[0] EQ 'xi_u' AND dimnames[1] EQ 'eta_v' :vargrid = 'F' 329 ELSE:BEGIN 329 ELSE:BEGIN 330 330 ; could we define the grid type from the file name?? 331 331 pattern = ['GRID.', 'GRID_', 'GRID', 'UPID_', '30ID_'] … … 369 369 endcase 370 370 ENDIF ELSE BEGIN 371 if keyword_set(boxzoom) then BEGIN 371 if keyword_set(boxzoom) then BEGIN 372 372 Case 1 Of 373 373 N_Elements(Boxzoom) Eq 1:bte = [lon1, lon2, lat1, lat2, 0., boxzoom[0]] … … 386 386 ENDIF 387 387 grille, mask, glam, gphi, gdep, nx, ny, nz, firstx, firsty, firstz, lastx, lasty, lastz 388 undefine, glam & undefine, gphi & ; We liberate some memo ty!388 undefine, glam & undefine, gphi & ; We liberate some memory! 389 389 ENDELSE 390 390 ;--------------------------------------------------------------------- … … 442 442 if found NE -1 then ncdf_attget, cdfid, name, attnames[found], missing_value 443 443 ; 444 ENDIF ELSE BEGIN 444 ENDIF ELSE BEGIN 445 445 IF NOT keyword_set(callitself) THEN varunit = '' 446 446 add_offset = 0. … … 484 484 ; we look for missing_value 485 485 IF size(missing_value, /type) NE 7 then BEGIN 486 IF size(missing_value, /type) EQ 1 THEN BEGIN 486 IF size(missing_value, /type) EQ 1 THEN BEGIN 487 487 missing_value = strlowcase(string(missing_value)) 488 IF strmid(missing_value, 0, 1, /reverse_offset) EQ 'f' THEN $ 488 IF strmid(missing_value, 0, 1, /reverse_offset) EQ 'f' THEN $ 489 489 missing_value = strmid(missing_value, 0, strlen(missing_value)-1) 490 IF isnumber(string(missing_value), tmp) EQ 1 THEN missing_value = tmp ELSE BEGIN 490 IF isnumber(string(missing_value), tmp) EQ 1 THEN missing_value = tmp ELSE BEGIN 491 491 print, 'Warning: missing value is not a number: ', missing_value 492 492 missing_value = - 1 493 493 ENDELSE 494 ENDIF 494 ENDIF 495 495 ; if missing_value NE valmask then begin 496 496 if abs(missing_value) LT 1e6 then missing = where(res EQ missing_value) $ … … 498 498 ; ENDIF ELSE missing = -1 499 499 ENDIF ELSE missing = -1 500 ; we apply add_offset, scale_factor and missing_value 500 ; we apply add_offset, scale_factor and missing_value 501 501 if scale_factor NE 1 then res = temporary(res)*scale_factor 502 502 if add_offset NE 0 then res = temporary(res)+add_offset … … 538 538 IF keyword_set(nostruct) THEN return, res 539 539 IF keyword_set(key_forgetold) THEN BEGIN 540 return, {arr:temporary(res), grid:vargrid, unit:varunit, experiment:varexp, name:varname} 541 ENDIF ELSE BEGIN 540 return, {arr:temporary(res), grid:vargrid, unit:varunit, experiment:varexp, name:varname} 541 ENDIF ELSE BEGIN 542 542 return, {tab:temporary(res), grille:vargrid, unite:varunit, experience:varexp, nom:varname} 543 543 ENDELSE
Note: See TracChangeset
for help on using the changeset viewer.