Skip to content

Commit 3d3c476

Browse files
authored
Merge pull request #589 from British-Oceanographic-Data-Centre/develop
Tidegauge and Profile tutorials refresh
2 parents 2677c9f + b1fc598 commit 3d3c476

18 files changed

+1715
-568
lines changed

CITATION.cff

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ authors:
3737
- family-names: "Gorman"
3838
given-names: "Luke"
3939
orcid: "https://orcid.org/0000-0002-2414-4311"
40-
title: "British-Oceanographic-Data-Centre/COAsT: v3.1.0"
41-
version: v3.1.1
42-
date-released: 2022-09-22
40+
title: "British-Oceanographic-Data-Centre/COAsT: v3.1.2"
41+
version: v3.1.2
42+
date-released: 2022-10-20

coast/data/tidegauge.py

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ def _read_bodc_data(fn_bodc, date_start=None, date_end=None, header_length: int
971971
### ~ Plotting ~ ###
972972
##############################################################################
973973

974-
def plot_timeseries(self, id, var_list=["ssh"], date_start=None, date_end=None, plot_line=False):
974+
def plot_timeseries(self, var_list=["ssh"], date_start=None, date_end=None, plot_line=False):
975975
"""
976976
Quick plot of time series stored within object's dataset
977977
Parameters
@@ -992,9 +992,10 @@ def plot_timeseries(self, id, var_list=["ssh"], date_start=None, date_end=None,
992992
var_list = [var_list]
993993

994994
for var_str in var_list:
995-
dim_str = self.dataset[var_str].dims[0]
996-
x = np.array(self.dataset[dim_str])
997-
y = np.array(self.dataset[var_str])
995+
# dim_str = self.dataset[var_str].dims[0] # commented out: could pull wrong dimensio
996+
# x = np.array(self.dataset[dim_str]) # return indices, not coordinate values
997+
x = np.array(self.dataset["time"])
998+
y = np.array(self.dataset[var_str].squeeze())
998999

9991000
# Use only values between stated dates
10001001
start_index = 0
@@ -1019,7 +1020,20 @@ def plot_timeseries(self, id, var_list=["ssh"], date_start=None, date_end=None,
10191020
plt.legend(var_list)
10201021
# Title and axes
10211022
plt.xlabel("Date")
1022-
plt.title("Site: " + self.dataset.site_name)
1023+
1024+
try:
1025+
self.dataset.id_name
1026+
except AttributeError:
1027+
try:
1028+
self.dataset.site_name
1029+
except AttributeError:
1030+
title_str = ""
1031+
else:
1032+
title_str = f"Site: {self.dataset.site_name}"
1033+
else:
1034+
title_str = f"Site: {self.dataset.id_name}"
1035+
1036+
plt.title(title_str)
10231037

10241038
return fig, ax
10251039

@@ -1057,19 +1071,22 @@ def plot_on_map_multiple(cls, tidegauge_list, color_var_str=None):
10571071
Y = []
10581072
C = []
10591073
for tg in tidegauge_list:
1060-
X.append(tg.dataset.longitude)
1061-
Y.append(tg.dataset.latitude)
1074+
X.append(tg.dataset.longitude.values)
1075+
Y.append(tg.dataset.latitude.values)
10621076
if color_var_str is not None:
10631077
C.append(tg.dataset[color_var_str].values)
10641078

1079+
X = np.hstack(X)
1080+
Y = np.hstack(Y)
10651081
title = ""
10661082
if color_var_str is None:
10671083
fig, ax = plot_util.geo_scatter(X, Y, title=title)
10681084
else:
1085+
C = np.hstack(C)
10691086
fig, ax = plot_util.geo_scatter(X, Y, title=title, c=C)
10701087

1071-
ax.set_xlim((min(X) - 10, max(X) + 10))
1072-
ax.set_ylim((min(Y) - 10, max(Y) + 10))
1088+
ax.set_xlim((np.min(X) - 10, np.max(X) + 10))
1089+
ax.set_ylim((np.min(Y) - 10, np.max(Y) + 10))
10731090
return fig, ax
10741091

10751092
##############################################################################

coast/diagnostics/profile_analysis.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,15 @@ def interpolate_vertical(cls, profile, new_depth, interp_method="linear", print_
385385
# Get arrays to interpolate
386386
interpx = profile.depth.values
387387
interpy = profile[vv].values
388+
if interpx.shape != interpy.shape:
389+
continue
388390

389391
# Remove NaNs
390392
xnans = np.isnan(interpx)
393+
try:
394+
ynans = np.isnan(interpy)
395+
except:
396+
debug(f"Issue with vv: {vv}")
391397
ynans = np.isnan(interpy)
392398
xynans = np.logical_or(xnans, ynans)
393399
interpx = interpx[~xynans]

coast/diagnostics/tidegauge_analysis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,8 @@ def threshold_statistics(cls, dataset, thresholds=np.arange(-0.4, 2, 0.1), peak_
257257
# NTR: Threshold Frequency (Peaks)
258258
ds_thresh["peak_count_" + vv][pp, nn] = np.sum(pk_values >= threshn)
259259

260-
# NTR: Threshold integral (Time over threshold)
261-
ds_thresh["time_over_threshold_" + vv][pp, nn] = np.sum(data_pp >= threshn)
260+
# NTR: Threshold integral (Timestamps over threshold)
261+
ds_thresh["time_over_threshold_" + vv][pp, nn] = np.sum(data_pp >= threshn) # sum of booleans
262262

263263
# NTR: Number of daily maxima over threshold
264264
ds_thresh["dailymax_count_" + vv][pp, nn] = np.sum(ds_daily_max.values >= threshn)

environment.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ channels:
66
dependencies:
77
- python==3.8.10
88
- pip>=22.2.2
9-
- cartopy>=0.20.2
10-
- gsw>=3.4.0
9+
- cartopy>=0.21.0
10+
- gsw==3.4.0
1111
- pip:
1212
- numpy==1.22.3
1313
- dask==2022.3.0
@@ -16,7 +16,7 @@ dependencies:
1616
- matplotlib>=3.5.3
1717
- netCDF4==1.5.8
1818
- scipy>=1.8.0
19-
- gsw>=3.4.0
19+
- gsw==3.4.0
2020
- utide>=0.3.0
2121
- scikit-learn>=1.0.2
2222
- scikit-image>=0.19.2

0 commit comments

Comments
 (0)