Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
plotter-nse
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
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
数学の武士
plotter-nse
Commits
34168f6d
Commit
34168f6d
authored
1 year ago
by
数学の武士
Browse files
Options
Downloads
Patches
Plain Diff
Hotfix for plt variable names
parent
954a99ad
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
plotter/ProcData.py
+39
-15
39 additions, 15 deletions
plotter/ProcData.py
with
39 additions
and
15 deletions
plotter/ProcData.py
+
39
−
15
View file @
34168f6d
...
...
@@ -2,18 +2,8 @@ import numpy as np
import
os
import
numpy
as
np
from
.binSubfunctions
import
*
import
re
def
character_indexes
(
string
,
match
):
indexes_of_match
=
[]
for
index
,
character
in
enumerate
(
string
):
if
character
==
match
:
indexes_of_match
.
append
(
index
)
return
indexes_of_match
def
GetVariableName
(
string
):
indexes_of_match
=
character_indexes
(
string
,
'"'
)
return
string
[
indexes_of_match
[
0
]
+
1
:
indexes_of_match
[
1
]]
class
ProcData
:
def
__init__
(
self
,
filename
=
None
):
self
.
filename
=
filename
...
...
@@ -25,10 +15,10 @@ class ProcData:
with
open
(
self
.
filename
,
"
r
"
)
as
file
:
file_data
=
file
.
read
().
split
(
'
\n
'
)
file
.
close
()
idx
=
character_indexes
(
file_data
[
1
],
'
=
'
)
names
=
[
GetVariableName
(
variable_name
)
for
variable_name
in
file_data
[
1
][
idx
[
0
]
:
].
split
(
'
,
'
)]
text
=
file_data
[
1
]
pattern
=
'
\"
(.*?)
\"
'
names
=
re
.
findall
(
pattern
,
text
)
self
.
variable_names
=
np
.
array
(
names
,
dtype
=
object
)
def
__get_variable_names_bin
(
self
):
...
...
@@ -271,18 +261,52 @@ class ProcData:
idx
=
np
.
where
(
np
.
abs
(
self
.
data
[
col
])
>
abs_val
)
self
.
data
[
col
][
idx
]
=
np
.
nan
def
__read_dsq
(
self
):
STIRNG_TERMINATOR
=
'
\x00
'
INT_LEN
=
4
TIME_VAR_NUM
=
0
f
=
open
(
self
.
filename
,
'
rb
'
)
nvars
=
int
.
from_bytes
(
f
.
read
(
INT_LEN
),
byteorder
=
'
little
'
)
names_len
=
int
.
from_bytes
(
f
.
read
(
INT_LEN
),
byteorder
=
'
little
'
)
+
len
(
STIRNG_TERMINATOR
)
self
.
variable_names
.
append
(
'
time
'
)
for
_
in
range
(
nvars
):
self
.
variable_names
.
append
(
str
(
f
.
read
(
names_len
),
encoding
=
'
utf-8
'
).
strip
(
STIRNG_TERMINATOR
))
buffer
=
np
.
frombuffer
(
f
.
read
(),
dtype
=
np
.
float64
)
nrecs
=
len
(
buffer
)
//
(
nvars
+
1
)
data
=
buffer
.
reshape
([
nrecs
,
nvars
+
1
])
f
.
close
()
time
=
data
[:,
TIME_VAR_NUM
]
vars
=
data
[:,
TIME_VAR_NUM
+
1
:]
self
.
data
[
'
time
'
]
=
np
.
copy
(
time
)
for
name
,
i
in
zip
(
self
.
variable_names
[
1
:
],
range
(
nvars
)):
self
.
data
[
name
]
=
np
.
copy
(
vars
.
T
[
i
])
# return DsqData(nvars, nrecs, time, vars, varnames)
def
process_file
(
self
,
ndim
,
column_names
,
mval
):
print
(
'
dddd
'
)
filename_parts
=
os
.
path
.
splitext
(
self
.
filename
)
filename_extension
=
filename_parts
[
-
1
]
self
.
var
=
column_names
self
.
mval
=
mval
#
print(ndim, self.filename)
print
(
ndim
,
self
.
filename
)
if
filename_extension
==
'
.plt
'
:
self
.
__read_plt
(
ndim
)
elif
filename_extension
==
'
.nsx
'
:
self
.
__read_bin
()
elif
filename_extension
==
'
.dsq
'
:
print
(
'
ffffff
'
)
self
.
__read_dsq
()
def
get_variable_names
(
self
):
filename_parts
=
os
.
path
.
splitext
(
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