Skip to content

Commit

Permalink
Add ESMDataSource (#372)
Browse files Browse the repository at this point in the history
  • Loading branch information
andersy005 authored Oct 12, 2021
1 parent 79ee48d commit 8770b80
Show file tree
Hide file tree
Showing 12 changed files with 384 additions and 1,008 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ jobs:
use-mamba: true
miniforge-variant: Mambaforge

- name: Set environment variables
run: |
echo "XARRAY_BACKEND_API=v2" >> $GITHUB_ENV
- name: Install intake-esm
run: |
python -m pip install -e . --no-deps --force-reinstall
Expand Down
2 changes: 1 addition & 1 deletion ci/environment-upstream-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dependencies:
- cartopy
- cftime
- codecov
- fastprogress>= 0.2.6
- fastprogress>= 1.0.0
- h5netcdf>=0.8.1
- ipython
- matplotlib
Expand Down
4 changes: 2 additions & 2 deletions ci/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ channels:
dependencies:
- cftime
- codecov
- fastprogress>= 0.2.6
- fastprogress>= 1.0.0
- fsspec>=0.8.0
- gcsfs
- h5netcdf>=0.8.1
Expand All @@ -24,7 +24,7 @@ dependencies:
- python=*=*cp*
- s3fs
- scipy
- xarray>=0.16.2
- xarray>=0.19
- zarr >=2.5
- pip:
- -r ../requirements.txt
11 changes: 8 additions & 3 deletions intake_esm/_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def search(
"""Search for entries in the catalog."""
query = query_model.normalize_query()
if not query:
warnings.warn(f'Empty query: {query} returned zero results.', stacklevel=2)
warnings.warn(f'Empty query: {query} returned zero results.', UserWarning, stacklevel=2)
return pd.DataFrame(columns=df.columns)
global_mask = np.ones(len(df), dtype=bool)
for column, values in query.items():
Expand All @@ -47,7 +47,10 @@ def search(
mask = df[column] == value
local_mask = local_mask | mask
global_mask = global_mask & local_mask
return df.loc[global_mask]
results = df.loc[global_mask]
if results.empty:
warnings.warn(f'Query: {query} returned zero results.', UserWarning, stacklevel=2)
return results


def search_apply_require_all_on(results: pd.DataFrame, query_model: 'QueryModel') -> pd.DataFrame:
Expand Down Expand Up @@ -78,5 +81,7 @@ def search_apply_require_all_on(results: pd.DataFrame, query_model: 'QueryModel'
if query_results:
return pd.concat(query_results)

warnings.warn(f'Query: {query_model.normalize_query()} returned zero results.', stacklevel=2)
warnings.warn(
f'Query: {query_model.normalize_query()} returned zero results.', UserWarning, stacklevel=2
)
return pd.DataFrame(columns=results.columns)
Loading

0 comments on commit 8770b80

Please sign in to comment.