コード例 #1
0
def read_post(filename = 'post_evaluation.dat', datadir = 'data',
                double = 0, quiet = 1, comment_char = '#'):
    """
    Read the post processed diagnostic variables.

    call signature::
    
      read_post(filename = 'post_evaluation.dat', datadir = 'data', double = 0, quiet = 0, comment_char = '#')
    
    Read the post processed diagnostic variables from 'data/post_evaluation.dat.
    Return an object with the variables.
    
    Keyword arguments:
      
      *filename*:
        Name of the post evaluation file.
        
      *datadir*:
        Name of the data directory.
        
      *double*:
        Not used yet (see the read_ts options).
        
      *quiet*:
        If True do not show how many lines are being read.
        
      *comment_char*:
        The comment character.
        
    """

    return pc.read_ts(filename = filename, datadir = datadir,
                 double = double, quiet = quiet, print_std = 0, plot_data = False, comment_char = comment_char)
コード例 #2
0
def read_post(filename = 'post_evaluation.dat', datadir = 'data',
                double = 0, quiet = 1, comment_char = '#'):
    """
    Read the post processed diagnostic variables.

    call signature::
    
      read_post(filename = 'post_evaluation.dat', datadir = 'data', double = 0, quiet = 0, comment_char = '#')
    
    Read the post processed diagnostic variables from 'data/post_evaluation.dat.
    Return an object with the variables.
    
    Keyword arguments:
      
      *filename*:
        Name of the post evaluation file.
        
      *datadir*:
        Name of the data directory.
        
      *double*:
        Not used yet (see the read_ts options).
        
      *quiet*:
        If True do not show how many lines are being read.
        
      *comment_char*:
        The comment character.
        
    """

    return pc.read_ts(filename = filename, datadir = datadir,
                 double = double, quiet = quiet, print_std = 0, plot_data = False, comment_char = comment_char)
コード例 #3
0
ファイル: test1.py プロジェクト: zzzxhahaha/pencil-code
def read_ts(datadir, filename='time-series-1.dat'):
    return pc.read_ts(
        datadir=datadir, filename=filename, plot_data=False, quiet=True
    )
コード例 #4
0
import numpy as np
import matplotlib.pyplot as plt
import pencil as pc

# ======================================
# pc.read_ts()
# ======================================

ts = pc.read_ts()
t = ts.t / 2 / np.pi
N = 50
tmax = t.max()
ux = ts.ux2m
uy = ts.uy2m
rhomax = ts.rhomax
rhomin = ts.rhomin

# ======================================
# pc.read_pararm()
# ======================================

par = pc.read_param()
h = par.cs0
if (par.iprimary == 1):
    q = par.pmass[1]
else:
    q = par.pmass[0]

par1 = par.pmass[1]
par2 = par.pmass[0]
gamma = par.gamma
コード例 #5
0
import pencil
import numpy
from matplotlib import pyplot
from matplotlib import cm
import sys
import os

#simulation_name = 
#script_name     = os.path.basename(__file__)

data        = pencil.read_var(trimall=True)
pdata       = pencil.read_pvar()
time_series = pencil.read_ts()
parameters  = pencil.read_param()

npar   = len(pdata.ipars)
xgrid  = data.x
ygrid  = data.y
zgrid  = data.z
dxgrid = data.dx
dygrid = data.dy
dzgrid = data.dz
x0 = xgrid[0]
y0 = ygrid[0]
z0 = zgrid[0]
x1 = xgrid[-1]
y1 = ygrid[-1]
z1 = zgrid[-1]
last_snap = numpy.floor(time_series.t[-1]/parameters.tausp) + 1

ivar_lower = 0
コード例 #6
0
# -*- coding: utf-8 -*-   vim: set fileencoding=utf-8 :

# Set up Python load path and configure a matplotlib backend that does not
# need X11. This needs to happen before importing the pencil module.
import sys
sys.path.append('../../../python')
import matplotlib
matplotlib.use('agg')
import pencil as pc

# Description:
#   Read time series and data cube, write a few values

datadir = '../data'

ts = pc.read_ts(datadir=datadir, plot_data=False, quiet=True)
var = pc.read_var(datadir=datadir, trimall=True, quiet=True)

# Now write to file
file = open('read_data.out', 'w')

file.write('ts.times :')
for t in ts.t[0:5]:
    file.write(' %g' % (t, ))
file.write('\n')

file.write('aa(5,5,0:4,1) :')
for a in var.aa[1, 0:5, 5, 5]:
    file.write(' %g' % (a, ))
file.write('\n')
コード例 #7
0
ファイル: read_data.py プロジェクト: debanjan0811/pencil-code
# Set up Python load path and configure a matplotlib backend that does not
# need X11. This needs to happen before importing the pencil module.
import sys
sys.path.append('../../../python')
import matplotlib
matplotlib.use('agg')
import pencil as pc


# Description:
#   Read time series and data cube, write a few values

datadir = '../data'

ts = pc.read_ts(datadir=datadir, plot_data=False, quiet=True)
var = pc.read_var(datadir=datadir, trimall=True, quiet=True)


# Now write to file
file = open('read_data.out', 'w')

file.write('ts.times :')
for t in ts.t[0:5]:
    file.write(' %g' % (t, ))
file.write('\n')

file.write('aa(5,5,0:4,1) :')
for a in var.aa[1, 0:5, 5, 5]:
    file.write(' %g' % (a, ))
file.write('\n')
コード例 #8
0
import pencil
import numpy
from matplotlib import pyplot
from matplotlib import cm
import sys
import os

base_path, script_name = os.path.split(sys.argv[0])
scratch, simulation_name = os.path.split(base_path)
script_name = script_name[:-3]

data = pencil.read_var(trimall=True, quiet=True)
pdata = pencil.read_pvar()
time_series = pencil.read_ts(quiet=True)
parameters = pencil.read_param(quiet=True)

npar = len(pdata.ipars)
xgrid = data.x
ygrid = data.y
zgrid = data.z
dxgrid = data.dx
dygrid = data.dy
dzgrid = data.dz
x0 = xgrid[0]
y0 = ygrid[0]
z0 = zgrid[0]
x1 = xgrid[-1]
y1 = ygrid[-1]
z1 = zgrid[-1]
last_snap = int(numpy.floor(data.t / parameters.tausp) + 1)
コード例 #9
0
ファイル: plot_ltaylor.py プロジェクト: belfhi/plotdata
        r"\usepackage[utf8x]{inputenc}",    # use utf8 fonts becasue your computer can handle it :)
        r"\usepackage[T1]{fontenc}",        # plots will be generated using this preamble
        ]
    }
mpl.rcParams.update(pgf_with_latex)

import matplotlib.pyplot as plt


# Setup Figure and Axes

fig, ax  = newfig(0.45)
setup_tsplot(ax)#, xlim=(.1,tser.t[-1]))
tmax = 0.
clrindx = iter(np.linspace(0,1,len(dirs)))

for dd in dirs:
    if args.verbose: print(dd)
    tser = pc.read_ts(datadir=dd, quiet=not args.verbose)
    make_tsplot(fig, ax)
    if tser.t[-1] > tmax:
        ax.set_xlim(.1, tser.t[-1])
    ax.legend(loc='upper left', frameon=False)

filename = dstart + '_taylor'
fig.tight_layout(pad=0.3)
if args.verbose:
    print(filename)
savefig(fig, path.join(figdir, filename))
print('SUCCESS')
コード例 #10
0
ファイル: helts.py プロジェクト: belfhi/plotdata
        r"\usepackage[T1]{fontenc}",        # plots will be generated using this preamble
        ]
    }
mpl.rcParams.update(pgf_with_latex)

import matplotlib.pyplot as plt

cscheme, clr1, clr2, clr3 = select_colors()

# check that there is a figure directory
figdir = 'figures'
check_figdir(figdir)

# Setup Figure and Axes
fwidth = 0.45
tser = pc.read_ts(datadir=args.ddir, quiet=not args.verbose)
par = pc.read_param(datadir=args.ddir, quiet=True)
kpeak = par.kpeak_aa
tau0 = (tser.brms[0]*kpeak)**-1
if args.verbose:
    print('tau = ', tau0)
#if args.peak:
#    args.tsplot = True
fig, ax  = newfig(fwidth)
ax.set_xscale('log')
ax.set_xlim(1e-2/tau0, 3e2/tau0)
#ax.set_yscale('log')
if args.helicity:
    ax.set_ylabel(r'$\mathcal{H}$')#/\mathcal{H}_0$')
    ax.plot(tser.t/tau0, np.abs(tser.ab_int)*10**5)#**2/tser.brms**2)#/tser.ab_int[0]))
    twx = ax.twinx()
コード例 #11
0
ファイル: Orbital.py プロジェクト: joshuashevchuk1/AGNpython
import pencil as pc
import matplotlib.pyplot as plt
import numpy as np
import scipy.constants as scp
import os

global radq1, thetaq1, t, xrq1, yrq1, xrq2, yrq2, vxq1, vyq1, vxq2, vyq2, r, vq1, vq2, v, G, ap1, ap2, ap3, a, rmax, e, ep1, v, xq2, yq2, xq1, yq1, vx, vy

TIMESERIES = pc.read_ts()

radq1 = TIMESERIES.xq1
thetaq1 = TIMESERIES.yq1
t = TIMESERIES.t

xrq1 = radq1 * np.cos(thetaq1)
yrq1 = radq1 * np.sin(thetaq1)

radq2 = TIMESERIES.xq2
thetaq2 = TIMESERIES.yq2

xrq2 = radq2 * np.cos(thetaq2)
yrq2 = radq2 * np.sin(thetaq2)

vxq1 = TIMESERIES.vxq1
vyq1 = TIMESERIES.vyq1

vxq2 = TIMESERIES.vxq2
vyq2 = TIMESERIES.vyq2

xq2 = TIMESERIES.xq2
yq2 = TIMESERIES.yq2
コード例 #12
0
ファイル: power_int.py プロジェクト: belfhi/plotdata
    try:
        dirs = sorted(dirs, key=lambda s: float(s.split('_')[-1]), reverse=True)
    except ValueError:
        dirs = sorted(dirs)
elif len(dirs) == 0:
    print('choose proper datadir')
    sys.exit(1)
if args.helical:
    #dirs.insert(0, 'helical')
    dirs.append( 'helical')
if args.verbose:
    print(dirs)
clrindx = iter(np.linspace(0,1,len(dirs)))

# calculate the timescales
tser = pc.read_ts(datadir=dirs[0])
par2 = pc.read_param(quiet=True, datadir=dirs[0], param2=True)
pars = pc.read_param(quiet=True, datadir=dirs[0])
vA0 = tser.brms[0]
k0 = pars.kpeak_aa
tau0 = (vA0*k0)**-1

# Simple plot
fig, ax  = newfig(0.45, ratio=0.75)


for dd in dirs:   
    if dstart.startswith('delta'):
        tstop = 1.
    else:
        tstop=0
コード例 #13
0
import pencil
import numpy
from matplotlib import pylab
import sys

params = pencil.read_param()
ts = pencil.read_ts()

tau = 0.014
g = 2.45

v_s = -tau * g
v_z_max = ts.vpzmax
v_z_min = ts.vpzmin
#v_z_mean = ts.vpzm
time = ts.t / tau

figure = pylab.figure()
subplot = figure.add_subplot(111)
subplot.plot(time, v_z_max, color="red", label="Maximum z-velocity")
subplot.plot(time, v_z_min, color="green", label="Minimum z-velocity")
#subplot.plot(time,v_z_min,color="black",label="Mean z-velocity")
subplot.plot(time,
             numpy.repeat(v_s, len(time)),
             linestyle="--",
             color="grey",
             label="Isolated terminal velocity")

subplot.set_title("vpzmax vs t")
subplot.set_ylabel("vpz")
subplot.set_xlabel("t (friction times)")
コード例 #14
0
ファイル: kmax_calc_plot.py プロジェクト: belfhi/plotdata
try:
    dirs = sorted(dirs, key=lambda a: float(a.split('_')[-1]), reverse=True)
except ValueError:
    pass
#dirs =sorted( [s for s in listdir('.') if (isdir(s) and s.startswith(dstart) and not isfile(join(s,'.noscale')))],
             #key=lambda s: float(s.split('_')[-1]))
if args.helical:
    dirs.append('helical')
dstart=dirs[0]
if args.verbose:
    print(dirs)
clrindx = iter(np.linspace(0,1,len(dirs)))

dim = pc.read_dim(datadir=dstart)
krms = np.loadtxt(join(dstart, 'power_krms.dat')).flatten()[:dim.nxgrid//2]
tser0 = pc.read_ts(quiet=not args.verbose, datadir=dstart)
par0 = pc.read_param(datadir=dstart, quiet=True)
kpeak = par0.kpeak_aa
tau0 = (tser0.brms[0]*kpeak)**-1
print('tau = ',tau0)
if args.verbose:
    print('krms shape: ',krms.shape)

if args.light:
    cscheme = plt.cm.Paired
else:
    cscheme = plt.cm.Dark2

# Simple plot
fig, ax  = newfig(0.45, ratio=0.75)
ax.set_xscale('log')
コード例 #15
0
ファイル: plot_specific_time.py プロジェクト: belfhi/plotdata
    "figure.figsize": figsize(0.95),     # default fig size of 0.9 textwidth
    "pgf.preamble": [
        r"\usepackage[utf8x]{inputenc}",    # use utf8 fonts becasue your computer can handle it :)
        r"\usepackage[T1]{fontenc}",        # plots will be generated using this preamble
        ]
    }
mpl.rcParams.update(pgf_with_latex)

import matplotlib.pyplot as plt

fwidth = 0.45
fig, ax = newfig(fwidth)


# calculate the timescales
tser = pc.read_ts(datadir=dirs[-1])
par2 = pc.read_param(quiet=True, datadir=dirs[-1], param2=True)
pars = pc.read_param(quiet=True, datadir=dirs[-1])
vA0 = tser.brms[0]
k0 = pars.kpeak_aa
tau0 = (vA0*k0)**-1
print('tau_0 = ',tau0)

if args.twin:
    twinax = ax.twinx()
    twinax.set_yscale('log')
    yl2 = twinax.get_ylim()
    if args.verbose:
        print(yl2)
    #twinax.set_ylim(1,1e4)
    twinax.set_ylabel(r'$E_{k\leq 7}/E_0$')