Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
wendelin
Commits
c3faebd6
Commit
c3faebd6
authored
Sep 06, 2024
by
Léo-Paul Géneau
👾
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_wendelin_drone: convert data if data line was deleted
parent
93dfd2fa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
40 deletions
+28
-40
bt5/erp5_wendelin_drone/PathTemplateItem/portal_callables/DataAnalysisLine_convertRawDroneDataToArray.py
..._callables/DataAnalysisLine_convertRawDroneDataToArray.py
+28
-40
No files found.
bt5/erp5_wendelin_drone/PathTemplateItem/portal_callables/DataAnalysisLine_convertRawDroneDataToArray.py
View file @
c3faebd6
import
pandas
as
pd
import
pandas
as
pd
import
numpy
as
np
import
numpy
as
np
from
zExceptions
import
BadRequest
# Function to remove non-ASCII characters from a string, because I can not be bothered to make to_records with utf8 right now
# Function to remove non-ASCII characters from a string, because I can not be bothered to make to_records with utf8 right now
def
remove_non_ascii
(
text
):
def
remove_non_ascii
(
text
):
...
@@ -8,36 +7,34 @@ def remove_non_ascii(text):
...
@@ -8,36 +7,34 @@ def remove_non_ascii(text):
progress_indicator
=
in_stream
[
"Progress Indicator"
]
in_data_stream
=
in_stream
[
"Data Bucket Stream"
]
in_data_stream
=
in_stream
[
"Data Bucket Stream"
]
out_data_array
=
out_array
[
"Data Array"
]
keys
=
in_data_stream
.
getKeyList
()
keys
=
in_data_stream
.
getKeyList
()
end
=
progress_indicator
.
getStringOffsetIndex
()
if
end
is
None
:
end
=
""
if
len
(
keys
)
==
0
:
if
len
(
keys
)
==
0
:
context
.
log
(
"No Keys found"
)
context
.
log
(
"No Keys found"
)
return
return
out_data_array
=
out_array
[
"Data Array"
]
dtype
=
{
'timestamp (ms)'
:
'<f8'
,
if
out_data_array
.
getArray
()
is
not
None
:
'latitude ()'
:
'<f8'
,
key_list
=
[
key
for
key
in
keys
if
not
out_data_array
.
hasContent
(
key
)]
'longitude ()'
:
'<f8'
,
else
:
'AMSL (m)'
:
'<f8'
,
key_list
=
keys
'rel altitude (m)'
:
'<f8'
,
'yaw ()'
:
'<f8'
,
if
len
(
key_list
)
==
0
:
'ground speed (m/s)'
:
'<f8'
,
context
.
log
(
"No new keys found"
)
'climb rate (m/s)'
:
'<f8'
}
return
if
len
([
x
for
x
in
keys
if
x
not
in
end
])
==
0
:
dtype
=
{
context
.
log
(
"No new keys found"
)
'timestamp (ms)'
:
'<f8'
,
return
'latitude ()'
:
'<f8'
,
'longitude ()'
:
'<f8'
,
new_end
=
""
'AMSL (m)'
:
'<f8'
,
for
key
in
[
x
for
x
in
keys
if
x
not
in
end
]:
'rel altitude (m)'
:
'<f8'
,
'yaw ()'
:
'<f8'
,
'ground speed (m/s)'
:
'<f8'
,
'climb rate (m/s)'
:
'<f8'
,
}
for
key
in
key_list
:
try
:
try
:
log
=
in_data_stream
.
getBucketByKey
(
key
)
log
=
in_data_stream
.
getBucketByKey
(
key
)
df
=
pd
.
read_csv
(
log
,
sep
=
';'
,
dtype
=
dtype
)
df
=
pd
.
read_csv
(
log
,
sep
=
';'
,
dtype
=
dtype
)
...
@@ -55,25 +52,16 @@ for key in [x for x in keys if x not in end]:
...
@@ -55,25 +52,16 @@ for key in [x for x in keys if x not in end]:
ndarray
=
df
.
to_records
(
index
=
False
)
#column_dtypes does not work here for some reasone, even if it is an actuall parameter
ndarray
=
df
.
to_records
(
index
=
False
)
#column_dtypes does not work here for some reasone, even if it is an actuall parameter
zbigarray
=
out_data_array
.
getArray
()
zbigarray
=
out_data_array
.
getArray
()
if
zbigarray
is
None
:
if
zbigarray
is
None
:
zbigarray
=
out_data_array
.
initArray
(
shape
=
(
0
,),
dtype
=
ndarray
.
dtype
.
fields
)
zbigarray
=
out_data_array
.
initArray
(
shape
=
(
0
,),
dtype
=
ndarray
.
dtype
.
fields
)
start_array
=
zbigarray
.
shape
[
0
]
start_array
=
zbigarray
.
shape
[
0
]
zbigarray
.
append
(
ndarray
)
zbigarray
.
append
(
ndarray
)
try
:
data_array_line
=
out_data_array
.
newContent
(
id
=
key
,
data_array_line
=
out_array
.
get
(
key
)
portal_type
=
"Data Array Line"
)
if
data_array_line
is
None
:
data_array_line
.
edit
(
data_array_line
=
out_data_array
.
newContent
(
id
=
key
,
reference
=
key
,
portal_type
=
"Data Array Line"
)
index_expression
=
"%s:%s"
%
(
start_array
,
zbigarray
.
shape
[
0
]),
data_array_line
.
edit
(
reference
=
key
,
)
index_expression
=
"%s:%s"
%
(
start_array
,
zbigarray
.
shape
[
0
])
)
except
BadRequest
:
context
.
log
(
"Data Array Line already exists"
)
except
ValueError
:
except
ValueError
:
context
.
log
(
"File "
+
str
(
key
)
+
" is not well formated"
)
context
.
log
(
"File "
+
str
(
key
)
+
" is not well formated"
)
new_end
=
new_end
+
str
(
key
)
progress_indicator
.
setStringOffsetIndex
(
end
+
new_end
)
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