Home > fvcom_prepro > write_FVCOM_wind_ts_speed.m

write_FVCOM_wind_ts_speed

PURPOSE ^

Write out time-varying/spatially constant wind forcing as speed.

SYNOPSIS ^

function write_FVCOM_wind_ts_speed(Mobj, WindFile, time, u10, v10)

DESCRIPTION ^

 Write out time-varying/spatially constant wind forcing as speed.

 function write_FVCOM_wind_ts_speed(Mobj, WindFile, time, u10, v10)

 DESCRIPTION:
    Write a time-varying, spatially constant wind file

 INPUT
    Mobj - MATLAB mesh object
    WindFile - output NetCDF filename (including path)
    time - time in MJD
    u10 - vector x component of wind field 10m above the surface.
    v10 - vector y component of wind field 10m above the surface.

 Note: the shape of u10 and v10 must match that of time since this
 currently only outputs temporally varying wind (not spatially varying).

 OUTPUT:
    NetCDF WindFile

 EXAMPLE USAGE
    time = 0:0.25:31;
    write_FVCOM_wind_ts_speed(...
       'casename_wnd.nc',...
       time, ones(size(time)),...
       ones(size(time))*0.25);

 Author(s):
    Geoff Cowles (University of Massachusetts Dartmouth)
    Pierre Cazenave (Plymouth Marine Laboratory)

 Revision history
   2012-10-08 Converted example_FVCOM_wind_ts_speed.m to use built-in
   MATLAB NetCDF functions for creating the output file, eliminating the
   need for the third party NetCDF library. Also added three additional
   arguments to the function call (time and u and v vectors). u and v
   vectors vary in time and space.

==============================================================================
warning off

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function write_FVCOM_wind_ts_speed(Mobj, WindFile, time, u10, v10)
0002 
0003 % Write out time-varying/spatially constant wind forcing as speed.
0004 %
0005 % function write_FVCOM_wind_ts_speed(Mobj, WindFile, time, u10, v10)
0006 %
0007 % DESCRIPTION:
0008 %    Write a time-varying, spatially constant wind file
0009 %
0010 % INPUT
0011 %    Mobj - MATLAB mesh object
0012 %    WindFile - output NetCDF filename (including path)
0013 %    time - time in MJD
0014 %    u10 - vector x component of wind field 10m above the surface.
0015 %    v10 - vector y component of wind field 10m above the surface.
0016 %
0017 % Note: the shape of u10 and v10 must match that of time since this
0018 % currently only outputs temporally varying wind (not spatially varying).
0019 %
0020 % OUTPUT:
0021 %    NetCDF WindFile
0022 %
0023 % EXAMPLE USAGE
0024 %    time = 0:0.25:31;
0025 %    write_FVCOM_wind_ts_speed(...
0026 %       'casename_wnd.nc',...
0027 %       time, ones(size(time)),...
0028 %       ones(size(time))*0.25);
0029 %
0030 % Author(s):
0031 %    Geoff Cowles (University of Massachusetts Dartmouth)
0032 %    Pierre Cazenave (Plymouth Marine Laboratory)
0033 %
0034 % Revision history
0035 %   2012-10-08 Converted example_FVCOM_wind_ts_speed.m to use built-in
0036 %   MATLAB NetCDF functions for creating the output file, eliminating the
0037 %   need for the third party NetCDF library. Also added three additional
0038 %   arguments to the function call (time and u and v vectors). u and v
0039 %   vectors vary in time and space.
0040 %
0041 %==============================================================================
0042 %warning off
0043 subname = 'example_FVCOM_wind_ts_speed';
0044 global ftbverbose;
0045 if(ftbverbose);
0046     fprintf('\n')
0047     fprintf(['begin : ' subname '\n'])
0048 end
0049 
0050 nElems = Mobj.nElems;
0051 nNodes = Mobj.nVerts;
0052 
0053 %------------------------------------------------------------------------------
0054 % write output to time and spatially-varying FVCOM wind file
0055 %------------------------------------------------------------------------------
0056 
0057 nc=netcdf.create(WindFile,'clobber');
0058 
0059 % define global attributes
0060 netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),'references','http://fvcom.smast.umassd.edu')
0061 % netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),'source','single-point time-dependent surface forcing')
0062 netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),'source','fvcom grid (unstructured) surface forcing')
0063 netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),'institution','Plymouth Marine Laboratory')
0064 netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),'history', sprintf('File created with %s from the MATLAB fvcom-toolbox', subname))
0065 
0066 % dimensions
0067 nele_dimid=netcdf.defDim(nc,'nele',nElems);
0068 nvert_dimid=netcdf.defDim(nc,'node',nNodes);
0069 time_dimid=netcdf.defDim(nc,'time',netcdf.getConstant('NC_UNLIMITED'));
0070 
0071 % time vars
0072 time_varid=netcdf.defVar(nc,'time','NC_FLOAT',time_dimid);
0073 netcdf.putAtt(nc,time_varid,'long_name','time');
0074 netcdf.putAtt(nc,time_varid,'units','days since 1858-11-17 00:00:00');
0075 netcdf.putAtt(nc,time_varid,'time_zone','none');
0076 netcdf.putAtt(nc,time_varid,'format','modified julian day (MJD)');
0077 
0078 itime_varid=netcdf.defVar(nc,'Itime','NC_INT',time_dimid);
0079 netcdf.putAtt(nc,itime_varid,'units','days since 1858-11-17 00:00:00');
0080 netcdf.putAtt(nc,itime_varid,'time_zone','none');
0081 netcdf.putAtt(nc,itime_varid,'format','modified julian day (MJD)');
0082 
0083 itime2_varid=netcdf.defVar(nc,'Itime2','NC_INT',time_dimid);
0084 netcdf.putAtt(nc,itime2_varid,'units','msec since 00:00:00');
0085 netcdf.putAtt(nc,itime2_varid,'time_zone','none');
0086 
0087 % Space and time variables
0088 u10_varid=netcdf.defVar(nc,'U10','NC_FLOAT',[nele_dimid,time_dimid]);
0089 netcdf.putAtt(nc,u10_varid,'long_name','Eastward Wind Velocity');
0090 netcdf.putAtt(nc,u10_varid,'standard_name','Wind Velocity');
0091 netcdf.putAtt(nc,u10_varid,'units','m/s');
0092 netcdf.putAtt(nc,u10_varid,'type','data');
0093 
0094 v10_varid=netcdf.defVar(nc,'V10','NC_FLOAT',[nele_dimid,time_dimid]);
0095 netcdf.putAtt(nc,v10_varid,'long_name','Northward Wind Velocity');
0096 netcdf.putAtt(nc,v10_varid,'standard_name','Wind Velocity');
0097 netcdf.putAtt(nc,v10_varid,'units','m/s');
0098 netcdf.putAtt(nc,v10_varid,'type','data');
0099 
0100 
0101 % end definitions
0102 netcdf.endDef(nc);
0103 
0104 % dump time
0105 netcdf.putVar(nc,time_varid,0,numel(time),time);
0106 netcdf.putVar(nc,itime_varid,floor(time));
0107 netcdf.putVar(nc,itime2_varid,0,numel(time),mod(time,1)*24*3600*1000);
0108 netcdf.putVar(nc,u10_varid,[0,0],[nElems,numel(time)],u10);
0109 netcdf.putVar(nc,v10_varid,[0,0],[nElems,numel(time)],v10);
0110 
0111 % close file
0112 netcdf.close(nc);
0113 
0114 if(ftbverbose);
0115     fprintf(['end   : ' subname '\n'])
0116 end
0117 
0118 
0119

Generated on Wed 20-Feb-2019 16:06:01 by m2html © 2005