Skip to content

Commit

Permalink
docstrings in dataset_modeldata
Browse files Browse the repository at this point in the history
  • Loading branch information
vergauwenthomas committed Aug 28, 2024
1 parent 365ad9b commit d45606d
Show file tree
Hide file tree
Showing 10 changed files with 418 additions and 824 deletions.
4 changes: 2 additions & 2 deletions metobs_toolkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@

# Special functions that can be directly called by te user
from metobs_toolkit.template_build_prompt import build_template_prompt
from metobs_toolkit.modeldata import connect_to_gee, import_modeldata_from_pkl

from metobs_toolkit.modeldata import import_modeldata_from_pkl
from metobs_toolkit.gee_api import connect_to_gee

# =============================================================================
# Version
Expand Down
8 changes: 6 additions & 2 deletions metobs_toolkit/dataset_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,11 @@ def get_station(self, stationname):

logger.info(f"Extract {stationname} from dataset.")

if self.df.empty:
raise MetobsDatasetError(
f"Cannot get station {stationname} from an empty Dataset."
)

# important: make sure all station attributes are of the same time as dataset.
# so that all methods can be inherited.

Expand All @@ -923,8 +928,7 @@ def get_station(self, stationname):
df=sta_df,
outliersdf=sta_outliers,
gaps=sta_gaps,
# gapfilldf=sta_gapfill,
# missing_fill_df=sta_missingfill,
gee_datasets=list(self.gee_datasets.values()),
metadf=sta_metadf,
obstypes=self.obstypes,
template=self.template,
Expand Down
344 changes: 266 additions & 78 deletions metobs_toolkit/dataset_modeldata.py

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion metobs_toolkit/datasetbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,15 @@ def _set_gaps(self, gapslist):
# TODO: run simple checks
self.gaps = gapslist

def _set_gee_dataset(self, geedatasetlist):
# clear all metadata and extracted timeseries form the geedatasets
gee_dataset_dict = {}
for gee_dataset in geedatasetlist:
gee_dataset._clear_data()
gee_dataset_dict[gee_dataset.name] = gee_dataset

self.gee_datasets = gee_dataset_dict

def _append_to_applied_qc(self, obstypename, checkname):
"""Add record to _applied_qc.
The applied qc is mainly used to save the order of applied checks,
Expand Down Expand Up @@ -272,7 +281,11 @@ def _append_to_applied_qc(self, obstypename, checkname):
# Getters
# =============================================================================
def _get_tz(self):
return self.df.index.get_level_values("datetime").tz
# IF no data --> tz is UTC (to work without data for gee fun)
if self.df.empty:
return "UTC"
else:
return self.df.index.get_level_values("datetime").tz

def _get_present_obstypes(self):
"""Get all present obstypenames in the df.
Expand Down
Loading

0 comments on commit d45606d

Please sign in to comment.