Commit 8c7f8105 by Anthony Schrapffer

### Update WMOreg: case island + coastal stations

parent 00bc9b0b
 ... @@ -36,8 +36,8 @@ class WMOREG: ... @@ -36,8 +36,8 @@ class WMOREG: """ """ # Point is (x,y)-(lon,lat) # Point is (x,y)-(lon,lat) p1 = Point(lon, lat) p1 = Point(lon, lat) out = np.array([p1.within(poly) for poly in self.polygonWMO]) out = np.array([poly.contains(p1) for poly in self.polygonWMO]) try : try : index = np.where(out)[0][0] index = np.where(out)[0][0] stReg, stSubreg = self.attributesPolygonWMO[index] stReg, stSubreg = self.attributesPolygonWMO[index] if output=="num": if output=="num": ... @@ -46,5 +46,19 @@ class WMOREG: ... @@ -46,5 +46,19 @@ class WMOREG: return [stReg, stSubreg] return [stReg, stSubreg] except: except: print("lon: {0}; lat: {1}".format(lon,lat)) print("lon: {0}; lat: {1}".format(lon,lat)) print("No valid WMO region has been found, verify the lon lat") print("Inexact location : finding the closest subregion.") out = np.array([self.get_distance(poly,p1) for poly in self.polygonWMO]) index = np.argmin(out) stReg, stSubreg = self.attributesPolygonWMO[index] if output=="num": return stReg*100+stSubreg elif output == "list": return [stReg, stSubreg] def get_distance(self, poly,p1): try: d = poly.exterior.distance(p1) except: d = np.min([p.exterior.distance(p1) for p in poly]) return d
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!