pyGPlates: PolygonOnSphere issues

Hi all,

quick question (Python 3.8.8 via Anaconda, pygplates rev 28, py 3.8, win 64) :

lons = np.array([-2, 2, 2, -2,-2])
lats = np.array([ 2, 2 ,-2,-2, 2])
pygplates.PolygonOnSphere( zip(lats, lons) )

doesn’t work - complains about TypeError: Expected a sequence of points, strangely as it is given here as example

lons = np.array([-2, 2, 2, -2,-2])
lats = np.array([ 2, 2 ,-2,-2, 2])
pygplates.PolygonOnSphere( list(zip(lats, lons)) )

doesn’t work - also complains about TypeError: Expected a sequence of points, despite type(list(zip(lats,lons))) being list.

points = []
points.append((-2, 2))
points.append((2, 2))
points.append((2, -2))
points.append((-2, -2))
points.append((-2, 2))
pygplates.PolygonOnSphere( points )

works, type(points) yields list as above.

Am I missing something?
Cheers,
Christian

Hi Christian,

Thanks for pointing that out. Turns out it’s the same issue with numpy.int32 as mentioned in this recent post.

It’s been fixed in internal releases, but the latest public release (August 2020) does not support it. (if I recall correctly more recent versions of NumPy necessitated that fix)

So, until the next public release, the workaround is the same as mentioned in that thread (eg, use float, or a NumPy float, instead of a NumPy integer):

lons = np.array([-2, 2, 2, -2,-2], dtype=float)

…or…

lons = np.array([-2, 2, 2, -2,-2], dtype=np.float64)

…or even use float literals in the array…

lons = np.array([-2.0, 2.0, 2.0, -2.0, -2.0])

Thanks John - that clarifies it. Haven’t tested again but given that you are aware and have a workaround I trust that this will do :wink:

(replying from my non-work account)