Introduced new test_read_netcdf.py function for directly converting netCDF files into XarrayContext.#226
Introduced new test_read_netcdf.py function for directly converting netCDF files into XarrayContext.#226dfang843 wants to merge 1 commit into
Conversation
directly converting netCDF files into XarrayContext.
alxmrs
left a comment
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 |
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) |
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) |
There was a problem hiding this comment.
I think open dataset handles this.
| engine: str | None = "netcdf4", | ||
| **open_kwargs, | ||
| ): | ||
| """ |
There was a problem hiding this comment.
We use Google style docstrings.
| table_name = path.stem | ||
|
|
||
| if chunks is None: | ||
| chunks = {"time": 24} if "time" in ds.dims else {d: -1 for d in ds.dims} |
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 |
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) |
There was a problem hiding this comment.
Let's use pytest conventions for tests.
No description provided.