diff --git a/doc/index.html b/doc/index.html index 05234dbea2ad576c4adcda7071cc2b143fdcd48b..d9387d0e9a47c32f5fcd508c60120495ea29e313 100755 --- a/doc/index.html +++ b/doc/index.html @@ -3,8 +3,8 @@ Matlab Index - - + + @@ -15,7 +15,7 @@

Matlab Index

Matlab Directories

+
  • fvcom_postproc
  • fvcom_prepro
  • swan_scripts
  • tests/utilities
  • utilities
  • Matlab Files found in these Directories

    @@ -27,43 +27,43 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ST_example example2 inCell smoothfield
    ST_phi2d example_FVCOM_river inbox smoothfield2
    ST_summary example_FVCOM_tsobc inkmlbb swan2netcdf
    ST_taucr example_FVCOM_wind_ts interp_POLCOMS2FVCOM transect_nodes_screen
    ST_wentworth example_FVCOM_wind_ts_speed isintriangle tri_from_bndry
    ST_wset example_fetchcalc julian2greg truncfield
    SW_Density example_init_lag lat_to_m utm2deg
    SW_Kviscosity example_my_project lon_to_m wave_fric
    SW_Viscosity example_surface_plot m_ll2ll wgs2utm
    add_coriolis fetch_calc m_to_lat wrf2fvcom_U10V10
    add_obc_nodes_graphic find_boundary_elements m_to_lon write_FVCOM_bath
    add_obc_nodes_list find_nearest_pt make_blank_mesh write_FVCOM_bedflag
    add_river_nodes_graphic fix_inside_boundary mjul2str write_FVCOM_cor
    add_river_nodes_list fvcom2swan mjul2str2 write_FVCOM_elevtide
    add_sigma_forDT gen_semistructured_mesh mjulian2greg write_FVCOM_forcing
    add_sponge_nodes gen_unstructured_mesh my_project write_FVCOM_grid
    add_sponge_nodes_list generate_mjd naut_2_cart write_FVCOM_meanflow
    add_stations_list get_AMM nodes2elems write_FVCOM_meanflow_ascii
    add_var_FVCOM_river get_FVCOM_rivers pl64 write_FVCOM_obc
    calc_fetch get_HYCOM_forcing plot_field write_FVCOM_obs_TS
    calc_sponge_radius get_MetUM_forcing plot_swan_mesh write_FVCOM_restart
    calc_tauw get_NAE2_forcing plotunswan write_FVCOM_river
    calc_tauw get_NCEP_forcing read_ERA_wind write_FVCOM_river_nml
    catstruct get_NCEP_year read_NCEP_wind write_FVCOM_spectide
    centroid get_POLCOMS_meanflow read_fvcom_bath write_FVCOM_sponge
    check_wset get_POLCOMS_netCDF read_fvcom_mesh write_FVCOM_stations
    connectivity get_POLCOMS_river_discharge read_fvcom_mesh write_FVCOM_tsobc
    deg2utm get_POLCOMS_river_positions read_kml write_FVCOM_wind_ts_speed
    do_ph_change_plot get_POLCOMS_tsobc read_netCDF_FVCOM write_FVCOM_z0
    do_ph_change_points_plot get_POLCOMS_tsobc_gcoms read_sigma write_SMS_2dm
    do_ph_max_change_plot get_POLPRED_spectide read_sms_map write_SMS_cst
    do_ph_vertical_profile get_fetch read_sms_mesh write_dtank
    do_residual get_runs read_specfile write_river_info
    do_residual_plot get_runs_test readdir ww3_to_swan_bndry
    do_surface_plot get_zeta_xtide runmean zero_to_nan
    do_transect_plot ginput2 set_elevtide
    do_vector_plot greg2julian set_spectide
    ST_taucr example_FVCOM_wind_ts interp_POLCOMS2FVCOM test_get_POLCOMS_tsobc
    ST_wentworth example_FVCOM_wind_ts_speed isintriangle test_grid2fvcom
    ST_wset example_fetchcalc julian2greg transect_nodes_screen
    SW_Density example_init_lag lat_to_m tri_from_bndry
    SW_Kviscosity example_my_project lon_to_m truncfield
    SW_Viscosity example_surface_plot m_ll2ll utm2deg
    add_coriolis fetch_calc m_to_lat wave_fric
    add_obc_nodes_graphic find_boundary_elements m_to_lon wgs2utm
    add_obc_nodes_list find_nearest_pt make_blank_mesh wrf2fvcom_U10V10
    add_river_nodes_graphic fix_inside_boundary mjul2str write_FVCOM_bath
    add_river_nodes_list fvcom2swan mjul2str2 write_FVCOM_bedflag
    add_sigma_forDT gen_semistructured_mesh mjulian2greg write_FVCOM_cor
    add_sponge_nodes gen_unstructured_mesh my_project write_FVCOM_elevtide
    add_sponge_nodes_list generate_mjd naut_2_cart write_FVCOM_forcing
    add_stations_list get_AMM nodes2elems write_FVCOM_grid
    add_var_FVCOM_river get_FVCOM_rivers pl64 write_FVCOM_meanflow
    calc_fetch get_HYCOM_forcing plot_field write_FVCOM_meanflow_ascii
    calc_sponge_radius get_MetUM_forcing plot_swan_mesh write_FVCOM_obc
    calc_tauw get_NAE2_forcing plotunswan write_FVCOM_obs_TS
    calc_tauw get_NCEP_forcing read_ERA_wind write_FVCOM_restart
    catstruct get_NCEP_year read_NCEP_wind write_FVCOM_river
    centroid get_POLCOMS_meanflow read_fvcom_bath write_FVCOM_river_nml
    check_wset get_POLCOMS_netCDF read_fvcom_mesh write_FVCOM_spectide
    connectivity get_POLCOMS_river_discharge read_fvcom_mesh write_FVCOM_sponge
    deg2utm get_POLCOMS_river_positions read_kml write_FVCOM_stations
    do_ph_change_plot get_POLCOMS_tsobc read_netCDF_FVCOM write_FVCOM_tsobc
    do_ph_change_points_plot get_POLCOMS_tsobc_gcoms read_sigma write_FVCOM_wind_ts_speed
    do_ph_max_change_plot get_POLPRED_spectide read_sms_map write_FVCOM_z0
    do_ph_vertical_profile get_fetch read_sms_mesh write_SMS_2dm
    do_residual get_runs read_specfile write_SMS_cst
    do_residual_plot get_runs_test readdir write_dtank
    do_surface_plot get_zeta_xtide runmean write_river_info
    do_transect_plot ginput2 set_elevtide ww3_to_swan_bndry
    do_vector_plot greg2julian set_spectide zero_to_nan
    do_volume greg2mjulian setup_metrics
    -
    Generated on Tue 04-Jun-2013 12:12:53 by m2html © 2005
    +
    Generated on Tue 04-Jun-2013 12:21:19 by m2html © 2005
    \ No newline at end of file diff --git a/doc/tests/utilities/graph.dot b/doc/tests/utilities/graph.dot new file mode 100644 index 0000000000000000000000000000000000000000..dfe5d3d683769d4f9776bf77dd0fda143f574c24 --- /dev/null +++ b/doc/tests/utilities/graph.dot @@ -0,0 +1,6 @@ +/* Created by mdot for Matlab */ +digraph m2html { + + test_get_POLCOMS_tsobc [URL="test_get_POLCOMS_tsobc.html"]; + test_grid2fvcom [URL="test_grid2fvcom.html"]; +} \ No newline at end of file diff --git a/doc/tests/utilities/graph.html b/doc/tests/utilities/graph.html new file mode 100644 index 0000000000000000000000000000000000000000..1868bb248e153b14ea4386db0e7a87c59be5234f --- /dev/null +++ b/doc/tests/utilities/graph.html @@ -0,0 +1,29 @@ + + + + Dependency Graph for tests/utilities + + + + + + + + + + +
    < Master indexIndex for tests/utilities >
    +

    Dependency Graph for tests/utilities

    + +
    +Dependency Graph for tests/utilities + + + + +
    + +
    Generated on Tue 04-Jun-2013 12:21:23 by m2html © 2005
    + + \ No newline at end of file diff --git a/doc/tests/utilities/graph.map b/doc/tests/utilities/graph.map new file mode 100644 index 0000000000000000000000000000000000000000..6ea70c93171af2e588803bdf678524efb93f7816 --- /dev/null +++ b/doc/tests/utilities/graph.map @@ -0,0 +1,2 @@ + + diff --git a/doc/tests/utilities/graph.png b/doc/tests/utilities/graph.png new file mode 100644 index 0000000000000000000000000000000000000000..f7a682262f88cd4999badd8e8e0089057d1e7e1d Binary files /dev/null and b/doc/tests/utilities/graph.png differ diff --git a/doc/tests/utilities/index.html b/doc/tests/utilities/index.html new file mode 100644 index 0000000000000000000000000000000000000000..df1670b4aa955c1ec3bf26184a4724dbe18e2ccb --- /dev/null +++ b/doc/tests/utilities/index.html @@ -0,0 +1,32 @@ + + + + Index for Directory tests/utilities + + + + + + + + + + +
    < Master indexIndex for tests/utilities >
    + +

    Index for tests/utilities

    + +

    Matlab files in this directory:

    + +
     test_get_POLCOMS_tsobcUnit test for get_POLCOMS_tsobc.
     test_grid2fvcomUnit test for grid2fvcom.
    + + + +

    Dependency Graph

    + +
    Generated on Tue 04-Jun-2013 12:21:21 by m2html © 2005
    + + \ No newline at end of file diff --git a/doc/tests/utilities/test_get_POLCOMS_tsobc.html b/doc/tests/utilities/test_get_POLCOMS_tsobc.html new file mode 100644 index 0000000000000000000000000000000000000000..f307101242c01cf7d4c74af77b44f1348bae670b --- /dev/null +++ b/doc/tests/utilities/test_get_POLCOMS_tsobc.html @@ -0,0 +1,287 @@ + + + + Description of test_get_POLCOMS_tsobc + + + + + + + + + +
    Home > tests > utilities > test_get_POLCOMS_tsobc.m
    + + + +

    test_get_POLCOMS_tsobc +

    + +

    PURPOSE ^

    +
    Unit test for get_POLCOMS_tsobc.
    + +

    SYNOPSIS ^

    +
    This is a script file.
    + +

    DESCRIPTION ^

    +
     Unit test for get_POLCOMS_tsobc.
    +
    + DESCRIPTION:
    +   Currently checks against a reference data set for the following:
    +       - number of nodes in the output
    +       - number of sigma layers in the output
    +       - number of time steps in the output
    +       - range of values in the node arrays
    +
    + It uses a simplified POLCOMS NetCDF file from January, 2001 as the base
    + input. The mesh object (Mobj) contains the required input for
    + get_POLCOMS_tsobc as well as a set of 'known good' results
    + (Mobj.temperature, Mobj.salt and Mobj.ts_times) for comparison against
    + the new result.
    +
    + Author(s):
    +   Pierre Cazenave (Plymouth Marine Laboratory)
    +
    + Revision history:
    +   2013-05-17 First version.
    +
    +==========================================================================
    + + +

    CROSS-REFERENCE INFORMATION ^

    +This function calls: + +This function is called by: + + + + + +

    SOURCE CODE ^

    +
    0001 % Unit test for get_POLCOMS_tsobc.
    +0002 %
    +0003 % DESCRIPTION:
    +0004 %   Currently checks against a reference data set for the following:
    +0005 %       - number of nodes in the output
    +0006 %       - number of sigma layers in the output
    +0007 %       - number of time steps in the output
    +0008 %       - range of values in the node arrays
    +0009 %
    +0010 % It uses a simplified POLCOMS NetCDF file from January, 2001 as the base
    +0011 % input. The mesh object (Mobj) contains the required input for
    +0012 % get_POLCOMS_tsobc as well as a set of 'known good' results
    +0013 % (Mobj.temperature, Mobj.salt and Mobj.ts_times) for comparison against
    +0014 % the new result.
    +0015 %
    +0016 % Author(s):
    +0017 %   Pierre Cazenave (Plymouth Marine Laboratory)
    +0018 %
    +0019 % Revision history:
    +0020 %   2013-05-17 First version.
    +0021 %
    +0022 %==========================================================================
    +0023 
    +0024 matlabrc
    +0025 close all
    +0026 clc
    +0027 
    +0028 addpath('/users/modellers/pica/Code/fvcom-toolbox/utilities')
    +0029 addpath('/users/modellers/pica/Code/fvcom-toolbox/fvcom_prepro/')
    +0030 
    +0031 % Temporary paths when on Riqui's machine
    +0032 addpath('/tmp/pica/fvcom-toolbox/fvcom_prepro/')
    +0033 addpath('/tmp/pica/fvcom-toolbox/utilities/')
    +0034 
    +0035 load('/tmp/pica/fvcom-toolbox/tests/data/get_POLCOMS_tsobc_data.mat');
    +0036 
    +0037 % Perform the interpolation using the new routine.
    +0038 obc_ts = {'/tmp/pica/fvcom-toolbox/tests/data/Daily.PolcomsErsem.2001.01.nc'};
    +0039 Mobj_new = get_POLCOMS_tsobc(Mobj, obc_ts);
    +0040 
    +0041 % Check we have the temperature, salinity and time fields in the new mesh
    +0042 % object.
    +0043 fnames = fieldnames(Mobj_new);
    +0044 
    +0045 for ff = 1:length(fnames)
    +0046     switch fnames{ff}
    +0047         case {'temperature', 'salt', 'ts_times'}
    +0048             assert(isfield(Mobj_new, fnames{ff}), 'Missing field %s', fnames{ff})
    +0049     end
    +0050 end
    +0051 
    +0052 % Clear out fields which don't exist in both Mobj and Mobj_new.
    +0053 fnames = intersect(fnames, fieldnames(Mobj));
    +0054 
    +0055 %%
    +0056 
    +0057 results = struct();
    +0058 
    +0059 for ff = 1:length(fnames)
    +0060 
    +0061     results.(fnames{ff}) = struct();
    +0062 
    +0063     switch fnames{ff}
    +0064         case {'siglayz', 'lon', 'lat', 'obc_nodes', 'nObcNodes', 'ts_times'}
    +0065 
    +0066             results.(fnames{ff}).vectorValues = 'FAIL';
    +0067 
    +0068             results.(fnames{ff}).check = ...
    +0069                 Mobj.(fnames{ff}) - Mobj_new.(fnames{ff});
    +0070             checkDiff = max(results.(fnames{ff}).check) - ...
    +0071                 min(results.(fnames{ff}).check);
    +0072             if checkDiff == 0
    +0073                 results.(fnames{ff}).vectorValues = 'PASS';
    +0074             end
    +0075 
    +0076         otherwise
    +0077 
    +0078             %--------------------------------------------------------------
    +0079             % Set the pass/fail flags for the tests. Assume fail and only
    +0080             % change if proven otherwise.
    +0081             %--------------------------------------------------------------
    +0082             results.(fnames{ff}).nodeNumber = 'FAIL';
    +0083             results.(fnames{ff}).elementNumber = 'FAIL';
    +0084             results.(fnames{ff}).numNodeTimes = 'FAIL';
    +0085             results.(fnames{ff}).nodeValues = 'FAIL';
    +0086 
    +0087             %--------------------------------------------------------------
    +0088             % Check we have the same number of points and time steps in the
    +0089             % new interpolation as in the original.
    +0090             %--------------------------------------------------------------
    +0091             [~, results.(fnames{ff}).origNodeTimes] = ...
    +0092                 size(Mobj.(fnames{ff}));
    +0093             [results.(fnames{ff}).nNodes, ...
    +0094                 results.(fnames{ff}).nNodeTimes] = ...
    +0095                 size(Mobj_new.(fnames{ff}));
    +0096 
    +0097             if results.(fnames{ff}).nNodes == Mobj.nVerts
    +0098                 results.(fnames{ff}).nodeNumber = 'PASS';
    +0099             end
    +0100             if results.(fnames{ff}).nNodeTimes == ...
    +0101                     results.(fnames{ff}).origNodeTimes
    +0102                 results.(fnames{ff}).numNodeTimes = 'PASS';
    +0103             end
    +0104 
    +0105             %--------------------------------------------------------------
    +0106             % Check the values in the node and element arrays match to
    +0107             % reference values.
    +0108             %--------------------------------------------------------------
    +0109             results.(fnames{ff}).nodeDiff = ...
    +0110                 Mobj.(fnames{ff}) - ...
    +0111                 Mobj_new.(fnames{ff});
    +0112 
    +0113             results.(fnames{ff}).nodeRange = ...
    +0114                 max(results.(fnames{ff}).nodeDiff(:)) - ...
    +0115                 min(results.(fnames{ff}).nodeDiff(:));
    +0116 
    +0117             if nodeRange == 0
    +0118                 results.(fnames{ff}).nodeValues = 'PASS';
    +0119             end
    +0120     end
    +0121 end
    +0122 
    +0123 %%
    +0124 %--------------------------------------------------------------------------
    +0125 % Print a summary of the testing
    +0126 %--------------------------------------------------------------------------
    +0127 totalTests = 0;
    +0128 totalPasses = 0;
    +0129 
    +0130 for ff = 1:length(fnames)
    +0131     resultnames = fieldnames(results.(fnames{ff}));
    +0132     numRes = length(resultnames);
    +0133 
    +0134     for fi = 1:numRes
    +0135 
    +0136         % Skip if the field is not a string (we're only interested in
    +0137         % pass/fail really.
    +0138         if ~ischar(results.(fnames{ff}).(resultnames{fi}))
    +0139             continue
    +0140         else
    +0141             % Increment the number of tests performed.
    +0142             totalTests = totalTests + 1;
    +0143         end
    +0144 
    +0145         % Get the total number of PASSed tests.
    +0146         if strcmp(results.(fnames{ff}).(resultnames{fi}), 'PASS')
    +0147             totalPasses = totalPasses + 1;
    +0148         end
    +0149 
    +0150         S = results.(fnames{ff}).(resultnames{fi});
    +0151 
    +0152         switch resultnames{fi}
    +0153             case 'vectorValues'
    +0154                 fprintf('%s %s values test\n', S, fnames{ff})
    +0155                 if strcmp(S, 'FAIL')
    +0156                     fprintf('\tmin/max of %s range: %f, %f\n', ...
    +0157                         fnames{ff}, ...
    +0158                         min(results.(fnames{ff}).check), ...
    +0159                         max(results.(fnames{ff}).check))
    +0160                 end
    +0161 
    +0162             case 'nodeNumber'
    +0163                 fprintf('%s %s node number test\n', S, fnames{ff})
    +0164                 if strcmp(S, 'FAIL')
    +0165                     fprintf('\toriginal/new number of %s nodes: %d, %d\n', ...
    +0166                         fnames{ff}, ...
    +0167                         Mobj.nVerts, ...
    +0168                         results.(fnames{ff}).nNodes)
    +0169                 end
    +0170 
    +0171             case 'elementNumber'
    +0172                 fprintf('%s %s element number test\n', S, fnames{ff})
    +0173                 if strcmp(S, 'FAIL')
    +0174                     fprintf('\toriginal/new number of %s elements: %d, %d\n', ...
    +0175                         fnames{ff}, ...
    +0176                         Mobj.nElems, ...
    +0177                         results.(fnames{ff}).nElems)
    +0178                 end
    +0179 
    +0180             case 'numNodeTimes'
    +0181                 fprintf('%s %s node time steps test\n', S, fnames{ff})
    +0182                 if strcmp(S, 'FAIL')
    +0183                     fprintf('\toriginal/new number of %s node times: %d, %d\n', ...
    +0184                         fnames{ff}, ...
    +0185                         results.(fnames{ff}).origNodeTimes, ...
    +0186                         results.(fnames{ff}).nNodeTimes)
    +0187                 end
    +0188 
    +0189             case 'numElementTimes'
    +0190                 fprintf('%s %s element time steps test\n', S, fnames{ff})
    +0191                 if strcmp(S, 'FAIL')
    +0192                     fprintf('\toriginal/new number of %s element times: %d, %d\n', ...
    +0193                         fnames{ff}, ...
    +0194                         results.(fnames{ff}).origElementTimes, ...
    +0195                         results.(fnames{ff}).nElementTimes)
    +0196                 end
    +0197 
    +0198             case 'nodeValues'
    +0199                 fprintf('%s %s node values test\n', S, fnames{ff})
    +0200                 if strcmp(S, 'FAIL')
    +0201                     fprintf('\trange of %s node values: %d\n', ...
    +0202                         fnames{ff}, ...
    +0203                         results.(fnames{ff}).nodeRange)
    +0204                 end
    +0205 
    +0206             case 'elementValues'
    +0207                 fprintf('%s %s element values test\n', S, fnames{ff})
    +0208                 if strcmp(S, 'FAIL')
    +0209                     fprintf('\trange of %s element values: %d\n', ...
    +0210                         fnames{ff}, ...
    +0211                         results.(fnames{ff}).elemRange)
    +0212                 end
    +0213         end
    +0214     end
    +0215 end
    +0216 
    +0217 fprintf('\n------------------SUMMARY------------------\n')
    +0218 fprintf('           %d of %d tests passed', totalPasses, totalTests)
    +0219 fprintf('\n-------------------------------------------\n')
    +
    Generated on Tue 04-Jun-2013 12:21:29 by m2html © 2005
    + + \ No newline at end of file diff --git a/doc/tests/utilities/test_grid2fvcom.html b/doc/tests/utilities/test_grid2fvcom.html new file mode 100644 index 0000000000000000000000000000000000000000..d902ea933fc33948d8fb38012b1e39bd61403e3c --- /dev/null +++ b/doc/tests/utilities/test_grid2fvcom.html @@ -0,0 +1,308 @@ + + + + Description of test_grid2fvcom + + + + + + + + + +
    Home > tests > utilities > test_grid2fvcom.m
    + + + +

    test_grid2fvcom +

    + +

    PURPOSE ^

    +
    Unit test for grid2fvcom.
    + +

    SYNOPSIS ^

    +
    This is a script file.
    + +

    DESCRIPTION ^

    +
     Unit test for grid2fvcom.
    +
    + DESCRIPTION:
    +   Currently checks against a reference data set for the following:
    +       - number of nodes in the output
    +       - number of elements in the output
    +       - number of time steps in the output
    +       - range of values in the node arrays
    +       - range of values in the element arrays
    +
    + It uses some NCEP data for the Irish Sea as the base input. This data is
    + from 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.
    +
    + Author(s):
    +   Pierre Cazenave (Plymouth Marine Laboratory)
    +
    + Revision history:
    +   2013-05-17 First version.
    +
    +==========================================================================
    + + +

    CROSS-REFERENCE INFORMATION ^

    +This function calls: + +This function is called by: + + + + + +

    SOURCE CODE ^

    +
    0001 % Unit test for grid2fvcom.
    +0002 %
    +0003 % DESCRIPTION:
    +0004 %   Currently checks against a reference data set for the following:
    +0005 %       - number of nodes in the output
    +0006 %       - number of elements in the output
    +0007 %       - number of time steps in the output
    +0008 %       - range of values in the node arrays
    +0009 %       - range of values in the element arrays
    +0010 %
    +0011 % It uses some NCEP data for the Irish Sea as the base input. This data is
    +0012 % from January, 2001. This includes an unstructured grid object (Mobj), the
    +0013 % NCEP forcing data struct (forcing) and a 'known good' result
    +0014 % (forcing_interp) for comparison against the new result.
    +0015 %
    +0016 % Author(s):
    +0017 %   Pierre Cazenave (Plymouth Marine Laboratory)
    +0018 %
    +0019 % Revision history:
    +0020 %   2013-05-17 First version.
    +0021 %
    +0022 %==========================================================================
    +0023 
    +0024 matlabrc
    +0025 close all
    +0026 clc
    +0027 
    +0028 addpath('/users/modellers/pica/Code/fvcom-toolbox/utilities')
    +0029 addpath('/users/modellers/pica/Code/fvcom-toolbox/fvcom_prepro/')
    +0030 
    +0031 % Temporary paths when on Riqui's machine
    +0032 addpath('/tmp/pica/fvcom-toolbox/fvcom_prepro/')
    +0033 addpath('/tmp/pica/fvcom-toolbox/utilities/')
    +0034 
    +0035 load('/tmp/pica/fvcom-toolbox/tests/data/grid2fvcom_data.mat');
    +0036 
    +0037 interpfields = {'uwnd', 'vwnd', 'slp', 'nshf', 'nlwrs', 'nswrs', 'P_E', ...
    +0038     'Et', 'time', 'lon', 'lat', 'x', 'y'};
    +0039 
    +0040 % Perform the interpolation using the new routine and check the outputs are
    +0041 % the same.
    +0042 forcing_interp_new = grid2fvcom(Mobj, interpfields, forcing);
    +0043 
    +0044 % Check we have the same number of fields (if we don't, we can't go any
    +0045 % further).
    +0046 fnames = fieldnames(forcing_interp);
    +0047 if length(fnames) ~= length(fieldnames(forcing_interp_new))
    +0048     error(['The number of reference struct field names (%d) does', ...
    +0049         ' not equal the number in the new struct (%d)'], ...
    +0050         length(fnames), length(fieldnames(forcing_interp_new)))
    +0051 end
    +0052 
    +0053 %%
    +0054 
    +0055 results = struct();
    +0056 
    +0057 for ff = 1:length(fnames)
    +0058 
    +0059     results.(fnames{ff}) = struct();
    +0060 
    +0061     switch fnames{ff}
    +0062         case {'time', 'lon', 'lat', 'x', 'y'}
    +0063 
    +0064             results.(fnames{ff}).vectorValues = 'FAIL';
    +0065 
    +0066             results.(fnames{ff}).check = ...
    +0067                 forcing_interp.(fnames{ff}) - forcing_interp_new.(fnames{ff});
    +0068             checkDiff = max(results.(fnames{ff}).check) - ...
    +0069                 min(results.(fnames{ff}).check);
    +0070             if checkDiff == 0
    +0071                 results.(fnames{ff}).vectorValues = 'PASS';
    +0072             end
    +0073 
    +0074         otherwise
    +0075 
    +0076             %--------------------------------------------------------------
    +0077             % Set the pass/fail flags for the tests. Assume fail and only
    +0078             % change if proven otherwise.
    +0079             %--------------------------------------------------------------
    +0080             results.(fnames{ff}).nodeNumber = 'FAIL';
    +0081             results.(fnames{ff}).elementNumber = 'FAIL';
    +0082             results.(fnames{ff}).numNodeTimes = 'FAIL';
    +0083             results.(fnames{ff}).numElementTimes = 'FAIL';
    +0084             results.(fnames{ff}).nodeValues = 'FAIL';
    +0085             results.(fnames{ff}).elementValues = 'FAIL';
    +0086 
    +0087             %--------------------------------------------------------------
    +0088             % Check we have the same number of points and time steps in the
    +0089             % new interpolation as in the original.
    +0090             %--------------------------------------------------------------
    +0091             [~, results.(fnames{ff}).origNodeTimes] = ...
    +0092                 size(forcing_interp.(fnames{ff}).node);
    +0093             [~, results.(fnames{ff}).origElementTimes] = ...
    +0094                 size(forcing_interp.(fnames{ff}).data);
    +0095             [results.(fnames{ff}).nNodes, ...
    +0096                 results.(fnames{ff}).nNodeTimes] = ...
    +0097                 size(forcing_interp_new.(fnames{ff}).node);
    +0098             [results.(fnames{ff}).nElems, ...
    +0099                 results.(fnames{ff}).nElementTimes] = ...
    +0100                 size(forcing_interp_new.(fnames{ff}).data);
    +0101 
    +0102             if results.(fnames{ff}).nNodes == Mobj.nVerts
    +0103                 results.(fnames{ff}).nodeNumber = 'PASS';
    +0104             end
    +0105             if results.(fnames{ff}).nElems == Mobj.nElems
    +0106                 results.(fnames{ff}).elementNumber = 'PASS';
    +0107             end
    +0108             if results.(fnames{ff}).nNodeTimes == ...
    +0109                     results.(fnames{ff}).origNodeTimes
    +0110                 results.(fnames{ff}).numNodeTimes = 'PASS';
    +0111             end
    +0112             if results.(fnames{ff}).nElementTimes == ...
    +0113                     results.(fnames{ff}).origElementTimes
    +0114                 results.(fnames{ff}).numElementTimes = 'PASS';
    +0115             end
    +0116 
    +0117             %--------------------------------------------------------------
    +0118             % Check the values in the node and element arrays match to
    +0119             % reference values.
    +0120             %--------------------------------------------------------------
    +0121             results.(fnames{ff}).nodeDiff = ...
    +0122                 forcing_interp.(fnames{ff}).node - ...
    +0123                 forcing_interp_new.(fnames{ff}).node;
    +0124             results.(fnames{ff}).elemDiff = ...
    +0125                 forcing_interp.(fnames{ff}).data - ...
    +0126                 forcing_interp_new.(fnames{ff}).data;
    +0127 
    +0128             results.(fnames{ff}).nodeRange = ...
    +0129                 max(results.(fnames{ff}).nodeDiff(:)) - ...
    +0130                 min(results.(fnames{ff}).nodeDiff(:));
    +0131             results.(fnames{ff}).elemRange = ...
    +0132                 max(results.(fnames{ff}).elemDiff(:)) - ...
    +0133                 min(results.(fnames{ff}).elemDiff(:));
    +0134 
    +0135             if results.(fnames{ff}).nodeRange == 0
    +0136                 results.(fnames{ff}).nodeValues = 'PASS';
    +0137             end
    +0138             if results.(fnames{ff}).elemRange == 0;
    +0139                 results.(fnames{ff}).elementValues = 'PASS';
    +0140             end
    +0141     end
    +0142 end
    +0143 
    +0144 %%
    +0145 %--------------------------------------------------------------------------
    +0146 % Print a summary of the testing
    +0147 %--------------------------------------------------------------------------
    +0148 totalTests = 0;
    +0149 totalPasses = 0;
    +0150 
    +0151 for ff = 1:length(fnames)
    +0152     resultnames = fieldnames(results.(fnames{ff}));
    +0153     numRes = length(resultnames);
    +0154 
    +0155     for fi = 1:numRes
    +0156 
    +0157         % Skip if the field is not a string (we're only interested in
    +0158         % pass/fail really.
    +0159         if ~ischar(results.(fnames{ff}).(resultnames{fi}))
    +0160             continue
    +0161         else
    +0162             % Increment the number of tests performed.
    +0163             totalTests = totalTests + 1;
    +0164         end
    +0165 
    +0166         % Get the total number of PASSed tests.
    +0167         if strcmp(results.(fnames{ff}).(resultnames{fi}), 'PASS')
    +0168             totalPasses = totalPasses + 1;
    +0169         end
    +0170 
    +0171         S = results.(fnames{ff}).(resultnames{fi});
    +0172 
    +0173         switch resultnames{fi}
    +0174             case 'vectorValues'
    +0175                 fprintf('%s %s values test\n', S, fnames{ff})
    +0176                 if strcmp(S, 'FAIL')
    +0177                     fprintf('\tmin/max of %s range: %f, %f\n', ...
    +0178                         fnames{ff}, ...
    +0179                         min(results.(fnames{ff}).check), ...
    +0180                         max(results.(fnames{ff}).check))
    +0181                 end
    +0182 
    +0183             case 'nodeNumber'
    +0184                 fprintf('%s %s node number test\n', S, fnames{ff})
    +0185                 if strcmp(S, 'FAIL')
    +0186                     fprintf('\toriginal/new number of %s nodes: %d, %d\n', ...
    +0187                         fnames{ff}, ...
    +0188                         Mobj.nVerts, ...
    +0189                         results.(fnames{ff}).nNodes)
    +0190                 end
    +0191 
    +0192             case 'elementNumber'
    +0193                 fprintf('%s %s element number test\n', S, fnames{ff})
    +0194                 if strcmp(S, 'FAIL')
    +0195                     fprintf('\toriginal/new number of %s elements: %d, %d\n', ...
    +0196                         fnames{ff}, ...
    +0197                         Mobj.nElems, ...
    +0198                         results.(fnames{ff}).nElems)
    +0199                 end
    +0200 
    +0201             case 'numNodeTimes'
    +0202                 fprintf('%s %s node time steps test\n', S, fnames{ff})
    +0203                 if strcmp(S, 'FAIL')
    +0204                     fprintf('\toriginal/new number of %s node times: %d, %d\n', ...
    +0205                         fnames{ff}, ...
    +0206                         results.(fnames{ff}).origNodeTimes, ...
    +0207                         results.(fnames{ff}).nNodeTimes)
    +0208                 end
    +0209 
    +0210             case 'numElementTimes'
    +0211                 fprintf('%s %s element time steps test\n', S, fnames{ff})
    +0212                 if strcmp(S, 'FAIL')
    +0213                     fprintf('\toriginal/new number of %s element times: %d, %d\n', ...
    +0214                         fnames{ff}, ...
    +0215                         results.(fnames{ff}).origElementTimes, ...
    +0216                         results.(fnames{ff}).nElementTimes)
    +0217                 end
    +0218 
    +0219             case 'nodeValues'
    +0220                 fprintf('%s %s node values test\n', S, fnames{ff})
    +0221                 if strcmp(S, 'FAIL')
    +0222                     fprintf('\trange of %s node values: %d\n', ...
    +0223                         fnames{ff}, ...
    +0224                         results.(fnames{ff}).nodeRange)
    +0225                 end
    +0226 
    +0227             case 'elementValues'
    +0228                 fprintf('%s %s element values test\n', S, fnames{ff})
    +0229                 if strcmp(S, 'FAIL')
    +0230                     fprintf('\trange of %s element values: %d\n', ...
    +0231                         fnames{ff}, ...
    +0232                         results.(fnames{ff}).elemRange)
    +0233                 end
    +0234         end
    +0235     end
    +0236 end
    +0237 
    +0238 fprintf('\n------------------SUMMARY------------------\n')
    +0239 fprintf('           %d of %d tests passed', totalPasses, totalTests)
    +0240 fprintf('\n-------------------------------------------\n')
    +
    Generated on Tue 04-Jun-2013 12:21:29 by m2html © 2005
    + + \ No newline at end of file diff --git a/make_doc.m b/make_doc.m index 8e85b5af2b49867c271bde67715ba7961c9bc820..14fd719c50b98b37a989b32e2744d3b644e73144 100644 --- a/make_doc.m +++ b/make_doc.m @@ -1,3 +1,3 @@ addpath('/users/modellers/pica/Code/MATLAB/toolboxes/m2html') -m2html('mfiles',{'fvcom_postproc','fvcom_prepro','utilities','swan_scripts','tests'},'htmldir','doc'); +m2html('mfiles',{'fvcom_postproc','fvcom_prepro','utilities','swan_scripts','tests/utilities'},'htmldir','doc','graph', 'on');