Skip to content

Commit

Permalink
Merge pull request #141 from MOchiara/chiara-patch-39
Browse files Browse the repository at this point in the history
[FIX] Removed cline computation and plots
  • Loading branch information
MOchiara authored Nov 28, 2024
2 parents 4dda296 + 6144c6f commit f8d440a
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 34 deletions.
11 changes: 1 addition & 10 deletions glidertest/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ def plot_basic_vars(ds: xr.Dataset, v_res=1, start_prof=0, end_prof=-1):
Returns
-------
Line plots for the averages of the different variables.
Thermo, halo and pycnocline are computed and plotted. A sentence stating the depth of the clines is printed too
Line plots for the averages of the different variables.
Original author
----------------
Expand All @@ -100,11 +99,6 @@ def plot_basic_vars(ds: xr.Dataset, v_res=1, start_prof=0, end_prof=-1):
denG = denG[start_prof:end_prof, :]
depthG = depthG[start_prof:end_prof, :]

halo = utilities.compute_cline(salG, depthG)
thermo = utilities.compute_cline(tempG, depthG)
pycno = utilities.compute_cline(denG, depthG)
print(
f'The thermocline, halocline and pycnocline are located at respectively {thermo}, {halo} and {pycno}m as shown in the plots as well')
with plt.style.context(glidertest_style_file):
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=RuntimeWarning)
Expand All @@ -118,9 +112,6 @@ def plot_basic_vars(ds: xr.Dataset, v_res=1, start_prof=0, end_prof=-1):
ax[0].plot(np.nanmean(tempG, axis=0), depthG[0, :], c='blue')
ax1.plot(np.nanmean(salG, axis=0), depthG[0, :], c='red')
ax2.plot(np.nanmean(denG, axis=0), depthG[0, :], c='black')
ax[0].axhline(thermo, linestyle='dashed', c='blue')
ax1.axhline(halo, linestyle='dashed', c='red')
ax2.axhline(pycno, linestyle='dashed', c='black')

ax[0].set(xlabel=f'Temperature [C]', ylabel='Depth (m)')
ax[0].tick_params(axis='x', colors='blue')
Expand Down
22 changes: 0 additions & 22 deletions glidertest/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,28 +113,6 @@ def construct_2dgrid(x, y, v, xi=1, yi=1):
YI, XI = np.meshgrid(yi, xi)
return grid, XI, YI

def compute_cline(var, depth_array):
"""
Find the depth of the maximum vertical difference for a specified variables
Parameters
----------
var: 2D array containing data from a selected variable gridded over time/profile/distance etc. and depth (y-axis))
depth_array: 2D array containing pressure/depth data gridded over time/profile/distance etc. and depth (y-axis))
Returns
-------
1D array containing the depth of the cline at each timestamp/profile/distance etc.
Original author
----------------
Chiara Monforte
"""
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=RuntimeWarning)
clin = np.where(np.abs(np.diff(np.nanmean(var, axis=0))) == np.nanmax(np.abs(np.diff(np.nanmean(var, axis=0)))))
return np.round(depth_array[0, clin[0]], 1)


def compute_sunset_sunrise(time, lat, lon):
"""
Calculates the local sunrise/sunset of the glider location from GliderTools.
Expand Down
2 changes: 0 additions & 2 deletions tests/test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ def test_utilitiesmix():
tempG, profG, depthG = utilities.construct_2dgrid(ds.PROFILE_NUMBER, ds.DEPTH, ds.TEMP, p, z)
denG, profG, depthG = utilities.construct_2dgrid(ds.PROFILE_NUMBER, ds.DEPTH, ds.DENSITY, p, z)

halo = utilities.compute_cline(denG, depthG)


def test_sunset_sunrise():
ds = fetchers.load_sample_dataset()
Expand Down

0 comments on commit f8d440a

Please sign in to comment.