Skip to content

Commit 423e789

Browse files
authored
Merge pull request #86 from ocefpaf/simplify_prkeys
2 parents 7535926 + b582f71 commit 423e789

5 files changed

Lines changed: 15 additions & 11 deletions

File tree

CHANGES.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
Changelog
22
---------
33

4+
Version 1.1.0
5+
6+
* Added more SBE valid pressure names
7+
* Wrap matplotlib plots
8+
* Use case fold to avoid to standardize names
9+
* Support pandas >=1.0
10+
11+
412
Version 1.0.0
513

614
* Major re-factor to use `pandas_flavor` instead of Monkey Patching.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# python-ctd
22

3-
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.11396.svg)](https://doi.org/10.5281/zenodo.11396) [![Build Status](https://travis-ci.org/pyoceans/python-ctd.svg?branch=master)](https://travis-ci.org/pyoceans/python-ctd) [![PyPI](https://img.shields.io/pypi/v/ctd.svg?style=plastic)](https://pypi.python.org/pypi/ctd) [![Build status](https://ci.appveyor.com/api/projects/status/m1wxtsb8gpm96i53?svg=true)](https://ci.appveyor.com/project/ocefpaf/python-ctd) [![License](http://img.shields.io/badge/license-BSD-blue.svg?style=flat)](https://github.com/pyoceans/python-ctd/blob/master/LICENSE.txt)
3+
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.11396.svg)](https://doi.org/10.5281/zenodo.11396) [![Build Status](https://travis-ci.org/pyoceans/python-ctd.svg?branch=master)](https://travis-ci.org/pyoceans/python-ctd) [![PyPI](https://img.shields.io/pypi/v/ctd.svg?style=plastic)](https://pypi.python.org/pypi/ctd) [![Build status](https://ci.appveyor.com/api/projects/status/m1wxtsb8gpm96i53?svg=true)](https://ci.appveyor.com/project/ocefpaf/python-ctd) [![License](http://img.shields.io/badge/license-BSD--3--Clause-blue.svg?style=flat)](https://github.com/pyoceans/python-ctd/blob/master/LICENSE.txt)
44

55
Tools to load hydrographic data as pandas DataFrame with some handy methods for
66
data pre-processing and analysis

ctd/read.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -381,16 +381,11 @@ def from_cnv(fname):
381381
)
382382
f.close()
383383

384-
key_set = False
385384
prkeys = ["prM ", "prE", "prDM", "pr50M", "pr50M1", "prSM", "prdM", "pr"]
386-
for prkey in prkeys:
387-
try:
388-
df.set_index(prkey, drop=True, inplace=True)
389-
key_set = True
390-
except KeyError:
391-
continue
392-
if not key_set:
393-
raise KeyError(f"Could not find pressure field (supported names are {prkeys}).")
385+
prkey = [key for key in prkeys if key in df.columns]
386+
if len(prkey) != 1:
387+
raise ValueError(f"Expectd one pressure column, got {prkey}.")
388+
df.set_index(prkey, drop=True, inplace=True)
394389
df.index.name = "Pressure [dbar]"
395390

396391
name = _basename(fname)[1]

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ flake8-mutable
88
flake8-print
99
ipykernel
1010
isort
11+
jupyter
1112
jupyter_client
1213
mypy
1314
nbconvert

tests/test_read.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,5 @@ def test_pressure_field_labels():
107107
for fname in sorted(data_path.glob("issue3prlabworks*.cnv")):
108108
ctd.from_cnv(fname)
109109
for fname in sorted(data_path.glob("issue3prlabfails*.cnv")):
110-
with pytest.raises(KeyError):
110+
with pytest.raises(ValueError):
111111
ctd.from_cnv(fname)

0 commit comments

Comments
 (0)