Skip to content

Commit

Permalink
added surface buffer arg
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Thomas committed May 7, 2023
1 parent 425b725 commit 04c9d5e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
4 changes: 2 additions & 2 deletions cshelph/cshelph.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,14 @@ def bin_data(dataset, lat_res, height_res):

return dataset1

def get_sea_height(binned_data):
def get_sea_height(binned_data, surface_buffer):
'''Calculate mean sea height for easier calculation of depth and cleaner figures'''

# Create sea height list
sea_height = []

# Group data by latitude
binned_data_sea = binned_data[(binned_data['photon_height'] > -0.5)] # Filter out subsurface data
binned_data_sea = binned_data[(binned_data['photon_height'] > surface_buffer)] # Filter out subsurface data
grouped_data = binned_data_sea.groupby(['lat_bins'], group_keys=True)
data_groups = dict(list(grouped_data))

Expand Down
24 changes: 16 additions & 8 deletions cshelph/run_bathy_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def main():
parser.add_argument("-elat", "--end_lat", type=float, required = False, help="Specify the stop latitude")
parser.add_argument("-minb", "--min_buffer", type=float, default = -40, required = False, help="Specify the stop latitude")
parser.add_argument("-maxb", "--max_buffer", type=float, default=5, required = False, help="Specify the stop latitude")
parser.add_argument("-sb", "--surface_buffer", type=float, default=-0.5, required = False, help="Specify the point at which sea surface points are excluded")

args = parser.parse_args()

Expand Down Expand Up @@ -116,15 +117,15 @@ def main():
# Filter data that should not be analyzed
# Filter for quality flags
print('filter quality flags')
if args.minb == -40:
pass
if args.min_buffer == -40:
min_buffer = -40
else:
min_buffer = args.minb
min_buffer = args.min_buffer

if args.maxb == 5:
pass
if args.max_buffer == 5:
max_buffer = 5
else:
max_buffer = args.maxb
max_buffer = args.max_buffer


dataset_sea1 = dataset_sea[(dataset_sea.confidence != 0) & (dataset_sea.confidence != 1)]
Expand All @@ -142,7 +143,11 @@ def main():
binned_data_sea = cshelph.bin_data(dataset_sea1, args.lat_res, args.h_res)

# Find mean sea height
sea_height = cshelph.get_sea_height(binned_data_sea)
if args.surface_buffer==-0.5:
surface_buffer = -0.5
else:
surface_buffer = args.surface_buffer
sea_height = cshelph.get_sea_height(binned_data_sea, surface_buffer)

# Set sea height
med_water_surface_h = np.nanmedian(sea_height)
Expand All @@ -154,7 +159,7 @@ def main():
try:
water_temp = cshelph.get_water_temp(args.input, latitude, longitude)
except Exception as e:
print('NO SST pROVIDED OR RETRIEVED: 20 degrees C assigned')
print('NO SST PROVIDED OR RETRIEVED: 20 degrees C assigned')
water_temp = 20

print("water temp:", water_temp)
Expand All @@ -179,12 +184,14 @@ def main():
# Bin dataset again for bathymetry
binned_data = cshelph.bin_data(dataset_bath, args.lat_res, args.h_res)

print("Locating bathymetric photons...")
if isinstance(args.thresh, int) == True:
# Find bathymetry
bath_height, geo_df = cshelph.get_bath_height(binned_data, args.thresh, med_water_surface_h, args.h_res)

# Create figure
plt.close()
print('Creating figa nd writing to GPKG')
cshelph.produce_figures(binned_data, bath_height, sea_height, 10, -20, args.thresh, file, geo_df, ref_y, ref_z, args.laser, epsg_num)
elif isinstance(args.threshlist, list)==True:
for thresh in args.threshlist:
Expand All @@ -193,6 +200,7 @@ def main():

# Create figure
plt.close()
print('Creating figa nd writing to GPKG')
cshelph.produce_figures(binned_data, bath_height, sea_height, 10, -20, str(thresh), file, geo_df, ref_y, ref_z, args.laser, epsg_num)


Expand Down
3 changes: 2 additions & 1 deletion cshelph/run_bathymetry_extraction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@
"- start_lat: The latitude at which you want the analysis to start\n",
"- end_lat: The latitude at which you want the analysis to end\n",
"- surface_buffer_min: When searching for the water surface this is the max value for the search window, default is 5m\n",
"- surface_buffer_max: When searching for the water surface this is the min value for the search window, default is -40m"
"- surface_buffer_max: When searching for the water surface this is the min value for the search window, default is -40m\n",
"- surface_buffer: When finding the water surface, photons below -0.5m are excluded. This parameter allows that threshold to be changed where the water surface is not at 0m (e.g., some raised bathymetry that causes a swell effect)"
]
},
{
Expand Down

0 comments on commit 04c9d5e

Please sign in to comment.