Skip to content

Commit

Permalink
Merge pull request #51 from jnsebgosselin/undo_zero_point_offset
Browse files Browse the repository at this point in the history
PR: Undo zero point offset for Solinst loggers of the Gold series and older
  • Loading branch information
jnsebgosselin committed Jan 8, 2020
2 parents 344ea8e + dbb34cb commit e288144
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ install:
- pip install -r requirements-dev.txt
- python setup.py build_ext --inplace
script:
- pytest -x hydsensread -v -rw --cov=hydsensread
- python runtests.py
after_success:
- coveralls

Expand Down
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
[![pypi version](https://img.shields.io/pypi/v/HydroSensorReader.svg)](https://pypi.org/project/HydroSensorReader/)

[![Build Status](https://travis-ci.org/cgq-qgc/HydroSensorReader.svg?branch=master)](https://travis-ci.org/cgq-qgc/HydroSensorReader)
[![Coverage Status](https://coveralls.io/repos/github/cgq-qgc/HydroSensorReader/badge.svg)](https://coveralls.io/github/cgq-qgc/HydroSensorReader)
[![Build status](https://ci.appveyor.com/api/projects/status/lhxr1vjup234fa62/branch/master?svg=true)](https://ci.appveyor.com/project/jnsebgosselin/hydrosensorreader/branch/master)
[![codecov](https://codecov.io/gh/cgq-qgc/HydroSensorReader/branch/master/graph/badge.svg)](https://codecov.io/gh/cgq-qgc/HydroSensorReader)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/f305b1763bf647c0b7342e4699c5f5db)](https://www.codacy.com/app/jnsebgosselin/HydroSensorReader?utm_source=github.com&utm_medium=referral&utm_content=cgq-qgc/HydroSensorReader&utm_campaign=Badge_Grade)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def _read_file_data(self):
self._date_list = self._get_date_list()
self._get_data()
self._format_data_units()
self._undo_zero_point_offset()
self._undo_altitude_correction()

# ---- Private API
Expand All @@ -158,8 +159,8 @@ def _format_data_units(self):

def _undo_altitude_correction(self):
"""
Undo the altitude correction for level and baro loggers of the
Gold series (1xxxxxx) and older.
Undo the automatic compensation for elevation applied to readings made
by level and baro loggers of the Gold series (1xxxxxx) and older.
See cgq-qgc/HydroSensorReader#43
"""
Expand All @@ -181,6 +182,27 @@ def _undo_altitude_correction(self):
self.sites.records[column] = (
self.sites.records[column] - 0.12 * altitude)

def _undo_zero_point_offset(self):
"""
Undo the zero point offset applied to readings made by level and baro
loggers of the Gold series (1xxxxxx) and older.
See cgq-qgc/HydroSensorReader#51
"""
serial_number = int(self.sites.instrument_serial_number)
if serial_number < 2000000:
for column in self.records.columns:
units = column.split('_')[-1]
if units == 'm':
self.sites.records[column] = (
self.sites.records[column] + 9.5)
elif units == 'cm':
self.sites.records[column] = (
self.sites.records[column] + 950)
elif units == 'ft':
self.sites.records[column] = (
self.sites.records[column] + 31.17)

def _get_data(self):
"""Return the numerical data from the Solinst data file."""
pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ def test_solinst_levelogger_gold(test_files_dir, testfile):
assert list(records.columns) == ["LEVEL_cm", "TEMPERATURE_degC"]

assert records.index[0] == Timestamp('2017-05-02 13:00:00')
assert records.iloc[0].iloc[0] == 923.561 - (0.12 * 42)
assert records.iloc[0].iloc[0] == 923.561 - (0.12 * 42) + 950
assert records.iloc[0].iloc[1] == 8.936

assert records.index[-1] == Timestamp('2017-05-04 14:45:00')
assert records.iloc[-1].iloc[0] == 934.8801 - (0.12 * 42)
assert records.iloc[-1].iloc[0] == 934.8801 - (0.12 * 42) + 950
assert records.iloc[-1].iloc[1] == 8.914

assert solinst_file.plot()
Expand All @@ -133,10 +133,10 @@ def test_solinst_levelogger_M5(test_files_dir, testfile):
assert list(records.columns) == ["LEVEL_cm"]

assert records.index[0] == Timestamp('2016-11-04 13:00:00')
assert records.iloc[0].iloc[0] == 314.0 - (0.12 * 170)
assert records.iloc[0].iloc[0] == 314.0 - (0.12 * 170) + 950

assert records.index[-1] == Timestamp('2016-11-06 14:45:00')
assert records.iloc[-1].iloc[0] == 317.5 - (0.12 * 170)
assert records.iloc[-1].iloc[0] == 317.5 - (0.12 * 170) + 950

assert solinst_file.plot()

Expand Down

0 comments on commit e288144

Please sign in to comment.