def draw_conductance(dt, startdt, enddt, hemi): """ Get the hall and pedersen conductance for one date and hemisphere """ estimator = ovation_prime.ConductanceEstimator(startdt, enddt) mlatgrid, mltgrid, pedgrid, hallgrid = estimator.get_conductance( dt, hemi=hemi, auroral=True, solar=True) f = pp.figure(figsize=(11, 5)) aH = f.add_subplot(121) aP = f.add_subplot(122) X, Y = satplottools.latlt2cart(mlatgrid.flatten(), mltgrid.flatten(), hemi) X = X.reshape(mlatgrid.shape) Y = Y.reshape(mltgrid.shape) satplottools.draw_dialplot(aH) satplottools.draw_dialplot(aP) mappableH = aH.pcolormesh(X, Y, hallgrid, vmin=0., vmax=20.) mappableP = aP.pcolormesh(X, Y, pedgrid, vmin=0., vmax=15.) aH.set_title("Hall Conductance") aP.set_title("Pedersen Conductance") f.colorbar(mappableH, ax=aH) f.colorbar(mappableP, ax=aP) f.suptitle( "OvationPyme Conductance Output {0} Hemisphere at {1} \n".format( hemi, dt.strftime('%c')), fontweight='bold') return f
def draw_interpolated_conductance(new_mlat_grid, new_mlt_grid, dt, startdt, enddt, hemi): """ Interpolate hall and pedersen conductance onto grid described by mlat_grid, mlt_grid """ estimator = ovation_prime.ConductanceEstimator(startdt, enddt) mlatgrid, mltgrid, pedgrid, hallgrid = estimator.get_conductance( dt, hemi=hemi, auroral=True, solar=True) ped_interpolator = ovation_prime.LatLocaltimeInterpolator( mlatgrid, mltgrid, pedgrid) new_pedgrid = ped_interpolator.interpolate(new_mlat_grid, new_mlt_grid) hall_interpolator = ovation_prime.LatLocaltimeInterpolator( mlatgrid, mltgrid, hallgrid) new_hallgrid = hall_interpolator.interpolate(new_mlat_grid, new_mlt_grid) f = pp.figure(figsize=(11, 5)) aH = f.add_subplot(121) aP = f.add_subplot(122) X, Y = satplottools.latlt2cart(new_mlat_grid.flatten(), new_mlt_grid.flatten(), hemi) X = X.reshape(new_mlat_grid.shape) Y = Y.reshape(new_mlt_grid.shape) satplottools.draw_dialplot(aH) satplottools.draw_dialplot(aP) mappableH = aH.pcolormesh(X, Y, new_hallgrid, vmin=0., vmax=20.) mappableP = aP.pcolormesh(X, Y, new_pedgrid, vmin=0., vmax=15.) aH.set_title("Hall Conductance") aP.set_title("Pedersen Conductance") f.colorbar(mappableH, ax=aH) f.colorbar(mappableP, ax=aP) f.suptitle( "OvationPyme Interpolated Conductance {0} Hemisphere at {1}".format( hemi, dt.strftime('%c')), fontweight='bold') return f
def draw_weighted_flux(dt, atype='diff', jtype='electron energy flux'): """ Test automatic generation of omni_intervals in ovation_utilities also by not specifying a start and end time for the FluxEstimator """ estimator = ovation_prime.FluxEstimator(atype, jtype) mlatgridN, mltgridN, fluxgridN = estimator.get_flux_for_time(dt, hemi='N') mlatgridS, mltgridS, fluxgridS = estimator.get_flux_for_time(dt, hemi='S') f = pp.figure(figsize=(11, 5)) aN = f.add_subplot(121) aS = f.add_subplot(122) XN, YN = satplottools.latlt2cart(mlatgridN.flatten(), mltgridN.flatten(), 'N') XS, YS = satplottools.latlt2cart(mlatgridS.flatten(), mltgridS.flatten(), 'S') XN = XN.reshape(mlatgridN.shape) YN = YN.reshape(mltgridN.shape) XS = XS.reshape(mlatgridS.shape) YS = YS.reshape(mltgridS.shape) satplottools.draw_dialplot(aN) satplottools.draw_dialplot(aS) mappableN = aN.pcolormesh(XN, YN, fluxgridN, vmin=0, vmax=2) mappableS = aS.pcolormesh(XS, YS, fluxgridS, vmin=0, vmax=2) #aN.set_title("Northern Hemisphere Flux") #aS.set_title("Southern Hemisphere Flux") f.colorbar(mappableN, ax=aN) f.colorbar(mappableS, ax=aS) f.suptitle( "OvationPyme Auroral Model Flux Output at {0} \n AuroralType:{1}, FluxType:{2}" .format(dt.strftime('%c'), atype, jtype), fontweight='bold') return f
def draw_seasonal_flux(seasonN='summer', seasonS='winter', atype='diff', jtype='electron energy flux', dF=2134.17): dF = 2134.17 estimatorN = ovation_prime.SeasonalFluxEstimator(seasonN, atype, jtype) estimatorS = ovation_prime.SeasonalFluxEstimator(seasonS, atype, jtype) fluxtupleN = estimatorN.get_gridded_flux(dF, combined_N_and_S=False) (mlatgridN, mltgridN, fluxgridN) = fluxtupleN[:3] fluxtupleS = estimatorS.get_gridded_flux(dF, combined_N_and_S=False) (mlatgridS, mltgridS, fluxgridS) = fluxtupleS[3:] f = pp.figure(figsize=(11, 5)) aN = f.add_subplot(121) aS = f.add_subplot(122) f2 = pp.figure(figsize=(5, 5)) a2 = f2.add_subplot(111) XN, YN = satplottools.latlt2cart(mlatgridN.flatten(), mltgridN.flatten(), 'N') XS, YS = satplottools.latlt2cart(mlatgridS.flatten(), mltgridS.flatten(), 'S') XN = XN.reshape(mlatgridN.shape) YN = YN.reshape(mltgridN.shape) XS = XS.reshape(mlatgridS.shape) YS = YS.reshape(mltgridS.shape) satplottools.draw_dialplot(aN) satplottools.draw_dialplot(aS) satplottools.draw_dialplot(a2) mappableN = aN.pcolormesh(XN, YN, fluxgridN, vmin=0, vmax=2) mappableS = aS.pcolormesh(XS, YS, fluxgridS, vmin=0, vmax=2) mappableNS = a2.pcolormesh(XN, YN, (fluxgridS + fluxgridN) / 2, vmin=0, vmax=2) #aN.set_title("Northern Hemisphere Flux") #aS.set_title("Southern Hemisphere Flux") f.colorbar(mappableN, ax=aN) f.colorbar(mappableS, ax=aS) f.colorbar(mappableNS, ax=a2) f.suptitle( "OvationPyme Auroral Model Raw Flux Output \n Season:{0}, AuroralType:{1}, FluxType:{2}, Newell Coupling:{3:.3f}" .format(seasonN, atype, jtype, dF), fontweight='bold') f2.suptitle( "OvationPyme Combined Hemisphere Output \n Season:{0}, AuroralType:{1}, FluxType:{2}, Newell Coupling:{3:.3f}" .format(seasonN, atype, jtype, dF), fontweight='bold') return f, f2
def plot_orbit_cond(sat, year, month, day, orbit, minlat=50., plotdir=None): # #Prepare Plots # import matplotlib.gridspec as gridspec from matplotlib.colors import LogNorm gs = gridspec.GridSpec(4, 11) f = pp.figure() #a0 = f.add_subplot(511) #a05 = f.add_subplot(512) split = 9 cbwidth = 1 a1 = pp.subplot(gs[0, :split]) a11 = pp.subplot(gs[0, split:split + cbwidth]) a2 = pp.subplot(gs[1, :split]) a22 = pp.subplot(gs[1:2, split:]) a3 = pp.subplot(gs[2, :split]) #a33 = pp.subplot(gs[2,split:]) a4 = pp.subplot(gs[3, :split]) a44 = pp.subplot(gs[3, split:split + cbwidth]) # # Get conductance CDF # cdffn = get_cdf(sat, year, month, day, 'ssj', cdfdir=cdfdir, return_file=True) cdffn_cond = get_cond_cdffn(cdffn) cdffn_cond_leaf = os.path.split(cdffn_cond)[-1] cdffn_cond_leaf = os.path.splitext(cdffn_cond_leaf)[0] hemi = 'N' if np.sign(orbit) == 1 else 'S' # # Figure Filename # if plotdir is None: plotdir = '/home/liamk/code/glowcond/%s' % (cdffn_cond_leaf) if not os.path.exists(plotdir): os.makedirs(plotdir) figfn = os.path.join( plotdir, '%s_%s_%d.png' % (cdffn_cond_leaf, hemi, np.abs(orbit))) with pycdf.CDF(cdffn_cond) as cdf: orbit_index = cdf['ORBIT_INDEX'][:].flatten() mlats = cdf['SC_APEX_LAT'][:].flatten() in_orbit = orbit_index == orbit subset = np.logical_and(in_orbit, np.abs(mlats) > minlat) dts = cdf['Epoch'][:][subset] uts = special_datetime.datetimearr2sod( cdf['Epoch'][:]).flatten()[subset] hod = uts / 3600. auroral_region = cdf['AURORAL_REGION'][:].flatten()[subset] chen = cdf['CHANNEL_ENERGIES'][:] glats = cdf['SC_GEOCENTRIC_LAT'][:].flatten()[subset] glons = cdf['SC_GEOCENTRIC_LON'][:].flatten()[subset] mlats = cdf['SC_APEX_LAT'][:].flatten()[subset] mlts = cdf['SC_APEX_MLT'][:].flatten()[subset] eflux = cdf['ELE_DIFF_ENERGY_FLUX'][:][subset, :] avg_energy = cdf['ELE_AVG_ENERGY'][:].flatten()[subset] total_eflux = cdf['ELE_TOTAL_ENERGY_FLUX'][:].flatten()[subset] total_eflux *= 1.6e-12 #eV/cm/s/sr -> mW/m^2 eflux *= 1.6e-12 z = cdf['CONDUCTIVITY_ALTITUDES'][:] ped = cdf['PEDERSEN_CONDUCTIVITY'][:][subset] hall = cdf['HALL_CONDUCTIVITY'][:][subset] intped = cdf['PEDERSEN_CONDUCTANCE'][:][subset] inthall = cdf['HALL_CONDUCTANCE'][:][subset] if spectrograms: #Plot Electron energy flux dmsp_spectrogram.dmsp_spectrogram( hod, eflux, chen, datalabel=None, cblims=[1e-7, 1e-2], ax=a1, ax_cb=a11, fluxunits='Electron\nEnergy Flux\n[mW/m^2]') #Plot Pedersen Conductance a2.plot(hod, intped, 'r.-', label='DMSP+GLOW') #a2.plot(uts[:-1],np.diff(inthall),label='dPed') #a2.set_ylim([0,120]) #a2.set_ylim([0,1]) a2.legend(ncol=2, loc=0) a2.set_ylabel('Pedersen\n Conductance\n[S]') satplottools.draw_dialplot(a22) x, y = satplottools.latlt2cart(mlats, mlts, hemi) a22.plot(x, y, 'k.') a22.text(x[-1], y[-1], 'End') #Plot Hall Conductance a3.plot(hod, inthall, 'r.-', label='DMSP+GLOW') a3.legend(ncol=2, loc=0) a3.set_ylabel('Hall\n Conductance\n[S]') #Draw conductivity as a pcolor plot with log-scaled color scale try: ped[ped <= 0.] = 0.01 T, Z = np.meshgrid(hod, z) mappable = a4.pcolor(T, Z, ped.T, norm=LogNorm(vmin=np.nanmin(ped), vmax=np.nanmax(ped)), cmap='jet') cb = pp.colorbar(mappable, cax=a44) cb.ax.set_ylabel('Pedersen\nConductivity\n [S/m]') a4.set_ylabel('Altitude\n[km]') except: pass for ax in [a1, a2, a3]: ax.xaxis.set_ticklabels([]) for ax in [a1, a2, a3, a4]: ax.set_xlim(hod[0], hod[-1]) a4.set_xlabel('Hour of Day') f.suptitle('%.2d-%2.d-%d %s orbit %d' % (year, month, day, hemi, orbit)) f.savefig(figfn) pp.close(f)
datalabel=None, cblims=[1e-7, 1e-2], ax=a1, ax_cb=a11, fluxunits='Electron\nEnergy Flux\n[mW/m^2]') #Plot Pedersen Conductance a2.plot(uts, intped, 'r.-', label='DMSP+GLOW') a2.plot(uts, cond_ped_op, 'b.-', label='OP2010+Robinson') #a2.plot(uts[:-1],np.diff(inthall),label='dPed') #a2.set_ylim([0,120]) #a2.set_ylim([0,1]) a2.legend(ncol=2, loc=0) a2.set_ylabel('Pedersen\n Conductance\n[S]') satplottools.draw_dialplot(a22) x, y = satplottools.latlt2cart(mlats, mlts, 'N') a22.plot(x, y, 'k.') a22.text(x[-1], y[-1], 'End') #Plot Hall Conductance a3.plot(uts, inthall, 'r.-', label='DMSP+GLOW') a3.plot(uts, cond_hall_op, 'b.-', label='OP2010+Robinson') a3.legend(ncol=2, loc=0) a3.set_ylabel('Hall\n Conductance\n[S]') #Draw conductivity as a pcolor plot with log-scaled color scale T, Z = np.meshgrid(uts, z) mappable = a4.pcolor(T, Z, ped.T,