Resampling swath to another swath: no attribute get_proj_coords
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 385
- Forks
- 102
- Avg merge
- 4d 2h
- Merged PRs (30d)
- 9
Description
According to the Resampling of swath data docs:
Pyresample can be used to resample a swath dataset to a grid, a grid to a swath or a swath to another swath.
but if
from pyresample import geometry
from pyresample.bilinear import XArrayBilinearResampler
# Missing variable definitions omitted for simplicity,
# but all 2D arrays, and radius_of_influence a number > 0 representing metres
source_def = geometry.SwathDefinition(lons=lons_s, lats=lats_s)
target_def = geometry.SwathDefinition(lons=lons_t, lats=lats_t)
resampler = XArrayBilinearResampler(source_def, target_def, radius_of_influence)
result = resampler.resample(data)
then the following error is raised:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/home/amell/test/whiteboard.ipynb Cell 27' in <cell line: 1>()
----> [1](vscode-notebook-cell://home/amell/test/whiteboard.ipynb#ch0000027vscode-remote?line=0) resampled_surface_precipitation = resampler.resample(ds_gpm_subset.surface_precipitation.values)
File ~/miniconda3/envs/test/lib/python3.10/site-packages/pyresample/bilinear/xarr.py:71, in XArrayBilinearResampler.resample(***failed resolving arguments***)
69 """Resample the given data."""
70 del nprocs
---> 71 self.get_bil_info()
72 return self.get_sample_from_bil_info(data, fill_value=fill_value, output_shape=None)
File ~/miniconda3/envs/test/lib/python3.10/site-packages/pyresample/bilinear/_base.py:118, in BilinearBase.get_bil_info(self, kdtree_class, nprocs)
115 self._get_index_array()
117 # Calculate vertical and horizontal fractional distances t and s
--> 118 self._get_fractional_distances()
119 self._get_target_proj_vectors()
120 self._get_slices()
File ~/miniconda3/envs/test/lib/python3.10/site-packages/pyresample/bilinear/_base.py:165, in BilinearBase._get_fractional_distances(self)
164 def _get_fractional_distances(self):
--> 165 out_x, out_y = self._get_output_xy()
166 # Get the four closest corner points around each output location
167 corner_points, self._index_array = \
168 _get_four_closest_corners(*self._get_input_xy(),
169 out_x, out_y,
...
217 def _get_output_xy(target_geo_def):
--> 218 out_x, out_y = target_geo_def.get_proj_coords(chunks=CHUNK_SIZE)
219 return da.compute(np.ravel(out_x), np.ravel(out_y))
AttributeError: 'SwathDefinition' object has no attribute 'get_proj_coords'
The same happens if NumpyBilinearResampler is used in place of XArrayBilinearResampler.
I expected pyresample to be consistent with the docs. On the other hand, in this example I expect that radius_of_influence is used on the WSG84, and not on some Cartesian coordinates.
Versions used:
- Python: 3.10.4
- Pyresample: 1.23.0
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with SwathDefinition and a bilinear resampler, then read pyresample/bilinear/xarr.py and pyresample/bilinear/_base.py around get_bil_info, _get_fractional_distances, and _get_output_xy. Check the swath-to-swath documentation and determine the intended coordinate handling and radius-of-influence units. Done means both XArrayBilinearResampler and NumpyBilinearResampler support the documented case or clearly document its limitation, with regression coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100