hevgyrt / ocean_wave_tracing Goto Github PK
View Code? Open in Web Editor NEWA numerical solver of the ray equations for ocean waves
License: GNU General Public License v3.0
A numerical solver of the ray equations for ocean waves
License: GNU General Public License v3.0
In the ocean_wave_tracing.py, get rid of the crude `warnings.filterwarnings('ignore').
The reason for having it there is the nulldivision when computing n = 0.5 * (1 + (2*k*d)/np.sinh(2*k*d))
for deep water
`
According to the expression in Dysthe 2001
Current version is missing velocity output (U,V) for each ray. Moreover, the ray_depth is not part of the to_ds() method.
These changes calls for some restructuring of the code and will impact tests etc.
Make sure that ambient parameters when specified within the Wave_tracing object, i.e. bathymetry and currents, follow standard conventions like the standard name and direction from the climate and forecast (CF) convention
Make the output file writer more sophisticated by means of (e.g.):
Some import errors that must be fixed:
Like:
import numpy as np
import maplotlib.pyplot as plt
from ocean_wave_tracing.ocean_wave_tracing import Wave_tracing
# Defining some properties of the medium
nx = 100; ny = 100 # number of grid points in x- and y-direction
x = np.linspace(0,2000,nx) # size x-domain [m]
y = np.linspace(0,3500,ny) # size y-domain [m]
T = 250 # simulation time [s]
U=np.zeros((nx,ny))
U[nx//2:,:]=1
# Define a wave tracing object
wt = Wave_tracing(U=U,V=np.zeros((ny,nx)),
nx=nx, ny=ny, nt=150,T=T,
dx=x[1]-x[0],dy=y[1]-y[0],
nb_wave_rays=20,
domain_X0=x[0], domain_XN=x[-1],
domain_Y0=y[0], domain_YN=y[-1],
)
# Set initial conditions
wt.set_initial_condition(wave_period=10,
theta0=np.pi/8)
# Solve
wt.solve()
# Plot
fig, ax = plt.subplots();
pc=ax.pcolormesh(wt.x,wt.y,wt.U.isel(time=0));
fig.colorbar(pc)
for ray_id in range(wt.nb_wave_rays):
ax.plot(wt.ray_x[ray_id,:],wt.ray_y[ray_id,:],'-k')
plt.show()
Updating ray_theta values to be within [0,360), sometimes we have np.mod(np.nan,2pi). Look how to circumvent this error
Use the code developed in
https://github.com/gauteh/hada/blob/main/hada/sources.py
https://github.com/gauteh/hada/blob/main/hada/cli.py
for making 1) variables
vo = np.full(shape, np.nan, dtype=block.dtype)
vo[:, inbounds] = block.values[:, ty.ravel(), tx.ravel()]
vo = xr.DataArray(vo,
[
("time", var.time.data),
("latitude", target.y),
("longitude", target.x),
],
attrs=var.attrs,
name=var.name)
# Positions in source grid
# vo.attrs['x'] = target_x
# vo.attrs['y'] = target_y
vo.latitude.attrs['units'] = 'degrees_north'
vo.latitude.attrs['standard_name'] = 'latitude'
vo.latitude.attrs['long_name'] = 'latitude'
vo.longitude.attrs['units'] = 'degrees_east'
vo.longitude.attrs['standard_name'] = 'longitude'
vo.longitude.attrs['long_name'] = 'longitude'
vo.attrs['grid_mapping'] = target.proj_name
vo.attrs['source'] = self.url
vo.attrs['source_name'] = self.name
and 2) making a dataset
ds = xr.Dataset()
for var in sources.scalar_variables:
logger.info(f'Searching for variable {var}')
(d, v) = sources.find_dataset_for_var(var)
if v is not None:
logger.info(f'Extracting {var} from {d}')
# Acquire variables on target grid
vo = d.regrid(v, target, t0, t1)
ds[vo.name] = vo
else:
logger.error(f'No dataset found for variable {var}.')
for vvar in sources.vector_variables:
varx = vvar[0]
vary = vvar[1]
logger.info(f'Searching for variable {varx},{vary}')
(d, vx, vy) = sources.find_dataset_for_var_pair(varx, vary)
if vx is not None:
logger.info(f'Extracting {varx} and {vary} from {d}')
# Acquire variables on target grid
vox = d.regrid(vx, target, t0, t1)
voy = d.regrid(vy, target, t0, t1)
vox, voy = d.rotate_vectors(vox, voy, target)
ds[vox.name] = vox
ds[voy.name] = voy
else:
logger.error(f'No dataset found for variable {varx},{vary}.')
The velocity_checker (in ocean_wave_tracing/util_methods.py) fails if the intput velcoity field is a xarray object with wrong dimension names (i.e. X and Y instead of x and y)
Add the following notebooks for verification of the numerical solver
And
Fix the plotting option when calling on pytest
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.