Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Update well name when importing a water dataset #417

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions gwhat/projet/manager_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,20 +818,7 @@ def accept_dataset(self):
del_dset(self.name)

# Update dataset attributes from UI and emit dataset.
if self._datatype == 'water level':
self._dataset['Well'] = self.station_name
self._dataset['Well ID'] = self.station_id
self._dataset['Province'] = self.province
self._dataset['Latitude'] = self.latitude
self._dataset['Longitude'] = self.longitude
self._dataset['Elevation'] = self.altitude
elif self._datatype == 'daily weather':
self._dataset.metadata['Station Name'] = self.station_name
self._dataset.metadata['Station ID'] = self.station_id
self._dataset.metadata['Location'] = self.province
self._dataset.metadata['Latitude'] = self.latitude
self._dataset.metadata['Longitude'] = self.longitude
self._dataset.metadata['Elevation'] = self.altitude
self._update_attributes_from_ui()
self.sig_new_dataset_imported.emit(self.name, self._dataset)

if len(self._queued_filenames):
Expand All @@ -848,6 +835,22 @@ def close(self):
self.directory.clear()
self.update_gui()

def _update_attributes_from_ui(self):
if self._datatype == 'water level':
self._dataset['Well'] = self.station_name
self._dataset['Well ID'] = self.station_id
self._dataset['Province'] = self.province
self._dataset['Latitude'] = self.latitude
self._dataset['Longitude'] = self.longitude
self._dataset['Elevation'] = self.altitude
elif self._datatype == 'daily weather':
self._dataset.metadata['Station Name'] = self.station_name
self._dataset.metadata['Station ID'] = self.station_id
self._dataset.metadata['Location'] = self.province
self._dataset.metadata['Latitude'] = self.latitude
self._dataset.metadata['Longitude'] = self.longitude
self._dataset.metadata['Elevation'] = self.altitude


if __name__ == '__main__':
import sys
Expand Down
7 changes: 5 additions & 2 deletions gwhat/projet/reader_waterlvl.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,10 @@ def __len__(self):
return len(self._dataf)

def __setitem__(self, key, value):
return NotImplementedError
raise NotImplementedError

def __iter__(self):
return NotImplementedError
raise NotImplementedError

# ---- Attributes
@property
Expand Down Expand Up @@ -405,6 +405,9 @@ def __getitem__(self, key):

return self.dset.__getitem__(key)

def __setitem__(self, key, value):
self._dataf.attrs[key] = value

def __load_dataset__(self, filename):
"""Loads the dataset from a file and saves it in the store."""
self._dataf = read_water_level_datafile(filename)
Expand Down