Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
E
extract_cyclones
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
cyclobs
extract_cyclones
Commits
04b550df
Commit
04b550df
authored
Sep 16, 2020
by
CEVAER
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed wrong polygon when data was crossing anti-meridian
parent
264f7225
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
3 deletions
+23
-3
bin/extractSmapCyclone.py
bin/extractSmapCyclone.py
+1
-1
bin/extractSmosCyclone.py
bin/extractSmosCyclone.py
+3
-2
extract_cyclones/__init__.py
extract_cyclones/__init__.py
+19
-0
No files found.
bin/extractSmapCyclone.py
View file @
04b550df
...
...
@@ -45,7 +45,7 @@ if __name__ == "__main__":
logger
.
setLevel
(
logging
.
INFO
)
logging
.
basicConfig
(
level
=
logging
.
INFO
)
from
smap
_cyclones
import
process_file
from
extract
_cyclones
import
process_file
engine
=
create_engine
(
args
.
dbd
,
pool_size
=
50
,
max_overflow
=
0
)
Session
=
sessionmaker
(
bind
=
engine
)
...
...
bin/extractSmosCyclone.py
View file @
04b550df
...
...
@@ -50,9 +50,10 @@ if __name__ == "__main__":
engine
=
create_engine
(
args
.
dbd
,
pool_size
=
50
,
max_overflow
=
0
)
Session
=
sessionmaker
(
bind
=
engine
)
attrs_to_del
=
[
"aprrox_local_equatorial_crossing_time"
,
"swath_sector"
]
attrs_to_del
=
[
"aprrox_local_equatorial_crossing_time"
,
"swath_sector"
,
"geospatial_bounds"
,
"geospatial_lat_min"
,
"geospatial_lat_max"
,
"geospatial_lon_min"
,
"geospatial_lon_max"
]
from
smap
_cyclones
import
process_file
from
extract
_cyclones
import
process_file
for
f
in
args
.
input
:
# TODO generate filename_format depending on input filename
...
...
smap
_cyclones/__init__.py
→
extract
_cyclones/__init__.py
View file @
04b550df
...
...
@@ -12,6 +12,7 @@ import numpy as np
import
math
from
geo_shapely
import
shape360
from
shapely.wkt
import
dumps
from
shapely.geometry
import
Polygon
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -27,6 +28,12 @@ def deg180(deg360):
return
res
def
deg360
(
deg180
):
"""shapely shape to 0 360 (for shapely.ops.transform)"""
lon
=
np
.
array
(
deg180
)
%
360
return
lon
def
get_track_points_from_database
(
session
,
date
):
req_tracks
=
session
.
query
(
SimpleTrack
,
func
.
ST_X
(
cast
(
SimpleTrack
.
geom
,
Geometry
)).
label
(
"lon"
),
func
.
ST_Y
(
cast
(
SimpleTrack
.
geom
,
Geometry
)).
label
(
"lat"
))
\
...
...
@@ -139,8 +146,18 @@ def set_nan_outside_time_offset(dataset, track_data, time_col_name, wind_col_nam
return
dataset
def
transform_polyg_180
(
p
):
coords
=
p
.
exterior
.
coords
new_coords
=
[(
c
[
0
]
-
360
,
c
[
1
])
if
c
[
0
]
>
180
else
(
c
[
0
],
c
[
1
])
for
c
in
coords
]
return
Polygon
(
new_coords
)
# Extract footprint (not taking NaN data into account)
def
compute_footprint
(
dataset
,
wind_field
):
# Using 0:360 range because the -180:180 range does create the right polygon with gdf.unary_union.convex_hull
dataset
[
"lon"
]
=
deg360
(
dataset
[
"lon"
])
df
=
dataset
.
to_dataframe
()
df
=
df
[
pd
.
isna
(
df
[
wind_field
])
==
False
]
df
=
df
.
reset_index
()
...
...
@@ -149,6 +166,8 @@ def compute_footprint(dataset, wind_field):
df
,
geometry
=
gpd
.
points_from_xy
(
df
.
lon
,
df
.
lat
))
p
=
gdf
.
unary_union
.
convex_hull
# Transforming the polygon so its coords are in range -180:180
p
=
transform_polyg_180
(
p
)
return
p
...
...
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