Skip to content

Commit

Permalink
Import naming schema from pangeo-forge-esgf (#30)
Browse files Browse the repository at this point in the history
* Import naming schema from pangeo-forge-esgf

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
jbusecke and pre-commit-ci[bot] authored May 2, 2024
1 parent f71bec0 commit ae9acc1
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions leap_data_management_utils/cmip_catalog.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import pandas as pd

# TODO: This should live in pangeo-forge-esgf?
# Need to test over there if the changes regarding member_id/varaint_label are correct
# are breaking anything.
# from pangeo_forge_esgf.utils import CMIP6_naming_schema_official
CMIP6_naming_schema_official = 'mip_era.activity_id.institution_id.source_id.experiment_id.member_id.table_id.variable_id.grid_label.version'
from pangeo_forge_esgf.utils import CMIP6_naming_schema


def _maybe_prepend_dummy_dcpp(s: str):
Expand All @@ -26,7 +21,7 @@ def _maybe_join(iterable):

def bq_df_to_intake_esm(df: pd.DataFrame) -> pd.DataFrame:
df = df.copy()
iid_facets = CMIP6_naming_schema_official.split('.')
iid_facets = CMIP6_naming_schema.split('.')
# some legit pandas magic here: https://stackoverflow.com/a/39358924
df_out = df['instance_id'].str.split('.', expand=True)
df_out = df_out.rename(columns={i: f for i, f in enumerate(iid_facets)})
Expand Down

0 comments on commit ae9acc1

Please sign in to comment.