Skip to content

Commit

Permalink
Make use of the fact that longitudes are an xarray data array, and us…
Browse files Browse the repository at this point in the history
…e 'y' dimension for rows/scanlines

This makes the code resillient towards any other (awkward) data layout than the standard (where first dimension is usually the rows.


Signed-off-by: Adam.Dybbroe <[email protected]>
  • Loading branch information
Adam.Dybbroe committed Nov 17, 2023
1 parent 6a8afc0 commit 05d7e37
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pyresample/geometry.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2010-2020 Pyresample developers
# Copyright (C) 2010-2023 Pyresample developers
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
Expand Down Expand Up @@ -693,16 +693,17 @@ def geocentric_resolution(self, ellps='WGS84', radius=None, nadir_factor=2):
if self.ndim == 1:
raise RuntimeError("Can't confidently determine geocentric "
"resolution for 1D swath.")
rows = self.shape[0]

rows = self.lons['y'].shape[0]
start_row = rows // 2 # middle row
src = CRS('+proj=latlong +datum=WGS84')
if radius:
dst = CRS("+proj=cart +a={} +b={}".format(radius, radius))
else:
dst = CRS("+proj=cart +ellps={}".format(ellps))
# simply take the first two columns of the middle of the swath
lons = self.lons[start_row: start_row + 1, :2]
lats = self.lats[start_row: start_row + 1, :2]
lons = self.lons.sel(y=start_row)[:2]
lats = self.lats.sel(y=start_row)[:2]
if hasattr(lons.data, 'compute'):
# dask arrays, compute them together
import dask.array as da
Expand Down

0 comments on commit 05d7e37

Please sign in to comment.