Skip to content

Commit

Permalink
Add tests and pin pangeo-forge-esgf>0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jbusecke committed May 31, 2024
1 parent f61657e commit 66d9207
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,4 @@ cython_debug/
#.idea/

_version.py
.vscode/settings.json
45 changes: 45 additions & 0 deletions leap_data_management_utils/tests/test_cmip_catalog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import pandas as pd

from leap_data_management_utils.cmip_catalog import bq_df_to_intake_esm


def test_bq_df_to_intake_esm():
bq_df = pd.DataFrame(
{
'instance_id': [
'CMIP6.AerChemMIP.MIROC.MIROC6.piClim-NTCF.sub-r1i1p1f1.Amon.tasmin.gn.v20190807', # modified to test the sub_experiment split
'CMIP6.AerChemMIP.MIROC.MIROC6.piClim-OC.r1i1p1f1.Amon.rlut.gn.v20190807',
],
'store': [
'gs://cmip6/CMIP6/AerChemMIP/MIROC/MIROC6/piClim-NTCF/r1i1p1f1/Amon/tasmin/gn/v20190807/',
'gs://cmip6/CMIP6/AerChemMIP/MIROC/MIROC6/piClim-OC/r1i1p1f1/Amon/rlut/gn/v20190807/',
],
'retracted': [False, False],
'tests_passed': [True, True],
}
)
intake_df = bq_df_to_intake_esm(bq_df)
for c in intake_df.columns:
print(c)
print(intake_df[c].to_list())

expected_intake_df = pd.DataFrame(
{
'activity_id': ['AerChemMIP', 'AerChemMIP'],
'institution_id': ['MIROC', 'MIROC'],
'source_id': ['MIROC6', 'MIROC6'],
'experiment_id': ['piClim-NTCF', 'piClim-OC'],
'member_id': ['sub-r1i1p1f1', 'r1i1p1f1'],
'table_id': ['Amon', 'Amon'],
'variable_id': ['tasmin', 'rlut'],
'grid_label': ['gn', 'gn'],
'sub_experiment_id': ['sub', 'none'],
'variant_label': ['r1i1p1f1', 'r1i1p1f1'],
'version': ['v20190807', 'v20190807'],
'zstore': [
'gs://cmip6/CMIP6/AerChemMIP/MIROC/MIROC6/piClim-NTCF/r1i1p1f1/Amon/tasmin/gn/v20190807/',
'gs://cmip6/CMIP6/AerChemMIP/MIROC/MIROC6/piClim-OC/r1i1p1f1/Amon/rlut/gn/v20190807/',
],
}
)
assert intake_df.equals(expected_intake_df)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ bigquery=[
"google-api-core",
"google-cloud-bigquery",
"db_dtypes",
"pangeo-forge-esgf",
"pangeo-forge-esgf>0.3.0",
]
pangeo-forge=[
"pangeo-forge-recipes",
Expand Down

0 comments on commit 66d9207

Please sign in to comment.