Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FloeNavi Toolbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FloeNavi - Coordinate Reference System
FloeNavi Toolbox
Commits
63920eea
Commit
63920eea
authored
4 years ago
by
Stefan Hendricks
Browse files
Options
Downloads
Patches
Plain Diff
bugfix: incorrect notation of the rotation vector
parent
5f5a02bb
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
floenavi/__init__.py
+39
-21
39 additions, 21 deletions
floenavi/__init__.py
with
39 additions
and
21 deletions
floenavi/__init__.py
+
39
−
21
View file @
63920eea
...
@@ -140,24 +140,29 @@ class FloeNavi(object):
...
@@ -140,24 +140,29 @@ class FloeNavi(object):
:return: icedrift.GeoReferenceStation (+ FloeNaviGrid if return_grid_solution is True)
:return: icedrift.GeoReferenceStation (+ FloeNaviGrid if return_grid_solution is True)
"""
"""
# Use default base station setup
# Use default base station setup
if not specifically supplied
if
basestation_setup
is
None
:
if
basestation_setup
is
None
:
basestation_setup
=
self
.
cfg
.
get_floenavi_cfg
(
dataset_time_bounds
)
basestation_setup
=
self
.
cfg
.
get_floenavi_cfg
(
dataset_time_bounds
)
# Load the collection of FloeNavi basestation files
# Check if base station setup exists
logger
.
info
(
"
--- Establish FloeNavi grid ---
"
)
if
basestation_setup
is
None
:
floenavi_grid
=
FloeNaviGrid
(
self
.
cfg
,
basestation_setup
)
floenavi_grid
.
set_time_bounds
(
dataset_time_bounds
)
# Get Reference station data from two positions
pos_ref
,
pos_hdg
,
fngrid
=
floenavi_grid
.
get_virtual_reference_station_positions
(
dataset_time_bounds
,
**
refstat_kwargs
)
if
pos_ref
is
not
None
:
refstat_ais
=
GeoReferenceStation
.
from_two_basestations
(
pos_ref
,
pos_hdg
)
refstat_ais
.
set_uncertainty
(
fngrid
.
origin_uncertainty_m
,
fngrid
.
heading_uncertainty_deg
)
else
:
refstat_ais
,
fngrid
=
None
,
None
refstat_ais
,
fngrid
=
None
,
None
else
:
# Load the collection of FloeNavi basestation files
logger
.
info
(
"
--- Establish FloeNavi grid ---
"
)
floenavi_grid
=
FloeNaviGrid
(
self
.
cfg
,
basestation_setup
)
floenavi_grid
.
set_time_bounds
(
dataset_time_bounds
)
# Get Reference station data from two positions
pos_ref
,
pos_hdg
,
fngrid
=
floenavi_grid
.
get_virtual_reference_station_positions
(
dataset_time_bounds
,
**
refstat_kwargs
)
if
pos_ref
is
not
None
:
refstat_ais
=
GeoReferenceStation
.
from_two_basestations
(
pos_ref
,
pos_hdg
)
refstat_ais
.
set_uncertainty
(
fngrid
.
origin_uncertainty_m
,
fngrid
.
heading_uncertainty_deg
)
else
:
refstat_ais
,
fngrid
=
None
,
None
# Return value
# Return value
if
not
return_grid_solution
:
if
not
return_grid_solution
:
return
refstat_ais
return
refstat_ais
...
@@ -1125,12 +1130,20 @@ class FloeNaviGridSolution(object):
...
@@ -1125,12 +1130,20 @@ class FloeNaviGridSolution(object):
origins_xc
=
np
.
full
((
2
,
self
.
bs1
.
n_records
),
np
.
nan
)
origins_xc
=
np
.
full
((
2
,
self
.
bs1
.
n_records
),
np
.
nan
)
origins_yc
=
origins_xc
.
copy
()
origins_yc
=
origins_xc
.
copy
()
for
i
,
bs
in
enumerate
([
self
.
bs1
,
self
.
bs2
]):
for
i
,
bs
in
enumerate
([
self
.
bs1
,
self
.
bs2
]):
xc
,
yc
=
self
.
get_origin
(
bs
.
geo
.
xc
,
bs
.
geo
.
yc
,
bs
.
range_m
,
bs
.
ref_angle
,
self
.
rotation
)
xc
,
yc
=
self
.
get_origin
(
bs
.
geo
.
longitude
,
bs
.
geo
.
latitude
,
bs
.
range_m
,
bs
.
ref_angle
,
self
.
rotation
)
invalid
=
np
.
where
(
np
.
logical_or
(
xc
>
1.0e10
,
yc
>
1.0e10
))[
0
]
invalid
=
np
.
where
(
np
.
logical_or
(
xc
>
1.0e10
,
yc
>
1.0e10
))[
0
]
xc
[
invalid
],
yc
[
invalid
]
=
np
.
nan
,
np
.
nan
xc
[
invalid
],
yc
[
invalid
]
=
np
.
nan
,
np
.
nan
origins_xc
[
i
,
:]
=
xc
origins_xc
[
i
,
:]
=
xc
origins_yc
[
i
,
:]
=
yc
origins_yc
[
i
,
:]
=
yc
# import matplotlib.pyplot as plt
# plt.figure()
# for i, bs in enumerate([self.bs1, self.bs2]):
# # plt.scatter(bs.geo.xc, bs.geo.yc, s=40, label="geo {}".format(bs.mmsi))
# plt.scatter(origins_xc[i, :], origins_yc[i, :], s=5, label="origin {}".format(bs.mmsi))
# plt.legend()
# plt.show()
# Compute the average deviation (uncertainty) of the origin
# Compute the average deviation (uncertainty) of the origin
origin_xc_delta
=
origins_xc
[
1
]
-
origins_xc
[
0
]
origin_xc_delta
=
origins_xc
[
1
]
-
origins_xc
[
0
]
origin_yc_delta
=
origins_yc
[
1
]
-
origins_yc
[
0
]
origin_yc_delta
=
origins_yc
[
1
]
-
origins_yc
[
0
]
...
@@ -1168,8 +1181,7 @@ class FloeNaviGridSolution(object):
...
@@ -1168,8 +1181,7 @@ class FloeNaviGridSolution(object):
angle
=
np
.
rad2deg
(
angle
)
angle
=
np
.
rad2deg
(
angle
)
return
angle
return
angle
@staticmethod
def
get_origin
(
self
,
lon
,
lat
,
range_m
,
ref_heading
,
rotation
):
def
get_origin
(
xc
,
yc
,
range_m
,
ref_heading
,
rotation
):
"""
"""
Compute the origin from basestation data and the known rotation of the
Compute the origin from basestation data and the known rotation of the
ice reference system
ice reference system
...
@@ -1180,11 +1192,17 @@ class FloeNaviGridSolution(object):
...
@@ -1180,11 +1192,17 @@ class FloeNaviGridSolution(object):
:param rotation:
:param rotation:
:return:
:return:
"""
"""
direction_to_origin_deg
=
180.
-
(
rotation
-
ref_heading
)
direction_to_origin_rad
=
np
.
deg2rad
(
direction_to_origin_deg
)
# Step 1: Project the origin positions in geographic space
vector_x
=
range_m
*
np
.
cos
(
direction_to_origin_rad
)
direction_to_origin_deg
=
rotation
-
ref_heading
+
180.
vector_y
=
range_m
*
np
.
sin
(
direction_to_origin_rad
)
g
=
pyproj
.
Geod
(
ellps
=
'
WGS84
'
)
return
xc
+
vector_x
,
yc
+
vector_y
origin_lon
,
origin_lat
,
_
=
g
.
fwd
(
lon
,
lat
,
direction_to_origin_deg
,
np
.
full
(
lon
.
shape
,
range_m
))
# Step 2: Compute x, y in local projection coordinates
p
=
pyproj
.
Proj
(
**
self
.
proj_dict
)
xc_orig
,
yc_orig
=
p
(
origin_lon
,
origin_lat
)
return
xc_orig
,
yc_orig
@property
@property
def
proj_dict
(
self
):
def
proj_dict
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment