def thermal_pressure_profiler(hf, step=-1): """In Pa""" try: hybrid_n = hr(hf, 'np_tot') except NoSuchVariable: hybrid_n = hr(hf, 'np') grid_points = hybrid_n.para['grid_points'] n = hybrid_n.get_timestep(step)[-1] ndata = n_km2cm(n) try: hybrid_temp = hr(hf, 'temp_tot') except NoSuchVariable: hybrid_temp = hr(hf, 'temp_p') t = hybrid_temp.get_timestep(step)[-1] tdata = t_K(t) # in Pa not pPa thermal_p_data = pressure_pPa(ndata, tdata) * 1e-12 p_therm = profile(points, grid_points, thermal_p_data) return p_therm
def insert_beta_plot(fig, ax, prefix, cax): hn = hr(prefix, 'np') para = hn.para n = hn.get_timestep(-1)[-1] try: T = hr(prefix, 'temp_tot').get_timestep(-1)[-1] except NoSuchVariable: T = hr(prefix, 'temp_p').get_timestep(-1)[-1] B = hr(prefix, 'bt').get_timestep(-1)[-1] # Convert units n = n / (1000.0**3) # 1/km^3 -> 1/m^3 T = 1.60218e-19 * T # eV -> J B = 1.6726219e-27 / 1.60217662e-19 * B # proton gyrofrequency -> T # Compute B \cdot B B2 = np.sum(B**2, axis=-1) # Compute plasma beta mu_0 = value('mag. constant') assert unit('mag. constant') == 'N A^-2' data = n * T / (B2 / (2 * mu_0)) m, x, y, s = beta_plot2(ax, data, para, 'xy', mccomas=True) if cax != 'None': fig.colorbar(m, cax=cax, orientation='horizontal')
def pressure_profiler(hf, step=-1): try: hybrid_n = hr(hf, 'np_tot') except NoSuchVariable: hybrid_n = hr(hf, 'np') grid_points = hybrid_n.para['grid_points'] n = hybrid_n.get_timestep(step)[-1] ndata = n_km2cm(n) try: hybrid_temp = hr(hf, 'temp_tot') except NoSuchVariable: hybrid_temp = hr(hf, 'temp_p') t = hybrid_temp.get_timestep(step)[-1] tdata = t_K(t) thermal_p_data = pressure_pPa(ndata, tdata) hybrid_b = hr(hf, 'bt') b = hybrid_b.get_timestep(step)[-1] bdata = b_pressure(b) p_therm = profile(points, grid_points, thermal_p_data) p_b = profile(points, grid_points, bdata) return zip(p_therm, p_b)
def plot_traj_context(fig, ax_xy, ax_xz, prefix, traj, size, mccomas=False): hybrid_np_CH4 = hr(prefix, 'np_CH4') np_3d = hybrid_np_CH4.get_timestep(-1)[-1] hh.direct_plot(fig, ax_xy, np_3d, hybrid_np_CH4.para, 'xy', norm=LogNorm(), fontsize=size, mccomas=mccomas) hh.direct_plot(fig, ax_xz, np_3d, hybrid_np_CH4.para, 'xz', norm=LogNorm(), fontsize=size, mccomas=mccomas) traj = traj / 1187. if mccomas: traj[:, 0] = -traj[:, 0] traj[:, 1] = -traj[:, 1] x = traj[:, 0] y = traj[:, 1] z = traj[:, 2] ax_xy.plot(x, y, color='black', linewidth=2, scalex=False, scaley=False) ax_xz.plot(x, z, color='black', linewidth=2, scalex=False, scaley=False)
def beta_data(prefix): hn = hr(prefix, 'np') para = hn.para n = hn.get_timestep(-1)[-1] T = hr(prefix, 'temp_p').get_timestep(-1)[-1] B = hr(prefix, 'bt').get_timestep(-1)[-1] # Convert units n = n / (1000.0**3) # 1/km^3 -> 1/m^3 T = 1.60218e-19 * T # eV -> J B = 1.6726219e-27 / 1.60217662e-19 * B # proton gyrofrequency -> T # Compute B \cdot B B2 = np.sum(B**2, axis=-1) # Compute plasma beta data = n * T / (B2 / (2 * 1.257e-6)) return para, data
def profiler(hf, step=-1): hybrid = hr(hf, var) grid_points = hybrid.para['grid_points'] v = hybrid.get_timestep(step)[-1] if modifier is not None: data = modifier(v) else: data = v return profile(points, grid_points, data)
def magnetic_pressure_profiler(hf, step=-1): hybrid_b = hr(hf, 'bt') b = hybrid_b.get_timestep(step)[-1] # in Pa not pPa bdata = b_pressure(b) * 1e-12 grid_points = hybrid_b.para['grid_points'] p_b = profile(points, grid_points, bdata) return p_b
def plot_1d_variable(fig, ax, args): # Get upstream values para = hp(args.prefix, force_version=args.force_version).para B0 = para['b0_init'] # T (yes, b0_init is already in Tesla. No need to convert.) n0 = para['nf_init']/1000**3 # m^-3 ## Handy parameters common to most plots c = 3e8 # speed of light in m/s q = 1.602e-19 # C m = para['ion_amu']*1.6726e-27 # kg q_over_m = q/m # C/kg e0 = 8.854e-12 # F/m mu_0 = 1.257e-6 # Some upstream parameters omega_pi = np.sqrt(n0*q*q_over_m/e0) # rad/s lambda_i = c/omega_pi # m omega_ci = q_over_m*B0 # rad/s ## Special cases first, the general case is the else block at the bottom if args.variable.name == 'pressure': steps, times, n = get_1d_scalar(hr(args.prefix, 'np_tot', force_version=args.force_version)) _, _, T = get_1d_scalar(hr(args.prefix, 'temp_tot', force_version=args.force_version)) # Convert units n = n/(1000.0**3) # 1/km^3 -> 1/m^3 T = q * T # eV -> J x = 1000*para['qx']/lambda_i # position in units of lambda_i t = times*omega_ci # time in units of omega_ci^-1 pressure = n*T mesh = ax.pcolormesh(t, x, pressure.T, cmap=args.colormap, norm=args.norm, vmin=args.vmin, vmax=args.vmax) ax.set_xlim(args.xlim) ax.set_ylim(args.ylim) elif args.variable.name == 'beta': steps, times, n = get_1d_scalar(hr(args.prefix, 'np_tot', force_version=args.force_version)) _, _, T = get_1d_scalar(hr(args.prefix, 'temp_tot', force_version=args.force_version)) _, _, B = get_1d_vector(hr(args.prefix, 'bt', force_version=args.force_version)) # Convert units n = n/(1000.0**3) # 1/km^3 -> 1/m^3 T = q * T # eV -> J B = B/q_over_m # ion gyrofrequency -> T # Compute B \cdot B B2 = np.sum(B**2, axis=-1) # Compute plasma beta beta = n*T/(B2/(2*mu_0)) x = 1000*para['qx']/lambda_i # position in units of lambda_i t = times*omega_ci # time in units of omega_ci^-1 mesh = ax.pcolormesh(t, x, beta.T, cmap=args.colormap, norm=args.norm, vmin=args.vmin, vmax=args.vmax) ax.set_xlim(args.xlim) ax.set_ylim(args.ylim) elif args.variable.name == 'bmag': steps, times, B = get_1d_magnetude(hr(args.prefix, 'bt', force_version=args.force_version)) B = B/q_over_m # ion gyrofrequency -> T x = 1000*para['qx']/lambda_i # position in units of lambda_i t = times*omega_ci # time in units of omega_ci^-1 mesh = ax.pcolormesh(t, x, B.T, cmap=args.colormap, norm=args.norm, vmin=args.vmin, vmax=args.vmax) ax.set_xlim(args.xlim) ax.set_ylim(args.ylim) elif args.variable.name == 'brat': steps, times, B = get_1d_magnetude(hr(args.prefix, 'bt', force_version=args.force_version)) B = B/q_over_m # ion gyrofrequency -> T B = B/para['b0_init'] # Normalize x = 1000*para['qx']/lambda_i # position in units of lambda_i t = times*omega_ci # time in units of omega_ci^-1 mesh = ax.pcolormesh(t, x, B.T, cmap=args.colormap, norm=args.norm, vmin=args.vmin, vmax=args.vmax) ax.set_xlim(args.xlim) ax.set_ylim(args.ylim) elif args.variable.name == 'upmag': steps, times, up = get_1d_magnetiude(hr(args.prefix, 'up', force_version=args.force_version)) x = 1000*para['qx']/lambda_i # position in units of lambda_i t = times*omega_ci # time in units of omega_ci^-1 mesh = ax.pcolormesh(t, x, up.T, cmap=args.colormap, norm=args.norm, vmin=args.vmin, vmax=args.vmax) ax.set_xlim(args.xlim) ax.set_ylim(args.ylim) else: h = hr(args.prefix,args.variable.name, force_version=args.force_version) var_sanity_check(h.isScalar, args.variable.coordinate) if h.isScalar: steps, times, data = get_1d_scalar(h) else: steps, times, data = get_1d_vector(h) data = data[:,:,args.variable.coordinate] x = 1000*para['qx']/lambda_i # position in units of lambda_i t = times*omega_ci # time in units of omega_ci^-1 mesh = ax.pcolormesh(t, x, data.T, cmap=args.colormap, norm=args.norm, vmin=args.vmin, vmax=args.vmax) ax.set_xlim(args.xlim) ax.set_ylim(args.ylim) ax.format_coord = build_pcolormesh_format_coord(mesh) return mesh
def plot_variable(fig1,fig2, ax1,ax2, args): ## Special cases first, the general case is direct_plot() at the bottom if args.variable.name == 'bs': hup = hr(args.prefix,'up') hn_tot = hr(args.prefix,'np') hn_h = hr(args.prefix,'np_He') hn_ch4 = hr(args.prefix,'np_CH4') ux = hup.get_timestep(args.stepnum)[-1] n_tot = hn_tot.get_timestep(args.stepnum)[-1] n_h = hn_h.get_timestep(args.stepnum)[-1] n_ch4 = hn_ch4.get_timestep(args.stepnum)[-1] ux = ux[:,:,:,0] para = hup.para bs_hi_plot(fig1, ax1, n_tot, n_h, n_ch4,ux, 401, 2.7e12, para, 'xy', mccomas=args.mccomas, titlesize=args.titlesize, labelsize=args.labelsize, ticklabelsize=args.ticklabelsize) bs_hi_plot(fig2, ax2, n_tot, n_h, n_ch4,ux, 401, 2.7e12, para, 'xz', mccomas=args.mccomas, titlesize=args.titlesize, labelsize=args.labelsize, ticklabelsize=args.ticklabelsize) elif args.variable.name == 'pressure': try: hn = hr(args.prefix, 'np_tot') except NoSuchVariable: hn = hr(args.prefix, 'np') para = hn.para n = hn.get_timestep(args.stepnum)[-1] try: T = hr(args.prefix, 'temp_tot').get_timestep(args.stepnum)[-1] except NoSuchVariable: T = hr(args.prefix, 'temp_p').get_timestep(args.stepnum)[-1] # Convert units n = n/(1000.0**3) # 1/km^3 -> 1/m^3 T = 1.60218e-19 * T # eV -> J data = n*T m1, X1, Y1, C1 = direct_plot(fig1, ax1, data, para, 'xy', cmap=args.colormap, norm=args.norm, vmin=args.vmin, vmax=args.vmax, mccomas=args.mccomas, titlesize=args.titlesize, labelsize=args.labelsize, ticklabelsize=args.ticklabelsize, cbtitle=args.units) m2, X2, Y2, C2 = direct_plot(fig2, ax2, data, para, 'xz', cmap=args.colormap, norm=args.norm, vmin=args.vmin, vmax=args.vmax, mccomas=args.mccomas, titlesize=args.titlesize, labelsize=args.labelsize, ticklabelsize=args.ticklabelsize, cbtitle=args.units) elif args.variable.name == 'beta': hn = hr(args.prefix, 'np') para = hn.para n = hn.get_timestep(args.stepnum)[-1] try: T = hr(args.prefix, 'temp_tot').get_timestep(args.stepnum)[-1] except NoSuchVariable: T = hr(args.prefix, 'temp_p').get_timestep(args.stepnum)[-1] B = hr(args.prefix, 'bt').get_timestep(args.stepnum)[-1] # Convert units n = n/(1000.0**3) # 1/km^3 -> 1/m^3 T = 1.60218e-19 * T # eV -> J B = para['ion_amu']*1.6726219e-27/1.60217662e-19 * B # ion gyrofrequency -> T # Compute B \cdot B B2 = np.sum(B**2, axis=-1) # Compute plasma beta data = n*T/(B2/(2*1.257e-6)) m1, X1, Y1, C1 = beta_plot2(ax1, data, para, 'xy', mccomas=args.mccomas) m2, X2, Y2, C2 = beta_plot2(ax2, data, para, 'xz', mccomas=args.mccomas) fig1.colorbar(m1, ax=ax1) fig2.colorbar(m2, ax=ax2) args.variable = 'Plasma Beta' elif args.variable.name == 'bmag': hb = hr(args.prefix, 'bt') para = hb.para B = hb.get_timestep(args.stepnum)[-1] B = para['ion_amu']*1.6726219e-27/1.60217662e-19 * B # ion gyrofrequency -> T Bmag = np.sqrt(np.sum(B**2, axis=-1)) data = Bmag m1, X1, Y1, C1 = direct_plot(fig1, ax1, data, para, 'xy', cmap=args.colormap, norm=args.norm, vmin=args.vmin, vmax=args.vmax, mccomas=args.mccomas, titlesize=args.titlesize, labelsize=args.labelsize, ticklabelsize=args.ticklabelsize) m2, X2, Y2, C2 = direct_plot(fig2, ax2, data, para, 'xz', cmap=args.colormap, norm=args.norm, vmin=args.vmin, vmax=args.vmax, mccomas=args.mccomas, titlesize=args.titlesize, labelsize=args.labelsize, ticklabelsize=args.ticklabelsize) elif args.variable.name == 'fmach': hn = hr(args.prefix, 'np') para = hn.para n = hn.get_timestep(args.stepnum)[-1] T = hr(args.prefix, 'temp_tot').get_timestep(args.stepnum)[-1] B = hr(args.prefix, 'bt').get_timestep(args.stepnum)[-1] u = hr(args.prefix, 'up').get_timestep(args.stepnum)[-1] ux = -u[:,:,:,0] n = n/(1000.0**3) # 1/km^3 -> 1/m^3 T = 1.60218e-19 * T # eV -> J B = para['ion_amu']*1.6726219e-27/1.60217662e-19 * B # ion gyrofrequency -> T B2 = np.sum(B**2, axis=-1) c = 3e8 # m/s mu0 = 1.257e-6 # H/m mp = 1.602e-19 # kg gamma = 3 # Upstream alfven velocity us_va = np.sqrt(B2[-1,0,0]/(mu0*mp*n[-1,0,0])) # Upstream ion acousitic speed us_vs = np.sqrt(gamma*T[-1,0,0]/mp) # Upstream fastmode velocity us_vf = c*np.sqrt((us_vs**2 + us_va**2)/(c**2 + us_va**2)) data = ux/us_vf m1, X1, Y1, C1 = direct_plot(fig1, ax1, data, para, 'xy', cmap=args.colormap, norm=args.norm, vmin=args.vmin, vmax=args.vmax, mccomas=args.mccomas, titlesize=args.titlesize, labelsize=args.labelsize, ticklabelsize=args.ticklabelsize) m2, X2, Y2, C2 = direct_plot(fig2, ax2, data, para, 'xz', cmap=args.colormap, norm=args.norm, vmin=args.vmin, vmax=args.vmax, mccomas=args.mccomas, titlesize=args.titlesize, labelsize=args.labelsize, ticklabelsize=args.ticklabelsize) elif args.variable.name == 'ratio': h = hr(args.prefix, 'np') ch4 = hr(args.prefix, 'np_CH4') h_data = h.get_timestep(args.stepnum)[-1] ch4_data = ch4.get_timestep(args.stepnum)[-1] para = h.para ratio_plot(fig1, ax1, h_data, ch4_data, para, 'xy', norm=args.norm, mccomas=args.mccomas, titlesize=args.titlesize, labelsize=args.labelsize, ticklabelsize=args.ticklabelsize) ratio_plot(fig2, ax2, h_data, ch4_data, para, 'xz', norm=args.norm, mccomas=args.mccomas, titlesize=args.titlesize, labelsize=args.labelsize, ticklabelsize=args.ticklabelsize) elif args.variable.name == 'upmag': h = hr(args.prefix,'up') data = h.get_timestep(args.stepnum)[-1] data = np.linalg.norm(data, axis=-1) para = h.para m1, X1, Y1, C1 = direct_plot(fig1, ax1, data, para, 'xy', cmap=args.colormap, norm=args.norm, vmin=args.vmin, vmax=args.vmax, mccomas=args.mccomas, titlesize=args.titlesize, labelsize=args.labelsize, ticklabelsize=args.ticklabelsize, cbtitle=args.units) m2, X2, Y2, C2 = direct_plot(fig2, ax2, data, para, 'xz', cmap=args.colormap, norm=args.norm, vmin=args.vmin, vmax=args.vmax, mccomas=args.mccomas, titlesize=args.titlesize, labelsize=args.labelsize, ticklabelsize=args.ticklabelsize, cbtitle=args.units) else: h = hr(args.prefix,args.variable.name) var_sanity_check(h.isScalar, args.variable.coordinate) data = h.get_timestep(args.stepnum)[-1] if not h.isScalar: data = data[:,:,:,args.variable.coordinate] if str(args.variable).startswith('bt'): data = h.para['ion_amu']*1.6726219e-27/1.60217662e-19 * data # ion gyrofrequency -> T para = h.para m1, X1, Y1, C1 = direct_plot(fig1, ax1, data, para, 'xy', cmap=args.colormap, norm=args.norm, vmin=args.vmin, vmax=args.vmax, mccomas=args.mccomas, titlesize=args.titlesize, labelsize=args.labelsize, ticklabelsize=args.ticklabelsize, cbtitle=args.units) m2, X2, Y2, C2 = direct_plot(fig2, ax2, data, para, 'xz', cmap=args.colormap, norm=args.norm, vmin=args.vmin, vmax=args.vmax, mccomas=args.mccomas, titlesize=args.titlesize, labelsize=args.labelsize, ticklabelsize=args.ticklabelsize, cbtitle=args.units)
for p in paras: grids.append(p['grid_points']) def profile(interp_points, grid_points, grid_data): rgi = RegularGridInterpolator(points=grid_points, values=grid_data, bounds_error=False) return rgi(interp_points) points, o = NH_tools.trajectory(NH_tools.close_start, NH_tools.close_end, 60.) profiles = [] for pre, grid in zip(prefixes, grids): v = hr(pre, 'up').get_last_timestep()[-1] vdata = np.linalg.norm(v, axis=-1) profiles.append(profile(points, grid, vdata)) plt.style.use('pluto-paper') fig, vax = plt.subplots(figsize=figaspect(0.6)) if args.which == 'shell': vax.set_title( "Simulation Flyby Velocity Profiles\nWith SW shell distribution") elif args.which == 'no-shell': vax.set_title( "Simulation Flyby Velocity Profiles\nWithout SW shell distribution") else: vax.set_title("Simulation Flyby Velocity Profiles") vax.set_xlabel('X ($R_p$)')
#!/usr/bin/python import argparse import HybridHelper as hh from HybridReader2 import HybridReader2 as hr import FortranFile as ff import matplotlib.pyplot as plt import numpy hh.parser.add_argument('filenum', type=int, help='Which time_stepping_error file to open') args = hh.parser.parse_args() params = hr(args.prefix, args.variable).para # open desired FortranFile f = ff.FortranFile('./' + args.prefix + '/c.time_stepping_error_' + str(args.filenum) + '.dat') def read_entry(f): entry = {} entry['step'] = f.readInts() assert len(entry['step']) == 1 entry['step'] = entry['step'][0] entry['rank'] = f.readInts() assert len(entry['rank']) == 1 entry['rank'] = int(entry['rank'][0]) entry['indicies'] = f.readInts( ) - 1 # subtract 1 to convert from 1-based indexing to 0-based indexing entry['coords'] = f.readReals()
def _espec_v4(data, options=None): if options is None: options= {'colorbars':['Blues','Greens','Reds']} # Load data from IDL spectrograms_by_species = data['spectrograms_by_species'] t = data['times'] x = data['positions'][0,:] y = data['positions'][1,:] z = data['positions'][2,:] o = data['orientations'] ebins = data['ebins'] # Separate parts H = spectrograms_by_species[:,:,0] He = spectrograms_by_species[:,:,1] CH4 = spectrograms_by_species[:,:,2] cnt_arr = H+He+CH4 # Build masked arrays for plotting the dominant species mH = masked_array(cnt_arr, mask=(~logical_and(H>He,H>CH4))) mHe = masked_array(cnt_arr, mask=(~logical_and(He>H,He>CH4))) mCH4 = masked_array(cnt_arr, mask=~logical_and(CH4>H,CH4>He)) # Setup subplot and colorbar axes # fig = plt.figure(figsize = (rcParams['figure.figsize'][0], 2*rcParams['figure.figsize'][1])) # gs = gridspec.GridSpec(8,1) # ax_spec = plt.subplot(gs[0,0]) # ax_theta = plt.subplot(gs[1,0], sharex=ax_spec) # ax_phi = plt.subplot(gs[2,0], sharex=ax_spec) # ax_spin = plt.subplot(gs[3,0], sharex=ax_spec) # # ax_xy = plt.subplot(gs[4:6,0]) # ax_xz = plt.subplot(gs[6:8,0], sharex=ax_xy) fig, (ax_spec, ax_theta, ax_phi, ax_spin, ax_xy, ax_xz) = plt.subplots(nrows=6, sharex=True, gridspec_kw={'height_ratios':[1,1,1,1,2,3]}, figsize=(rcParams['figure.figsize'][0], 2.25*rcParams['figure.figsize'][1])) fig.subplots_adjust(right=0.8, hspace=0.05) spec_pos = ax_spec.get_position() cbar_CH4 = fig.add_axes([spec_pos.x1+.01, spec_pos.y0+.01, 0.1/3, spec_pos.height-.02]) cbar_CH4_pos = cbar_CH4.get_position() cbar_He = fig.add_axes([cbar_CH4_pos.x1, spec_pos.y0+.01, 0.1/3, spec_pos.height-.02]) cbar_He_pos = cbar_He.get_position() cbar_H = fig.add_axes([cbar_He_pos.x1, spec_pos.y0+.01, 0.1/3,spec_pos.height-.02]) # Plot spectrograms and make colorbars Hhist = ax_spec.pcolormesh(t, ebins, mH, norm=LogNorm(), cmap=options['colorbars'][0], vmin=1e-3, vmax=1e4) Hcb = fig.colorbar(Hhist, cax=cbar_H) Hcb.ax.minorticks_on() Hehist = ax_spec.pcolormesh(t, ebins, mHe, norm=LogNorm(), cmap=options['colorbars'][1], vmin=1e-3, vmax=1e4) Hecb = fig.colorbar(Hehist, cax=cbar_He, format="") CH4hist = ax_spec.pcolormesh(t, ebins, mCH4, norm=LogNorm(), cmap=options['colorbars'][2], vmin=1e-3, vmax=1e4) CH4cb = fig.colorbar(CH4hist, cax=cbar_CH4, format="") # Plot orientations ax_theta.plot(t, o[0], marker='o', markersize=1.3, linestyle='None', color='black') ax_phi.plot(t, o[1], marker='o', markersize=1.3, linestyle='None', color='black') ax_spin.plot(t, o[2], marker='o', markersize=1.3, linestyle='None', color='black') ax_theta.set_ylim(-180,180) ax_phi.set_ylim(-180,180) ax_spin.set_ylim(-180,180) # Plot positions h = hr('/home/nathan/data/2017-Wed-Aug-30/pluto-1/databig','np') n = h.get_last_timestep()[-1] # Get grid spacing qx = h.para['qx'] qy = h.para['qy'] qzrange = h.para['qzrange'] # Find the center index of the grid cx = h.para['nx']/2 cy = h.para['ny']/2 cz = h.para['zrange']/2 # the offset of pluto from the center isn't always availible try: po = h.para['pluto_offset'] except KeyError: print("Couldn't get pluto_offset. It has been assumed to be 30, but it probably isn't.") po = 30 # Set constatnt for Pluto radius Rp = 1187. # km # Shift grid so that Pluto lies at (0,0,0) and convert from km to Rp qx = (qx - qx[len(qx)/2 + po])/Rp qy = (qy - qy[len(qy)/2])/Rp qzrange = (qzrange - qzrange[len(qzrange)/2])/Rp qt = [NH_tools.time_at_pos(x*Rp) for x in qx] T,Y = np.meshgrid(qt,qy) ax_xy.pcolormesh(T,Y,n[:,:,cz].transpose(), cmap='viridis', norm=LogNorm()) T,Z = np.meshgrid(qt,qzrange) ax_xz.pcolormesh(T,Z,n[:,cy,:].transpose(), cmap='viridis', norm=LogNorm()) ax_xy.plot(t, y/Rp-np.max(qy), color='black', linewidth=2) ax_xz.plot(t, np.zeros(z.shape), color='black', linewidth=2) # Set title, labels and adjust figure ax_spec.set_xlim(np.min(t), np.max(t)) ax_spec.set_ylim(5e1, 1e4) ax_spec.set_title("Synthetic SWAP Energy Spectrogram", y=1.4) Hecb.ax.set_title('COIN (Hz)', fontdict={'fontsize':'small'}) ax_spec.set_yscale('log') ax_spec.set_ylabel('Energy/Q ($eV/q$)') ax_theta.set_ylabel('Sun Theta\nAngle (deg)') ax_phi.set_ylabel('Sun Phi\nAngle (deg)') ax_spin.set_ylabel('Spin\nAngle (deg)') ax_xz.set_xlabel('Time (UTC)') ax_xy.set_ylabel('Y ($R_p$)') ax_xz.set_ylabel('Z ($R_p$)') ax_xy.set_ylim(np.min(qy), np.max(qy)) ax_xz.set_ylim(1.5*np.min(qy), 1.5*np.max(qy)) ax_xz.set_xticklabels([sp.timout(et, 'HR:MN:SC') for et in ax_spec.get_xticks()], rotation=-20, horizontalalignment='left') ax_twin = ax_spec.twiny() ax_twin.set_xlabel('X ($R_p$)') ax_twin.set_xlim(*ax_spec.get_xlim()) ax_twin.set_xticks(ax_spec.get_xticks()) ax_twin.set_xticklabels(['{0:.2f}'.format(NH_tools.pos_at_time(et)/1187) for et in ax_spec.get_xticks()], y=1.05) # This breaks the convention of previous versions return fig, None