ctd
¶
Read module
- ctd.read.from_bl(fname)[source]¶
Read Seabird bottle-trip (bl) file
Example
>>> from pathlib import Path >>> import ctd >>> data_path = Path(__file__).parents[1].joinpath("tests", "data") >>> df = ctd.from_bl(str(data_path.joinpath("bl", "bottletest.bl"))) >>> df._metadata["time_of_reset"] datetime.datetime(2018, 6, 25, 20, 8, 55)
- ctd.read.from_btl(fname)[source]¶
DataFrame constructor to open Seabird CTD BTL-ASCII format.
Examples
>>> from pathlib import Path >>> import ctd >>> data_path = Path(__file__).parents[1].joinpath("tests", "data") >>> bottles = ctd.from_btl(data_path.joinpath("btl", "bottletest.btl"))
- ctd.read.from_castaway_csv(fname)[source]¶
DataFrame constructor to open CastAway CSV format.
Example
>>> import ctd >>> cast = ctd.from_castaway_csv("tests/data/castaway_data.csv") >>> cast.columns Index(['depth', 'temperature', 'conductivity', 'specific_conductance', 'salinity', 'sound_velocity', 'density'], dtype='object')
- ctd.read.from_cnv(fname)[source]¶
DataFrame constructor to open Seabird CTD CNV-ASCII format.
Examples
>>> from pathlib import Path >>> import ctd >>> data_path = Path(__file__).parents[1].joinpath("tests", "data") >>> cast = ctd.from_cnv(data_path.joinpath("CTD_big.cnv.bz2")) >>> downcast, upcast = cast.split() >>> ax = downcast["t090C"].plot_cast()
- ctd.read.from_edf(fname)[source]¶
DataFrame constructor to open XBT EDF ASCII format.
Examples
>>> from pathlib import Path >>> import ctd >>> data_path = Path(__file__).parents[1].joinpath("tests", "data") >>> cast = ctd.from_edf(data_path.joinpath("XBT.EDF.gz")) >>> ax = cast["temperature"].plot_cast()
- ctd.read.from_fsi(fname, skiprows=9)[source]¶
DataFrame constructor to open Falmouth Scientific, Inc. (FSI) CTD ASCII format.
Examples
>>> from pathlib import Path >>> import ctd >>> data_path = Path(__file__).parents[1].joinpath("tests", "data") >>> cast = ctd.from_fsi(data_path.joinpath("FSI.txt.gz")) >>> downcast, upcast = cast.split() >>> ax = downcast["TEMP"].plot_cast()
- ctd.read.rosette_summary(fname)[source]¶
Make a BTL (bottle) file from a ROS (bottle log) file.
More control for the averaging process and at which step we want to perform this averaging eliminating the need to read the data into SBE Software again after pre-processing. NOTE: Do not run LoopEdit on the upcast!
Examples
>>> from pathlib import Path >>> import ctd >>> data_path = Path(__file__).parents[1].joinpath("tests", "data") >>> fname = data_path.joinpath("CTD/g01l01s01.ros") >>> ros = ctd.rosette_summary(fname) >>> ros = ros.groupby(ros.index).mean() >>> ros.pressure.values.astype(int) array([835, 806, 705, 604, 503, 404, 303, 201, 151, 100, 51, 1])
processing
¶
Processing module
- ctd.processing.bindata(df, delta=1.0, method='average')[source]¶
Bin average the index (usually pressure) to a given interval (default delta = 1).
- ctd.processing.despike(df, n1=2, n2=20, block=100, keep=0)[source]¶
Wild Edit Seabird-like function. Passes with Standard deviation n1 and n2 with window size block.
- ctd.processing.lp_filter(df, sample_rate=24.0, time_constant=0.15)[source]¶
Filter a series with time_constant (use 0.15 s for pressure), and for a signal of sample_rate in Hertz (24 Hz for 911+). NOTE: 911+ systems do not require filter for temperature nor salinity.
Examples
>>> from pathlib import Path >>> import matplotlib.pyplot as plt >>> import ctd >>> data_path = Path(__file__).parents[1].joinpath("tests", "data") >>> raw = ctd.from_cnv(data_path.joinpath("CTD-spiked-unfiltered.cnv.bz2")) >>> prc = ctd.from_cnv(data_path.joinpath("CTD-spiked-filtered.cnv.bz2")) >>> kw = {"sample_rate": 24.0, "time_constant": 0.15} >>> original = prc.index.values >>> unfiltered = raw.index.values >>> filtered = raw.lp_filter(**kw).index.values >>> fig, ax = plt.subplots() >>> (l1,) = ax.plot(original, "k", label="original") >>> (l2,) = ax.plot(unfiltered, "r", label="unfiltered") >>> (l3,) = ax.plot(filtered, "g", label="filtered") >>> leg = ax.legend()
Notes
- ctd.processing.movingaverage(df, window_size=48)[source]¶
Moving average on a data frame or series.
- Inputs:
windows_size : integer
- ctd.processing.remove_up_to(df, idx)[source]¶
Remove all the data above a certain index value where index can be pressure or depth.
plotting
¶
Plotting module