Skip to main content

Tool to convert Seabird cnv textfiles

Project description

Python toolbox to read and process Seabird cnv files.

These text files are the standard output files of the Seabird CTD software.

The main purpose for pycnv is to create a standardised interface for slightly differing naming conventions of sensors in the cnv files and the usage of the Gibb Sea Water Toolbox (gsw) for the calculation of all derived parameters as practical salinity, absolute salinity, potential and conservative temperature or density. For this purpose pycnv does only need pressure, conductivity and temperature, all other properties will be derived from these. Furthermore pycnv will take care for a different absolute salinity computation in the Baltic Sea, by automatically checking of a cast was made in the Baltic Sea and choosing the correct function.

Install

The package was developed using python 3.5+, it might work with earlier versions, but its not supported. The newest Gibb Sea Water Toolbox (gsw) depends also on python 3.5+, pycnv heavily depends on the gsw toolbox. It therefore strongly recommended to use python 3.5+.

User

Install as a user using pip

pip install pycnv

Install as a user from the repository

python setup.py install --user

Uninstall as a user

pip uninstall pycnv

Developer

Install as a developer

python setup.py develop --user

Uninstall as a user

pip uninstall pycnv

FEATURES

  • The data can be accessed by the original names defined in the cnv file in the named array called data. E.g. header name “# name 11 = oxsatML/L: Oxygen Saturation, Weiss [ml/l]” can be accessed like this: data[‘oxsatML/L’].

  • Standard parameters (Temperature, Conductivity, pressure, oxygen) are mapped to standard names. E.g. data[‘T0’] for the first temperature sensor and data[‘C1’] for the second conductivity sensor.

  • If the standard parameters (C0,T0,p), (C1,T1,p) are available the Gibbs Sea water toolbox is used to calculate absolute salinity, SA, conservative temperature, CT, and potential temperature pt. The data is stored in a second field called computed data: cdata. E.g. cdata[‘SA00’]. The code used to compute the properties are

    SP = gsw.SP_from_C(data['C' + isen], T, data['p'])
    SA = gsw.SA_from_SP(SP,data['p'],lon = lon, lat = lat)
    if(baltic == True):
        SA = gsw.SA_from_SP_Baltic(SA,lon = lon, lat = lat)
    
    PT = gsw.pt0_from_t(SA, T, data['p'])
    CT = gsw.CT_from_t(SA, T, data['p'])
    pot_rho = gsw.pot_rho_t_exact(SA, T, data['p'], p_ref)
  • The cnv object provides standard entries for pressure (cnv.p), temperature (cnv.T), conservative temperature (cnv.CT), practical salinity (cnv.SP), absolute salinity (cnv.SA), potential density (cnv.pot_rho), oxygen (cnv.oxy). The units have the extension _units, i.e. cnv.p_units

  • The module checks if the cast was made in the Baltic Sea, if so, the modified Gibbs sea water functions are automatically used.

  • The package provides scripts to search a given folder for cnv files and can create a summary of the folder in a csv format easily readable by python or office programs. The search can be refined by a location or a predefined station.

  • Possibility to provide an own function for parsing custom header information.

  • Plotting of the profile using matplotlib

USAGE

The package installs the executables:

  • pycnv

  • pycnv_sum_folder

EXAMPLES

Plot the absolute salinity and oxygen of a CTD cast:

import pycnv
import pylab as pl
fname = 'test.cnv' # Some CTD cast

cnv = pycnv.pycnv(fname)
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())

# 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

# Plot standard parameters
pl.figure(1)
pl.clf()
pl.subplot(1,2,1)
pl.plot(cnv.SA,cnv.p)
pl.xlabel('Absolute salinity [' + cnv.SA_unit + ']')
pl.ylabel('Pressure [' + cnv.p_unit + ']')
pl.gca().invert_yaxis()

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()

pl.show()

Lists all predefined stations (in terminal):

pycnv_sum_folder --list_stations

Makes a summary of the folder called cnv_data of all casts around station TF0271 with a radius of 5000 m, prints it to the terminal and saves it into the file TF271.txt (in terminal):

pycnv_sum_folder --data_folder cnv_data --station TF0271 5000 -p -f TF271.txt

Show and plot conservative temperature, salinity and potential density of a cnv file into a pdf:

pycnv --plot show,save,CT00,SA00,pot_rho00 ctd_cast.cnv

Interpolate all CTD casts on station TF0271 onto the same pressure axis and make a netCDF out of it:

see code pycnv/test/make_netcdf.py

Devices tested

  • SEACAT (SBE16) V4.0g

  • MICROCAT (SBE37)

  • SBE 11plus V 5.1e

  • SBE 11plus V 5.1g

  • Sea-Bird SBE 9 Software Version 4.206

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycnv-0.5.0.tar.gz (194.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pycnv-0.5.0-py3-none-any.whl (46.5 kB view details)

Uploaded Python 3

File details

Details for the file pycnv-0.5.0.tar.gz.

File metadata

  • Download URL: pycnv-0.5.0.tar.gz
  • Upload date:
  • Size: 194.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for pycnv-0.5.0.tar.gz
Algorithm Hash digest
SHA256 3e448f79bef091bcc229cbeffb94bebeab68a71037f09b8b5589f34ff8cf83d8
MD5 dbbfa1731dc12dcc23f1162f911fbd1f
BLAKE2b-256 7a877bd22194264a4e1a54cfd653729c04f701bd54b829f675d6f26e002eaab7

See more details on using hashes here.

File details

Details for the file pycnv-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: pycnv-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 46.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for pycnv-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bd0ba41cc1c310c157bfef4383abcd70bd3259bac6b9f58120134696d57e5bc3
MD5 d382308617944a1f9ee8a64cce44cc81
BLAKE2b-256 45629bee9d417111fda0b166aa9e96fe1899cc21e445d7c3734e64f656075c59

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page