Home > RPSstuff > write_gnome_curv.m

write_gnome_curv

PURPOSE ^

WRITE_GNOME_CURV Writes curvilinear NOAA/GNOME-compatible NetCDF

SYNOPSIS ^

function []=write_gnome_curv(cdfout,lon,lat,jdmat,u,v,depth,sigma,title);

DESCRIPTION ^

 WRITE_GNOME_CURV Writes curvilinear NOAA/GNOME-compatible NetCDF
 Usage: write_gnome_curv(cdfout,lon,lat,jdmat,u,v,depth,sigma,title);
 Inputs:
     CDFOUT: name for output GNOME-compatible netcdf file
     LON and LAT: 2D arrays of lon/lat (decimal degrees, west negative)
     U, V: 4D arrays (t,z,y,x) of east and north velocity (m/s).  Note
       that it is assumed that u,v are colocated at the lon,lat points and
       indicate true eastward and northward velocities (not grid-relative
       velocities).
     JDMAT: time vector (Matlab DATENUM format)
     DEPTH: 2D array of model depths (m).  Depths should be -99999. or NaN
       at land values.  This will be used to make a land mask.
     SIGMA: sigma level column vector for u,v vertical positions (nondimensional) 
     TITLE:   text string to appear in GNOME file

 Note: Currently GNOME only uses the top layer currents, so to save space
      I only write one layer to the netcdf file.  
      Used this way, U has dimensions (NZ 1 NY NX), and sigma is a single
      arbitrary value (like 0).

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function []=write_gnome_curv(cdfout,lon,lat,jdmat,u,v,depth,sigma,title);
0002 % WRITE_GNOME_CURV Writes curvilinear NOAA/GNOME-compatible NetCDF
0003 % Usage: write_gnome_curv(cdfout,lon,lat,jdmat,u,v,depth,sigma,title);
0004 % Inputs:
0005 %     CDFOUT: name for output GNOME-compatible netcdf file
0006 %     LON and LAT: 2D arrays of lon/lat (decimal degrees, west negative)
0007 %     U, V: 4D arrays (t,z,y,x) of east and north velocity (m/s).  Note
0008 %       that it is assumed that u,v are colocated at the lon,lat points and
0009 %       indicate true eastward and northward velocities (not grid-relative
0010 %       velocities).
0011 %     JDMAT: time vector (Matlab DATENUM format)
0012 %     DEPTH: 2D array of model depths (m).  Depths should be -99999. or NaN
0013 %       at land values.  This will be used to make a land mask.
0014 %     SIGMA: sigma level column vector for u,v vertical positions (nondimensional)
0015 %     TITLE:   text string to appear in GNOME file
0016 %
0017 % Note: Currently GNOME only uses the top layer currents, so to save space
0018 %      I only write one layer to the netcdf file.
0019 %      Used this way, U has dimensions (NZ 1 NY NX), and sigma is a single
0020 %      arbitrary value (like 0).
0021 
0022 % Rich Signell (rsignell@usgs.gov)
0023 % August 23, 2005
0024 
0025 nc=netcdf(cdfout,'clobber');
0026 
0027 [nt,nz,ny,nx]=size(u);
0028 
0029 % dimensions
0030 nc('y')=ny;
0031 nc('x')=nx;
0032 nc('sigma')=nz;
0033 nc('time')=0;   % Time is the unlimited (record) dimension
0034 
0035 % variables
0036 
0037 nc{'lat'}=ncfloat('y','x');
0038 nc{'lat'}.long_name='Latitude';
0039 nc{'lat'}.units='degrees_north';
0040 
0041 nc{'lon'}=ncfloat('y','x');
0042 nc{'lon'}.long_name='Longitude';
0043 nc{'lon'}.units='degrees_east';
0044 
0045 nc{'sigma'}=ncfloat('sigma');
0046 nc{'sigma'}.long_name='Sigma';
0047 nc{'sigma'}.units='sigma_level';
0048 nc{'sigma'}.positive='down';
0049 nc{'sigma'}.standard_name='ocean_sigma_coordinate';
0050 nc{'sigma'}.formula_terms='sigma: sigma eta:zeta depth:depth';
0051 
0052 nc{'mask'}=ncfloat('y','x');
0053 nc{'mask'}.long_name='land mask';
0054 nc{'mask'}.units='nondimensional';
0055 
0056 nc{'time'}=ncfloat('time');
0057 nc{'time'}.long_name='Time';
0058 nc{'time'}.units=['hours since 2000-01-01 00:00:00 00:00'];
0059 
0060 nc{'depth'}=ncfloat('y','x');
0061 nc{'depth'}.long_name='Bathymetry';
0062 nc{'depth'}.units='meters';
0063 
0064 nc{'u'}=ncshort('time','sigma','y','x');
0065 nc{'u'}.long_name='Eastward Water Velocity';
0066 nc{'u'}.units='m/s';
0067 nc{'u'}.FillValue_=ncshort(-9999);
0068 nc{'u'}.scale_factor=ncfloat(0.01);
0069 nc{'u'}.add_offset=ncfloat(0.0);
0070 
0071 
0072 nc{'v'}=ncshort('time','sigma','y','x');
0073 nc{'v'}.long_name='Northward Water Velocity';
0074 nc{'v'}.units='m/s';
0075 nc{'v'}.FillValue_=ncshort(-9999);
0076 nc{'v'}.scale_factor=ncfloat(0.01);
0077 nc{'v'}.add_offset=ncfloat(0.0);
0078 
0079 
0080 nc.Conventions='COARDS';
0081 nc.file_type='Full_Grid';
0082 nc.grid_type='CURVILINEAR';
0083 nc.z_type='sigma';
0084 nc.model='POM';
0085 nc.title=title;
0086 
0087 % depth & land mask
0088 iland=find(isnan(depth) | depth==-99999.);
0089 
0090 mask=ones(size(depth));
0091 mask(iland)=0;
0092 
0093 nc{'time'}(1:nt)=(jdmat-datenum([2000 1 1 0 0 0]))*24;   % convert from Matlab time
0094 nc{'lat'}(:)=lat;
0095 nc{'lon'}(:)=lon;
0096 nc{'sigma'}(:)=abs(sigma);
0097 nc{'depth'}(:)=depth;
0098 nc{'mask'}(:)=mask;
0099 nc{'u',1}(1:nt,:,:,:)=u;
0100 nc{'v',1}(1:nt,:,:,:)=v;
0101 
0102 close(nc);

Generated on Wed 30-Nov-2005 14:45:02 by m2html © 2003