Skip to content

Commit

Permalink
Calc amp/phase within the test
Browse files Browse the repository at this point in the history
  • Loading branch information
SorooshMani-NOAA committed Aug 1, 2024
1 parent 43fa46e commit 6a2e07c
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions tests/test_tidal_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')

Expand Down

0 comments on commit 6a2e07c

Please sign in to comment.