diff --git a/.travis.yml b/.travis.yml index 0397d93..427347b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/docs/README.md b/docs/README.md index 7b82416..5661690 100644 --- a/docs/README.md +++ b/docs/README.md @@ -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) diff --git a/hydsensread/file_reader/compagny_file_reader/solinst_file_reader.py b/hydsensread/file_reader/compagny_file_reader/solinst_file_reader.py index 04bafdb..4b256fd 100644 --- a/hydsensread/file_reader/compagny_file_reader/solinst_file_reader.py +++ b/hydsensread/file_reader/compagny_file_reader/solinst_file_reader.py @@ -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 @@ -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 """ @@ -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 diff --git a/hydsensread/tests/files/1XXXXXX_solinst_levelogger_gold.csv b/hydsensread/file_reader/compagny_file_reader/tests/files/1XXXXXX_solinst_levelogger_gold.csv similarity index 100% rename from hydsensread/tests/files/1XXXXXX_solinst_levelogger_gold.csv rename to hydsensread/file_reader/compagny_file_reader/tests/files/1XXXXXX_solinst_levelogger_gold.csv diff --git a/hydsensread/tests/files/1XXXXXX_solinst_levelogger_gold.lev b/hydsensread/file_reader/compagny_file_reader/tests/files/1XXXXXX_solinst_levelogger_gold.lev similarity index 100% rename from hydsensread/tests/files/1XXXXXX_solinst_levelogger_gold.lev rename to hydsensread/file_reader/compagny_file_reader/tests/files/1XXXXXX_solinst_levelogger_gold.lev diff --git a/hydsensread/tests/files/2XXXXXX_solinst_colon_as_decimalsep.csv b/hydsensread/file_reader/compagny_file_reader/tests/files/2XXXXXX_solinst_colon_as_decimalsep.csv similarity index 100% rename from hydsensread/tests/files/2XXXXXX_solinst_colon_as_decimalsep.csv rename to hydsensread/file_reader/compagny_file_reader/tests/files/2XXXXXX_solinst_colon_as_decimalsep.csv diff --git a/hydsensread/tests/files/2XXXXXX_solinst_colon_as_decimalsep.xle b/hydsensread/file_reader/compagny_file_reader/tests/files/2XXXXXX_solinst_colon_as_decimalsep.xle similarity index 100% rename from hydsensread/tests/files/2XXXXXX_solinst_colon_as_decimalsep.xle rename to hydsensread/file_reader/compagny_file_reader/tests/files/2XXXXXX_solinst_colon_as_decimalsep.xle diff --git a/hydsensread/tests/files/2XXXXXX_solinst_levelogger_edge.csv b/hydsensread/file_reader/compagny_file_reader/tests/files/2XXXXXX_solinst_levelogger_edge.csv similarity index 100% rename from hydsensread/tests/files/2XXXXXX_solinst_levelogger_edge.csv rename to hydsensread/file_reader/compagny_file_reader/tests/files/2XXXXXX_solinst_levelogger_edge.csv diff --git a/hydsensread/tests/files/2XXXXXX_solinst_levelogger_edge.lev b/hydsensread/file_reader/compagny_file_reader/tests/files/2XXXXXX_solinst_levelogger_edge.lev similarity index 100% rename from hydsensread/tests/files/2XXXXXX_solinst_levelogger_edge.lev rename to hydsensread/file_reader/compagny_file_reader/tests/files/2XXXXXX_solinst_levelogger_edge.lev diff --git a/hydsensread/tests/files/2XXXXXX_solinst_levelogger_edge.xle b/hydsensread/file_reader/compagny_file_reader/tests/files/2XXXXXX_solinst_levelogger_edge.xle similarity index 100% rename from hydsensread/tests/files/2XXXXXX_solinst_levelogger_edge.xle rename to hydsensread/file_reader/compagny_file_reader/tests/files/2XXXXXX_solinst_levelogger_edge.xle diff --git a/hydsensread/tests/files/XXXX_solinst_levelogger_M5.csv b/hydsensread/file_reader/compagny_file_reader/tests/files/XXXX_solinst_levelogger_M5.csv similarity index 100% rename from hydsensread/tests/files/XXXX_solinst_levelogger_M5.csv rename to hydsensread/file_reader/compagny_file_reader/tests/files/XXXX_solinst_levelogger_M5.csv diff --git a/hydsensread/tests/files/XXXX_solinst_levelogger_M5.lev b/hydsensread/file_reader/compagny_file_reader/tests/files/XXXX_solinst_levelogger_M5.lev similarity index 100% rename from hydsensread/tests/files/XXXX_solinst_levelogger_M5.lev rename to hydsensread/file_reader/compagny_file_reader/tests/files/XXXX_solinst_levelogger_M5.lev diff --git a/hydsensread/tests/test_solinst_reader.py b/hydsensread/file_reader/compagny_file_reader/tests/test_solinst_reader.py similarity index 95% rename from hydsensread/tests/test_solinst_reader.py rename to hydsensread/file_reader/compagny_file_reader/tests/test_solinst_reader.py index ff49abe..a801902 100644 --- a/hydsensread/tests/test_solinst_reader.py +++ b/hydsensread/file_reader/compagny_file_reader/tests/test_solinst_reader.py @@ -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() @@ -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()