pySeabird is a package to parse/load CTD data files. It should be an easy task but the problem is that the format have been changing along the time. Work with multiple ships/cruises data requires first to understand each file, to normalize it into a common format for only than start your analysis. That can still be done with few general regular expression rules, but I would rather use strict rules. If I'm loading hundreds or thousands of profiles, I want to be sure that no mistake passed by. I rather ignore a file in doubt and warn it, than belive that it was loaded right and be part of my analysis.
With that in mind, I wrote this package with the ability to load multiple rules, so new rules can be added without change the main engine.
For more information, check the documentatio
In [1]:
%matplotlib inline
from seabird.cnv import fCNV
from gsw import z_from_p
Let's first download an example file with some CTD data
In [2]:
!wget https://raw.githubusercontent.com/castelao/seabird/master/sampledata/CTD/dPIRX003.cnv
In [3]:
profile = fCNV('dPIRX003.cnv')
The profile dPIRX003.cnv.OK was loaded with the default rule cnv.yaml
In [4]:
print("Header: %s" % profile.attributes.keys())
print("Data: %s" % profile.keys())
We have latitude in the header, and pressure in the data.
In [5]:
z = z_from_p(profile['PRES'], profile.attributes['LATITUDE'])
In [6]:
from matplotlib import pyplot as plt
plt.plot(profile['TEMP'], z,'b')
plt.plot(profile['TEMP2'], z,'g')
plt.xlabel('temperature')
plt.ylabel('depth')
plt.title(profile.attributes['filename'])
Out[6]:
In [ ]: