Skip to content

Commit

Permalink
cleanup tests for env contours functions
Browse files Browse the repository at this point in the history
  • Loading branch information
hivanov-nrel authored and simmsa committed Dec 31, 2024
1 parent 946d97b commit 149b61b
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions mhkit/tests/Wave_TestResourceMetrics.m
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ function test_plot_elevation_timeseries(testCase)

function test_environmental_contour(testCase)

assumeFail(testCase, "Not compatible with latest MHKIT-Python")
% assumeFail(testCase, "Not compatible with latest MHKIT-Python")

relative_file_name= '../../examples/data/wave/Hm0_Te_46022.json';
full_file_name = fullfile(fileparts(mfilename('fullpath')), relative_file_name);
Expand Down Expand Up @@ -319,24 +319,24 @@ function test_environmental_contour(testCase)
dt = (time2-time1)/1000.;
time_R = 100;

contour = environmental_contour(Hm0, Te, dt, time_R);
contour = environmental_contours(Hm0, Te, dt, time_R, 'PCA');

relative_file_name= '../../examples/data/wave/Hm0_Te_contours_46022.csv';
full_file_name = fullfile(fileparts(mfilename('fullpath')), relative_file_name);
expected_contours = readmatrix(full_file_name);

Hm0_expected = expected_contours(:,2);
Te_expected = expected_contours(:,1);
Hm0_expected = expected_contours(:,1);
Te_expected = expected_contours(:,2);

assertEqual(testCase,table2array(contour.contour2),Hm0_expected,'RelTol',0.01);
assertEqual(testCase,table2array(contour.contour1),Te_expected,'RelTol',0.01);
assertEqual(testCase,contour.contour1,Hm0_expected','RelTol',0.01);
assertEqual(testCase,contour.contour2,Te_expected','RelTol',0.01);


end

function test_plot_environmental_contour(testCase)

assumeFail(testCase, "Not compatible with latest MHKIT-Python")
%assumeFail(testCase, "Not compatible with latest MHKIT-Python")

relative_file_name= '../../examples/data/wave/Hm0_Te_46022.json';
full_file_name = fullfile(fileparts(mfilename('fullpath')), relative_file_name);
Expand Down Expand Up @@ -369,7 +369,7 @@ function test_plot_environmental_contour(testCase)
dt = (time2-time1)/1000.;
time_R = 100;

contour = environmental_contour(Hm0, Te, dt, time_R);
contour = environmental_contours(Hm0, Te, dt, time_R, 'PCA');

filename = 'wave_plot_env_contour.png';
if isfile(filename)
Expand All @@ -388,7 +388,8 @@ function test_plot_environmental_contour(testCase)
function test_plot_environmental_contour_multiyear(testCase)

assumeFail(testCase, "Not compatible with latest MHKIT-Python")

% not sure about why this test exists...return period has to be float or
% int and cannot be a list...
relative_file_name= '../../examples/data/wave/Hm0_Te_46022.json';
full_file_name = fullfile(fileparts(mfilename('fullpath')), relative_file_name);

Expand Down Expand Up @@ -420,7 +421,7 @@ function test_plot_environmental_contour_multiyear(testCase)
dt = (time2-time1)/1000.;
time_R = [100, 120, 130];

contour = environmental_contour(Hm0, Te, dt, time_R);
contour = environmental_contours(Hm0, Te, dt, time_R, 'PCA');

filename = 'wave_plot_env_contour_multiyear.png';
if isfile(filename)
Expand Down

0 comments on commit 149b61b

Please sign in to comment.