Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Docker-in-Docker (DinD) capabilities of public runners deactivated.
More info
Open sidebar
IPSL
LMD
InTro
RoutingPP
Commits
8c7f8105
Commit
8c7f8105
authored
Jan 19, 2021
by
Anthony Schrapffer
Browse files
Update WMOreg: case island + coastal stations
parent
00bc9b0b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
+17
-3
Stations/WMOref.py
Stations/WMOref.py
+17
-3
No files found.
Stations/WMOref.py
View file @
8c7f8105
...
...
@@ -36,8 +36,8 @@ class WMOREG:
"""
# Point is (x,y)-(lon,lat)
p1
=
Point
(
lon
,
lat
)
out
=
np
.
array
([
p
1
.
with
in
(
p
oly
)
for
poly
in
self
.
polygonWMO
])
try
:
out
=
np
.
array
([
p
oly
.
conta
in
s
(
p
1
)
for
poly
in
self
.
polygonWMO
])
try
:
index
=
np
.
where
(
out
)[
0
][
0
]
stReg
,
stSubreg
=
self
.
attributesPolygonWMO
[
index
]
if
output
==
"num"
:
...
...
@@ -46,5 +46,19 @@ class WMOREG:
return
[
stReg
,
stSubreg
]
except
:
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment