Skip to content

Commit

Permalink
Update documentation in regrid2.py (#509)
Browse files Browse the repository at this point in the history
Following the document returns error for `regridder = regrid2.Regrid2Regridder(ds.grid, output_grid)` as below:


```python
AttributeError                            Traceback (most recent call last)
Cell In[25], line 1
----> 1 regridder = regrid2.Regrid2Regridder(ds.grid, output_grid)

File ~/mambaforge/envs/pmp_devel_20230223/lib/python3.9/site-packages/xcdat/regridder/regrid2.py:55, in Regrid2Regridder.__init__(self, input_grid, output_grid, **options)
     13 """
     14 Pure python implementation of the regrid2 horizontal regridder from
     15 CDMS2's regrid2 module.
   (...)
     51 >>> data_new_grid = regridder.horizontal("ts", ds)
     52 """
     53 super().__init__(input_grid, output_grid, **options)
---> 55 self._src_lat = self._input_grid.bounds.get_bounds("Y")
     56 self._src_lon = self._input_grid.bounds.get_bounds("X")
     58 self._dst_lat = self._output_grid.bounds.get_bounds("Y")

AttributeError: 'str' object has no attribute 'bounds'
```

Which is because `type(ds.grid)` is `str`, while `type(ds.regridder.grid)` is `xarray.core.dataset.Dataset`. 

Corrected commend will be
```regridder = regrid2.Regrid2Regridder(ds.regridder.grid, output_grid)
```
  • Loading branch information
lee1043 committed Jun 20, 2023
1 parent be3244e commit 792cdbd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion xcdat/regridder/regrid2.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(
Create regridder:
>>> regridder = regrid2.Regrid2Regridder(ds.grid, output_grid)
>>> regridder = regrid2.Regrid2Regridder(ds.regridder.grid, output_grid)
Regrid data:
Expand Down

0 comments on commit 792cdbd

Please sign in to comment.