Skip to content
Snippets Groups Projects
Commit d4abd2ac authored by lukas leufen's avatar lukas leufen
Browse files

add station_type check for local stored data

parent 5a7ec78a
Branches
Tags
2 merge requests!17update to v0.4.0,!16handle station type
Pipeline #26578 passed
...@@ -80,12 +80,20 @@ class DataPrep(object): ...@@ -80,12 +80,20 @@ class DataPrep(object):
data = self._slice_prep(xr.open_dataarray(file_name)) data = self._slice_prep(xr.open_dataarray(file_name))
self.data = self.check_for_negative_concentrations(data) self.data = self.check_for_negative_concentrations(data)
self.meta = pd.read_csv(meta_file, index_col=0) self.meta = pd.read_csv(meta_file, index_col=0)
if self.station_type is not None:
self.check_station_type()
except FileNotFoundError as e: except FileNotFoundError as e:
logging.warning(e) logging.warning(e)
data, self.meta = self.download_data_from_join(file_name, meta_file) data, self.meta = self.download_data_from_join(file_name, meta_file)
data = self._slice_prep(data) data = self._slice_prep(data)
self.data = self.check_for_negative_concentrations(data) self.data = self.check_for_negative_concentrations(data)
def check_station_type(self):
if self.meta.at["station_type", self.station[0]] != self.station_type:
self.data = None
self.meta = None
raise join.EmptyQueryResult
def download_data_from_join(self, file_name: str, meta_file: str) -> [xr.DataArray, pd.DataFrame]: def download_data_from_join(self, file_name: str, meta_file: str) -> [xr.DataArray, pd.DataFrame]:
""" """
Download data from TOAR database using the JOIN interface. Download data from TOAR database using the JOIN interface.
...@@ -114,7 +122,7 @@ class DataPrep(object): ...@@ -114,7 +122,7 @@ class DataPrep(object):
def __repr__(self): def __repr__(self):
return f"Dataprep(path='{self.path}', network='{self.network}', station={self.station}, " \ return f"Dataprep(path='{self.path}', network='{self.network}', station={self.station}, " \
f"variables={self.variables}, **{self.kwargs})" f"variables={self.variables}, station_type='{self.station_type}', **{self.kwargs})"
def interpolate(self, dim: str, method: str = 'linear', limit: int = None, def interpolate(self, dim: str, method: str = 'linear', limit: int = None,
use_coordinate: Union[bool, str] = True, **kwargs): use_coordinate: Union[bool, str] = True, **kwargs):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment