def plot_ewind(read=True): if read: ewind= [] for fn1, fn2 in zip(fns1,fns2): g1, g2 = gitm.read(fn1), gitm.read(fn2) ewind1, ewind2 = g1['V!Dn!N (east)'], g2['V!Dn!N (east)'] ewindd = ewind2 - ewind1 ewindt1 = [] for alt in alts: ialt = np.argmin(np.abs(g1['Altitude'][0, 0, 2:-2]-alt*1000))+2 ewindt2 = [] for lt in lts: ilt = np.argmin(np.abs(g1['LT'][2:-2, 0, 0]-lt))+2 ewindt2.append( np.array(ewindd[ilt, 2:-2, ialt]).reshape(1,1,1,-1)) ewindt2 = np.concatenate(ewindt2, axis=2) ewindt1.append(ewindt2) ewindt1 = np.concatenate(ewindt1, axis=1) ewind.append(ewindt1) ewind = np.concatenate(ewind, axis=0) lat = g1['dLat'][0, 2:-2, 0] np.savez('/home/guod/tmp/ewind', ewind=ewind, lat=lat) ldf = np.load('/home/guod/tmp/ewind.npz') ewind, lat = ldf['ewind'], ldf['lat'] plt.close() plt.contourf( timeidx, lat, ewind[:,3, 1, :].T, levels=np.linspace(-100,100,21), cmap='seismic') plt.ylim(-90, -40) plt.show() return
def plot_divrhov_rho(read=True): if read: divrhov = [] for fn1, fn2 in zip(fns1,fns2): g1, g2 = gitm.read(fn1), gitm.read(fn2) # density change (shrink) lon1 = np.array(g1['Longitude']) lat1 = np.array(g1['Latitude']) alt1 = np.array(g1['Altitude']) Re = 6371*1000 # Earth radius, unit: m RR = Re+alt1 omega = 2*np.pi/(24*3600) rho1 = np.array(g1['Rho']) nwind1 = np.array(g1['V!Dn!N (north)']) ewind1 = np.array(g1['V!Dn!N (east)']) + omega*RR*np.cos(lat1) uwind1 = np.array(g1['V!Dn!N (up)']) div_rhov1 = \ (cr.calc_div_hozt(lon1, lat1, alt1, rho1*nwind1, rho1*ewind1)\ +cr.calc_div_vert(alt1, rho1*uwind1))/rho1 # density change (no shrink) lon2 = np.array(g2['Longitude']) lat2 = np.array(g2['Latitude']) alt2 = np.array(g2['Altitude']) Re = 6371*1000 # Earth radius, unit: m RR = Re+alt2 omega = 2*np.pi/(24*3600) rho2 = np.array(g2['Rho']) nwind2 = np.array(g2['V!Dn!N (north)']) ewind2 = np.array(g2['V!Dn!N (east)']) + omega*RR*np.cos(lat2) uwind2 = np.array(g2['V!Dn!N (up)']) div_rhov2 = \ (cr.calc_div_hozt(lon2, lat2, alt2, rho2*nwind2, rho2*ewind2)\ +cr.calc_div_vert(alt2, rho2*uwind2))/rho2 div_rhov = div_rhov1 - div_rhov2 divrhov1 = [] for alt in alts: ialt = np.argmin(np.abs(g1['Altitude'][0, 0, 2:-2]-alt*1000))+2 divrhov2 = [] for lt in lts: ilt = np.argmin(np.abs(g1['LT'][2:-2, 0, 0]-lt))+2 divrhov2.append( np.array(div_rhov[ilt, 2:-2, ialt]).reshape(1,1,1,-1)) divrhov2 = np.concatenate(divrhov2, axis=2) divrhov1.append(divrhov2) divrhov1 = np.concatenate(divrhov1, axis=1) divrhov.append(divrhov1) divrhov = np.concatenate(divrhov, axis=0) lat = g1['dLat'][0, 2:-2, 0] np.savez('/home/guod/tmp/divrhov_rho', divrhov=divrhov, lat=lat) ldf = np.load('/home/guod/tmp/divrhov_rho.npz') divrhov, lat = ldf['divrhov'], ldf['lat'] plt.close() plt.contourf( timeidx, lat, divrhov[:,3, 1, :].T, levels=np.linspace(-1,1,21)*1e-4, cmap='seismic') plt.ylim(-90, -40) plt.show() return
def plot_rho(read=True): if read: rho = [] for fn1, fn2 in zip(fns1,fns2): g1, g2 = gitm.read(fn1), gitm.read(fn2) rho1, rho2 = g1['Rho'], g2['Rho'] rhod = 100*(rho2 - rho1)/rho1 rhot1 = [] for alt in alts: ialt = np.argmin(np.abs(g1['Altitude'][0, 0, 2:-2]-alt*1000))+2 rhot2 = [] for lt in lts: ilt = np.argmin(np.abs(g1['LT'][2:-2, 0, 0]-lt))+2 rhot2.append( np.array(rhod[ilt, 2:-2, ialt]).reshape(1,1,1,-1)) rhot2 = np.concatenate(rhot2, axis=2) rhot1.append(rhot2) rhot1 = np.concatenate(rhot1, axis=1) rho.append(rhot1) rho = np.concatenate(rho, axis=0) lat = g1['dLat'][0, 2:-2, 0] np.savez('/home/guod/tmp/rho', rho=rho, lat=lat) ldf = np.load('/home/guod/tmp/rho.npz') rho, lat = ldf['rho'], ldf['lat'] plt.close() plt.contourf( timeidx, lat, rho[:,3, 1, :].T, levels=np.linspace(-5,5,21), cmap='seismic') plt.ylim(-90, -40) plt.show() return
def plot_hozt_vgradrho_rho(read=True): if read: gradrho = [] for fn1, fn2 in zip(fns1,fns2): g1, g2 = gitm.read(fn1), gitm.read(fn2) lon1 = np.array(g1['Longitude']) lat1 = np.array(g1['Latitude']) alt1 = np.array(g1['Altitude']) Re = 6371*1000 # Earth radius, unit: m RR = Re+alt1 omega = 2*np.pi/(24*3600) rho1 = np.array(g1['Rho']) nwind1 = np.array(g1['V!Dn!N (north)']) ewind1 = np.array(g1['V!Dn!N (east)']) + omega*RR*np.cos(lat1) vgradrho1 = \ (nwind1*cr.calc_rusanov_lats(lat1,alt1,rho1)\ +ewind1*cr.calc_rusanov_lons(lon1,lat1,alt1,rho1))/rho1 lon2 = np.array(g2['Longitude']) lat2 = np.array(g2['Latitude']) alt2 = np.array(g2['Altitude']) Re = 6371*1000 # Earth radius, unit: m RR = Re+alt2 omega = 2*np.pi/(24*3600) rho2 = np.array(g2['Rho']) nwind2 = np.array(g2['V!Dn!N (north)']) ewind2 = np.array(g2['V!Dn!N (east)']) + omega*RR*np.cos(lat2) vgradrho2 = \ (nwind2*cr.calc_rusanov_lats(lat2,alt2,rho2)\ +ewind2*cr.calc_rusanov_lons(lon2,lat2,alt2,rho2))/rho2 vgradrhod = vgradrho1 - vgradrho2 gradrho1 = [] for alt in alts: ialt = np.argmin(np.abs(g1['Altitude'][0, 0, 2:-2]-alt*1000))+2 gradrho2 = [] for lt in lts: ilt = np.argmin(np.abs(g1['LT'][2:-2, 0, 0]-lt))+2 gradrho2.append( np.array(vgradrhod[ilt, 2:-2, ialt]).reshape(1,1,1,-1)) gradrho2 = np.concatenate(gradrho2, axis=2) gradrho1.append(gradrho2) gradrho1 = np.concatenate(gradrho1, axis=1) gradrho.append(gradrho1) gradrho = np.concatenate(gradrho, axis=0) lat = g1['dLat'][0, 2:-2, 0] np.savez('/home/guod/tmp/hozt_vgradrho', gradrho=gradrho, lat=lat) ldf = np.load('/home/guod/tmp/hozt_vgradrho.npz') gradrho, lat = ldf['gradrho'], ldf['lat'] plt.close() plt.contourf( timeidx, lat, gradrho[:,3, 1, :].T, levels=np.linspace(-1,1,21)*1e-4, cmap='seismic') plt.ylim(-90, -40) plt.show() return
def plot_hozt_divv(read=True): if read: divv = [] for fn1, fn2 in zip(fns1,fns2): g1, g2 = gitm.read(fn1), gitm.read(fn2) lat1 = np.array(g1['Latitude']) alt1 = np.array(g1['Altitude']) Re = 6371*1000 # Earth radius, unit: m RR = Re+alt1 omega = 2*np.pi/(24*3600) nwind1 = np.array(g1['V!Dn!N (north)']) ewind1 = np.array(g1['V!Dn!N (east)']) + omega*RR*np.cos(lat1) div_v1 = cr.calc_div_hozt( g1['Longitude'], g1['Latitude'], g1['Altitude'], nwind1, ewind1) lat2 = np.array(g2['Latitude']) alt2 = np.array(g2['Altitude']) Re = 6371*1000 # Earth radius, unit: m RR = Re+alt2 omega = 2*np.pi/(24*3600) nwind2 = np.array(g2['V!Dn!N (north)']) ewind2 = np.array(g2['V!Dn!N (east)']) + omega*RR*np.cos(lat2) div_v2 = cr.calc_div_hozt( g2['Longitude'], g2['Latitude'], g2['Altitude'], nwind2, ewind2) div_v = div_v1 - div_v2 divv1 = [] for alt in alts: ialt = np.argmin(np.abs(g1['Altitude'][0, 0, 2:-2]-alt*1000))+2 divv2 = [] for lt in lts: ilt = np.argmin(np.abs(g1['LT'][2:-2, 0, 0]-lt))+2 divv2.append( np.array(div_v[ilt, 2:-2, ialt]).reshape(1,1,1,-1)) divv2 = np.concatenate(divv2, axis=2) divv1.append(divv2) divv1 = np.concatenate(divv1, axis=1) divv.append(divv1) divv = np.concatenate(divv, axis=0) lat = g1['dLat'][0, 2:-2, 0] np.savez('/home/guod/tmp/hozt_divv', divv=divv, lat=lat) ldf = np.load('/home/guod/tmp/hozt_divv.npz') divv, lat = ldf['divv'], ldf['lat'] plt.close() plt.contourf( timeidx, lat, divv[:,3, 1, :].T, levels=np.linspace(-1,1,21)*1e-4, cmap='seismic') plt.ylim(-90, -40) plt.show() return
def plot_vert_vgradrho_rho(read=True): if read: gradrho = [] for fn1, fn2 in zip(fns1,fns2): g1, g2 = gitm.read(fn1), gitm.read(fn2) rho1 = np.array(g1['Rho']) vgradrho1 = \ g1['V!Dn!N (up)'] \ * cr.calc_rusanov_alts_ausm(g1['Altitude'],rho1)/g1['Rho'] rho2 = np.array(g2['Rho']) vgradrho2 = \ g2['V!Dn!N (up)']\ * cr.calc_rusanov_alts_ausm(g2['Altitude'],rho2)/g2['Rho'] vgradrhod = vgradrho1 - vgradrho2 gradrho1 = [] for alt in alts: ialt = np.argmin(np.abs(g1['Altitude'][0, 0, 2:-2]-alt*1000))+2 gradrho2 = [] for lt in lts: ilt = np.argmin(np.abs(g1['LT'][2:-2, 0, 0]-lt))+2 gradrho2.append( np.array(vgradrhod[ilt, 2:-2, ialt]).reshape(1,1,1,-1)) gradrho2 = np.concatenate(gradrho2, axis=2) gradrho1.append(gradrho2) gradrho1 = np.concatenate(gradrho1, axis=1) gradrho.append(gradrho1) gradrho = np.concatenate(gradrho, axis=0) lat = g1['dLat'][0, 2:-2, 0] np.savez('/home/guod/tmp/vert_vgradrho', gradrho=gradrho, lat=lat) ldf = np.load('/home/guod/tmp/vert_vgradrho.npz') gradrho, lat = ldf['gradrho'], ldf['lat'] plt.close() plt.contourf( timeidx, lat, gradrho[:,3, 1, :].T, levels=np.linspace(-1,1,21)*1e-4, cmap='seismic') plt.ylim(-90, -40) plt.show() return
def plot_vert_divv(read=True): if read: divv = [] for fn1, fn2 in zip(fns1,fns2): g1, g2 = gitm.read(fn1), gitm.read(fn2) velr = np.array(g1['V!Dn!N (up)']) div_v1 = cr.calc_div_vert(g1['Altitude'], velr) velr = np.array(g2['V!Dn!N (up)']) div_v2 = cr.calc_div_vert(g2['Altitude'], velr) div_v = div_v1 - div_v2 divv1 = [] for alt in alts: ialt = np.argmin(np.abs(g1['Altitude'][0, 0, 2:-2]-alt*1000))+2 divv2 = [] for lt in lts: ilt = np.argmin(np.abs(g1['LT'][2:-2, 0, 0]-lt))+2 divv2.append( np.array(div_v[ilt, 2:-2, ialt]).reshape(1,1,1,-1)) divv2 = np.concatenate(divv2, axis=2) divv1.append(divv2) divv1 = np.concatenate(divv1, axis=1) divv.append(divv1) divv = np.concatenate(divv, axis=0) lat = g1['dLat'][0, 2:-2, 0] np.savez('/home/guod/tmp/vert_divv', divv=divv, lat=lat) ldf = np.load('/home/guod/tmp/vert_divv.npz') divv, lat = ldf['divv'], ldf['lat'] plt.close() plt.contourf( timeidx, lat, divv[:,3, 1, :].T, levels=np.linspace(-1,1,21)*1e-4, cmap='seismic') plt.ylim(-90, -40) plt.show() return
""" The thermospheric neutral density at 150 km is lower at the pole than the surrounding area even the ion drift is set to zero. Why is this happening? """ import matplotlib.pyplot as plt import numpy as np import os import gitm_new as gitm import gitm_3D_const_alt as g3ca import gitm_pressure as gp import calc_rusanov as cr gallfn = '/Users/guod/data/GITMOutput/run_shrink_notides_tmp/UA/data/3DALL_t030323_000004.bin' gthmfn = '/Users/guod/data/GITMOutput/run_shrink_notides_tmp/UA/data/3DTHM_t030323_000004.bin' gall = gitm.read(gallfn) lontp = gall['Longitude'] lattp = gall['Latitude'] alttp = gall['Altitude'] Re = 6371 * 1000 # Earth radius, unit: m RR = Re + alttp omega = 2 * np.pi / (24 * 3600) rhotp = gall['Rho'] nwindtp = gall['V!Dn!N (north)'] ewindtp = gall['V!Dn!N (east)'] + omega * RR * np.cos(lattp) uwindtp = gall['V!Dn!N (up)'] gall['div_rhov'] = \ -(cr.calc_div_hozt(lontp, lattp, alttp, rhotp*nwindtp, rhotp*ewindtp)\ +cr.calc_div_vert(alttp, rhotp*uwindtp))/rhotp gall['vert_divv'] = -cr.calc_div_vert(alttp, uwindtp) gall['hozt_divv'] = -cr.calc_div_hozt(lontp, lattp, alttp, nwindtp, ewindtp) gall['vert_vgradrho'] = -uwindtp * cr.calc_rusanov_alts_ausm(alttp,
def figure5_7(alt=150): times = pd.to_datetime([ '2003-03-22 00:00:00', '2003-03-22 00:30:00', '2003-03-22 01:00:00', '2003-03-22 02:00:00', '2003-03-22 03:00:00', '2003-03-22 06:00:00']) plt.close('all') plt.figure(figsize=(9.5, 9.25)) xtitle = [ r'$-\nabla\cdot w$', r'$-\nabla\cdot u$', r'$-\frac{w\cdot\nabla\rho}{\rho}$', r'$-\frac{u\cdot\nabla\rho}{\rho}$', r'$\frac{\partial \rho}{\rho\partial t}$', r'$\delta\rho$ (%)'] ylabel = times.strftime('%H:%M') qlat, qlon = convert(-90, 0, 0, date=dt.date(2003,3,22), a2g=True) for itime, time in enumerate(times): strtime = time.strftime('%y%m%d_%H%M') fn1 = glob.glob( '/home/guod/simulation_output/momentum_analysis/'\ 'run_no_shrink_iondrift_4_1/data/3DALL_t%s*.bin' % strtime) fn2 = glob.glob( '/home/guod/simulation_output/momentum_analysis/'\ 'run_shrink_iondrift_4_c1/data/3DALL_t%s*.bin' % strtime) g1 = gitm.read(fn1[0]) g2 = gitm.read(fn2[0]) lon1 = g1['Longitude'] lat1 = g1['Latitude'] alt1 = g1['Altitude'] Re = 6371*1000 # Earth radius, unit: m RR = Re+alt1 omega = 2*pi/(24*3600) rho1 = np.array(g1['Rho']) nwind1 = g1['V!Dn!N (north)'] ewind1 = g1['V!Dn!N (east)'] + omega*RR*np.cos(lat1) uwind1 = g1['V!Dn!N (up)'] div_rhov1 = \ (cr.calc_div_hozt(lon1, lat1, alt1, rho1*nwind1, rho1*ewind1)\ +cr.calc_div_vert(alt1, rho1*uwind1))/rho1 vert_divv1 = cr.calc_div_vert(alt1, uwind1) hozt_divv1 = cr.calc_div_hozt(lon1, lat1, alt1, nwind1, ewind1) vert_vgradrho1 = uwind1*cr.calc_rusanov_alts_ausm(alt1,rho1)/rho1 hozt_vgradrho1 = \ (nwind1*cr.calc_rusanov_lats(lat1,alt1,rho1)\ +ewind1*cr.calc_rusanov_lons(lon1,lat1,alt1,rho1))/rho1 dc1 = [ vert_divv1, hozt_divv1, vert_vgradrho1, hozt_vgradrho1, div_rhov1, rho1] lon2 = g2['Longitude'] lat2 = g2['Latitude'] alt2 = g2['Altitude'] Re = 6371*1000 # Earth radius, unit: m RR = Re+alt2 omega = 2*pi/(24*3600) rho2 = g2['Rho'] nwind2 = g2['V!Dn!N (north)'] ewind2 = g2['V!Dn!N (east)'] + omega*RR*np.cos(lat2) uwind2 = g2['V!Dn!N (up)'] div_rhov2 = \ (cr.calc_div_hozt(lon2, lat2, alt2, rho2*nwind2, rho2*ewind2)\ +cr.calc_div_vert(alt2, rho2*uwind2))/rho2 vert_divv2 = cr.calc_div_vert(alt2, uwind2) hozt_divv2 = cr.calc_div_hozt(lon2, lat2, alt2, nwind2, ewind2) vert_vgradrho2 = uwind2*cr.calc_rusanov_alts_ausm(alt2,rho2)/rho2 hozt_vgradrho2 = \ (nwind2*cr.calc_rusanov_lats(lat2,alt2,rho2)\ +ewind2*cr.calc_rusanov_lons(lon2,lat2,alt2,rho2))/rho2 dc2 = [ vert_divv2, hozt_divv2, vert_vgradrho2, hozt_vgradrho2, div_rhov2, rho2] alt_ind = np.argmin(np.abs(alt1[0, 0, :]/1000-alt)) alt_str = '%6.0f' % (alt1[0, 0, alt_ind]/1000) for idc in range(6): lonticklabel = [0, 0, 0, 0] if idc == 0: lonticklabel[3] = lonticklabel[-1]+1 if idc == 5: lonticklabel[1] = lonticklabel[-1]+1 if itime == 0: lonticklabel[0] = lonticklabel[-2]+1 if itime == 5: lonticklabel[2] = lonticklabel[-2]+1 ax, projection = gcc.create_map( 6, 6, itime*6+idc+1, 'polar', nlat=nlat, slat=slat, dlat=10, centrallon=g3ca.calculate_centrallon(g1, 'polar', useLT=True), coastlines=False, lonticklabel=lonticklabel) g1['temp'] = -(dc1[idc] - dc2[idc]) if idc==5: g1['temp'] = 100*(dc1[idc] - dc2[idc])/dc2[idc] lon0, lat0, zdata0 = g3ca.contour_data('temp', g1, alt=alt) fp = (lat0[:,0]>slat) & (lat0[:,0]<nlat) lon0, lat0, zdata0 = lon0[fp, :], lat0[fp,:], zdata0[fp,:] levels = np.linspace(-8,8,21)*1e-5 if idc==5: levels = np.linspace(-30,30,21) hc = ax.contourf( lon0, lat0, zdata0, levels, transform=ccrs.PlateCarree(), cmap='seismic', extend='both') # wind difference alt_ind = np.argmin(np.abs(alt1[0, 0, :]/1000-alt)) alt_str = '%6.0f' % (alt1[0, 0, alt_ind]/1000) lon1, lat1, ewind1, nwind1 = g3ca.vector_data( g1, 'neutral', alt=alt) lon2, lat2, ewind2, nwind2 = g3ca.vector_data( g2, 'neutral', alt=alt) lon0, lat0 = lon1, lat1 lon0, lat0, ewind0, nwind0 = g3ca.convert_vector( lon0, lat0, ewind1-ewind2, nwind1-nwind2, plot_type='polar', projection=projection) hq = ax.quiver( lon0, lat0, ewind0, nwind0, scale=1500, scale_units='inches', regrid_shape=20, headwidth=5) ax.scatter( qlon, qlat, s=10, color='k', transform=ccrs.PlateCarree()) ax.scatter( 0, -90, color='w', s=10, transform=ccrs.PlateCarree(), zorder=1000) if idc==0: plt.text( -0.3, 0.5, ylabel[itime], rotation=90, transform=ax.transAxes, verticalalignment='center') if itime==0: plt.title(xtitle[idc], y=1.15, fontsize=14) texts = ['(a)', '(b)', '(c)', '(d)', '(e)', '(f)'] plt.text(0.05,1,texts[idc],transform=plt.gca().transAxes, color='r') if itime==5: axp = ax.get_position() cax = [axp.x0, axp.y0-0.03, axp.x1-axp.x0, 1/20*(axp.y1-axp.y0)] cax = plt.axes(cax) ticks = np.arange(-8e-5, 8.1e-5, 4e-5) if idc<5 else \ np.arange(-30, 31, 15) hcb = plt.colorbar( hc, cax=cax, extendrect=True, orientation='horizontal', ticks=ticks) if idc<5: hcb.formatter.set_powerlimits((0,0)) hcb.update_ticks() plt.subplots_adjust(wspace=0, hspace=0) if alt==300: plt.savefig(savepath+'Figure5.eps') plt.savefig(savepath+'Figure5.jpeg') if alt==600: plt.savefig(savepath+'Figure7.eps') plt.savefig(savepath+'Figure7.jpeg') return
fn2 = '/home/guod/simulation_output/momentum_analysis/'\ 'run_no_shrink_iondrift_4_1_high_resolution/data/3DALL_t030322_000103.bin' fn1 = '/home/guod/simulation_output/momentum_analysis/'\ 'run_shrink_iondrift_4_c1_high_resolution/data/3DALL_t030322_000203.bin' fn2 = '/home/guod/simulation_output/momentum_analysis/'\ 'run_no_shrink_iondrift_4_1_high_resolution/data/3DALL_t030322_000203.bin' fn1 = '/home/guod/simulation_output/momentum_analysis/'\ 'run_shrink_iondrift_4_c1_high_resolution/data/3DALL_t030322_000302.bin' fn2 = '/home/guod/simulation_output/momentum_analysis/'\ 'run_no_shrink_iondrift_4_1_high_resolution/data/3DALL_t030322_000302.bin' fn1 = '/home/guod/simulation_output/momentum_analysis/run_shrink_iondrift_4_c1/data/3DALL_t030322_000501.bin' fn2 = '/home/guod/simulation_output/momentum_analysis/run_no_shrink_iondrift_4_1/data/3DALL_t030322_000501.bin' # fn1 ='/home/guod/simulation_output/momentum_analysis/run_shrink_iondrift_4_c1/data/3DALL_t030322_001003.bin' # fn2 ='/home/guod/simulation_output/momentum_analysis/run_no_shrink_iondrift_4_1/data/3DALL_t030322_001003.bin' fn1 = '/home/guod/simulation_output/momentum_analysis/run_shrink_iondrift_4_c1/data/3DALL_t030322_003003.bin' fn2 = '/home/guod/simulation_output/momentum_analysis/run_no_shrink_iondrift_4_1/data/3DALL_t030322_003002.bin' # fn1 ='/home/guod/simulation_output/momentum_analysis/run_shrink_iondrift_4_c1/data/3DALL_t030322_010002.bin' # fn2 ='/home/guod/simulation_output/momentum_analysis/run_no_shrink_iondrift_4_1/data/3DALL_t030322_010000.bin' # fn1 ='/home/guod/simulation_output/momentum_analysis/run_shrink_iondrift_4_c1/data/3DALL_t030322_060000.bin' # fn2 ='/home/guod/simulation_output/momentum_analysis/run_no_shrink_iondrift_4_1/data/3DALL_t030322_060000.bin' fn1 = '/home/guod/simulation_output/momentum_analysis/run_shrink_iondrift_4_c4/data/3DALL_t030322_180502.bin' fn2 = '/home/guod/simulation_output/momentum_analysis/run_no_shrink_iondrift_4_4/data/3DALL_t030322_180502.bin' fn1 = '/home/guod/simulation_output/momentum_analysis/run_shrink_iondrift_4_c4/data/3DALL_t030322_181003.bin' fn2 = '/home/guod/simulation_output/momentum_analysis/run_no_shrink_iondrift_4_4/data/3DALL_t030322_181000.bin' fn1 = '/home/guod/simulation_output/momentum_analysis/run_shrink_iondrift_4_c4/data/3DALL_t030322_183002.bin' fn2 = '/home/guod/simulation_output/momentum_analysis/run_no_shrink_iondrift_4_4/data/3DALL_t030322_183002.bin' g1 = gitm.read(fn1) g2 = gitm.read(fn2) #const_lon(g2, 0, 100, 600) const_lon_diff(g1, g2, 4, 50, 100, 600, -90, -30)
""" The thermospheric neutral density at 150 km is lower at the pole than the surrounding area even the ion drift is set to zero. Why is this happening? """ import matplotlib.pyplot as plt import numpy as np import os import gitm_new as gitm import gitm_3D_const_alt as g3ca import gitm_pressure as gp import calc_rusanov as cr gallfn = '/Users/guod/data/GITMOutput/run_shrink_notides_tmp/UA/data/3DALL_t030323_000004.bin' gthmfn = '/Users/guod/data/GITMOutput/run_shrink_notides_tmp/UA/data/3DTHM_t030323_000004.bin' gall = gitm.read(gallfn) lontp = gall['Longitude'] lattp = gall['Latitude'] alttp = gall['Altitude'] Re = 6371*1000 # Earth radius, unit: m RR = Re+alttp omega = 2*np.pi/(24*3600) rhotp = gall['Rho'] nwindtp = gall['V!Dn!N (north)'] ewindtp = gall['V!Dn!N (east)'] + omega*RR*np.cos(lattp) uwindtp = gall['V!Dn!N (up)'] gall['div_rhov'] = \ -(cr.calc_div_hozt(lontp, lattp, alttp, rhotp*nwindtp, rhotp*ewindtp)\ +cr.calc_div_vert(alttp, rhotp*uwindtp))/rhotp gall['vert_divv'] = -cr.calc_div_vert(alttp, uwindtp) gall['hozt_divv'] = -cr.calc_div_hozt(lontp, lattp, alttp, nwindtp, ewindtp) gall['vert_vgradrho'] = -uwindtp*cr.calc_rusanov_alts_ausm(alttp,rhotp)/rhotp
def figure5_7_refer(alt=300): times = pd.to_datetime([ '2003-03-22 00:00:00', '2003-03-22 00:30:00', '2003-03-22 01:00:00', '2003-03-22 02:00:00', '2003-03-22 03:00:00', '2003-03-22 06:00:00']) plt.close('all') plt.figure(figsize=(3, 9.25)) ylabel = times.strftime('%H:%M') qlat, qlon = convert(-90, 0, 0, date=dt.date(2003,3,22), a2g=True) for itime, time in enumerate(times): strtime = time.strftime('%y%m%d_%H%M') fn1 = glob.glob( '/home/guod/simulation_output/momentum_analysis/'\ 'run_no_shrink_iondrift_4_1/data/3DALL_t%s*.bin' % strtime) fn2 = glob.glob( '/home/guod/simulation_output/momentum_analysis/'\ 'run_shrink_iondrift_4_c1/data/3DALL_t%s*.bin' % strtime) g1 = gitm.read(fn1[0]) g2 = gitm.read(fn2[0]) lon1, lat1, alt1, T1 = \ g1['Longitude'], g1['Latitude'], g1['Altitude'], g1['Temperature'] lon2, lat2, alt2, T2 = \ g2['Longitude'], g2['Latitude'], g2['Altitude'], g2['Temperature'] alt_ind = np.argmin(np.abs(alt1[0, 0, :]/1000-alt)) alt_str = '%6.0f' % (alt1[0, 0, alt_ind]/1000) lonticklabel=[0, 1, 0, 1] if itime == 0: lonticklabel[0] = 1 if itime == 5: lonticklabel[2] = 1 ax, projection = gcc.create_map( 6, 1, itime+1, 'polar', nlat=nlat, slat=slat, dlat=10, centrallon=g3ca.calculate_centrallon(g1, 'polar', useLT=True), coastlines=False, lonticklabel=lonticklabel) g1['temp'] = T1-T2 lon0, lat0, zdata0 = g3ca.contour_data('temp', g1, alt=alt) fp = (lat0[:,0]>slat) & (lat0[:,0]<nlat) lon0, lat0, zdata0 = lon0[fp, :], lat0[fp,:], zdata0[fp,:] hc = ax.contourf( lon0, lat0, zdata0, levels=np.linspace(-60, 60, 21), transform=ccrs.PlateCarree(), cmap='seismic', extend='both') # wind difference lon1, lat1, ewind1, nwind1 = g3ca.vector_data( g1, 'neutral', alt=alt) lon2, lat2, ewind2, nwind2 = g3ca.vector_data( g2, 'neutral', alt=alt) lon0, lat0 = lon1, lat1 lon0, lat0, ewind0, nwind0 = g3ca.convert_vector( lon0, lat0, ewind1-ewind2, nwind1-nwind2, plot_type='polar', projection=projection) hq = ax.quiver( lon0, lat0, ewind0, nwind0, scale=1500, scale_units='inches', regrid_shape=20, headwidth=5) ax.scatter( qlon, qlat, s=10, color='k', transform=ccrs.PlateCarree()) ax.scatter( 0, -90, color='w', s=10, transform=ccrs.PlateCarree(), zorder=1000) plt.text( -0.3, 0.5, ylabel[itime], rotation=90, transform=ax.transAxes, verticalalignment='center') if itime==0: plt.title(r'$T_d$ (K)', y=1.15) if itime==5: axp = ax.get_position() cax = [axp.x0, axp.y0-0.03, axp.x1-axp.x0, 1/20*(axp.y1-axp.y0)] cax = plt.axes(cax) ticks = np.arange(-60, 61, 20) hcb = plt.colorbar( hc, cax=cax, extendrect=True, orientation='horizontal', ticks=ticks) plt.subplots_adjust(wspace=0, hspace=0) plt.show() return
import gitm_new as gitm import numpy as np from numpy import pi import gitm_3D_const_alt as g3ca from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt from aacgmv2 import convert import datetime as dt plt.close('all') path1 = '/home/guod/simulation_output/momentum_analysis/'+\ 'run_shrink_iondrift_4_c1/data/3DALL_t030322_060000.bin' path2 = '/home/guod/simulation_output/momentum_analysis/'+\ 'run_no_shrink_iondrift_4_1/data/3DALL_t030322_060000.bin' g1 = gitm.read(path1) g2 = gitm.read(path2) fig = plt.figure(figsize=(5.41, 8.54)) ax = fig.add_subplot(111, projection='3d') levels = [ np.linspace(6.1e-10, 17.8e-10, 21), np.linspace(1.1e-10, 2.7e-10, 21), np.linspace(1.3e-11, 3.9e-11, 21), np.linspace(2.6e-12, 9.503e-12, 21), np.linspace(4.3e-13, 2.71e-12, 21), np.linspace(7.4e-14, 8.2e-13, 21) ] olat = -40 olatr = np.abs(olat) / 180 * np.pi glats, glons = convert(-90, 0, 0, date=dt.date(2003, 3, 22), a2g=True)
def plot_rho_wind_ut(ns='SH', alt=150): path = '/home/guod/simulation_output/momentum_analysis/run_no_shrink_igrf_1_1/data' fn01 = path+'/3DALL_t030323_000000.bin' fn02 = path+'/3DALL_t030323_030000.bin' fn03 = path+'/3DALL_t030323_060001.bin' fn04 = path+'/3DALL_t030323_090002.bin' fn05 = path+'/3DALL_t030323_120000.bin' fn06 = path+'/3DALL_t030323_150001.bin' fn07 = path+'/3DALL_t030323_180000.bin' fn08 = path+'/3DALL_t030323_210002.bin' fn09 = path+'/3DALL_t030324_000000.bin' fn2 = [fn01, fn02, fn03, fn04, fn05, fn06, fn07, fn08, fn09] if ns=='SH': nlat, slat = -50, -90 elif ns=='NH': nlat, slat = 90, 50 glats, glons = convert(-90, 0, 0, date=dt.date(2003,1,1), a2g=True) glatn, glonn = convert(90, 0, 0, date=dt.date(2003,1,1), a2g=True) fig1 = plt.figure(1, figsize=(5.28,8.49)) titf = ['(a)','(b)','(c)','(d)','(e)','(f)','(g)','(h)'] for k in range(8): g2 = gitm.read(fn2[k]) title = 'UT: '+g2['time'].strftime('%H') lon2, lat2, rho2 = g3ca.contour_data('Rho', g2, alt=alt) ilat2 = (lat2[:,0]>=slat) & (lat2[:,0]<=nlat) min_div_mean = \ np.min(rho2[ilat2, :]) / \ (np.mean(rho2[ilat2, :]*np.cos(lat2[ilat2, :]/180*np.pi)) /\ np.mean(np.cos(lat2[ilat2,:]/180*np.pi))) print(ns,': ',100*(min_div_mean-1)) lon2, lat2, ewind2, nwind2 = g3ca.vector_data(g2,'neu',alt=alt) if k ==0: lonticklabel = [1, 0, 0, 1] elif k==1: lonticklabel = [1, 1, 0, 0] elif k in [2, 4]: lonticklabel = [0, 0, 0, 1] elif k in [3, 5]: lonticklabel = [0, 1, 0, 0] elif k==6: lonticklabel = [0, 0, 1, 1] elif k==7: lonticklabel = [0, 1, 1, 0] olat=False if k<7 else True # No shrink plt.figure(1) centrallon = g3ca.calculate_centrallon(g2, 'pol', useLT=True) ax, projection = gcc.create_map( 4,2,k+1, 'pol', nlat, slat, centrallon, coastlines=False, dlat=10, useLT=True, lonticklabel=lonticklabel, olat=olat) hc1 = ax.contourf(lon2, lat2, rho2, np.linspace(0.8e-9, 1.6e-9), transform=ccrs.PlateCarree(),cmap='jet', extend='both') lon9, lat9, ewind9, nwind9 = g3ca.convert_vector( lon2, lat2, ewind2, nwind2, 'pol', projection) hq1 = ax.quiver( lon9,lat9,ewind9,nwind9,scale=1500,scale_units='inches', regrid_shape=20) ax.scatter(glons, glats, transform=ccrs.PlateCarree(), s=35, c='k') ax.scatter(glonn, glatn, transform=ccrs.PlateCarree(), s=35, c='k') ax.scatter(0, 90, transform=ccrs.PlateCarree(), s=35, c='w', zorder=100) ax.scatter(0, -90, transform=ccrs.PlateCarree(), s=35, c='w', zorder=100) plt.title(titf[k]+' '+title,x=0,y=0.93) plt.figure(1) plt.subplots_adjust( hspace=0.01, wspace=0.01, left=0.05, right=0.95, top=0.95, bottom=0.12) cax = plt.axes([0.25,0.07,0.5,0.02]) hcb = plt.colorbar( hc1,cax=cax,orientation='horizontal',ticks=np.arange(0.8,1.7,0.2)*1e-9) hcb.set_label(r'$\rho$ (kg/$m^3$)') plt.quiverkey(hq1, 0.5,0.12, 500, '500m/s',coordinates='figure') plt.savefig(savepath+'1'+ns+'AllUT.eps') plt.savefig(savepath+'1'+ns+'AllUT.jpeg') return
import gitm_new as gitm import numpy as np from numpy import pi import gitm_3D_const_alt as g3ca from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt from aacgmv2 import convert import datetime as dt plt.close('all') path1 = '/home/guod/simulation_output/momentum_analysis/'+\ 'run_shrink_iondrift_4_c1/data/3DALL_t030322_060000.bin' path2 = '/home/guod/simulation_output/momentum_analysis/'+\ 'run_no_shrink_iondrift_4_1/data/3DALL_t030322_060000.bin' g1 = gitm.read(path1) g2 = gitm.read(path2) fig = plt.figure(figsize=(5.41, 8.54)) ax = fig.add_subplot(111, projection='3d') levels = [np.linspace(6.1e-10, 17.8e-10,21), np.linspace(1.1e-10, 2.7e-10, 21), np.linspace(1.3e-11, 3.9e-11,21), np.linspace(2.6e-12, 9.503e-12,21), np.linspace(4.3e-13, 2.71e-12,21), np.linspace(7.4e-14, 8.2e-13,21)] olat = -40 olatr = np.abs(olat)/180*np.pi glats, glons = convert(-90,0,0,date=dt.date(2003,3,22), a2g=True) glats, glons = glats/180*pi, glons/180*pi artalt = [10, 200, 380, 540, 680, 820] realalt = [150, 200, 300, 400, 500, 600] for ik, alt in enumerate([150, 200, 300, 400, 500, 600]): lon0, lat0, rho1 = g3ca.contour_data('Rho', g1, alt=alt)
def plot_06ut_18ut(ns='SH', alt=150, tf=[1, 0, 0, 0, 0, 0]): # 0:rho and wind; 1: diff rho and wind; 2:ion drag; 3:vni; 4:ion convection # 5:ion density; 6:electron density; path = '/home/guod/simulation_output/momentum_analysis/run_shrink_dipole_1_c1/UA/data' fn1 = path + '/3DALL_t030322_060002.bin' fn2 = path + '/3DALL_t030322_180002.bin' g11 = [gitm.read(fn1), gitm.read(fn2)] # shrink, dipole #print(g11[0]['Altitude'][0,0,np.argmin(np.abs(g11[0]['Altitude'][0,0,:]-150*1000))]) path = '/home/guod/simulation_output/momentum_analysis/run_shrink_igrf_1_c1/UA/data' fn1 = path + '/3DALL_t030322_060002.bin' fn2 = path + '/3DALL_t030322_180003.bin' g12 = [gitm.read(fn1), gitm.read(fn2)] # shrink, igrf path = '/home/guod/simulation_output/momentum_analysis/run_no_shrink_dipole_1_1/UA/data' fn1 = path + '/3DALL_t030322_060000.bin' fn2 = path + '/3DALL_t030322_180001.bin' g21 = [gitm.read(fn1), gitm.read(fn2)] # no shrink, diple path = '/home/guod/simulation_output/momentum_analysis/run_no_shrink_igrf_1_1/UA/data' fn1 = path + '/3DALL_t030322_060001.bin' fn2 = path + '/3DALL_t030322_180002.bin' g22 = [gitm.read(fn1), gitm.read(fn2)] # no shrink, igrf if ns == 'SH': nlat, slat = -50, -90 elif ns == 'NH': nlat, slat = 90, 50 glats, glons = convert(-90, 0, 0, date=dt.date(2003, 1, 1), a2g=True) glatn, glonn = convert(90, 0, 0, date=dt.date(2003, 1, 1), a2g=True) fign = ['(a)', '(b)', '(c)', '(d)'] # Rho and wind if tf[0]: plt.figure(1, figsize=(8, 7.55)) for k in range(4): gtemp = g22 if k in [0, 1] else g21 ax, projection, hc, hq = plot_polar_contour_vector( 2, 2, k + 1, gtemp[k % 2], nlat, slat, alt, contour=True, zstr='Rho', vector=True, neuion='neu', useLT=True, coastlines=False, levels=np.linspace(0.8e-9, 1.6e-9, 21)) if k in [0, 1]: ax.scatter(glons, glats, transform=ccrs.PlateCarree(), s=55, c='k') ax.scatter(glonn, glatn, transform=ccrs.PlateCarree(), s=55, c='k') ax.scatter(0, 90, transform=ccrs.PlateCarree(), s=55, c='w', zorder=100) ax.scatter(0, -90, transform=ccrs.PlateCarree(), s=55, c='w', zorder=100) if k in [0, 1]: plt.title('UT: ' + gtemp[k % 2]['time'].strftime('%H'), y=1.05) if k in [0, 2]: text = 'IGRF' if k == 0 else 'Dipole' plt.text(-0.2, 0.5, text, fontsize=14, verticalalignment='center', transform=plt.gca().transAxes, rotation=90) plt.text(0, 1, fign[k], fontsize=14, transform=plt.gca().transAxes) plt.subplots_adjust(bottom=0.13, top=0.93, wspace=0.15, hspace=0.15) cax = plt.axes([0.3, 0.08, 0.4, 0.02]) plt.colorbar(hc[0], cax=cax, orientation='horizontal', ticks=np.arange(0.8e-9, 1.7e-9, 0.2e-9)) cax.set_xlabel(r'$\rho (kg/m^3)$') plt.quiverkey(hq[0], 0.5, 0.12, 500, '500m/s', coordinates='figure') plt.savefig(savepath + '2' + ns + 'RhoWind.jpeg') plt.savefig(savepath + '2' + ns + 'RhoWind.eps') # ion drag if tf[1]: plt.figure(1, figsize=(8, 7.55)) for k in range(4): gtemp = g22 if k in [0, 1] else g21 calc_rhoi(gtemp[0]) calc_rhoi(gtemp[1]) gtemp[0]['iondrag'] = \ gtemp[0]['rhoi']/gtemp[0]['Rho']*gtemp[0]['Collision(in)']*\ np.sqrt((gtemp[0]['V!Di!N (east)']-gtemp[0]['V!Dn!N (east)'])**2 +\ (gtemp[0]['V!Di!N (north)']-gtemp[0]['V!Dn!N (north)'])**2) gtemp[1]['iondrag'] = \ gtemp[1]['rhoi']/gtemp[1]['Rho']*gtemp[1]['Collision(in)']*\ np.sqrt((gtemp[1]['V!Di!N (east)']-gtemp[1]['V!Dn!N (east)'])**2 +\ (gtemp[1]['V!Di!N (north)']-gtemp[1]['V!Dn!N (north)'])**2) ax, projection, hc, hq = plot_polar_contour_vector( 2, 2, k + 1, gtemp[k % 2], nlat, slat, alt, contour=True, zstr='iondrag', vector=False, neuion='neu', useLT=True, coastlines=False, levels=np.linspace(0, 0.05, 21)) if k in [0, 1]: ax.scatter(glons, glats, transform=ccrs.PlateCarree(), s=55, c='k') ax.scatter(glonn, glatn, transform=ccrs.PlateCarree(), s=55, c='k') ax.scatter(0, 90, transform=ccrs.PlateCarree(), s=55, c='w', zorder=100) ax.scatter(0, -90, transform=ccrs.PlateCarree(), s=55, c='w', zorder=100) if k in [0, 1]: plt.title('UT: ' + gtemp[k % 2]['time'].strftime('%H'), y=1.05) if k in [0, 2]: text = 'IGRF' if k == 0 else 'Dipole' plt.text(-0.2, 0.5, text, fontsize=14, verticalalignment='center', transform=plt.gca().transAxes, rotation=90) plt.subplots_adjust(bottom=0.13, top=0.93, wspace=0.15, hspace=0.15) cax = plt.axes([0.3, 0.08, 0.4, 0.02]) plt.colorbar(hc[0], cax=cax, orientation='horizontal', ticks=np.arange(0, 0.051, 0.01)) cax.set_xlabel(r'Ion Drag $(m/s^2)$') plt.savefig(savepath + '3' + ns + 'IonDrag.jpeg') plt.savefig(savepath + '3' + ns + 'IonDrag.eps') # vni if tf[2]: plt.figure(1, figsize=(8, 7.55)) for k in range(4): gtemp = g22 if k in [0, 1] else g21 calc_rhoi(gtemp[0]) calc_rhoi(gtemp[1]) gtemp[0]['vni'] = \ gtemp[0]['rhoi']/gtemp[0]['Rho']*gtemp[0]['Collision(in)'] gtemp[1]['vni'] = \ gtemp[1]['rhoi']/gtemp[1]['Rho']*gtemp[1]['Collision(in)'] ax, projection, hc, hq = plot_polar_contour_vector( 2, 2, k + 1, gtemp[k % 2], nlat, slat, alt, contour=True, zstr='vni', vector=False, neuion='neu', useLT=True, coastlines=False, levels=np.linspace(0, 0.0002, 21)) if k in [0, 1]: ax.scatter(glons, glats, transform=ccrs.PlateCarree(), s=55, c='k') ax.scatter(glonn, glatn, transform=ccrs.PlateCarree(), s=55, c='k') ax.scatter(0, 90, transform=ccrs.PlateCarree(), s=55, c='w', zorder=100) ax.scatter(0, -90, transform=ccrs.PlateCarree(), s=55, c='w', zorder=100) if k in [0, 1]: plt.title('UT: ' + gtemp[k % 2]['time'].strftime('%H'), y=1.05) if k in [0, 2]: text = 'IGRF' if k == 0 else 'Dipole' plt.text(-0.2, 0.5, text, fontsize=14, verticalalignment='center', transform=plt.gca().transAxes, rotation=90) plt.subplots_adjust(bottom=0.13, top=0.93, wspace=0.15, hspace=0.15) cax = plt.axes([0.3, 0.08, 0.4, 0.02]) plt.colorbar(hc[0], cax=cax, orientation='horizontal', ticks=np.arange(0, 0.00021, 0.0001)) cax.set_xlabel(r'$\nu_{ni}$ $(s^{-1})$') plt.savefig(savepath + '4' + ns + 'vni.jpeg') plt.savefig(savepath + '4' + ns + 'vni.eps') # ion convection if tf[3]: plt.figure(1, figsize=(8, 7.55)) for k in range(4): gtemp = g22 if k in [0, 1] else g21 gtemp[0]['vi'] = np.sqrt(gtemp[0]['V!Di!N (east)']**2 + gtemp[0]['V!Di!N (north)']**2) gtemp[1]['vi'] = np.sqrt(gtemp[1]['V!Di!N (east)']**2 + gtemp[1]['V!Di!N (north)']**2) ax, projection, hc, hq = plot_polar_contour_vector( 2, 2, k + 1, gtemp[k % 2], nlat, slat, alt, contour=True, zstr='vi', vector=True, neuion='ion', useLT=True, coastlines=False, levels=np.linspace(0, 1000, 21)) if k in [0, 1]: ax.scatter(glons, glats, transform=ccrs.PlateCarree(), s=55, c='k') ax.scatter(glonn, glatn, transform=ccrs.PlateCarree(), s=55, c='k') ax.scatter(0, 90, transform=ccrs.PlateCarree(), s=55, c='w', zorder=100) ax.scatter(0, -90, transform=ccrs.PlateCarree(), s=55, c='w', zorder=100) if k in [0, 1]: plt.title('UT: ' + gtemp[k % 2]['time'].strftime('%H'), y=1.05) if k in [0, 2]: text = 'IGRF' if k == 0 else 'Dipole' plt.text(-0.2, 0.5, text, fontsize=14, verticalalignment='center', transform=plt.gca().transAxes, rotation=90) plt.subplots_adjust(bottom=0.13, top=0.93, wspace=0.15, hspace=0.15) cax = plt.axes([0.3, 0.08, 0.4, 0.02]) plt.colorbar(hc[0], cax=cax, orientation='horizontal', ticks=np.arange(0, 1001, 200)) cax.set_xlabel(r'Vi (m/s)') plt.savefig(savepath + '5' + ns + 'IonV.jpeg') plt.savefig(savepath + '5' + ns + 'IonV.eps') # ion density if tf[4]: plt.figure(1, figsize=(8, 7.55)) for k in range(4): gtemp = g22 if k in [0, 1] else g21 calc_rhoi(gtemp[0]) calc_rhoi(gtemp[1]) ax, projection, hc, hq = plot_polar_contour_vector( 2, 2, k + 1, gtemp[k % 2], nlat, slat, alt, contour=True, zstr='rhoi', vector=False, neuion='neu', useLT=True, coastlines=False, levels=np.linspace(0, 12e-15, 21)) if k in [0, 1]: ax.scatter(glons, glats, transform=ccrs.PlateCarree(), s=55, c='k') ax.scatter(glonn, glatn, transform=ccrs.PlateCarree(), s=55, c='k') ax.scatter(0, 90, transform=ccrs.PlateCarree(), s=55, c='w', zorder=100) ax.scatter(0, -90, transform=ccrs.PlateCarree(), s=55, c='w', zorder=100) if k in [0, 1]: plt.title('UT: ' + gtemp[k % 2]['time'].strftime('%H'), y=1.05) if k in [0, 2]: text = 'IGRF' if k == 0 else 'Dipole' plt.text(-0.2, 0.5, text, fontsize=14, verticalalignment='center', transform=plt.gca().transAxes, rotation=90) plt.subplots_adjust(bottom=0.13, top=0.93, wspace=0.15, hspace=0.15) cax = plt.axes([0.3, 0.08, 0.4, 0.02]) plt.colorbar(hc[0], cax=cax, orientation='horizontal', ticks=np.arange(0, 12.1e-15, 3e-15)) cax.set_xlabel(r'$\rho_i$ $(kg/m^3)$') plt.savefig(savepath + '6' + ns + 'Rhoi.jpeg') plt.savefig(savepath + '6' + ns + 'Rhoi.eps') # electron density if tf[5]: plt.figure(1, figsize=(8, 7.55)) for k in range(4): gtemp = g22 if k in [0, 1] else g21 calc_rhoi(gtemp[0]) calc_rhoi(gtemp[1]) ax, projection, hc, hq = plot_polar_contour_vector( 2, 2, k + 1, gtemp[k % 2], nlat, slat, alt, contour=True, zstr='e-', vector=False, neuion='neu', useLT=True, coastlines=False, levels=np.linspace(0, 0.9e12, 21)) if k in [0, 1]: ax.scatter(glons, glats, transform=ccrs.PlateCarree(), s=55, c='k') ax.scatter(glonn, glatn, transform=ccrs.PlateCarree(), s=55, c='k') ax.scatter(0, 90, transform=ccrs.PlateCarree(), s=55, c='w', zorder=100) ax.scatter(0, -90, transform=ccrs.PlateCarree(), s=55, c='w', zorder=100) if k in [0, 1]: plt.title('UT: ' + gtemp[k % 2]['time'].strftime('%H'), y=1.05) if k in [0, 2]: text = 'IGRF' if k == 0 else 'Dipole' plt.text(-0.2, 0.5, text, fontsize=14, verticalalignment='center', transform=plt.gca().transAxes, rotation=90) plt.subplots_adjust(bottom=0.13, top=0.93, wspace=0.15, hspace=0.15) cax = plt.axes([0.3, 0.08, 0.4, 0.02]) plt.colorbar(hc[0], cax=cax, orientation='horizontal', ticks=np.arange(0, 0.31e12, 0.1e12)) cax.set_xlabel(r'Ne ($m^{-3}$)') # plt.savefig(savepath+'7'+ns+'Ne.jpeg') # plt.savefig(savepath+'7'+ns+'Ne.eps') return
def plot_06ut_18ut(ns='SH',alt=150,tf=[1,0,0,0,0,0]): # 0:rho and wind; 1: diff rho and wind; 2:ion drag; 3:vni; 4:ion convection # 5:ion density; 6:electron density; path = '/home/guod/simulation_output/momentum_analysis/run_shrink_dipole_1_c1/UA/data' fn1 = path+'/3DALL_t030322_060002.bin' fn2 = path+'/3DALL_t030322_180002.bin' g11 = [gitm.read(fn1), gitm.read(fn2)] # shrink, dipole #print(g11[0]['Altitude'][0,0,np.argmin(np.abs(g11[0]['Altitude'][0,0,:]-150*1000))]) path = '/home/guod/simulation_output/momentum_analysis/run_shrink_igrf_1_c1/UA/data' fn1 = path+'/3DALL_t030322_060002.bin' fn2 = path+'/3DALL_t030322_180003.bin' g12 = [gitm.read(fn1), gitm.read(fn2)] # shrink, igrf path = '/home/guod/simulation_output/momentum_analysis/run_no_shrink_dipole_1_1/UA/data' fn1 = path+'/3DALL_t030322_060000.bin' fn2 = path+'/3DALL_t030322_180001.bin' g21 = [gitm.read(fn1), gitm.read(fn2)] # no shrink, diple path = '/home/guod/simulation_output/momentum_analysis/run_no_shrink_igrf_1_1/UA/data' fn1 = path+'/3DALL_t030322_060001.bin' fn2 = path+'/3DALL_t030322_180002.bin' g22 = [gitm.read(fn1), gitm.read(fn2)] # no shrink, igrf if ns == 'SH': nlat, slat = -50, -90 elif ns == 'NH': nlat, slat = 90, 50 glats, glons = convert(-90, 0, 0, date=dt.date(2003,1,1), a2g=True) glatn, glonn = convert(90, 0, 0, date=dt.date(2003,1,1), a2g=True) fign=['(a)','(b)','(c)','(d)'] # Rho and wind if tf[0]: plt.figure(1, figsize=(8, 7.55)) for k in range(4): gtemp = g22 if k in [0, 1] else g21 ax, projection, hc, hq = plot_polar_contour_vector( 2, 2, k+1, gtemp[k%2], nlat, slat, alt, contour=True, zstr='Rho', vector=True, neuion='neu', useLT=True, coastlines=False, levels=np.linspace(0.8e-9, 1.6e-9, 21)) if k in [0, 1]: ax.scatter(glons, glats, transform=ccrs.PlateCarree(), s=55, c='k') ax.scatter(glonn, glatn, transform=ccrs.PlateCarree(), s=55, c='k') ax.scatter(0, 90, transform=ccrs.PlateCarree(), s=55, c='w',zorder=100) ax.scatter(0, -90, transform=ccrs.PlateCarree(), s=55, c='w',zorder=100) if k in [0, 1]: plt.title('UT: '+gtemp[k%2]['time'].strftime('%H'), y=1.05) if k in [0, 2]: text = 'IGRF' if k==0 else 'Dipole' plt.text( -0.2, 0.5, text, fontsize=14, verticalalignment='center', transform=plt.gca().transAxes, rotation=90) plt.text( 0, 1, fign[k], fontsize=14, transform=plt.gca().transAxes) plt.subplots_adjust(bottom=0.13,top=0.93, wspace=0.15, hspace=0.15) cax = plt.axes([0.3, 0.08, 0.4, 0.02]) plt.colorbar( hc[0], cax=cax, orientation='horizontal', ticks=np.arange(0.8e-9, 1.7e-9, 0.2e-9)) cax.set_xlabel(r'$\rho (kg/m^3)$') plt.quiverkey(hq[0], 0.5,0.12, 500, '500m/s',coordinates='figure') plt.savefig(savepath+'2'+ns+'RhoWind.jpeg') plt.savefig(savepath+'2'+ns+'RhoWind.eps') # ion drag if tf[1]: plt.figure(1, figsize=(8, 7.55)) for k in range(4): gtemp = g22 if k in [0, 1] else g21 calc_rhoi(gtemp[0]) calc_rhoi(gtemp[1]) gtemp[0]['iondrag'] = \ gtemp[0]['rhoi']/gtemp[0]['Rho']*gtemp[0]['Collision(in)']*\ np.sqrt((gtemp[0]['V!Di!N (east)']-gtemp[0]['V!Dn!N (east)'])**2 +\ (gtemp[0]['V!Di!N (north)']-gtemp[0]['V!Dn!N (north)'])**2) gtemp[1]['iondrag'] = \ gtemp[1]['rhoi']/gtemp[1]['Rho']*gtemp[1]['Collision(in)']*\ np.sqrt((gtemp[1]['V!Di!N (east)']-gtemp[1]['V!Dn!N (east)'])**2 +\ (gtemp[1]['V!Di!N (north)']-gtemp[1]['V!Dn!N (north)'])**2) ax, projection, hc, hq = plot_polar_contour_vector( 2, 2, k+1, gtemp[k%2], nlat, slat, alt, contour=True, zstr='iondrag', vector=False, neuion='neu', useLT=True, coastlines=False, levels=np.linspace(0, 0.05, 21)) if k in [0, 1]: ax.scatter(glons, glats, transform=ccrs.PlateCarree(), s=55, c='k') ax.scatter(glonn, glatn, transform=ccrs.PlateCarree(), s=55, c='k') ax.scatter(0, 90, transform=ccrs.PlateCarree(), s=55, c='w',zorder=100) ax.scatter(0, -90, transform=ccrs.PlateCarree(), s=55, c='w',zorder=100) if k in [0, 1]: plt.title('UT: '+gtemp[k%2]['time'].strftime('%H'), y=1.05) if k in [0, 2]: text = 'IGRF' if k==0 else 'Dipole' plt.text( -0.2, 0.5, text, fontsize=14, verticalalignment='center', transform=plt.gca().transAxes, rotation=90) plt.subplots_adjust(bottom=0.13,top=0.93, wspace=0.15, hspace=0.15) cax = plt.axes([0.3, 0.08, 0.4, 0.02]) plt.colorbar( hc[0], cax=cax, orientation='horizontal', ticks=np.arange(0, 0.051, 0.01)) cax.set_xlabel(r'Ion Drag $(m/s^2)$') plt.savefig(savepath+'3'+ns+'IonDrag.jpeg') plt.savefig(savepath+'3'+ns+'IonDrag.eps') # vni if tf[2]: plt.figure(1, figsize=(8, 7.55)) for k in range(4): gtemp = g22 if k in [0, 1] else g21 calc_rhoi(gtemp[0]) calc_rhoi(gtemp[1]) gtemp[0]['vni'] = \ gtemp[0]['rhoi']/gtemp[0]['Rho']*gtemp[0]['Collision(in)'] gtemp[1]['vni'] = \ gtemp[1]['rhoi']/gtemp[1]['Rho']*gtemp[1]['Collision(in)'] ax, projection, hc, hq = plot_polar_contour_vector( 2, 2, k+1, gtemp[k%2], nlat, slat, alt, contour=True, zstr='vni', vector=False, neuion='neu', useLT=True, coastlines=False, levels=np.linspace(0, 0.0002, 21)) if k in [0, 1]: ax.scatter(glons, glats, transform=ccrs.PlateCarree(), s=55, c='k') ax.scatter(glonn, glatn, transform=ccrs.PlateCarree(), s=55, c='k') ax.scatter(0, 90, transform=ccrs.PlateCarree(), s=55, c='w',zorder=100) ax.scatter(0, -90, transform=ccrs.PlateCarree(), s=55, c='w',zorder=100) if k in [0, 1]: plt.title('UT: '+gtemp[k%2]['time'].strftime('%H'), y=1.05) if k in [0, 2]: text = 'IGRF' if k==0 else 'Dipole' plt.text( -0.2, 0.5, text, fontsize=14, verticalalignment='center', transform=plt.gca().transAxes, rotation=90) plt.subplots_adjust(bottom=0.13,top=0.93, wspace=0.15, hspace=0.15) cax = plt.axes([0.3, 0.08, 0.4, 0.02]) plt.colorbar( hc[0], cax=cax, orientation='horizontal', ticks=np.arange(0, 0.00021, 0.0001)) cax.set_xlabel(r'$\nu_{ni}$ $(s^{-1})$') plt.savefig(savepath+'4'+ns+'vni.jpeg') plt.savefig(savepath+'4'+ns+'vni.eps') # ion convection if tf[3]: plt.figure(1, figsize=(8, 7.55)) for k in range(4): gtemp = g22 if k in [0, 1] else g21 gtemp[0]['vi'] = np.sqrt( gtemp[0]['V!Di!N (east)']**2 + gtemp[0]['V!Di!N (north)']**2) gtemp[1]['vi'] = np.sqrt( gtemp[1]['V!Di!N (east)']**2 + gtemp[1]['V!Di!N (north)']**2) ax, projection, hc, hq = plot_polar_contour_vector( 2, 2, k+1, gtemp[k%2], nlat, slat, alt, contour=True, zstr='vi', vector=True, neuion='ion', useLT=True, coastlines=False, levels=np.linspace(0, 1000, 21)) if k in [0, 1]: ax.scatter(glons, glats, transform=ccrs.PlateCarree(), s=55, c='k') ax.scatter(glonn, glatn, transform=ccrs.PlateCarree(), s=55, c='k') ax.scatter(0, 90, transform=ccrs.PlateCarree(), s=55, c='w',zorder=100) ax.scatter(0, -90, transform=ccrs.PlateCarree(), s=55, c='w',zorder=100) if k in [0, 1]: plt.title('UT: '+gtemp[k%2]['time'].strftime('%H'), y=1.05) if k in [0, 2]: text = 'IGRF' if k==0 else 'Dipole' plt.text( -0.2, 0.5, text, fontsize=14, verticalalignment='center', transform=plt.gca().transAxes, rotation=90) plt.subplots_adjust(bottom=0.13,top=0.93, wspace=0.15, hspace=0.15) cax = plt.axes([0.3, 0.08, 0.4, 0.02]) plt.colorbar( hc[0], cax=cax, orientation='horizontal', ticks=np.arange(0, 1001, 200)) cax.set_xlabel(r'Vi (m/s)') plt.savefig(savepath+'5'+ns+'IonV.jpeg') plt.savefig(savepath+'5'+ns+'IonV.eps') # ion density if tf[4]: plt.figure(1, figsize=(8, 7.55)) for k in range(4): gtemp = g22 if k in [0, 1] else g21 calc_rhoi(gtemp[0]) calc_rhoi(gtemp[1]) ax, projection, hc, hq = plot_polar_contour_vector( 2, 2, k+1, gtemp[k%2], nlat, slat, alt, contour=True, zstr='rhoi', vector=False, neuion='neu', useLT=True, coastlines=False, levels=np.linspace(0, 12e-15, 21)) if k in [0, 1]: ax.scatter(glons, glats, transform=ccrs.PlateCarree(), s=55, c='k') ax.scatter(glonn, glatn, transform=ccrs.PlateCarree(), s=55, c='k') ax.scatter(0, 90, transform=ccrs.PlateCarree(), s=55, c='w',zorder=100) ax.scatter(0, -90, transform=ccrs.PlateCarree(), s=55, c='w',zorder=100) if k in [0, 1]: plt.title('UT: '+gtemp[k%2]['time'].strftime('%H'), y=1.05) if k in [0, 2]: text = 'IGRF' if k==0 else 'Dipole' plt.text( -0.2, 0.5, text, fontsize=14, verticalalignment='center', transform=plt.gca().transAxes, rotation=90) plt.subplots_adjust(bottom=0.13,top=0.93, wspace=0.15, hspace=0.15) cax = plt.axes([0.3, 0.08, 0.4, 0.02]) plt.colorbar( hc[0], cax=cax, orientation='horizontal', ticks=np.arange(0, 12.1e-15, 3e-15)) cax.set_xlabel(r'$\rho_i$ $(kg/m^3)$') plt.savefig(savepath+'6'+ns+'Rhoi.jpeg') plt.savefig(savepath+'6'+ns+'Rhoi.eps') # electron density if tf[5]: plt.figure(1, figsize=(8, 7.55)) for k in range(4): gtemp = g22 if k in [0, 1] else g21 calc_rhoi(gtemp[0]) calc_rhoi(gtemp[1]) ax, projection, hc, hq = plot_polar_contour_vector( 2, 2, k+1, gtemp[k%2], nlat, slat, alt, contour=True, zstr='e-', vector=False, neuion='neu', useLT=True, coastlines=False, levels=np.linspace(0, 0.9e12, 21)) if k in [0, 1]: ax.scatter(glons, glats, transform=ccrs.PlateCarree(), s=55, c='k') ax.scatter(glonn, glatn, transform=ccrs.PlateCarree(), s=55, c='k') ax.scatter(0, 90, transform=ccrs.PlateCarree(), s=55, c='w',zorder=100) ax.scatter(0, -90, transform=ccrs.PlateCarree(), s=55, c='w',zorder=100) if k in [0, 1]: plt.title('UT: '+gtemp[k%2]['time'].strftime('%H'), y=1.05) if k in [0, 2]: text = 'IGRF' if k==0 else 'Dipole' plt.text( -0.2, 0.5, text, fontsize=14, verticalalignment='center', transform=plt.gca().transAxes, rotation=90) plt.subplots_adjust(bottom=0.13,top=0.93, wspace=0.15, hspace=0.15) cax = plt.axes([0.3, 0.08, 0.4, 0.02]) plt.colorbar( hc[0], cax=cax, orientation='horizontal', ticks=np.arange(0, 0.31e12, 0.1e12)) cax.set_xlabel(r'Ne ($m^{-3}$)') # plt.savefig(savepath+'7'+ns+'Ne.jpeg') # plt.savefig(savepath+'7'+ns+'Ne.eps') return
def plot_rho_wind_ut(ns='SH', alt=150): path = '/home/guod/simulation_output/momentum_analysis/run_no_shrink_igrf_1_1/data' fn01 = path + '/3DALL_t030323_000000.bin' fn02 = path + '/3DALL_t030323_030000.bin' fn03 = path + '/3DALL_t030323_060001.bin' fn04 = path + '/3DALL_t030323_090002.bin' fn05 = path + '/3DALL_t030323_120000.bin' fn06 = path + '/3DALL_t030323_150001.bin' fn07 = path + '/3DALL_t030323_180000.bin' fn08 = path + '/3DALL_t030323_210002.bin' fn09 = path + '/3DALL_t030324_000000.bin' fn2 = [fn01, fn02, fn03, fn04, fn05, fn06, fn07, fn08, fn09] if ns == 'SH': nlat, slat = -50, -90 elif ns == 'NH': nlat, slat = 90, 50 glats, glons = convert(-90, 0, 0, date=dt.date(2003, 1, 1), a2g=True) glatn, glonn = convert(90, 0, 0, date=dt.date(2003, 1, 1), a2g=True) fig1 = plt.figure(1, figsize=(5.28, 8.49)) titf = ['(a)', '(b)', '(c)', '(d)', '(e)', '(f)', '(g)', '(h)'] for k in range(8): g2 = gitm.read(fn2[k]) title = 'UT: ' + g2['time'].strftime('%H') lon2, lat2, rho2 = g3ca.contour_data('Rho', g2, alt=alt) ilat2 = (lat2[:, 0] >= slat) & (lat2[:, 0] <= nlat) min_div_mean = \ np.min(rho2[ilat2, :]) / \ (np.mean(rho2[ilat2, :]*np.cos(lat2[ilat2, :]/180*np.pi)) /\ np.mean(np.cos(lat2[ilat2,:]/180*np.pi))) print(ns, ': ', 100 * (min_div_mean - 1)) lon2, lat2, ewind2, nwind2 = g3ca.vector_data(g2, 'neu', alt=alt) if k == 0: lonticklabel = [1, 0, 0, 1] elif k == 1: lonticklabel = [1, 1, 0, 0] elif k in [2, 4]: lonticklabel = [0, 0, 0, 1] elif k in [3, 5]: lonticklabel = [0, 1, 0, 0] elif k == 6: lonticklabel = [0, 0, 1, 1] elif k == 7: lonticklabel = [0, 1, 1, 0] olat = False if k < 7 else True # No shrink plt.figure(1) centrallon = g3ca.calculate_centrallon(g2, 'pol', useLT=True) ax, projection = gcc.create_map(4, 2, k + 1, 'pol', nlat, slat, centrallon, coastlines=False, dlat=10, useLT=True, lonticklabel=lonticklabel, olat=olat) hc1 = ax.contourf(lon2, lat2, rho2, np.linspace(0.8e-9, 1.6e-9), transform=ccrs.PlateCarree(), cmap='jet', extend='both') lon9, lat9, ewind9, nwind9 = g3ca.convert_vector( lon2, lat2, ewind2, nwind2, 'pol', projection) hq1 = ax.quiver(lon9, lat9, ewind9, nwind9, scale=1500, scale_units='inches', regrid_shape=20) ax.scatter(glons, glats, transform=ccrs.PlateCarree(), s=35, c='k') ax.scatter(glonn, glatn, transform=ccrs.PlateCarree(), s=35, c='k') ax.scatter(0, 90, transform=ccrs.PlateCarree(), s=35, c='w', zorder=100) ax.scatter(0, -90, transform=ccrs.PlateCarree(), s=35, c='w', zorder=100) plt.title(titf[k] + ' ' + title, x=0, y=0.93) plt.figure(1) plt.subplots_adjust(hspace=0.01, wspace=0.01, left=0.05, right=0.95, top=0.95, bottom=0.12) cax = plt.axes([0.25, 0.07, 0.5, 0.02]) hcb = plt.colorbar(hc1, cax=cax, orientation='horizontal', ticks=np.arange(0.8, 1.7, 0.2) * 1e-9) hcb.set_label(r'$\rho$ (kg/$m^3$)') plt.quiverkey(hq1, 0.5, 0.12, 500, '500m/s', coordinates='figure') plt.savefig(savepath + '1' + ns + 'AllUT.eps') plt.savefig(savepath + '1' + ns + 'AllUT.jpeg') return
fn2 = '/home/guod/simulation_output/momentum_analysis/'\ 'run_no_shrink_iondrift_4_1_high_resolution/data/3DALL_t030322_000103.bin' fn1 = '/home/guod/simulation_output/momentum_analysis/'\ 'run_shrink_iondrift_4_c1_high_resolution/data/3DALL_t030322_000203.bin' fn2 = '/home/guod/simulation_output/momentum_analysis/'\ 'run_no_shrink_iondrift_4_1_high_resolution/data/3DALL_t030322_000203.bin' fn1 = '/home/guod/simulation_output/momentum_analysis/'\ 'run_shrink_iondrift_4_c1_high_resolution/data/3DALL_t030322_000302.bin' fn2 = '/home/guod/simulation_output/momentum_analysis/'\ 'run_no_shrink_iondrift_4_1_high_resolution/data/3DALL_t030322_000302.bin' fn1 ='/home/guod/simulation_output/momentum_analysis/run_shrink_iondrift_4_c1/data/3DALL_t030322_000501.bin' fn2 ='/home/guod/simulation_output/momentum_analysis/run_no_shrink_iondrift_4_1/data/3DALL_t030322_000501.bin' # fn1 ='/home/guod/simulation_output/momentum_analysis/run_shrink_iondrift_4_c1/data/3DALL_t030322_001003.bin' # fn2 ='/home/guod/simulation_output/momentum_analysis/run_no_shrink_iondrift_4_1/data/3DALL_t030322_001003.bin' fn1 ='/home/guod/simulation_output/momentum_analysis/run_shrink_iondrift_4_c1/data/3DALL_t030322_003003.bin' fn2 ='/home/guod/simulation_output/momentum_analysis/run_no_shrink_iondrift_4_1/data/3DALL_t030322_003002.bin' # fn1 ='/home/guod/simulation_output/momentum_analysis/run_shrink_iondrift_4_c1/data/3DALL_t030322_010002.bin' # fn2 ='/home/guod/simulation_output/momentum_analysis/run_no_shrink_iondrift_4_1/data/3DALL_t030322_010000.bin' # fn1 ='/home/guod/simulation_output/momentum_analysis/run_shrink_iondrift_4_c1/data/3DALL_t030322_060000.bin' # fn2 ='/home/guod/simulation_output/momentum_analysis/run_no_shrink_iondrift_4_1/data/3DALL_t030322_060000.bin' fn1 = '/home/guod/simulation_output/momentum_analysis/run_shrink_iondrift_4_c4/data/3DALL_t030322_180502.bin' fn2 = '/home/guod/simulation_output/momentum_analysis/run_no_shrink_iondrift_4_4/data/3DALL_t030322_180502.bin' fn1 = '/home/guod/simulation_output/momentum_analysis/run_shrink_iondrift_4_c4/data/3DALL_t030322_181003.bin' fn2 = '/home/guod/simulation_output/momentum_analysis/run_no_shrink_iondrift_4_4/data/3DALL_t030322_181000.bin' fn1 = '/home/guod/simulation_output/momentum_analysis/run_shrink_iondrift_4_c4/data/3DALL_t030322_183002.bin' fn2 = '/home/guod/simulation_output/momentum_analysis/run_no_shrink_iondrift_4_4/data/3DALL_t030322_183002.bin' g1 = gitm.read(fn1) g2 = gitm.read(fn2) #const_lon(g2, 0, 100, 600) const_lon_diff(g1, g2, 4, 50, 100, 600, -90, -30)