Commit 97f37306 authored by Pierre Cazenave's avatar Pierre Cazenave

Add spatial dimensions to the wind speed data (so it is spatially uniform,...

Add spatial dimensions to the wind speed data (so it is spatially uniform, rather than a point source)
parent 548cdaaf
function write_FVCOM_wind_ts_speed(WindFile, time, u10, v10) function write_FVCOM_wind_ts_speed(Mobj, WindFile, time, u10, v10)
% example file for FVCOM, time-varying/spatially constant wind forcing as speed % example file for FVCOM, time-varying/spatially constant wind forcing as speed
% %
...@@ -8,6 +8,7 @@ function write_FVCOM_wind_ts_speed(WindFile, time, u10, v10) ...@@ -8,6 +8,7 @@ function write_FVCOM_wind_ts_speed(WindFile, time, u10, v10)
% Write a time-varying, spatially constant wind file % Write a time-varying, spatially constant wind file
% %
% INPUT % INPUT
% Mobj - MATLAB mesh object
% WindFile - output NetCDF filename (including path) % WindFile - output NetCDF filename (including path)
% time - time in MJD % time - time in MJD
% u10 - vector x component of wind field 10m above the surface. % u10 - vector x component of wind field 10m above the surface.
...@@ -35,7 +36,7 @@ function write_FVCOM_wind_ts_speed(WindFile, time, u10, v10) ...@@ -35,7 +36,7 @@ function write_FVCOM_wind_ts_speed(WindFile, time, u10, v10)
% MATLAB NetCDF functions for creating the output file, eliminating the % MATLAB NetCDF functions for creating the output file, eliminating the
% need for the third party NetCDF library. Also added three additional % 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 % arguments to the function call (time and u and v vectors). u and v
% vectors vary in time but not (yet) in space). % vectors vary in time but not (yet) in space.
% %
%============================================================================== %==============================================================================
warning off warning off
...@@ -46,6 +47,9 @@ if(ftbverbose); ...@@ -46,6 +47,9 @@ if(ftbverbose);
fprintf(['begin : ' subname '\n']) fprintf(['begin : ' subname '\n'])
end end
nElems = Mobj.nElems;
nNodes = Mobj.nVerts;
%------------------------------------------------------------------------------ %------------------------------------------------------------------------------
% write output to time and spatially-varying FVCOM wind file % write output to time and spatially-varying FVCOM wind file
%------------------------------------------------------------------------------ %------------------------------------------------------------------------------
...@@ -60,6 +64,8 @@ netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),'history','Generated using the ...@@ -60,6 +64,8 @@ netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),'history','Generated using the
% dimensions % dimensions
time_dimid=netcdf.defDim(nc,'time',netcdf.getConstant('NC_UNLIMITED')); time_dimid=netcdf.defDim(nc,'time',netcdf.getConstant('NC_UNLIMITED'));
nele_dimid=netcdf.defDim(nc,'nele',nElems);
nvert_dimid=netcdf.defDim(nc,'nele',nNodes);
% time vars % time vars
time_varid=netcdf.defVar(nc,'time','NC_FLOAT',time_dimid); time_varid=netcdf.defVar(nc,'time','NC_FLOAT',time_dimid);
...@@ -77,18 +83,20 @@ itime2_varid=netcdf.defVar(nc,'Itime2','NC_INT',time_dimid); ...@@ -77,18 +83,20 @@ itime2_varid=netcdf.defVar(nc,'Itime2','NC_INT',time_dimid);
netcdf.putAtt(nc,itime2_varid,'units','msec since 00:00:00'); netcdf.putAtt(nc,itime2_varid,'units','msec since 00:00:00');
netcdf.putAtt(nc,itime2_varid,'time_zone','none'); netcdf.putAtt(nc,itime2_varid,'time_zone','none');
u10_varid=netcdf.defVar(nc,'U10','NC_FLOAT',time_dimid); % Space and time variables
u10_varid=netcdf.defVar(nc,'U10','NC_FLOAT',[time_dimid,nele_dimid]);
netcdf.putAtt(nc,u10_varid,'long_name','Eastward Wind Velocity'); netcdf.putAtt(nc,u10_varid,'long_name','Eastward Wind Velocity');
netcdf.putAtt(nc,u10_varid,'standard_name','Wind Velocity'); netcdf.putAtt(nc,u10_varid,'standard_name','Wind Velocity');
netcdf.putAtt(nc,u10_varid,'units','m/s'); netcdf.putAtt(nc,u10_varid,'units','m/s');
netcdf.putAtt(nc,u10_varid,'type','data'); netcdf.putAtt(nc,u10_varid,'type','data');
v10_varid=netcdf.defVar(nc,'V10','NC_FLOAT',time_dimid); v10_varid=netcdf.defVar(nc,'V10','NC_FLOAT',[time_dimid,nele_dimid]);
netcdf.putAtt(nc,v10_varid,'long_name','Northward Wind Velocity'); netcdf.putAtt(nc,v10_varid,'long_name','Northward Wind Velocity');
netcdf.putAtt(nc,v10_varid,'standard_name','Wind Velocity'); netcdf.putAtt(nc,v10_varid,'standard_name','Wind Velocity');
netcdf.putAtt(nc,v10_varid,'units','m/s'); netcdf.putAtt(nc,v10_varid,'units','m/s');
netcdf.putAtt(nc,v10_varid,'type','data'); netcdf.putAtt(nc,v10_varid,'type','data');
% end definitions % end definitions
netcdf.endDef(nc); netcdf.endDef(nc);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment