Easier time series plotting.
This commit is contained in:
@@ -118,6 +118,7 @@ def parse_ts(fdir, fname):
|
|||||||
line[i] = line[i].replace('_total', "tot")
|
line[i] = line[i].replace('_total', "tot")
|
||||||
line[i] = line[i].replace('A', "aa")
|
line[i] = line[i].replace('A', "aa")
|
||||||
line[i] = line[i].replace('LNRHO', "lnrho")
|
line[i] = line[i].replace('LNRHO', "lnrho")
|
||||||
|
line[i] = line[i].replace('ENTROPY', "ss")
|
||||||
line[i] = line[i].replace('X', "x")
|
line[i] = line[i].replace('X', "x")
|
||||||
line[i] = line[i].replace('Y', "y")
|
line[i] = line[i].replace('Y', "y")
|
||||||
line[i] = line[i].replace('Z', "z")
|
line[i] = line[i].replace('Z', "z")
|
||||||
|
@@ -19,3 +19,4 @@
|
|||||||
|
|
||||||
|
|
||||||
from . import slices
|
from . import slices
|
||||||
|
from . import lineplot
|
||||||
|
93
analysis/python/astar/visual/lineplot.py
Normal file
93
analysis/python/astar/visual/lineplot.py
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
'''
|
||||||
|
Copyright (C) 2014-2019, Johannes Pekkilae, Miikka Vaeisalae.
|
||||||
|
|
||||||
|
This file is part of Astaroth.
|
||||||
|
|
||||||
|
Astaroth is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Astaroth is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Astaroth. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
'''
|
||||||
|
import pylab as plt
|
||||||
|
import numpy as np
|
||||||
|
import matplotlib.gridspec as gridspec
|
||||||
|
import matplotlib.colors as colors
|
||||||
|
|
||||||
|
CM_INFERNO = plt.get_cmap('inferno')
|
||||||
|
|
||||||
|
end_rm = -1 #-35#-40
|
||||||
|
|
||||||
|
def plot_min_man_rms(ts, xaxis, yaxis1, yaxis2, yaxis3):
|
||||||
|
plt.plot(ts.var[xaxis][:end_rm], ts.var[yaxis1][:end_rm], label=yaxis1)
|
||||||
|
plt.plot(ts.var[xaxis][:end_rm], ts.var[yaxis2][:end_rm], label=yaxis2)
|
||||||
|
plt.plot(ts.var[xaxis][:end_rm], ts.var[yaxis3][:end_rm], label=yaxis3)
|
||||||
|
plt.xlabel(xaxis)
|
||||||
|
plt.legend()
|
||||||
|
|
||||||
|
def plot_ts(ts, show_all=False, lnrho=False, uutot=False, uux=False, uuy=False, uuz=False, ss=False):
|
||||||
|
|
||||||
|
if show_all:
|
||||||
|
lnrho=True
|
||||||
|
uutot=True
|
||||||
|
uux=True
|
||||||
|
uuy=True
|
||||||
|
uuz=True
|
||||||
|
ss=True
|
||||||
|
|
||||||
|
if lnrho:
|
||||||
|
plt.figure()
|
||||||
|
xaxis = 't_step'
|
||||||
|
yaxis1 = 'lnrho_rms'
|
||||||
|
yaxis2 = 'lnrho_min'
|
||||||
|
yaxis3 = 'lnrho_max'
|
||||||
|
plot_min_man_rms(ts, xaxis, yaxis1, yaxis2, yaxis3)
|
||||||
|
|
||||||
|
if uutot:
|
||||||
|
plt.figure()
|
||||||
|
xaxis = 't_step'
|
||||||
|
yaxis1 = 'uutot_rms'
|
||||||
|
yaxis2 = 'uutot_min'
|
||||||
|
yaxis3 = 'uutot_max'
|
||||||
|
plot_min_man_rms(ts, xaxis, yaxis1, yaxis2, yaxis3)
|
||||||
|
|
||||||
|
if uux:
|
||||||
|
plt.figure()
|
||||||
|
xaxis = 't_step'
|
||||||
|
yaxis1 = 'uux_rms'
|
||||||
|
yaxis2 = 'uux_min'
|
||||||
|
yaxis3 = 'uux_max'
|
||||||
|
plot_min_man_rms(ts, xaxis, yaxis1, yaxis2, yaxis3)
|
||||||
|
|
||||||
|
if uuy:
|
||||||
|
plt.figure()
|
||||||
|
xaxis = 't_step'
|
||||||
|
yaxis1 = 'uuy_rms'
|
||||||
|
yaxis2 = 'uuy_min'
|
||||||
|
yaxis3 = 'uuy_max'
|
||||||
|
plot_min_man_rms(ts, xaxis, yaxis1, yaxis2, yaxis3)
|
||||||
|
|
||||||
|
if uuz:
|
||||||
|
plt.figure()
|
||||||
|
xaxis = 't_step'
|
||||||
|
yaxis1 = 'uuz_rms'
|
||||||
|
yaxis2 = 'uuz_min'
|
||||||
|
yaxis3 = 'uuz_max'
|
||||||
|
plot_min_man_rms(ts, xaxis, yaxis1, yaxis2, yaxis3)
|
||||||
|
|
||||||
|
if ss:
|
||||||
|
plt.figure()
|
||||||
|
xaxis = 't_step'
|
||||||
|
yaxis1 = 'ss_rms'
|
||||||
|
yaxis2 = 'ss_min'
|
||||||
|
yaxis3 = 'ss_max'
|
||||||
|
plot_min_man_rms(ts, xaxis, yaxis1, yaxis2, yaxis3)
|
||||||
|
|
||||||
|
plt.show()
|
@@ -14,7 +14,16 @@
|
|||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"# Here we read data from the run directory"
|
"### Here we read data from the run directory"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"meshdir = \"/scratch/data/mvaisala/iotest/\""
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -24,7 +33,6 @@
|
|||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"imesh = 0\n",
|
"imesh = 0\n",
|
||||||
"meshdir = \"/scratch/data/mvaisala/iotest/\"\n",
|
|
||||||
"mesh = ad.read.Mesh(imesh, fdir=meshdir)"
|
"mesh = ad.read.Mesh(imesh, fdir=meshdir)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -32,7 +40,7 @@
|
|||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"# Example visualization funtion call. "
|
"### Example visualization funtion call. "
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -46,6 +54,38 @@
|
|||||||
"vis.slices.plot_3(mesh, mesh.uu[0], title = r'$u_x$', bitmap = False, fname = 'uux')"
|
"vis.slices.plot_3(mesh, mesh.uu[0], title = r'$u_x$', bitmap = False, fname = 'uux')"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"### Ploting time series"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"ts = ad.read.TimeSeries(fdir=meshdir)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"vis.lineplot.plot_ts(ts, lnrho=1, uutot=1, uux=1, ss=1)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
|
@@ -199,65 +199,6 @@ if 'sl' in sys.argv:
|
|||||||
|
|
||||||
if 'ts' in sys.argv:
|
if 'ts' in sys.argv:
|
||||||
ts = ad.read.TimeSeries(fdir=meshdir)
|
ts = ad.read.TimeSeries(fdir=meshdir)
|
||||||
|
vis.lineplot.plot_ts(ts, lnrho=1, uutot=1, uux=1, ss=1)
|
||||||
end_rm = -1 #-35#-40
|
|
||||||
|
|
||||||
plt.figure()
|
|
||||||
xaxis = 't_step'
|
|
||||||
yaxis1 = 'lnrho_rms'
|
|
||||||
yaxis2 = 'lnrho_min'
|
|
||||||
yaxis3 = 'lnrho_max'
|
|
||||||
plt.plot(ts.var[xaxis][:end_rm], ts.var[yaxis1][:end_rm], label=yaxis1)
|
|
||||||
plt.plot(ts.var[xaxis][:end_rm], ts.var[yaxis2][:end_rm], label=yaxis2)
|
|
||||||
plt.plot(ts.var[xaxis][:end_rm], ts.var[yaxis3][:end_rm], label=yaxis3)
|
|
||||||
plt.xlabel(xaxis)
|
|
||||||
plt.legend()
|
|
||||||
|
|
||||||
plt.figure()
|
|
||||||
xaxis = 't_step'
|
|
||||||
yaxis1 = 'uutot_rms'
|
|
||||||
yaxis2 = 'uutot_min'
|
|
||||||
yaxis3 = 'uutot_max'
|
|
||||||
plt.plot(ts.var[xaxis][:end_rm], ts.var[yaxis1][:end_rm], label=yaxis1)
|
|
||||||
plt.plot(ts.var[xaxis][:end_rm], ts.var[yaxis2][:end_rm], label=yaxis2)
|
|
||||||
plt.plot(ts.var[xaxis][:end_rm], ts.var[yaxis3][:end_rm], label=yaxis3)
|
|
||||||
plt.xlabel(xaxis)
|
|
||||||
plt.legend()
|
|
||||||
|
|
||||||
plt.figure()
|
|
||||||
xaxis = 't_step'
|
|
||||||
yaxis1 = 'uux_rms'
|
|
||||||
yaxis2 = 'uux_min'
|
|
||||||
yaxis3 = 'uux_max'
|
|
||||||
plt.plot(ts.var[xaxis][:end_rm], ts.var[yaxis1][:end_rm], label=yaxis1)
|
|
||||||
plt.plot(ts.var[xaxis][:end_rm], ts.var[yaxis2][:end_rm], label=yaxis2)
|
|
||||||
plt.plot(ts.var[xaxis][:end_rm], ts.var[yaxis3][:end_rm], label=yaxis3)
|
|
||||||
plt.xlabel(xaxis)
|
|
||||||
plt.legend()
|
|
||||||
|
|
||||||
plt.figure()
|
|
||||||
xaxis = 't_step'
|
|
||||||
yaxis1 = 'uuy_rms'
|
|
||||||
yaxis2 = 'uuy_min'
|
|
||||||
yaxis3 = 'uuy_max'
|
|
||||||
plt.plot(ts.var[xaxis][:end_rm], ts.var[yaxis1][:end_rm], label=yaxis1)
|
|
||||||
plt.plot(ts.var[xaxis][:end_rm], ts.var[yaxis2][:end_rm], label=yaxis2)
|
|
||||||
plt.plot(ts.var[xaxis][:end_rm], ts.var[yaxis3][:end_rm], label=yaxis3)
|
|
||||||
plt.xlabel(xaxis)
|
|
||||||
plt.legend()
|
|
||||||
|
|
||||||
plt.figure()
|
|
||||||
xaxis = 't_step'
|
|
||||||
yaxis1 = 'uuz_rms'
|
|
||||||
yaxis2 = 'uuz_min'
|
|
||||||
yaxis3 = 'uuz_max'
|
|
||||||
plt.plot(ts.var[xaxis][:end_rm], ts.var[yaxis1][:end_rm], label=yaxis1)
|
|
||||||
plt.plot(ts.var[xaxis][:end_rm], ts.var[yaxis2][:end_rm], label=yaxis2)
|
|
||||||
plt.plot(ts.var[xaxis][:end_rm], ts.var[yaxis3][:end_rm], label=yaxis3)
|
|
||||||
plt.xlabel(xaxis)
|
|
||||||
plt.legend()
|
|
||||||
|
|
||||||
|
|
||||||
plt.show()
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user