Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
MessdatenSilo
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lennard Kloock
MessdatenSilo
Commits
4de149a6
Commit
4de149a6
authored
3 years ago
by
SirWalross
Browse files
Options
Downloads
Patches
Plain Diff
Comment code better
parent
967d2f29
No related branches found
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
convert.py
+7
-3
7 additions, 3 deletions
convert.py
with
7 additions
and
3 deletions
convert.py
+
7
−
3
View file @
4de149a6
...
@@ -7,11 +7,11 @@ from datetime import datetime, timedelta
...
@@ -7,11 +7,11 @@ from datetime import datetime, timedelta
from
pathlib
import
Path
from
pathlib
import
Path
import
glob
import
glob
from
time
import
strptime
,
time
from
time
import
strptime
,
time
from
typing
import
Dict
from
typing
import
Dict
,
Optional
import
numpy
as
np
import
numpy
as
np
import
scipy.io
import
scipy.io
data
:
Dict
[
str
,
np
.
ndarray
]
=
{}
# a numpy array for each week
data
:
Dict
[
str
,
np
.
ndarray
]
=
{}
# a
dict of
numpy array
's, one
for each week
header
=
[
"
Timestamp
"
]
+
[
f
"
dms
{
i
+
1
}
"
for
i
in
range
(
4
)]
+
[
f
"
temp
{
i
+
1
}
"
for
i
in
range
(
4
)]
+
[
"
n
"
]
header
=
[
"
Timestamp
"
]
+
[
f
"
dms
{
i
+
1
}
"
for
i
in
range
(
4
)]
+
[
f
"
temp
{
i
+
1
}
"
for
i
in
range
(
4
)]
+
[
"
n
"
]
start_time
:
float
=
0
start_time
:
float
=
0
...
@@ -25,11 +25,14 @@ def convertfunc(x: bytes) -> float:
...
@@ -25,11 +25,14 @@ def convertfunc(x: bytes) -> float:
files
=
sorted
(
glob
.
glob
(
str
(
Path
.
joinpath
(
Path
(
__file__
).
parent
,
"
data
"
,
"
log.*.log
"
))))
files
=
sorted
(
glob
.
glob
(
str
(
Path
.
joinpath
(
Path
(
__file__
).
parent
,
"
data
"
,
"
log.*.log
"
))))
for
file
in
files
:
for
file
in
files
:
date
=
datetime
(
*
strptime
(
Path
(
file
).
suffixes
[
0
][
1
:].
split
(
"
_
"
)[
0
],
"
%Y-%m-%d
"
)[:
6
])
-
timedelta
(
days
=
2
)
date
=
datetime
(
*
strptime
(
Path
(
file
).
suffixes
[
0
][
1
:].
split
(
"
_
"
)[
0
],
"
%Y-%m-%d
"
)[:
6
])
-
timedelta
(
days
=
2
)
week_start
=
(
date
-
timedelta
(
days
=
date
.
weekday
())
+
timedelta
(
days
=
2
)).
strftime
(
"
%Y-%m-%d
"
)
week_start
=
(
date
-
timedelta
(
days
=
date
.
weekday
())
+
timedelta
(
days
=
2
)).
strftime
(
"
%Y-%m-%d
"
)
csv_data
=
np
.
genfromtxt
(
file
,
skip_header
=
1
,
delimiter
=
"
,
"
,
converters
=
{
0
:
convertfunc
})
csv_data
=
np
.
genfromtxt
(
file
,
skip_header
=
1
,
delimiter
=
"
,
"
,
converters
=
{
0
:
convertfunc
})
# either add the data from one day to already existing entry for that week or create new entry
if
week_start
in
data
.
keys
():
if
week_start
in
data
.
keys
():
data
[
week_start
]
=
np
.
vstack
((
data
[
week_start
],
csv_data
))
data
[
week_start
]
=
np
.
vstack
((
data
[
week_start
],
csv_data
))
else
:
else
:
...
@@ -37,6 +40,7 @@ for file in files:
...
@@ -37,6 +40,7 @@ for file in files:
Path
(
f
"
{
Path
(
__file__
).
parent
}
/out
"
).
mkdir
(
parents
=
True
,
exist_ok
=
True
)
Path
(
f
"
{
Path
(
__file__
).
parent
}
/out
"
).
mkdir
(
parents
=
True
,
exist_ok
=
True
)
# save each week as seperate '.mat' file
for
week_start
,
arr
in
data
.
items
():
for
week_start
,
arr
in
data
.
items
():
scipy
.
io
.
savemat
(
scipy
.
io
.
savemat
(
f
"
{
Path
(
__file__
).
parent
}
/out/data.
{
week_start
}
.mat
"
,
f
"
{
Path
(
__file__
).
parent
}
/out/data.
{
week_start
}
.mat
"
,
...
...
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