diff --git a/tests/test_tidal_run.py b/tests/test_tidal_run.py index b580285b..19f60774 100644 --- a/tests/test_tidal_run.py +++ b/tests/test_tidal_run.py @@ -7,6 +7,7 @@ import pytest import pandas as pd import numpy as np +from scipy.interpolate import griddata from adcircpy.cmd import tidal_run from adcircpy.driver import AdcircRun @@ -71,29 +72,29 @@ def test_tidal_run(shinnecock_mesh_directory): df_adjy.to_csv(output_directory / f'debug_adjy_{constituent}_{index}.csv') ############### dataset = ds._get_dataset('elevation', constituent) - zi = dataset['PHAS'][yidx, xidx] - mask = ~zi.mask + zi1 = dataset['PHAS'][yidx, xidx] + mask = ~zi1.mask if mask.size == 1: - mask = np.array(zi * mask, dtype=bool) - xi2 = xi[mask].flatten() - yi2 = yi[mask].flatten() - zi = zi[mask].flatten() - pd.DataFrame({'xi': xi2, 'yi': yi2, 'zi': zi}).to_csv( + mask = np.array(zi1 * mask, dtype=bool) + xi1 = xi[mask].flatten() + yi1 = yi[mask].flatten() + zi1 = zi1[mask].flatten() + pd.DataFrame({'xi': xi1, 'yi': yi1, 'zi': zi1}).to_csv( output_directory / f'debug_adjxyz_phase_{constituent}_{index}.csv' ) + phase = griddata((xi1, yi1), zi1, (xq, yq), method='linear', fill_value=np.nan,) - zi = dataset['AMPL'][yidx, xidx] - mask = ~zi.mask + zi2 = dataset['AMPL'][yidx, xidx] + mask = ~zi2.mask if mask.size == 1: - mask = np.array(zi * mask, dtype=bool) + mask = np.array(zi2 * mask, dtype=bool) xi2 = xi[mask].flatten() yi2 = yi[mask].flatten() - zi = zi[mask].flatten() - pd.DataFrame({'xi': xi2, 'yi': yi2, 'zi': zi}).to_csv( + zi2 = zi2[mask].flatten() + pd.DataFrame({'xi': xi2, 'yi': yi2, 'zi': zi2}).to_csv( output_directory / f'debug_adjxyz_ampl_{constituent}_{index}.csv' ) - ############### - amp, phase = mesh.forcings.tides.tidal_dataset(constituent, vertices) + amp = griddata((xi2, yi2), zi2, (xq, yq), method='linear', fill_value=np.nan,) * 0.01 df_tide = pd.DataFrame({'amp': amp, 'phase': phase}) df_tide.to_csv(output_directory / f'debug_tide_{constituent}_{index}.csv')