<jupyter_start><jupyter_text>--- Generating T-S PlotsInvestigating T-S plots for potential use of unsupervised methods to cluster profiler data. This is probably a stretch goal!<jupyter_code># Imports
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import seawater

sns.set_style("whitegrid")<jupyter_output><empty_output><jupyter_text>Load files<jupyter_code>profiler_data = pd.read_csv('../../coastal_upwelling_output/profiler_data_2018.csv')
profiler_data['time'] = pd.to_datetime(profiler_data['time'])
# Specify the variable(s) of interest
profiler_var = ['seawater_pressure', 'density', 'practical_salinity', 'seawater_temperature', 'corrected_dissolved_oxygen']
# Specify the units for each variable of interest
profiler_units = {'seawater_pressure': ['dbar'], 'density': ['kg m-3'], 'practical_salinity': ['1'], 'seawater_temperature': ['ºC'], 'corrected_dissolved_oxygen': ['µmol kg-1']}<jupyter_output><empty_output><jupyter_text>--- T-S diagrams<jupyter_code>profiler_data
data = profiler_data[(profiler_data['time'].dt.month == 8) & (profiler_data['time'].dt.day == 18)]
plt.figure(figsize=(12,12))

# calculate the density lines - from OOI Argo Float lab
x = np.arange(31.5 ,34, .1)
y = np.arange(6, 15, .5)
X, Y = np.meshgrid(x, y)
Z = seawater.eos80.dens0(X, Y) - 1000

# plot the contours
CS = plt.contour(X, Y, Z, colors='grey', levels=np.arange(20, 30, .5), linestyles='dashed')
plt.clabel(CS, inline=1, fontsize=10, fmt='%0.1f')

plt.scatter(data['practical_salinity'], data['seawater_temperature'], c=data['seawater_pressure'], cmap='viridis_r')
plt.grid()
plt.xlabel('Salinity')
plt.ylabel('Temperature (deg C)')
cbh = plt.colorbar()
cbh.set_label('Pressure (dbar)')
plt.title('July 18, 2018')<jupyter_output><empty_output><jupyter_text>This is cool! Can I make time a slider?<jupyter_code>data = profiler_data[(profiler_data['time'].dt.month == 8)]
plt.figure(figsize=(12,12))

# calculate the density lines - from OOI Argo Float lab
x = np.arange(31.5 ,34, .1)
y = np.arange(6, 15, .5)
X, Y = np.meshgrid(x, y)
Z = seawater.eos80.dens0(X, Y) - 1000

# plot the contours
CS = plt.contour(X, Y, Z, colors='grey', levels=np.arange(20, 30, .5), linestyles='dashed')
plt.clabel(CS, inline=1, fontsize=10, fmt='%0.1f')

plt.scatter(data['practical_salinity'], data['seawater_temperature'], c=data['seawater_pressure'], cmap='viridis_r')
plt.grid()
plt.xlabel('Salinity')
plt.ylabel('Temperature (deg C)')
cbh = plt.colorbar()
cbh.set_label('Pressure (dbar)')
data = profiler_data[(profiler_data['time'].dt.month == 8)]
plt.figure(figsize=(12,12))

# calculate the density lines - from OOI Argo Float lab
x = np.arange(31.5 ,34, .1)
y = np.arange(6, 15, .5)
X, Y = np.meshgrid(x, y)
Z = seawater.eos80.dens0(X, Y) - 1000

# plot the contours
CS = plt.contour(X, Y, Z, colors='grey', levels=np.arange(20, 30, .5), linestyles='dashed')
plt.clabel(CS, inline=1, fontsize=10, fmt='%0.1f')

plt.scatter(data['practical_salinity'], data['seawater_temperature'], c=data['time'], cmap='viridis')
plt.grid()
plt.xlabel('Salinity')
plt.ylabel('Temperature (deg C)')
cbh = plt.colorbar()
data = profiler_data[(profiler_data['time'].dt.month == 10)]
plt.figure(figsize=(12,12))

# calculate the density lines - from OOI Argo Float lab
x = np.arange(31.5 ,34, .1)
y = np.arange(6, 15, .5)
X, Y = np.meshgrid(x, y)
Z = seawater.eos80.dens0(X, Y) - 1000

# plot the contours
CS = plt.contour(X, Y, Z, colors='grey', levels=np.arange(20, 30, .5), linestyles='dashed')
plt.clabel(CS, inline=1, fontsize=10, fmt='%0.1f')

plt.scatter(data['practical_salinity'], data['seawater_temperature'], c=data['time'], cmap='viridis')
plt.grid()
plt.xlabel('Salinity')
plt.ylabel('Temperature (deg C)')
cbh = plt.colorbar()
cbh.set_label('Pressure (dbar)')
data = profiler_data[(profiler_data['time'].dt.month == 11)]
plt.figure(figsize=(12,12))

# calculate the density lines - from OOI Argo Float lab
x = np.arange(31.5 ,34, .1)
y = np.arange(6, 15, .5)
X, Y = np.meshgrid(x, y)
Z = seawater.eos80.dens0(X, Y) - 1000

# plot the contours
CS = plt.contour(X, Y, Z, colors='grey', levels=np.arange(20, 30, .5), linestyles='dashed')
plt.clabel(CS, inline=1, fontsize=10, fmt='%0.1f')

plt.scatter(data['practical_salinity'], data['seawater_temperature'], c=data['time'], cmap='viridis')
plt.grid()
plt.xlabel('Salinity')
plt.ylabel('Temperature (deg C)')
cbh = plt.colorbar()
cbh.set_label('Pressure (dbar)')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18460505705974492, 'fraction_numerical': 0.039606175878272545, 'mean_word_length': 6.327868852459017, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '100927', 'license': 'MIT', 'n_tokens_mistral': 1952, 'n_tokens_neox': 1784, 'n_words': 380, 'path': 'extras/.ipynb_checkpoints/T-S_plots-checkpoint.ipynb', 'repo_name': 'dgumustel/coastal-upwelling', 'size': '4469'}