Skip to content
Snippets Groups Projects
Commit 56447d21 authored by Eleanor Frajka-Williams's avatar Eleanor Frajka-Williams
Browse files

Update ctd-pycnv-starter.ipynb

Added comment to top of file to 'not edit'.
parent 3a636601
Branches
No related tags found
No related merge requests found
%% Cell type:code id: tags:
``` python
# Importing the required module for plotting data
#
# Don't edit this file. Make a copy and rename it (e.g. with your name/group names)
#
# # Importing the required module for plotting data
import gsw # See https://teos-10.github.io/GSW-Python/
import pycnv # See https://pypi.org/project/pycnv/
import pylab as pl
# Defining the file path where the CNV file is located
# Choose either Seepraktikum 2023 data: https://bit.ly/3ut6NtV
file_path = 'Seepraktikum_2023/SBE19plus_01907321_2023_05_12_Cast36_loop_window.cnv'
# Or MSM121 data: https://bit.ly/3Ri19E2
file_path = 'msm121_profiles/MSM121_015_1db.cnv'
# Or MSM121 to-yo profiles: https://bit.ly/3GlQh1D
# file_path = 'MSM121_060/MSM121_060_001_05db.cnv'
# Load the data from the given file_path (may need to update to match your file location)
cnv = pycnv.pycnv(file_path)
# Print some info to the screen
print('Test if we are in the Baltic Sea (usage of different equation of state): ' + str(cnv.baltic))
print('Position of cast is: Longitude:', cnv.lon,'Latitude:',cnv.lat)
print('Time of cast was:', cnv.date)
print('Number of sensor entries (len(cnv.data.keys())):',len(cnv.data.keys()))
print('Names of sensor entries (cnv.data.keys()):',cnv.data.keys())
```
%% Cell type:code id: tags:
``` python
# Get data of entry
key0 = list(cnv.data.keys())[0]
data0 = cnv.data[key0]
# Get derived data:
keyd0 = list(cnv.cdata.keys())[0]
datad0 = cnv.cdata[keyd0]
# Get unit of derived data
datad0_unit = cnv.cunits[keyd0]
# Standard names are mapped to
# cnv.p,cnv.CT,cnv.T,cnv.SP,cnv.oxy
# units are _unit, e.g. cnv.p_unit
```
%% Cell type:code id: tags:
``` python
# Plot standard parameters
pl.figure(1)
pl.clf()
pl.subplot(1,2,1)
pl.plot(cnv.SA,cnv.p) # Note that pycnv has done the TEOS-10 conversion to SA for you using gsw
pl.xlabel('Absolute salinity [' + cnv.SA_unit + ']')
pl.ylabel('Pressure [' + cnv.p_unit + ']')
pl.gca().invert_yaxis() # Question: What happens if you comment out this line?
# Step 1a: Add grid lines
# Step 1b: Limit the top of the plot to the surface (p=0)
# Step 1c: Add a second plot for temperature, to the right of the salinity plot
# Step 1d: Add a title to your figure, perhaps the station number, latitude and longitude
# Step 1e: Print the figure to a *png file
```
%% Cell type:code id: tags:
``` python
# Plotting profile data on the same axes
pl.subplot(1,2,2)
pl.plot(cnv.oxy,cnv.p)
pl.plot(cnv.cdata['oxy0'],cnv.p)
pl.plot(cnv.cdata['oxy1'],cnv.p)
pl.xlabel('Oxygen [' + cnv.oxy_unit + ']')
pl.ylabel('Pressure [' + cnv.p_unit + ']')
pl.gca().invert_yaxis()
# Step 2a-e: Clean up the figure as above
# Step 2f (optional): Compute the apparent oxygen utilisation
# See: https://en.wikipedia.org/wiki/Apparent_oxygen_utilisation
# you will need to calculate oxygen solubility (see the gsw documentation for O2_sol)
```
%% Cell type:code id: tags:
``` python
# Make a T-S diagram
pl.figure(1)
pl.clf()
pl.subplot(1,2,1)
pl.plot(cnv.SA,cnv.CT)
pl.xlabel('Absolute salinity [' + cnv.SA_unit + ']')
pl.ylabel('Conservative temperature [' + cnv.CT_unit + ']')
# Step 3a: Add contours of potential density
# - Hint, you will need to create a vector of temperature and salinity spanning at
# least the ranges in the profile
# - You will then need to use these gridded vectors to calculate potential density using the gsw toolbox
# Step 3b: Add contour labels for the density
# Step 3c: Add a title
# Step 3d: Print the figure as a *png
```
%% Cell type:code id: tags:
``` python
# Challenge 4: Load multiple cnv files into python.
# Step 4a: Plot a map of the stations
# Step 4b (optional): Add bathymetry
# - see e.g. GEBCO https://www.gebco.net/data_and_products/gridded_bathymetry_data/
# - or ETOPO1. Note these files are big when full resolution and global.
# You will probably want to slice/prepare the data in a separate python notebook/file
# Step 4c: Load multiple stations into python
# - Option one: Keep them all as separate variables (cnv1, cnv2, cnv3, etc)
# - Option two: Combine them into a multidimensaionl np.ndarray
# In order to combine them, they will need to be interpolated onto the same
# pressure grid (suggested 1 dbar grid).
# Step 4d: Plot multiple temperature profiles on a single set of axes (see Step 1)
# Step 4e: Repeat for salinity
# Step 4f: Repeat for T-S diagrams (see Step 3)
# Noting the data type that cnv is using may help:
type(cnv.SA)
```
%% Cell type:code id: tags:
``` python
# Challenge 5: Only works with option two in challenge 4.
# Step 5a: Choose stations that are in a line (plot a map)
# Step 5b: Calculate buoyancy frequency N^2 = db/dz. See gsw.Nsquared
# - Plot this. Note where it is large / small.
# Step 5b: Calculate distance between CTD profiles
# Step 5c: Calculate buoyancy b = -g\rho/\rho_0.
# - See e.g. Clement et al. 2023: https://doi.org/10.1175/JPO-D-22-0178.1
# Step 5d: Calculate the density gradient db/dx where x is the distance between stations
```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment