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
2604f981
Commit
2604f981
authored
11 months ago
by
Debolskiy Andrey
Browse files
Options
Downloads
Patches
Plain Diff
add utils.py
parent
cbee0fc0
Branches
add-disp-flux-calc
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
plotter/Plotter.py
+52
-49
52 additions, 49 deletions
plotter/Plotter.py
plotter/__init__.py
+1
-0
1 addition, 0 deletions
plotter/__init__.py
plotter/main.py
+3
-1
3 additions, 1 deletion
plotter/main.py
plotter/utils.py
+10
-0
10 additions, 0 deletions
plotter/utils.py
with
66 additions
and
50 deletions
plotter/Plotter.py
+
52
−
49
View file @
2604f981
...
@@ -9,6 +9,7 @@ from .ProcData import ProcData
...
@@ -9,6 +9,7 @@ from .ProcData import ProcData
import
copy
import
copy
from
matplotlib.cm
import
ScalarMappable
from
matplotlib.cm
import
ScalarMappable
class
Plotter
:
class
Plotter
:
ani_pngs_dir
=
"
plotter_lib_pngs/
"
ani_pngs_dir
=
"
plotter_lib_pngs/
"
...
@@ -43,7 +44,6 @@ class Plotter:
...
@@ -43,7 +44,6 @@ class Plotter:
names
=
d
.
variable_names
names
=
d
.
variable_names
var_names
.
append
(
np
.
array
(
names
,
dtype
=
object
))
var_names
.
append
(
np
.
array
(
names
,
dtype
=
object
))
if
(
len
(
var_names
)
>
1
):
if
(
len
(
var_names
)
>
1
):
for
i
in
range
(
1
,
len
(
var_names
)):
for
i
in
range
(
1
,
len
(
var_names
)):
if
np
.
equal
(
var_names
[
0
],
var_names
[
i
]).
any
()
!=
True
:
if
np
.
equal
(
var_names
[
0
],
var_names
[
i
]).
any
()
!=
True
:
...
@@ -55,7 +55,6 @@ class Plotter:
...
@@ -55,7 +55,6 @@ class Plotter:
self
.
file_column_names
=
var_names
[
0
]
self
.
file_column_names
=
var_names
[
0
]
def
set
(
self
,
args
,
**
kwargs
):
def
set
(
self
,
args
,
**
kwargs
):
self
.
__check_arg_dim_equiv
(
args
)
self
.
__check_arg_dim_equiv
(
args
)
self
.
filename
=
args
.
filename
self
.
filename
=
args
.
filename
...
@@ -113,12 +112,13 @@ class Plotter:
...
@@ -113,12 +112,13 @@ class Plotter:
else
:
else
:
plt
.
plot
(
self
.
file_data
[
0
].
data
[
x_name
],
self
.
file_data
[
0
].
data
[
y_name
],
linewidth
=
4
)
plt
.
plot
(
self
.
file_data
[
0
].
data
[
x_name
],
self
.
file_data
[
0
].
data
[
y_name
],
linewidth
=
4
)
plt
.
legend
(
self
.
var
)
plt
.
legend
(
self
.
var
)
plt
.
xlabel
(
x_name
,
fontsize
=
10
,
fontweight
=
'
bold
'
)
plt
.
xlabel
(
x_name
,
fontsize
=
10
,
fontweight
=
'
bold
'
)
if
self
.
if_manual_plot
:
plt
.
show
()
if
self
.
if_manual_plot
:
else
:
plt
.
close
(
fig
)
plt
.
show
()
else
:
plt
.
close
(
fig
)
if
self
.
if_save_result
:
fig
.
savefig
(
self
.
out
+
self
.
oname
[
0
])
if
self
.
if_save_result
:
fig
.
savefig
(
self
.
out
+
self
.
oname
[
0
])
def
__get_min_max_ax
(
self
):
def
__get_min_max_ax
(
self
):
...
@@ -147,7 +147,6 @@ class Plotter:
...
@@ -147,7 +147,6 @@ class Plotter:
self
.
min_max_var_vals
=
np
.
array
([
min_val
,
max_val
])
self
.
min_max_var_vals
=
np
.
array
([
min_val
,
max_val
])
def
__ani_plot
(
self
):
def
__ani_plot
(
self
):
if
self
.
if_save_result
:
if
self
.
if_save_result
:
png_names
=
[]
png_names
=
[]
...
@@ -234,7 +233,8 @@ class Plotter:
...
@@ -234,7 +233,8 @@ class Plotter:
Y
=
self
.
file_data
[
0
].
data
[
y_name
]
Y
=
self
.
file_data
[
0
].
data
[
y_name
]
Z
=
self
.
file_data
[
0
].
data
[
self
.
var
[
i
]]
Z
=
self
.
file_data
[
0
].
data
[
self
.
var
[
i
]]
vmin
=
min_val
[
self
.
var
[
i
]];
vmax
=
max_val
[
self
.
var
[
i
]];
vmin
=
min_val
[
self
.
var
[
i
]];
vmax
=
max_val
[
self
.
var
[
i
]];
levels
=
np
.
linspace
(
vmin
,
vmax
,
25
)
levels
=
np
.
linspace
(
vmin
,
vmax
,
25
)
if
self
.
function
==
self
.
plot_diff
:
if
self
.
function
==
self
.
plot_diff
:
...
@@ -253,8 +253,10 @@ class Plotter:
...
@@ -253,8 +253,10 @@ class Plotter:
ax
.
set_xlabel
(
x_name
)
ax
.
set_xlabel
(
x_name
)
ax
.
set_ylabel
(
y_name
)
ax
.
set_ylabel
(
y_name
)
if
self
.
if_manual_plot
:
plt
.
show
()
if
self
.
if_manual_plot
:
else
:
plt
.
close
(
fig
)
plt
.
show
()
else
:
plt
.
close
(
fig
)
if
self
.
if_save_result
:
fig
.
savefig
(
self
.
out
+
fig_names
[
i
]
+
fig_end
)
if
self
.
if_save_result
:
fig
.
savefig
(
self
.
out
+
fig_names
[
i
]
+
fig_end
)
def
__get_min_max_bar
(
self
):
def
__get_min_max_bar
(
self
):
...
@@ -366,7 +368,6 @@ class Plotter:
...
@@ -366,7 +368,6 @@ class Plotter:
avg_data
=
np
.
average
(
matrix_data
,
axis
=
(
1
,
0
))
avg_data
=
np
.
average
(
matrix_data
,
axis
=
(
1
,
0
))
return
avg_data
return
avg_data
def
__avg_plot
(
self
):
def
__avg_plot
(
self
):
os
.
system
(
"
mkdir -p
"
+
self
.
out
)
os
.
system
(
"
mkdir -p
"
+
self
.
out
)
fig
=
plt
.
figure
()
fig
=
plt
.
figure
()
...
@@ -384,8 +385,10 @@ class Plotter:
...
@@ -384,8 +385,10 @@ class Plotter:
plt
.
legend
(
self
.
var
)
plt
.
legend
(
self
.
var
)
plt
.
xlabel
(
x_name
,
fontsize
=
10
,
fontweight
=
'
bold
'
)
plt
.
xlabel
(
x_name
,
fontsize
=
10
,
fontweight
=
'
bold
'
)
if
self
.
if_manual_plot
:
plt
.
show
()
if
self
.
if_manual_plot
:
else
:
plt
.
close
(
fig
)
plt
.
show
()
else
:
plt
.
close
(
fig
)
if
self
.
if_save_result
:
fig
.
savefig
(
self
.
out
+
self
.
oname
[
0
])
if
self
.
if_save_result
:
fig
.
savefig
(
self
.
out
+
self
.
oname
[
0
])
def
__dump
(
self
):
def
__dump
(
self
):
...
@@ -452,6 +455,6 @@ class Plotter:
...
@@ -452,6 +455,6 @@ class Plotter:
def
plot_diff
(
self
):
def
plot_diff
(
self
):
self
.
__plot_diff
()
self
.
__plot_diff
()
def
get_data
(
self
):
def
get_data
(
self
)
->
list
:
return_data
=
[
copy
.
deepcopy
(
data
.
data
)
for
data
in
self
.
file_data
]
return_data
=
[
copy
.
deepcopy
(
data
.
data
)
for
data
in
self
.
file_data
]
return
return_data
return
return_data
This diff is collapsed.
Click to expand it.
plotter/__init__.py
+
1
−
0
View file @
2604f981
...
@@ -8,4 +8,5 @@ from .main import ani_plot_contour
...
@@ -8,4 +8,5 @@ from .main import ani_plot_contour
from
.main
import
avg_plot
from
.main
import
avg_plot
from
.main
import
plot_diff
from
.main
import
plot_diff
from
.main
import
get_data
from
.main
import
get_data
from
.utils
import
utils
This diff is collapsed.
Click to expand it.
plotter/main.py
+
3
−
1
View file @
2604f981
...
@@ -7,6 +7,7 @@ import os
...
@@ -7,6 +7,7 @@ import os
manual_plot
=
False
manual_plot
=
False
save_result
=
True
save_result
=
True
def
dump
(
filename
,
var
=
[
None
],
mval
=
[
None
]):
def
dump
(
filename
,
var
=
[
None
],
mval
=
[
None
]):
Plot
=
Plotter
()
Plot
=
Plotter
()
args
=
Args
([
filename
],
Plot
.
dump
,
var
,
mval
,
oname
=
[
None
],
out
=
[
None
])
args
=
Args
([
filename
],
Plot
.
dump
,
var
,
mval
,
oname
=
[
None
],
out
=
[
None
])
...
@@ -72,3 +73,4 @@ def get_data(filename, ndim):
...
@@ -72,3 +73,4 @@ def get_data(filename, ndim):
Plot
.
set
(
args
,
if_manual_plot
=
manual_plot
,
if_save_result
=
save_result
)
Plot
.
set
(
args
,
if_manual_plot
=
manual_plot
,
if_save_result
=
save_result
)
data
=
Plot
.
get_data
()
data
=
Plot
.
get_data
()
return
data
return
data
This diff is collapsed.
Click to expand it.
plotter/utils.py
0 → 100644
+
10
−
0
View file @
2604f981
from
.Plotter
import
Plotter
class
utils
:
pole
=
'
russkoe
'
def
__init__
(
self
):
self
.
pl
=
Plotter
()
def
plot_diff
(
self
):
print
(
'
hello world
'
)
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