Skip to content
Snippets Groups Projects
Commit 2b26cd98 authored by POLCHER Jan's avatar POLCHER Jan :bicyclist_tone4:
Browse files

Avoid going through the XYZ coordinate system for SphericalGeometry. Use the from_lonlat function.

parent cd20f2e9
No related branches found
No related tags found
No related merge requests found
......@@ -38,13 +38,12 @@ def corners(lon, lat) :
#
for i in range(iim) :
for j in range(jjm) :
#
allon=[lon[j,i]-hdlon, lon[j,i]+hdlon, lon[j,i]+hdlon, lon[j,i]-hdlon, lon[j,i]-hdlon]
allat=[lat[j,i]+hdlat, lat[j,i]+hdlat, lat[j,i]-hdlat, lat[j,i]-hdlat, lat[j,i]+hdlat]
polyxyz=RPP.lonlat2xyz(allon, allat)
centxyz=RPP.lonlat2xyz(lon[j,i], lat[j,i])
cornerspoly.append(polygon.SphericalPolygon(polyxyz,inside=centxyz))
#
cornerspoly.append(polygon.SphericalPolygon.from_lonlat(allon, allat, center=[lon[j,i], lat[j,i]]))
#
index.append([j,i])
cornersll.append([[tlon,tlat] for tlon,tlat in zip(allon, allat)])
......
......@@ -101,16 +101,13 @@ def corners(indF, proj, istart, jstart, lon, lat) :
[istart+ij[0]-0.5*dlon,jstart+ij[1]-0.0*dlat],
[istart+ij[0]-0.5*dlon,jstart+ij[1]+0.5*dlat]]
polyll=proj.ijll(polyg)
polyxyz=RPP.lonlat2xyz([p[0] for p in polyll],[p[1] for p in polyll])
centll=proj.ijll([[istart+ij[0],jstart+ij[1]]])[0]
#
allon.append([p[0] for p in polyll])
allat.append([p[1] for p in polyll])
#
centll=[lon[ij[1]-1,ij[0]-1], lat[ij[1]-1,ij[0]-1]]
sphpoly=polygon.SphericalPolygon.from_lonlat([p[0] for p in polyll], [p[1] for p in polyll], center=centll)
#
centxyz=RPP.lonlat2xyz(centll[0],centll[1])
sphpoly=polygon.SphericalPolygon(polyxyz,inside=centxyz)
areas.append((sphpoly.area())*EarthRadius**2)
cornerspoly.append(sphpoly)
cornersll.append(polyll)
......@@ -274,8 +271,6 @@ class ModelGrid :
#
self.contfrac=self.landgather(self.land)
#
self.coordxyz = RPP.lonlat2xyz([coo[0] for coo in self.coordll], [coo[1] for coo in self.coordll])
#
for ip in self.neighbours[0][:] :
if ip >= 0 :
DEBUG("Neighbour : "+str(ip)+" P index : "+str(self.indP[ip])+" F index : "+str(indF[ip][:]))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment