-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy patht5-interpolating-profiles.py
More file actions
38 lines (29 loc) · 1.21 KB
/
t5-interpolating-profiles.py
File metadata and controls
38 lines (29 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import pandas as pd, numpy as np
from matplotlib import pyplot as plt
import tutools as tt
# Import GLODAP dataset
glodap = pd.read_csv("data/GLODAPv2.2020_Indian_Ocean.csv", na_values=-9999)
#%% Select station to use for testing
fvar = "tco2" # dissolved inorganic carbon
L = (glodap.cruise == 387) & (glodap.station == 13) & ~np.isnan(glodap[fvar])
# Extract x and y variables
x_values = glodap[fvar][L].to_numpy()
depth_values = glodap.depth[L].to_numpy()
# Get the interpolating function
interpolator = tt.get_cluster_interp(depth_values, x_values)[2]
# glodap_station = glodap[L]
# test = get_depth_interpolation(glodap_station)
all_stations = glodap[:5000].groupby(by=["cruise", "station"]).apply(
tt.get_depth_interpolation)
#%% Don't forget to run the function!
depth_clusters, x_clusters, depth_plotting, x_plotting = tt.cluster_profile(
depth_values, x_values, bandwidth=8
)
# Basic plotting
fig, ax = plt.subplots(dpi=300)
glodap[L].plot.scatter(fvar, "depth", ax=ax, c="xkcd:blue", s=50)
# glodap[L].plot(fvar, "depth", ax=ax, legend=False)
ax.scatter(x_clusters, depth_clusters, c="xkcd:strawberry", s=10)
ax.plot(x_plotting, depth_plotting, c="xkcd:strawberry")
ax.set_ylim([1250, 0])
# ax.invert_yaxis()