Skip to content

[Feature]: Improve create_grid function #496

@jasonb5

Description

@jasonb5

Is your feature request related to a problem?

The create_grid arguments are not descriptive due to the use of **kwargs,

Describe the solution you'd like

Update create_grid function to def create_grid(x: Optional[Union[xr.DataArray, Tuple[xr.DataArray, xr.DataArray]]] = None, y: Optional[Union[xr.DataArray, Tuple[xr.DataArray, xr.DataArray]]] = None, z: Optional[Union[xr.DataArray, Tuple[xr.DataArray, xr.DataArray]]] = None, attrs: Optional[Dict[str, str]] = None) -> xr.Dataset.

Users can now explicitly define x, y, and z dimensions when creating a grid.

attrs will be grid attributes, we should consider if there are any defaults we want.

Add create_axis function, def create_axis(name: str, data: Union[List[Union[int, float]], np.ndarray], bounds: Optional[Union[List[List[Union[int, float]]], np.ndarray]] = None, attrs: Dict[str, str]) -> Tuple[xr.DataArray, Optional[xr.DataArray]]

attrs will be merged into the default attributes where the defaults take precedence.

If bounds is not passed should we automatically generate them? Otherwise we could add a generate_bounds argument to trigger the generation.

Describe alternatives you've considered

def create_grid(x: GridCoord, y: GridCoord, z: GridCoord) -> xr.Dataset:

Where GridCoord could be any of the following forms.

(name, data)
(name, data, attrs)
(name, data, bnds)
(name, data, bnds, attrs)

The data and bnds options can be List or np.ndarray.

Additional context

Previous discussion #388 (comment).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions