elevation_spec = [0, 1, 0] # grab time index 0, quantity code 1, radial index 0 elevation_scale_factor = 1.5 # scale_factor (used in tandem with stddev -- see scale_data above) color_spec = [0, 3, 0] #grab time index 0, quantity code 3, radial index 0 color_scale_factor = 2.5 if (vis_option == 2): # Radial component of velocity gives the elevation and the color hillsize = 0.003 elevation_spec = [0, 1, 0] elevation_scale_factor = 1.5 color_spec = [0, 1, 0] color_scale_factor = 1.5 shell1 = ShellSlice(shellfile, path='./', slice_spec=elevation_spec) elevation_data = shell1.vals[:, :].reshape(shell1.nphi, shell1.ntheta) elevation_data = np.transpose(elevation_data) shell2 = ShellSlice(shellfile, path='./', slice_spec=color_spec) color_data = shell2.vals[:, :].reshape(shell1.nphi, shell1.ntheta) color_data = np.transpose(color_data) nphi = shell1.nphi ntheta = shell2.ntheta # Scale both the elevation and the color data as desired # If rendering something with a spherical mean, set no_mean = True # in the call to scale_data (as with temperature/entropy) scale_data(elevation_data, scale_factor=elevation_scale_factor) scale_data(color_data, scale_factor=color_scale_factor)
rec_spec = [0, 3, 1] # grab time index 0, quantity code 3, and radial index 1 save_figure = False # Set to true to save to a figure_file (below) figure_file = 'shell_slice_basemap.png' #The resolution of the png file or the view window in pixels xpixels = 1024 ypixels = 1024 # Initialize the projection. # lon_0, lat_0 are the center point of the projection. # resolution = 'l' means use low resolution coastlines. m = Basemap(projection='ortho', lon_0=-20, lat_0=35, resolution='l') #Read in the data a = ShellSlice(shellfile, path='./', slice_spec=rec_spec) data = a.vals[:, :, 0, 0, 0].reshape(a.nphi, a.ntheta) data = np.transpose(data) maxabs = 3 * np.std(data) # saturate data at +/- 3 sigma dlon = 360.0 / (a.nphi) dlat = 180.0 / a.ntheta #Scale the data for i in range(a.ntheta): for j in range(a.nphi): if (data[i, j] > maxabs): data[i, j] = maxabs if (data[i, j] < -maxabs): data[i, j] = -maxabs data[i, j] = data[i, j] / maxabs
# Create 'datadir' if it doesn't exist already if (not os.path.isdir(datadir)): os.makedirs(datadir) slicedir = dirname + '/Shell_Slices/' files = os.listdir(slicedir) files.sort() rr, tt, cost, sint, rr_depth, ri, ro, d = np.load(datadir + 'grid_info.npy') nr = len(rr) nt = len(tt) nph = 2 * nt sint_2d = sint.reshape((1, nt)) print('Reading ' + slicedir + files[-1] + ' ...') a = ShellSlice(slicedir + files[-1], '') vr = a.vals[:, :, :, a.lut[1], 0] nrad = len(a.radius) fplus = np.zeros(nrad) fminus = np.zeros(nrad) for i in range(nrad): vr_loc = vr[:, :, i] where_p = np.where(vr_loc > 0) where_m = np.where(vr_loc < 0) ind_p = np.zeros((nph, nt)) ind_p[where_p] = 1 ind_m = np.zeros((nph, nt)) ind_m[where_m] = 1
# self.lut : Lookup table for the different diagnostics output # ------------------------------------- import pylab as p import numpy as np from diagnostic_reading import ShellSlice import matplotlib.pyplot as plt from matplotlib import ticker # Set saveplot to True to save to a .png file. # Set to False to view plots interactively on-screen. saveplot = False savefile = 'shell_slice.png' #Read in our shell slice a = ShellSlice(filename='03280000', path='Shell_Slices/') #Identify the variables indices for vr,vphi, and entropy var_inds = [a.lut[1], a.lut[3], a.lut[64]] rad_inds = [0, 3, 6] # pick 3 depth to plot at tind = 0 # grab time index 0 (the first record of the file) #Tex can be enclosed in dollar signs within a string. The r in front of the string is necessary for strings enclosing Tex units = [r'm s$^{-1}$', r'm s$^{-1}$', r'erg g$^{-1}$ K$^{-1}$'] vnames = [r'v$_r$', r'v$_\phi$', "S'"] ncol = len(var_inds) nrow = len(rad_inds) nplots = ncol * nrow #Create the plots. This first portion only handles the projection and colorbars.