Ejemplo n.º 1
0
nargs = len(args)

if (nargs == 0):
    index_first, index_last = nfiles - 101, nfiles - 1
    # By default trace over the last 100 files
else:
    index_first, index_last = get_desired_range(int_file_list, args)

# Set the timetrace savename by the directory, what we are saving,
# and first and last iteration files for the trace
savename = 'lmvals_trace-' + file_list[index_first] + '_' +\
        file_list[index_last] + '.pkl'
savefile = datadir + savename

# Read in first Shell_Spectra file for (spectral) grid info
spec0 = Shell_Spectra(radatadir + file_list[index_first], '')

# Create 1d array of (float) l-values
lmax = spec0.lmax
lvals = np.arange(lmax + 1, dtype='float')

# Trace over the relevant data range
print ('Considering Shell_Spectra files %s through %s for the trace ...'\
       %(file_list[index_first], file_list[index_last]))

iter1, iter2 = int_file_list[index_first], int_file_list[index_last]

iter1, iter2 = int_file_list[index_first], int_file_list[index_last]

vals = []
times = []
Ejemplo n.º 2
0
        desired_iter = di_trans['val_iter']
        iiter = np.argmin(np.abs(int_file_list - desired_iter))

# directory for plots (depends on whether logscale = True, so do this after
# command-line-arguments are read
plotdir = dirname + '/plots/spec_l/vars_sample' + tag + '/'
if not logscale:
    plotdir = plotdir + 'notlog/'
if not os.path.isdir(plotdir):
    os.makedirs(plotdir)

# Read in pspec data
fname = file_list[iiter]

# Read in desired shell spectrum
spec = Shell_Spectra(radatadir + fname, '')
rvals = spec.radius / rsun
qv = spec.qv
lut = spec.lut
nr = spec.nr
nell = spec.nell
lvals = np.arange(nell, dtype='float')
lpower = spec.lpower[:, :, :, 0, :]

# Find desired radius (by default ir=0--near outer surface)
if not rval is None:
    ir = np.argmin(np.abs(rvals - rval))
rval = rvals[ir]  # in any case, this is the actual rvalue we get

# Get local time (in seconds)
t_loc = spec.time[0]
Ejemplo n.º 3
0
ax[1].plot(power[:, rind, tind, 1])
ax[1].set_xlabel(r'Degree $\ell$')
ax[1].set_title('Velocity Power (m=0)')

ax[2].plot(power[:, rind, tind, 2])
ax[2].set_xlabel(r'Degree $\ell$')
ax[2].set_title('Velocity Power ( total - {m=0} )')

plt.tight_layout()
savefile = 'Power_1D.pdf'
print('Saving figure to: ', savefile)
plt.savefig(savefile)

fig, ax = plt.subplots()
ss = Shell_Spectra(istring)

mmax = ss.mmax
lmax = ss.lmax
power_spectrum = numpy.zeros((lmax + 1, mmax + 1), dtype='float64')

for i in range(1, 4):  # i takes on values 1,2,3
    qind = ss.lut[i]
    complex_spectrum = ss.vals[:, :, rind, qind, tind]
    power_spectrum = power_spectrum + numpy.real(
        complex_spectrum)**2 + numpy.imag(complex_spectrum)**2

power_spectrum = numpy.transpose(power_spectrum)

tiny = 1e-6
img = ax.imshow(numpy.log10(power_spectrum + tiny), origin='lower')