Skip to content

Commit

Permalink
Making coordinate variables searchable (#212)
Browse files Browse the repository at this point in the history
- Updated builders to scan for all variables, not just data variables.
- Updated tests to include coordinate variable discovery.
  • Loading branch information
charles-turner-1 authored Oct 18, 2024
1 parent 017cd2d commit ab37010
Show file tree
Hide file tree
Showing 3 changed files with 209 additions and 84 deletions.
2 changes: 1 addition & 1 deletion src/access_nri_intake/source/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def parse_access_ncfile(
) as ds:
dvars = _VarInfo()

for var in ds.data_vars:
for var in ds.variables:
attrs = ds[var].attrs
dvars.append_attrs(var, attrs) # type: ignore

Expand Down
8 changes: 4 additions & 4 deletions src/access_nri_intake/source/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from dataclasses import asdict, dataclass, field
from datetime import timedelta
from pathlib import Path
from typing import Union
from typing import Optional, Union

import cftime
import xarray as xr
Expand All @@ -33,7 +33,7 @@ class _AccessNCFileInfo:
filename: Union[str, Path]
file_id: str
path: str
filename_timestamp: Union[str, None]
filename_timestamp: Optional[str]
frequency: str
start_date: str
end_date: str
Expand Down Expand Up @@ -139,7 +139,7 @@ def _guess_start_end_dates(ts, te, frequency):

def get_timeinfo(
ds: xr.Dataset,
filename_frequency: Union[str, None],
filename_frequency: Optional[str],
time_dim: str,
) -> tuple[str, str, str]:
"""
Expand Down Expand Up @@ -177,7 +177,7 @@ def _todate(t):
time_format = "%Y-%m-%d, %H:%M:%S"
ts = None
te = None
frequency: Union[str, tuple[Union[int, None], str]] = "fx"
frequency: Union[str, tuple[Optional[int], str]] = "fx"
has_time = time_dim in ds

if has_time:
Expand Down
Loading

0 comments on commit ab37010

Please sign in to comment.