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
22220af6
Commit
22220af6
authored
1 year ago
by
数学の武士
Browse files
Options
Downloads
Patches
Plain Diff
Add contour ani
parent
9d069f89
No related branches found
No related tags found
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
plotter/Plotter.py
+75
-2
75 additions, 2 deletions
plotter/Plotter.py
plotter/ProcData.py
+0
-1
0 additions, 1 deletion
plotter/ProcData.py
plotter/__init__.py
+1
-0
1 addition, 0 deletions
plotter/__init__.py
plotter/main.py
+15
-1
15 additions, 1 deletion
plotter/main.py
setup.py
+5
-5
5 additions, 5 deletions
setup.py
with
96 additions
and
9 deletions
plotter/Plotter.py
+
75
−
2
View file @
22220af6
...
...
@@ -76,7 +76,7 @@ class Plotter:
for
p
in
self
.
data
:
p
.
process_file
(
ndim
,
self
.
var
,
self
.
mval
)
elif
args
.
func
==
self
.
plot_contour
:
elif
args
.
func
==
self
.
plot_contour
or
args
.
func
==
self
.
ani_plot_contour
:
ndim
=
2
if
self
.
var
==
None
and
len
(
self
.
variable_names
)
!=
0
:
self
.
var
=
[
self
.
variable_names
[
i
]
for
i
in
range
(
ndim
,
len
(
self
.
variable_names
))]
...
...
@@ -175,6 +175,75 @@ class Plotter:
else
:
plt
.
close
(
fig
)
if
self
.
if_save_result
:
fig
.
savefig
(
self
.
out
+
fig_names
[
i
]
+
fig_end
)
def
__get_min_max_bar
(
self
):
self
.
filename
=
natsort
.
natsorted
(
self
.
filename
,
reverse
=
False
)
self
.
vals
=
{
var
:
[]
for
var
in
self
.
var
}
for
var
in
self
.
var
:
max_val
=
-
1e9
min_val
=
1e9
for
data
in
self
.
data
:
maval
=
np
.
max
(
data
.
data
[
var
])
mival
=
np
.
min
(
data
.
data
[
var
])
if
maval
>
max_val
:
max_val
=
maval
if
mival
<
min_val
:
min_val
=
mival
self
.
vals
[
var
]
=
np
.
array
([
min_val
,
max_val
])
def
__ani_plot_contour
(
self
):
if
self
.
if_save_result
:
# png_names = {var:[] for var in self.var}
os
.
system
(
"
mkdir -p
"
+
self
.
out
)
os
.
system
(
"
mkdir -p
"
+
self
.
ani_pngs_dir
)
x_name
=
self
.
variable_names
[
0
]
y_name
=
self
.
variable_names
[
1
]
if
self
.
oname
==
None
:
fig_names
=
self
.
var
fig_end
=
"
.gif
"
else
:
fig_names
=
self
.
oname
fig_end
=
""
X
=
self
.
data
[
0
].
data
[
x_name
]
Y
=
self
.
data
[
0
].
data
[
y_name
]
i
=
0
for
var
in
self
.
var
:
title
=
var
counter
=
0
png_names
=
[]
for
data
in
self
.
data
:
fig
,
ax
=
plt
.
subplots
(
1
,
1
)
ax
.
set_title
(
title
)
ax
.
set_xlabel
(
x_name
)
ax
.
set_ylabel
(
y_name
)
Z
=
data
.
data
[
var
]
cp
=
ax
.
contourf
(
X
,
Y
,
Z
,
vmin
=
self
.
vals
[
var
][
0
],
vmax
=
self
.
vals
[
var
][
1
])
fig
.
colorbar
(
cp
)
# Add a colorbar to a plot
plt
.
close
(
fig
)
figname
=
var
+
str
(
counter
)
fig
.
savefig
(
self
.
ani_pngs_dir
+
figname
+
'
.png
'
)
name
=
self
.
ani_pngs_dir
+
figname
+
'
.png
'
png_names
.
append
(
name
)
counter
+=
1
images
=
[]
for
file_name
in
png_names
:
images
.
append
(
imageio
.
v2
.
imread
(
file_name
))
imageio
.
mimsave
(
self
.
out
+
fig_names
[
i
]
+
fig_end
,
images
,
duration
=
5
,
)
i
+=
1
shutil
.
rmtree
(
self
.
ani_pngs_dir
)
def
__avg
(
self
,
data
,
var_name
):
cx
=
data
[
'
cx
'
]
cy
=
data
[
'
cy
'
]
...
...
@@ -229,3 +298,7 @@ class Plotter:
def
plot_contour
(
self
):
self
.
__plot_contour
()
def
ani_plot_contour
(
self
):
self
.
__get_min_max_bar
()
self
.
__ani_plot_contour
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
plotter/ProcData.py
+
0
−
1
View file @
22220af6
...
...
@@ -111,7 +111,6 @@ class ProcData:
if
self
.
mval
!=
None
:
print
(
self
.
mval
)
for
col
,
abs_val
in
zip
(
column_names
,
self
.
mval
):
# print(col, abs_val)
check_variable_idx
=
np
.
where
(
self
.
variable_names
==
col
)[
0
][
0
]
idx
=
np
.
where
(
np
.
abs
(
file_data
[
check_variable_idx
])
>
abs_val
)[
0
]
file_data
[
check_variable_idx
][
idx
]
=
np
.
nan
...
...
This diff is collapsed.
Click to expand it.
plotter/__init__.py
+
1
−
0
View file @
22220af6
...
...
@@ -4,5 +4,6 @@ from .main import dump
from
.main
import
plot
from
.main
import
ani_plot
from
.main
import
plot_contour
from
.main
import
ani_plot_contour
from
.main
import
avg_plot
This diff is collapsed.
Click to expand it.
plotter/main.py
+
15
−
1
View file @
22220af6
...
...
@@ -4,7 +4,7 @@ from pathlib import PurePath
import
natsort
import
os
manual_plot
=
Fals
e
manual_plot
=
Tru
e
save_result
=
True
def
dump
(
filename
,
var
=
[
None
],
mval
=
[
None
]):
...
...
@@ -40,6 +40,20 @@ def plot_contour(filename, out = './', oname = [None], var=[None], mval=[None]):
Plot
.
set
(
args
,
if_manual_plot
=
manual_plot
,
if_save_result
=
save_result
)
Plot
.
plot_contour
()
def
ani_plot_contour
(
filename
,
out
=
'
./
'
,
oname
=
[
None
],
var
=
[
None
],
mval
=
[
None
]):
pp
=
str
(
PurePath
(
filename
).
parent
)
+
'
/
'
name
=
str
(
PurePath
(
filename
).
name
)
command
=
'
find
'
+
pp
+
'
-name
'
+
"'"
+
name
+
"'"
output_stream
=
os
.
popen
(
command
)
out_res
=
output_stream
.
read
().
split
(
'
\n
'
)[
0
:
-
1
]
output_stream
.
close
()
names
=
natsort
.
natsorted
(
out_res
,
reverse
=
False
)
Plot
=
Plotter
()
args
=
Args
(
names
,
Plot
.
ani_plot_contour
,
var
=
var
,
mval
=
mval
,
oname
=
oname
,
out
=
out
)
Plot
.
set
(
args
,
if_manual_plot
=
manual_plot
,
if_save_result
=
save_result
)
Plot
.
ani_plot_contour
()
def
avg_plot
(
filename
,
out
=
'
./
'
,
oname
=
'
fig.png
'
,
var
=
[
None
],
mval
=
[
None
]):
Plot
=
Plotter
()
args
=
Args
([
filename
],
Plot
.
avg_plot
,
var
=
var
,
mval
=
mval
,
oname
=
oname
,
out
=
out
)
...
...
This diff is collapsed.
Click to expand it.
setup.py
+
5
−
5
View file @
22220af6
...
...
@@ -4,11 +4,11 @@ if __name__ == "__main__":
setuptools
.
setup
(
name
=
'
plotter
'
,
version
=
"
0.1
"
,
install_requires
=
[
"
numpy>=1.23.5
"
,
"
matplotlib >=3.6.2
"
,
"
natsort >=8.2.0
"
,
"
imageio >=2.22.4
"
],
#
install_requires=[
#
"numpy>=1.23.5",
#
"matplotlib >=3.6.2",
#
"natsort >=8.2.0",
#
"imageio >=2.22.4"],
packages
=
setuptools
.
find_packages
(
where
=
'
.
'
,
...
...
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