Description ToDo
%matplotlib inline
from cotede.qc import fProfileQC
Let's first download an example file with some CTD data
!wget https://raw.githubusercontent.com/castelao/seabird/master/tests/test_data/dPIRX003.cnv
--2015-03-31 15:47:26-- https://raw.githubusercontent.com/castelao/seabird/master/tests/test_data/dPIRX003.cnv Resolving raw.githubusercontent.com... 199.27.74.133 Connecting to raw.githubusercontent.com|199.27.74.133|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 47291 (46K) [text/plain] Saving to: 'dPIRX003.cnv' dPIRX003.cnv 100%[=====================>] 46.18K 261KB/s in 0.2s 2015-03-31 15:47:27 (261 KB/s) - 'dPIRX003.cnv' saved [47291/47291]
pqc = fProfileQC('dPIRX003.cnv')
Using rules from: cnv.yaml evaluating: temperature temperature evaluating: temperature2 temperature evaluating: salinity salinity evaluating: salinity2 salinity
The file dPIRX003.cnv was parsed with the default rules cnv.yaml by PySeabird. Than, the temperature and salinity data, from the primary and secondary sensors were evaluated by the default Quality Control rules.
pqc.attributes
{'bad_flag': '-9.990e-29', 'datetime': datetime.datetime(2008, 4, 2, 18, 52, 30), 'file_type': 'ascii', 'filename': 'dPIRX003.cnv', 'latitude': 12.674333333333333, 'longitude': -38.00183333333333, 'md5': '4b941b902a3aea7d99e1cf4c78c51877', 'nquan': '11', 'nvalues': '349', 'seasave': 'Win32 V 5.37d', 'start_time': 'Apr 02 2008 18:52:30'}
Printing the datetime of the profile
print pqc.attributes['datetime']
2008-04-02 18:52:30
pqc.keys()
['timeS', 'pressure', 'temperature', 'temperature2', 'conductivity', 'conductivity2', 'potemperature', 'potemperature2', 'salinity', 'salinity2', 'flag']
The first 20 records of temperature
pqc['temperature'][:20]
masked_array(data = [15.8635 15.4798 15.3983 15.293 15.1721 15.0904 15.0685 15.0887 15.0373 15.0092 14.9356 14.8848 14.7707 14.7372 14.7144 14.7371 14.738 14.7466 14.7556 --], mask = [False False False False False False False False False False False False False False False False False False False True], fill_value = -9.99e-29)
The Q.C. flags are stored at pqc.flags and is a dictionary, being one item per variable evaluated. For example, to see the flags for the secondary salinity instrument, just do
pqc.flags['salinity2'].keys()
['global_range', 'gradient_depthconditional', 'gradient', 'digit_roll_over', 'tukey53H_norm', 'woa_comparison', 'spike', 'spike_depthconditional']
To check the gradient test flag for the first 20ths records:
pqc.flags['salinity2']['gradient'][:20]
array([0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 9], dtype=int8)
from matplotlib import pyplot as plt
plt.plot(pqc['temperature'], pqc['pressure'],'b')
plt.plot(pqc['temperature2'], pqc['pressure'],'g')
plt.gca().invert_yaxis()
plt.xlabel('temperature')
plt.ylabel('pressure')
plt.title(pqc.attributes['filename'])
<matplotlib.text.Text at 0x11403d810>