Skip to content

Commit

Permalink
Revert "Merge branch '660-coordinate-variables' into 199-data-request…
Browse files Browse the repository at this point in the history
…-20km-regional-projections-for-cordex-cmip6-queensland-future-climate-science"

This reverts commit 27e460f, reversing
changes made to 0c96e28.
  • Loading branch information
charles-turner-1 committed Oct 14, 2024
1 parent b3dc52d commit b3da577
Show file tree
Hide file tree
Showing 8 changed files with 418 additions and 789 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,3 @@ dmypy.json
sandpit.ipynb
*.DS_Store
bin/build_all.sh.o*

# Vs Code
.vscode/
7 changes: 0 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,3 @@ repos:
hooks:
- id: black
language_version: python3
# Mypy
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.11.2'
hooks:
- id: mypy
name: mypy
additional_dependencies: [types-PyYAML==6.0.12.20240808]
25 changes: 12 additions & 13 deletions src/access_nri_intake/catalog/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
""" Manager for adding/updating intake sources in an intake-dataframe-catalog like the ACCESS-NRI catalog """

import os
from typing import Optional, Union

import intake
from intake_dataframe_catalog.core import DfFileCatalog
Expand All @@ -31,7 +30,7 @@ class CatalogManager:
Add/update intake sources in an intake-dataframe-catalog like the ACCESS-NRI catalog
"""

def __init__(self, path: str):
def __init__(self, path):
"""
Initialise a CatalogManager instance to add/update intake sources in a
intake-dataframe-catalog like the ACCESS-NRI catalog
Expand Down Expand Up @@ -59,14 +58,14 @@ def __init__(self, path: str):

def build_esm(
self,
name: str,
description: str,
name,
description,
builder,
path: Union[str, list[str]],
path,
translator=DefaultTranslator,
metadata: Optional[dict] = None,
directory: Optional[str] = None,
overwrite: bool = False,
metadata=None,
directory=None,
overwrite=False,
**kwargs,
):
"""
Expand Down Expand Up @@ -125,12 +124,12 @@ def build_esm(

def load(
self,
name: str,
description: str,
path: str,
driver: str = "esm_datastore",
name,
description,
path,
driver="esm_datastore",
translator=DefaultTranslator,
metadata: Optional[dict] = None,
metadata=None,
**kwargs,
):
"""
Expand Down
24 changes: 11 additions & 13 deletions src/access_nri_intake/catalog/translators.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import pandas as pd
import tlz
from intake import DataSource

from . import COLUMNS_WITH_ITERABLES

Expand Down Expand Up @@ -74,7 +73,7 @@ class DefaultTranslator:
of metadata for use in an intake-dataframe-catalog.
"""

def __init__(self, source: DataSource, columns: list[str]):
def __init__(self, source, columns):
"""
Initialise a DefaultTranslator. This Translator works as follows:
Expand All @@ -94,13 +93,13 @@ def __init__(self, source: DataSource, columns: list[str]):

self.source = source
self.columns = columns
self._dispatch: dict[str, Callable[[], pd.Series]] = {
self._dispatch = {
column: partial(self._default_translator, column=column)
for column in columns
}
self._dispatch_keys = _DispatchKeys()

def _default_translator(self, column: str) -> pd.Series:
def _default_translator(self, column):
"""
Try to translate a column from a source using the default translator. This translator works as follows:
- If the input source is an intake-esm datastore, the translator will first look for the column in the
Expand Down Expand Up @@ -146,7 +145,7 @@ def _default_translator(self, column: str) -> pd.Series:

return pd.Series([val] * len_df)

def translate(self, groupby: Optional[list[str]] = None) -> pd.DataFrame:
def translate(self, groupby=None):
"""
Return the translated :py:class:`~pandas.DataFrame` of metadata and merge into set of
set of rows with unique values of the columns specified.
Expand Down Expand Up @@ -228,7 +227,7 @@ class Cmip6Translator(DefaultTranslator):
CMIP6 Translator for translating metadata from the NCI CMIP6 intake datastores.
"""

def __init__(self, source: DataSource, columns: list[str]):
def __init__(self, source, columns):
"""
Initialise a Cmip6Translator
Expand Down Expand Up @@ -259,7 +258,7 @@ class Cmip5Translator(DefaultTranslator):
CMIP5 Translator for translating metadata from the NCI CMIP5 intake datastores.
"""

def __init__(self, source: DataSource, columns: list[str]):
def __init__(self, source, columns):
"""
Initialise a Cmip5Translator
Expand Down Expand Up @@ -290,7 +289,7 @@ class EraiTranslator(DefaultTranslator):
ERAI Translator for translating metadata from the NCI ERA-Interim intake datastore.
"""

def __init__(self, source: DataSource, columns: list[str]):
def __init__(self, source, columns):
"""
Initialise a EraiTranslator
Expand Down Expand Up @@ -402,14 +401,13 @@ class _DispatchKeys:
variable: Optional[str] = None


def _cmip_realm_translator(series) -> pd.Series:
def _cmip_realm_translator(series):
"""
Return realm from CMIP realm metadata, fixing some issues. This function takes
a series of strings and returns a series of tuples as there are sometimes multiple
realms per cmip asset
Return realm from CMIP realm metadata, fixing some issues. This function returns
a tuple as there are sometimes multiple realms per cmip asset
"""

def _translate(string: str) -> tuple[str, ...]:
def _translate(string):
translations = {
"na": "none",
"landonly": "land",
Expand Down
Loading

0 comments on commit b3da577

Please sign in to comment.