Introduced new test_read_netcdf.py function for directly converting netCDF files into XarrayContext. - #226
Open
dfang843 wants to merge 1 commit into
Open
Introduced new test_read_netcdf.py function for directly converting netCDF files into XarrayContext.#226dfang843 wants to merge 1 commit into
dfang843 wants to merge 1 commit into
Conversation
directly converting netCDF files into XarrayContext.
alxmrs
requested changes
Jul 12, 2026
alxmrs
left a comment
Member
There was a problem hiding this comment.
First (quick) pass. Thanks for the PR!
| self.register_udf(cft.make_cftime_udf(units, cal)) | ||
| break # One UDF per context is enough. | ||
|
|
||
| @classmethod |
Member
There was a problem hiding this comment.
I think this should be an instance method.
| """ | ||
| path = Path(path) | ||
|
|
||
| ds = xr.open_dataset(path, engine=engine, **open_kwargs) |
Member
There was a problem hiding this comment.
The engine should be best-effort a netcdf engine IMO, and users won't need to pass it in, since the method name implies the type of data.
| XarrayContext | ||
| A context with the dataset already registered. | ||
| """ | ||
| path = Path(path) |
Member
There was a problem hiding this comment.
I think open dataset handles this.
| engine: str | None = "netcdf4", | ||
| **open_kwargs, | ||
| ): | ||
| """ |
| table_name = path.stem | ||
|
|
||
| if chunks is None: | ||
| chunks = {"time": 24} if "time" in ds.dims else {d: -1 for d in ds.dims} |
Member
There was a problem hiding this comment.
Let's be correct, not polite. The users must pass in chunks.
| from .reader import read_xarray_table | ||
|
|
||
| from pathlib import Path | ||
| from matplotlib.dates import date2num |
Collaborator
Author
There was a problem hiding this comment.
These libraries have been imported to ensure that test_read_netcdf.py doesn't throw errors when running.
| from metpy.cbook import get_test_data | ||
| from xarray_sql import XarrayContext | ||
|
|
||
| path = get_test_data('irma_gfs_example.nc', False) |
Member
There was a problem hiding this comment.
Let's use pytest conventions for tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.