Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CoincellExperimentController
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
Service Desk
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
Klemm, Carl Philipp
CoincellExperimentController
Commits
1f655899
Commit
1f655899
authored
1 year ago
by
Carl Philipp Klemm
Browse files
Options
Downloads
Patches
Plain Diff
scripts: createdataset: create a tar file instead of a directory of files
parent
d8460af6
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
scripts/createdataset.py
+13
-4
13 additions, 4 deletions
scripts/createdataset.py
scripts/spectrafile.py
+9
-6
9 additions, 6 deletions
scripts/spectrafile.py
with
22 additions
and
10 deletions
scripts/createdataset.py
+
13
−
4
View file @
1f655899
import
argparse
import
argparse
import
os
import
os
from
tqdm
import
tqdm
from
tqdm
import
tqdm
import
tarfile
from
chargefile
import
ChargeFile
from
chargefile
import
ChargeFile
from
spectrafile
import
SpectraFile
from
spectrafile
import
SpectraFile
...
@@ -39,9 +40,17 @@ if __name__ == "__main__":
...
@@ -39,9 +40,17 @@ if __name__ == "__main__":
step
=
int
(
tokens
[
0
])
step
=
int
(
tokens
[
0
])
cellid
=
int
(
tokens
[
1
])
cellid
=
int
(
tokens
[
1
])
substep
=
int
(
tokens
[
2
])
substep
=
int
(
tokens
[
2
])
celldir
=
os
.
path
.
join
(
args
.
out
,
str
(
cellid
))
if
not
os
.
path
.
exists
(
celldir
):
os
.
makedirs
(
celldir
)
sf
=
SpectraFile
(
os
.
path
.
join
(
args
.
data
,
filename
),
cellid
,
step
,
substep
,
charge_files
,
len
(
cells
))
sf
=
SpectraFile
(
os
.
path
.
join
(
args
.
data
,
filename
),
cellid
,
step
,
substep
,
charge_files
,
len
(
cells
))
sf
.
write
(
celldir
)
sf
.
write
(
args
.
out
)
try
:
os
.
remove
(
f
"
{
args
.
out
}
.tar
"
)
except
FileNotFoundError
:
pass
tar
=
tarfile
.
open
(
f
"
{
args
.
out
}
.tar
"
,
mode
=
"
x
"
)
for
filename
in
tqdm
(
os
.
listdir
(
args
.
out
)):
path
=
os
.
path
.
join
(
args
.
out
,
filename
)
tar
.
add
(
path
,
arcname
=
os
.
path
.
split
(
path
)[
-
1
])
os
.
remove
(
path
)
os
.
rmdir
(
args
.
out
)
This diff is collapsed.
Click to expand it.
scripts/spectrafile.py
+
9
−
6
View file @
1f655899
...
@@ -26,11 +26,14 @@ class SpectraFile:
...
@@ -26,11 +26,14 @@ class SpectraFile:
raise
ParseError
(
f
"
file name and file content of SpectraFile
{
filename
}
do not match
"
)
raise
ParseError
(
f
"
file name and file content of SpectraFile
{
filename
}
do not match
"
)
def
write
(
self
,
directory
:
str
):
def
write
(
self
,
directory
:
str
):
meta_dsc_string
=
"
step, substep, cellid, temparature, ocv, charge_cycles, thermal_cycles, last_avg_cap, last_avg_step, last_cap, last_cap_step, soc
"
metaList
=
[
float
(
self
.
step
),
float
(
self
.
substep
),
float
(
self
.
cellid
),
float
(
self
.
temperature
),
float
(
self
.
ocv
),
metastring
=
f
"
{
self
.
step
}
,
{
self
.
substep
}
,
{
self
.
cellid
}
,
{
self
.
temperature
}
,
{
self
.
ocv
}
,
{
self
.
meta
.
charge_cycles
}
,
{
self
.
meta
.
thermal_cycles
}
,
"
float
(
self
.
meta
.
charge_cycles
),
float
(
self
.
meta
.
thermal_cycles
),
float
(
self
.
meta
.
last_avg_cap
),
float
(
self
.
meta
.
last_avg_cap_step
),
metastring
+=
f
"
{
self
.
meta
.
last_avg_cap
}
,
{
self
.
meta
.
last_avg_cap_step
}
,
{
self
.
meta
.
last_cap
}
,
{
self
.
meta
.
last_cap_step
}
,
{
self
.
meta
.
soc
}
"
float
(
self
.
meta
.
last_cap
),
float
(
self
.
meta
.
last_cap_step
),
float
(
self
.
meta
.
soc
)]
self
.
spectra
.
setLabels
(
metaList
)
self
.
spectra
.
headerDescription
=
meta_dsc_string
meta_dsc_strings
=
[
"
step
"
,
"
substep
"
,
"
cellid
"
,
"
temparature
"
,
"
ocv
"
,
"
charge_cycles
"
,
"
thermal_cycles
"
,
self
.
spectra
.
header
=
metastring
"
last_avg_cap
"
,
"
last_avg_step
"
,
"
last_cap
"
,
"
last_cap_step
"
,
"
soc
"
]
self
.
spectra
.
headerDescription
=
"
File origin
"
self
.
spectra
.
header
=
"
CoinCellHell mesurement file
"
self
.
spectra
.
labelNames
=
meta_dsc_strings
self
.
spectra
.
saveToDisk
(
os
.
path
.
join
(
directory
,
self
.
filename
))
self
.
spectra
.
saveToDisk
(
os
.
path
.
join
(
directory
,
self
.
filename
))
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