Commit 9a32c656 authored by Pierre Cazenave's avatar Pierre Cazenave

Change the NetCDF output file variable name and add the scaling factor for the...

Change the NetCDF output file variable name and add the scaling factor for the sigma levels to the NetCDF file
parent fefb97b6
function write_FVCOM_meanflow(Mobj, outfile, data)
function write_FVCOM_meanflow(Mobj, ncfile, data)
% Export mean flow forcing at the open boundary to NetCDF.
%
% function write_FVCOM_meanflow(Mobj, outfile, data)
% function write_FVCOM_meanflow(Mobj, ncfile, datfile, data)
%
% DESCRIPTION:
% Setup an FVCOM hydrographic open boundary mean flow forcing file.
......@@ -9,12 +9,12 @@ function write_FVCOM_meanflow(Mobj, outfile, data)
% INPUT:
% Mobj - MATLAB mesh object (with fields mf_time, siglay, siglev,
% nObcNodes and read_obc_nodes).
% outfile - Output file name.
% ncfile - Output NetCDF file name.
% data - 2D array of mean flow along the open boundary (nobc, time).
%
% OUTPUT:
% FVCOM mean flow values along the FVCOM open boundary in a file named
% outfile.
% FVCOM mean flow values along the FVCOM open boundary in a NETCDF file
% named ncfile.
%
% Author(s):
% Pierre Cazenave (Plymouth Marine Laboratory)
......@@ -32,13 +32,13 @@ if ftbverbose
end
% open new NetCDF file
nc = netcdf.create(outfile, 'clobber');
nc = netcdf.create(ncfile, 'clobber');
% define dimensions
netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'), 'type', 'FVCOM MEANFLOW TIME SERIES FILE')
netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'), 'title', 'FVCOM MEANFLOW TIME SERIES data for open boundary')
netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'), 'history', 'File created using the write_FVCOM_meanflow.m from the MATLAB fvcom-toolbox')
netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'), 'filename', outfile)
netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'), 'filename', ncfile)
netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'), 'Conventions', 'CF-1.0')
% define dimensions
......@@ -87,6 +87,10 @@ netcdf.putVar(nc, time_varid, 0, numel(Mobj.mf_times), Mobj.mf_times);
netcdf.putVar(nc, itime_varid, floor(Mobj.mf_times));
netcdf.putVar(nc, itime2_varid, 0, numel(Mobj.mf_times), mod(Mobj.mf_times, 1) * 24 * 3600 * 1000);
netcdf.putVar(nc, nmfcell_varid, Mobj.read_obc_nodes{1});
% MFDIST is calculated here as the diff of the sigma levels. This should
% work for uniform and gaussian etc. distributions so long as Mobj.siglev
% has the right values in it.
netcdf.putVar(nc, mfdist_varid, repmat(abs(diff(Mobj.siglev)), [numel(Mobj.read_obc_nodes{1}), 1])');
netcdf.putVar(nc, dmfqdis_varid, [0, 0], [numel(Mobj.read_obc_nodes{1}), numel(Mobj.mf_times)], data);
netcdf.close(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