added another kwargs for read in #384
Closed
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.
Overview
When trying to read in FVCOM model output, the necessary
kwargs
are not passed forward in the open function.Expected Usage
Without this change
Returns the following because the dropped variables are not being dropped.
With the change in the PR, the same code returns the following, which appears to be the correct error for the inputs at this time:
File ~/packages/uxarray/uxarray/core/api.py:165, in open_dataset(grid_filename_or_obj, filename_or_obj, gridspec, vertices, islatlon, isconcave, use_dual, **kwargs)
109 """Wraps
xarray.open_dataset()
, given a grid topology definition with a110 single dataset file or object with corresponding data.
111
(...)
161 >>> ux_ds = ux.open_dataset("grid_filename.g", "grid_filename_vortex.nc")
162 """
164 ## Grid definition
--> 165 uxgrid = open_grid(grid_filename_or_obj,
166 gridspec=gridspec,
167 vertices=vertices,
168 islatlon=islatlon,
169 isconcave=isconcave,
170 use_dual=use_dual,
171 **kwargs)
173 ## UxDataset
174 ds = xr.open_dataset(filename_or_obj, decode_times=False,
175 **kwargs) # type: ignore
File ~/packages/uxarray/uxarray/core/api.py:90, in open_grid(grid_filename_or_obj, gridspec, vertices, islatlon, isconcave, use_dual, **kwargs)
85 else:
86 grid_ds = xr.open_dataset(grid_filename_or_obj,
87 decode_times=False,
88 **kwargs) # type: ignore
---> 90 uxgrid = Grid(grid_ds,
91 gridspec=gridspec,
92 vertices=vertices,
93 islatlon=islatlon,
94 isconcave=isconcave,
95 source_grid=str(grid_filename_or_obj),
96 use_dual=use_dual)
98 return uxgrid
File ~/packages/uxarray/uxarray/core/grid.py:100, in Grid.init(self, input_obj, **kwargs)
97 # check if initializing from string
98 # TODO: re-add gridspec initialization when implemented
99 elif isinstance(input_obj, xr.Dataset):
--> 100 self.mesh_type = parse_grid_type(input_obj)
101 self.from_ds(dataset=input_obj)
102 else:
File ~/packages/uxarray/uxarray/utils/helpers.py:48, in parse_grid_type(dataset)
46 mesh_type = "mpas"
47 else:
---> 48 raise RuntimeError(f"Could not recognize dataset format.")
49 return mesh_type
51 # check mesh topology and dimension
RuntimeError: Could not recognize dataset format.