cgq-qgc / HydroSensorReader

This project provides tools to read files from probes, sensors, or anything used in hydrogeology.
MIT License
8 stars 2 forks source link

Plotting two solinst files consecutively with different level units doesn't work #48

Closed jnsebgosselin closed 4 years ago

jnsebgosselin commented 4 years ago

Running this script, where the files are from the tests folder located here:

filename = "2XXXXXX_solinst_levelogger_edge_testfile.csv"
reader = SolinstFileReader(osp.join(dirname, filename))

print(reader.sites)
print(reader.sites.instrument_serial_number)
print(reader.records.keys())

reader.plot()

filename = "2XXXXXX_solinst_levelogger_edge_testfile.lev"
reader = SolinstFileReader(osp.join(dirname, filename))

print(reader.sites)
print(reader.sites.instrument_serial_number)
print(reader.records.keys())

reader.plot()

Genereates the following traceback. Note that no error occurs if both dataset are plotted individually in a new namespace.

Traceback (most recent call last):

  File "C:\Users\User\HydroSensorReader\hydsensread\file_reader\compagny_file_reader\solinst_file_reader.py", line 587, in <module>
    reader.plot()

  File "C:\Users\User\HydroSensorReader\hydsensread\file_reader\compagny_file_reader\solinst_file_reader.py", line 108, in plot
    *args, **kwargs)

  File "C:\Users\User\HydroSensorReader\hydsensread\file_reader\abstract_file_reader.py", line 237, in plot
    new_axis = self._add_axe_to_plot(main_axis, lines)

  File "C:\Users\User\HydroSensorReader\hydsensread\file_reader\abstract_file_reader.py", line 253, in _add_axe_to_plot
    new_axis.plot(self.records[new_line_def.param],

  File "C:\Anaconda3\envs\spyder_dev2\lib\site-packages\pandas\core\frame.py", line 2995, in __getitem__
    indexer = self.columns.get_loc(key)

  File "C:\Anaconda3\envs\spyder_dev2\lib\site-packages\pandas\core\indexes\base.py", line 2899, in get_loc
    return self._engine.get_loc(self._maybe_cast_indexer(key))

  File "pandas\_libs\index.pyx", line 107, in pandas._libs.index.IndexEngine.get_loc

  File "pandas\_libs\index.pyx", line 131, in pandas._libs.index.IndexEngine.get_loc

  File "pandas\_libs\hashtable_class_helper.pxi", line 1607, in pandas._libs.hashtable.PyObjectHashTable.get_item

  File "pandas\_libs\hashtable_class_helper.pxi", line 1614, in pandas._libs.hashtable.PyObjectHashTable.get_item

KeyError: 'LEVEL_cm'
jnsebgosselin commented 4 years ago

https://stackoverflow.com/questions/13087344/python-function-default-parameter-is-evaluated-only-once

https://stackoverflow.com/questions/43255782/python-mutable-default-arguments-to-functions