|
|
@ -5,7 +5,7 @@ import numpy as np
|
|
|
|
import pandas as pd
|
|
|
|
import pandas as pd
|
|
|
|
import geopandas as gpd
|
|
|
|
import geopandas as gpd
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
from shapely.geometry import LineString
|
|
|
|
from shapely.geometry import Point, LineString
|
|
|
|
|
|
|
|
|
|
|
|
# Set contour elevation
|
|
|
|
# Set contour elevation
|
|
|
|
contour_z = 0.7
|
|
|
|
contour_z = 0.7
|
|
|
@ -32,32 +32,44 @@ contours = []
|
|
|
|
for beach in beaches:
|
|
|
|
for beach in beaches:
|
|
|
|
for block in blocks:
|
|
|
|
for block in blocks:
|
|
|
|
for date in dates:
|
|
|
|
for date in dates:
|
|
|
|
x = []
|
|
|
|
points = []
|
|
|
|
y = []
|
|
|
|
|
|
|
|
for profile in profiles:
|
|
|
|
for profile in profiles:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
# Get data for current profile
|
|
|
|
# Get data for current block/profile (if it exists)
|
|
|
|
survey = df.loc[(beach, block, profile, date), :]
|
|
|
|
survey = df.loc[(beach, block, profile, date), :]
|
|
|
|
survey = survey.set_index('Chainage')
|
|
|
|
except KeyError:
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
# Reverse survey chainage so elevation is increasing
|
|
|
|
# Reverse profile direction so elevation is increasing
|
|
|
|
survey = survey[::-1]
|
|
|
|
survey = survey[::-1]
|
|
|
|
|
|
|
|
survey = survey.set_index('Chainage')
|
|
|
|
|
|
|
|
|
|
|
|
# Find largest chainage in profile above contour elevation
|
|
|
|
# Ignore profile information past high point
|
|
|
|
idx = survey.where(
|
|
|
|
high_idx = survey['Elevation'].idxmax()
|
|
|
|
survey['Elevation'] > contour_z).first_valid_index()
|
|
|
|
survey = survey[:high_idx]
|
|
|
|
elevation = survey.loc[:idx, 'Elevation']
|
|
|
|
|
|
|
|
eastings = survey.loc[:idx, 'Easting']
|
|
|
|
|
|
|
|
northings = survey.loc[:idx, 'Northing']
|
|
|
|
|
|
|
|
x = np.interp(contour_z, elevation, eastings)
|
|
|
|
|
|
|
|
y = np.interp(contour_z, elevation, northings)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
except KeyError:
|
|
|
|
# Extract coordinates for current profile
|
|
|
|
pass
|
|
|
|
elevation = survey['Elevation'].values
|
|
|
|
|
|
|
|
eastings = survey['Easting'].values
|
|
|
|
|
|
|
|
northings = survey['Northing'].values
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Check if entire profile is above reference elevation
|
|
|
|
|
|
|
|
if np.all(elevation > contour_z):
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Find first points on either side of reference elevation
|
|
|
|
|
|
|
|
crossing_idx = np.where(elevation < contour_z)[0][-1]
|
|
|
|
|
|
|
|
idx = slice(crossing_idx, crossing_idx + 2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Calculate shoreline intersection coordinates
|
|
|
|
|
|
|
|
x = np.interp(contour_z, elevation[idx], eastings[idx])
|
|
|
|
|
|
|
|
y = np.interp(contour_z, elevation[idx], northings[idx])
|
|
|
|
if x and y:
|
|
|
|
if x and y:
|
|
|
|
|
|
|
|
points.append(Point(x, y))
|
|
|
|
|
|
|
|
|
|
|
|
# Join points from same date into a line
|
|
|
|
# Join points from same date into a line
|
|
|
|
line = LineString([(x1, y1) for x1, y1 in zip(x, y)])
|
|
|
|
if len(points) > 1:
|
|
|
|
|
|
|
|
line = LineString(points)
|
|
|
|
contours.append({
|
|
|
|
contours.append({
|
|
|
|
'date': date,
|
|
|
|
'date': date,
|
|
|
|
'beach': beach,
|
|
|
|
'beach': beach,
|
|
|
|