|
|
@ -3,11 +3,11 @@ from multiprocessing import Pool
|
|
|
|
|
|
|
|
|
|
|
|
import click
|
|
|
|
import click
|
|
|
|
import numpy as np
|
|
|
|
import numpy as np
|
|
|
|
import numpy.ma as ma
|
|
|
|
|
|
|
|
import pandas as pd
|
|
|
|
import pandas as pd
|
|
|
|
from scipy import stats
|
|
|
|
from scipy import stats
|
|
|
|
|
|
|
|
|
|
|
|
from analysis import runup_models
|
|
|
|
from analysis import runup_models
|
|
|
|
|
|
|
|
from utils import crossings
|
|
|
|
from logs import setup_logging
|
|
|
|
from logs import setup_logging
|
|
|
|
|
|
|
|
|
|
|
|
logger = setup_logging()
|
|
|
|
logger = setup_logging()
|
|
|
@ -270,35 +270,6 @@ def slope_from_profile(profile_x, profile_z, top_elevation, btm_elevation, metho
|
|
|
|
return -slope
|
|
|
|
return -slope
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def crossings(profile_x, profile_z, constant_z):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Finds the x coordinate of a z elevation for a beach profile. Much faster than using shapely to calculate
|
|
|
|
|
|
|
|
intersections since we are only interested in intersections of a constant value. Will return multiple
|
|
|
|
|
|
|
|
intersections if found. Used in calculating beach slope.
|
|
|
|
|
|
|
|
Adapted from https://stackoverflow.com/a/34745789
|
|
|
|
|
|
|
|
:param profile_x: List of x coordinates for the beach profile section
|
|
|
|
|
|
|
|
:param profile_z: List of z coordinates for the beach profile section
|
|
|
|
|
|
|
|
:param constant_z: Float of the elevation to find corresponding x coordinates
|
|
|
|
|
|
|
|
:return: List of x coordinates which correspond to the constant_z
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Remove nans to suppress warning messages
|
|
|
|
|
|
|
|
valid = ~ma.masked_invalid(profile_z).mask
|
|
|
|
|
|
|
|
profile_z = np.array(profile_z)[valid]
|
|
|
|
|
|
|
|
profile_x = np.array(profile_x)[valid]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Normalize the 'signal' to zero.
|
|
|
|
|
|
|
|
# Use np.subtract rather than a list comprehension for performance reasons
|
|
|
|
|
|
|
|
z = np.subtract(profile_z, constant_z)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Find all indices right before any crossing.
|
|
|
|
|
|
|
|
# TODO Sometimes this can give a runtime warning https://stackoverflow.com/a/36489085
|
|
|
|
|
|
|
|
indicies = np.where(z[:-1] * z[1:] < 0)[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Use linear interpolation to find intersample crossings.
|
|
|
|
|
|
|
|
return [profile_x[i] - (profile_x[i] - profile_x[i + 1]) / (z[i] - z[i + 1]) * (z[i]) for i in indicies]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@click.command()
|
|
|
|
@click.command()
|
|
|
|
@click.option("--waves-csv", required=True, help="")
|
|
|
|
@click.option("--waves-csv", required=True, help="")
|
|
|
|
@click.option("--tides-csv", required=True, help="")
|
|
|
|
@click.option("--tides-csv", required=True, help="")
|
|
|
|