source: trunk/SRC/ToBeReviewed/INIT/initncdf.pro @ 325

Last change on this file since 325 was 325, checked in by pinsard, 17 years ago

modification of some headers (+some corrections) to prepare usage of the new idldoc

  • Property svn:keywords set to Id
File size: 4.6 KB
RevLine 
[33]1;+
2;
[142]3; @file_comments
[172]4; Initfile for Netcdf file. define all the grid parameters through
5; an appropriate call to computegid
[33]6;
[142]7; @categories
[172]8; Grid
[231]9;
[325]10; @param ncfilein {in}{required}{type=scalar string}
[142]11; A string giving the name of the NetCdf file
[33]12;
[172]13; @keyword START1 {default=0}{type=scalar: 0 or 1}
[142]14; Index the axis from 1 instead of 0 when using
[221]15; /xyindex and/or /zindex
[33]16;
[172]17; @keyword ZAXISNAME {default='z', 'level', 'lev', 'depth...'}{type=scalar string}
[231]18; A string giving the name of the variable in the file
19; that contains the [xyz]axis.
[33]20;
[172]21; @keyword XYINDEX {default=0}{type=scalar: 0 or 1}
[142]22; To define the x/y axis with index instead of using
[231]23; the values contained in X/YAXISNAME.
24; x/yaxis = keyword_set(start1) + findgen(jpi/jpj)
[142]25; this forces key_onearth = 0
[33]26;
[172]27; @keyword ZINDEX {default=0}{type=scalar: 0 or 1}
[142]28; To define the z axis with index instead of using
[231]29; the values contained in ZAXISNAME.
30; zaxis = keyword_set(start1) + findgen(jpk)
31;
[142]32; @keyword _EXTRA
[271]33; Used to pass keywords to <pro>computegrid</pro>,
34; <pro>ncdf_getaxis</pro>, <pro>ncdf_getmask</pro> and <pro>isafile</pro>
[33]35;
[142]36; @uses
37; common.pro
[33]38;
[142]39; @restrictions
[231]40; Change the grid parameters (see <pro>computegrid</pro>)
[33]41;
[142]42; @restrictions
[226]43; the file must contain an x and an y axis. (1 ou 2 dimensional array)
[33]44;
[142]45; @examples
[231]46; IDL> initncdf,'toto.nc',glam=[-180,180]
[33]47;
[142]48; @history
[157]49; Sebastien Masson (smasson\@lodyc.jussieu.fr)
[142]50;                      8 May 2002
[33]51;
[142]52; @version
53; $Id$
[33]54;
55;-
[221]56PRO initncdf, ncfilein $
[271]57              , ZAXISNAME = zaxisname, START1 = start1 $
[33]58              , XYINDEX = xyindex, ZINDEX = zindex $
59              , _EXTRA = ex
60;
[114]61  compile_opt idl2, strictarrsubs
62;
[33]63@common
64;----------------------------------------------------------
65; check the name of the file
66  ncfile = isafile(FILENAME = ncfilein, IODIRECTORY = iodir, _extra = ex)
67  if size(ncfile, /type) NE 7 then BEGIN
[236]68    ras = report( 'initncdf cancelled')
[33]69    return
70  endif
71; if the file is stored on tape
[231]72  if !version.os_family EQ 'unix' then spawn, 'file '+ncfile+' > /dev/null'
[33]73;----------------------------------------------------------
74; open the file
75  cdfid = ncdf_open(ncfile)
76; what is inside the file
77  inside = ncdf_inquire(cdfid)
78;----------------------------------------------------------
79; name of the variables
80  namevar = strarr(inside.nvars)
81  for varid = 0, inside.nvars-1 do begin
82    invar = ncdf_varinq(cdfid, varid)
83    namevar[varid] = strlowcase(invar.name)
84  ENDFOR
85;----------------------------------------------------------
[221]86; find the x/yaxis
87 ncdf_getaxis, cdfid, dimidx, dimidy, xaxis, yaxis $
88               , START1 = start1, XYINDEX = xyindex, ROMSGRID = romsgrid, _extra = ex
[33]89;----------------------------------------------------------
90; find the zaxis
[172]91  IF keyword_set(romsgrid) THEN BEGIN
[231]92    FOR i = 0, inside.ndims-1 DO BEGIN
[172]93      ncdf_diminq, cdfid, i, name, size
94      CASE strlowcase(name) OF
95        's_rho':zaxis = reverse(indgen(size))
96        's_u':zaxis = reverse(indgen(size))
97        's_v':zaxis = reverse(indgen(size))
98        's_psi':zaxis = reverse(indgen(size))
99        's_w':zaxis = reverse(indgen(size-1))
100        ELSE:
101      ENDCASE
[231]102    ENDFOR
[172]103    IF (where(namevar EQ 'h'))[0] NE -1 THEN BEGIN
104      ncdf_varget, cdfid, 'h', romsh
105    ENDIF ELSE romsh = -1
[231]106  ENDIF ELSE BEGIN
[172]107    if keyword_set(zaxisname) then zaxisname = strlowcase(zaxisname) ELSE zaxisname = 'z'
108    zvarid = (where(namevar EQ 'nav_lev' or namevar EQ zaxisname OR namevar EQ 'level' OR namevar EQ 'lev' OR strmid(namevar, 0, 5) EQ 'depth'))[0]
109    if zvarid EQ -1 AND inside.ndims GT 3 then begin
[297]110      ras = report( 'initncdf: the zaxis was not found..., check the use of ZAXISNAME keyword if you want to find one...')
[33]111;     stop
[172]112    endif
[33]113; read the zaxis
[172]114    if zvarid NE -1 THEN ncdf_varget, cdfid, zvarid, zaxis
[231]115  ENDELSE
[172]116  IF keyword_set(zindex) AND keyword_set(zaxis) THEN $
117     zaxis = keyword_set(start1) + findgen(n_elements(zaxis))
[33]118;----------------------------------------------------------
119; mask
[271]120  tmask = ncdf_getmask(cdfid, _extra = ex)
121;----------------------------------------------------------
[172]122;
[33]123  ncdf_close, cdfid
124;
[271]125;----------------------------------------------------------
126; call compute the grid
[231]127  if NOT keyword_set(zaxis) then BEGIN
[33]128    computegrid, xaxis = xaxis, yaxis = yaxis $
[231]129                 , mask = tmask, onearth = 1b - keyword_set(xyindex), ROMSH = romsh, _EXTRA = ex
130  ENDIF ELSE BEGIN
[33]131    computegrid, xaxis = xaxis, yaxis = yaxis, zaxis = zaxis $
[172]132                 , mask = tmask, onearth = 1b - keyword_set(xyindex), ROMSH = romsh, _EXTRA = ex
[231]133  ENDELSE
[33]134  IF n_elements(time) EQ 0 THEN time = 0
[231]135  jpt = n_elements(time)
[33]136;----------------------------------------------------------
137
138  return
139end
Note: See TracBrowser for help on using the repository browser.