Skip to content

Commit

Permalink
Merge pull request #53 from cgq-qgc/dont_undo_alt_or_offset
Browse files Browse the repository at this point in the history
PR: Don't undo altitude or zero point offset systematically
  • Loading branch information
jnsebgosselin authored Feb 10, 2020
2 parents c35d02c + e771a00 commit ba5f50f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ 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
def _format_data_units(self):
Expand All @@ -157,7 +155,7 @@ def _format_data_units(self):
columns_map[column] = column
self.records.rename(columns_map, axis='columns', inplace=True)

def _undo_altitude_correction(self):
def undo_altitude_correction(self):
"""
Undo the automatic compensation for elevation applied to readings made
by level and baro loggers of the Gold series (1xxxxxx) and older.
Expand All @@ -182,7 +180,7 @@ def _undo_altitude_correction(self):
self.sites.records[column] = (
self.sites.records[column] - 0.12 * altitude)

def _undo_zero_point_offset(self):
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,23 @@ 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) + 950
assert records.iloc[0].iloc[0] == 923.561
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) + 950
assert records.iloc[-1].iloc[0] == 934.8801
assert records.iloc[-1].iloc[1] == 8.914

# Test undo altitude correction.
solinst_file.undo_altitude_correction()
assert records.iloc[-1].iloc[0] == 934.8801 - (0.12 * 42)
assert records.iloc[-1].iloc[0] == 934.8801 - (0.12 * 42)

# Test undo zero point offset.
solinst_file.undo_zero_point_offset()
assert records.iloc[0].iloc[0] == 923.561 - (0.12 * 42) + 950
assert records.iloc[-1].iloc[0] == 934.8801 - (0.12 * 42) + 950

assert solinst_file.plot()


Expand All @@ -133,9 +143,19 @@ 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) + 950
assert records.iloc[0].iloc[0] == 314.0

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

# Test undo altitude correction.
solinst_file.undo_altitude_correction()
assert records.iloc[0].iloc[0] == 314.0 - (0.12 * 170)
assert records.iloc[-1].iloc[0] == 317.5 - (0.12 * 170)

# Test undo zero point offset.
solinst_file.undo_zero_point_offset()
assert records.iloc[0].iloc[0] == 314.0 - (0.12 * 170) + 950
assert records.iloc[-1].iloc[0] == 317.5 - (0.12 * 170) + 950

assert solinst_file.plot()
Expand Down

0 comments on commit ba5f50f

Please sign in to comment.