Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
oeigner
LINK - Forschungsprojekt Repo
Commits
91636621
Commit
91636621
authored
Jun 22, 2021
by
Fabian Kovac
Browse files
[i] added todos and get INCA RR data in func
parent
91b97ef6
Changes
1
Show whitespace changes
Inline
Side-by-side
FHSTP/prep.py
View file @
91636621
...
...
@@ -2,8 +2,8 @@
# Title: Data Preparation for LINK Configs and Transmissions
# Author: Fabian Kovac <ds191008@fhstp.ac.at>
# Team: University of Applied Sciences St. Pölten
# Version: 1.
1
# Last changed: 2021-06-2
1
# Version: 1.
2
# Last changed: 2021-06-2
2
#
import
sys
...
...
@@ -201,8 +201,8 @@ def utm_to_lambert(lon: np.array, lat: np.array) -> tuple:
return
x
,
y
def
lambert_to_inca_
coords
(
x
:
np
.
array
,
y
:
np
.
array
)
->
tuple
:
"""Convert x and y of Lambert Conic Conformal Projection to INCA
coordinates
def
lambert_to_inca_
idx
(
x
:
np
.
array
,
y
:
np
.
array
)
->
tuple
:
"""Convert x and y of Lambert Conic Conformal Projection to INCA
index
(rounded lambert coordinates)
Parameters:
...
...
@@ -216,23 +216,24 @@ def lambert_to_inca_coords(x: np.array, y: np.array) -> tuple:
return
np
.
round
(
x
/
1000
,
decimals
=
0
).
astype
(
int
),
np
.
round
(
y
/
1000
,
decimals
=
0
).
astype
(
int
)
def
get_inca_
indices
(
datetimes
:
np
.
array
,
x
:
np
.
array
,
y
:
np
.
array
)
->
np
.
array
:
"""Get
indices of
INCA RR data based on Lamber Conic Conformal Coordinates
def
get_inca_
data
(
inca_data
:
np
.
array
,
datetimes
:
np
.
array
,
x
:
np
.
array
,
y
:
np
.
array
)
->
np
.
array
:
"""Get INCA RR data based on Lamber Conic Conformal Coordinates
Parameters:
inca_data (np.array): Tensor containing INCA RR data
datetimes (np.array): Vector containing datetimes of transmissions
x (np.array): Vector containing x values of LINK
y (np.array): Vector containing y values of LINK
Returns:
i
dx_times, idx, idy
(np.array):
Three v
ector
s
containing
indices to
INCA RR data
i
nca_RR
(np.array):
V
ector containing INCA RR data
based on datetimes and lambert coordinates
"""
# convert utm coordinates to lambert conic conformal projection
lccX
,
lccY
=
utm_to_lambert
(
x
,
y
)
# convert lambert coordinates to INCA indices
idx
,
idy
=
lambert_to_inca_
coords
(
lccX
,
lccY
)
idx
,
idy
=
lambert_to_inca_
idx
(
lccX
,
lccY
)
# generate times of day in 15min (window) intervals
...
...
@@ -242,11 +243,20 @@ def get_inca_indices(datetimes: np.array, x: np.array, y: np.array) -> np.array:
# generate times of LINK data
link_times
=
datetimes
.
map
(
lambda
x
:
f
'
{
x
[
-
4
:
-
2
]
}
:
{
x
[
-
2
:
]
}
'
)
# get
L
IN
K
indices of IN
CA
times
# get IN
CA
indices of
L
IN
K
times
idx_times
=
np
.
searchsorted
(
inca_times
,
link_times
)
# return INCA data based on time indices and lambert coordinates
return
idx_times
,
idx
,
idy
# get INCA RR data based on time indices and lambert coordinates
inca_RR
=
inca_data
[
idx_times
,
idy
,
idx
]
# TODO: discuss retrieving INCA RR data
# currently data is based on the exact point of the link
# maybe get mean RR of 5x5 km grid around point?
# maybe get RR data based on conv2d with a 5x5 gaussian filter around point?
# --> let's discuss!
return
inca_RR
def
prep
()
->
None
:
...
...
@@ -260,7 +270,7 @@ def prep() -> None:
_log
(
'
\n
******************************** READ FILES ********************************'
)
# read files
# read
config and transmission
files
df_config
=
pd
.
read_csv
(
file_config
,
sep
=
';'
)
_log
(
f
'Read config file with shape
{
df_config
.
shape
}
'
)
df_trans
=
pd
.
read_csv
(
file_trans
,
sep
=
';'
)
...
...
@@ -449,13 +459,10 @@ def prep() -> None:
inca_data
=
load_inca_data
(
dir_inca
)
_log
(
f
'Loaded INCA data from
{
str
(
dir_inca
).
split
(
"/"
)[
-
1
]
}
'
)
idx_times
,
IxStart
,
IyStart
=
get_inca_indices
(
df_link
[
'DateTime'
],
df_link
[
'XStart'
],
df_link
[
'YStart'
])
_
,
IxEnd
,
IyEnd
=
get_inca_indices
(
df_link
[
'DateTime'
],
df_link
[
'XEnd'
],
df_link
[
'YEnd'
])
_log
(
'Calculated INCA RR indices based on lambert coordinates and datetimes'
)
df_link
[
'RRStart'
]
=
inca_data
[
idx_times
,
IyStart
,
IxStart
]
df_link
[
'RREnd'
]
=
inca_data
[
idx_times
,
IyEnd
,
IxEnd
]
_log
(
'Set INCA RR data based on lambert coordinates'
)
# set INCA RR data based on datetime and coordinates
df_link
[
'RRStart'
]
=
get_inca_data
(
inca_data
,
df_link
[
'DateTime'
],
df_link
[
'XStart'
],
df_link
[
'YStart'
])
df_link
[
'RREnd'
]
=
get_inca_data
(
inca_data
,
df_link
[
'DateTime'
],
df_link
[
'XEnd'
],
df_link
[
'YEnd'
])
_log
(
'Merged INCA RR data to LINK dataframe'
)
_log
(
'
\n
******************************** SAVE FILES ********************************'
)
...
...
Write
Preview
Supports
Markdown
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