Commit d2c50d1a authored by Pierre Cazenave's avatar Pierre Cazenave

Add some (simple) unit tests to make sure the results of the toolbox functions...

Add some (simple) unit tests to make sure the results of the toolbox functions are maintained between changes.

At the moment, this is only a simple check against an existing result, so it is not particularly comprehensive, but it should sound alarm bells if something has broken catastrophically.

The data against which grid2fvcom is compared is not included in the toolbox as it is too large (and this whole testing thing might be moved to a separate repository if it makes more sense that way).
parent 5b943d34
% Unit test for grid2fvcom.
% Check we always produce the same interpolated values.
% Use some NCEP data for the Irish Sea as the base input. This data is from
% around January, 2001. This includes an unstructured grid object (Mobj),
% the NCEP forcing data struct (forcing) and a 'known good' result
% (forcing_interp) for comparison against the new result.
interpfields = {'uwnd', 'vwnd', 'slp', 'nshf', 'nlwrs', 'nswrs', 'P_E', ...
'Et', 'time', 'lon', 'lat', 'x', 'y'};
% Perform the interpolation using the new routine and check the outputs are
% the same.
forcing_interp_new = grid2fvcom(Mobj, interpfields, forcing);
% Now we have the new results, compare the ranges of values in the old and
% the new to make sure they're the same.
fnames = fieldnames(forcing_interp);
for ff = 1:length(fnames)
node_diff = forcing_interp.(fnames{ff}).node - ...
elem_diff = forcing_interp.(fnames{ff}).data - ...
fprintf('%s min/max of node differences: %f\n', min(node_diff), max(node_diff))
fprintf('%s min/max of element differences: %f\n', min(elem_diff), max(elem_diff))
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