Skip to content

Commit

Permalink
Merge pull request #505 from djhoese/feature-proj-coords-no-dask
Browse files Browse the repository at this point in the history
Allow use of non-dask pyresample get_proj_vectors method
  • Loading branch information
djhoese authored Dec 19, 2018
2 parents 09fee83 + ce6f8d5 commit 2f931e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions satpy/readers/yaml_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,8 +739,11 @@ def _load_dataset_with_area(self, dsid, coords):

if area is not None:
ds.attrs['area'] = area
if (('x' not in ds.coords) or('y' not in ds.coords)) and \
hasattr(area, 'get_proj_vectors_dask'):
calc_coords = (('x' not in ds.coords) or('y' not in ds.coords)) and hasattr(area, 'get_proj_vectors_dask')
if calc_coords and hasattr(area, 'get_proj_vectors'):
ds['x'], ds['y'] = area.get_proj_vectors()
elif calc_coords:
# older pyresample with dask-only method
ds['x'], ds['y'] = area.get_proj_vectors_dask(CHUNK_SIZE)
return ds

Expand Down
7 changes: 5 additions & 2 deletions satpy/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,8 +790,11 @@ def compute(self, data, expand=True, **kwargs):
# Update coords if we can
if ('y' in data.coords or 'x' in data.coords) and isinstance(target_geo_def, AreaDefinition):
coord_chunks = (d_arr.chunks[y_axis], d_arr.chunks[x_axis])
x_coord, y_coord = target_geo_def.get_proj_vectors_dask(
chunks=coord_chunks)
if hasattr(target_geo_def, 'get_proj_vectors'):
x_coord, y_coord = target_geo_def.get_proj_vectors()
else:
# older version of pyresample
x_coord, y_coord = target_geo_def.get_proj_vectors_dask(chunks=coord_chunks)
if 'y' in data.coords:
coords['y'] = y_coord
if 'x' in data.coords:
Expand Down

0 comments on commit 2f931e3

Please sign in to comment.