Ejemplo n.º 1
0
def plotbrvr(fName,shell,tsolar,outer_grid=None,lims={'br':[-5.,5.],
                                      'vr':[200.,800]}):
    # get LFM stuff out
    simtime = lfmhlib.get_time(fName)
    R,theta,phi = lfmhlib.r_theta_phi_uniform(fName)
    R/=6.96e10   # FIX ME HARD CODED UNITS
#    islice=argmin(abs(R-shell))   # index of the desired radial distance
    islice = shell


    br = lfmhlib.read_var(fName,'br')
    vr = lfmhlib.read_var(fName,'vr')

    # shift to start of CR
    br = lfmhlib.time_shift(simtime,br[:,:,islice],tsolar)
    vr = lfmhlib.time_shift(simtime,vr[:,:,islice],tsolar)

    # Plot
    if outer_grid==None:
        gs = gridspec.GridSpec(2,2,width_ratios=[14,1],hspace=0.1)
    else:
        gs = gridspec.GridSpecFromSubplotSpec(2,2,subplot_spec=outer_grid,width_ratios=[14,1],hspace=0.1)

    p1c = 0.5*(phi[1:]+phi[:-1])
    t1c = 0.5*(theta[1:]+theta[:-1])

    # Br
    ax1=plt.subplot(gs[0,0],aspect='equal')
    ax1_cb=plt.subplot(gs[0,1])
    p1=ax1.pcolormesh(phi*180/pi,(pi/2.-theta)*180./pi,br.T*1.e5,vmin=lims['br'][0],vmax=lims['br'][1],cmap='RdBu_r',rasterized=True)
    plt.colorbar(p1,cax=ax1_cb).set_label(r'B$_r$, nT')
    ax1.contour(p1c*180./pi,(pi/2-t1c)*180/pi,br.T,[0.],colors='black')
    ax1.axhline(0.,linestyle='--',color='black')

    # Vr
    ax2=plt.subplot(gs[1,0],aspect='equal',sharex=ax1)
    ax2_cb=plt.subplot(gs[1,1])
    p2=ax2.pcolormesh(phi*180/pi,(pi/2.-theta)*180./pi,vr.T*1.e-5,vmin=lims['vr'][0],vmax=lims['vr'][1],rasterized=True)
    plt.colorbar(p2,cax=ax2_cb).set_label(r'V$_r$, km/s')
    plt.axhline(0)
    ax2.contour(p1c*180./pi,(pi/2-t1c)*180/pi,br.T,[0.],colors='white')
    ax2.axhline(0.,linestyle='--',color='white')

    for ax in [ax1,ax2]:
        ax.set_ylabel(r'$\theta$')
        ax.set_xlim(0,360)
        ax.set_ylim(-70,70)

        if ax!=ax2:
            plt.setp(ax.get_xticklabels(), visible=False) 
        else:
            ax.set_xlabel(r'$\phi$')

    return(ax1,ax2)
Ejemplo n.º 2
0
dates = []
vr = []
br = []
n  = []
t  = []
vr0= []
br0= []
n0 = []
t0 = []
i_ind = []
j_ind = []
k_ind = []
for i,f in enumerate(lfmFiles[start_ind:]):
    if i==0: 
        simtime0 = lfmhlib.get_time(f)
        R,theta,phi,Rc,thetac,phic = lfmhlib.r_theta_phi_uniform(f)
        nk = phic.size
        
    simtime = lfmhlib.get_time(f)

    d = start_dati+datetime.timedelta(seconds=simtime-simtime0)
    dates.append(d)
    print(d)

    # look for the corresponding ACE record
    aceind = argmin([abs((ddd-d).total_seconds()) for ddd in ACE_dati])

    pace = (pi-Omega*(simtime-simtime0))%(2*pi)
    pace1 = (pi-Omega*(simtime-simtime0))
    tace = 90.-ACE_theta[aceind]
Ejemplo n.º 3
0
start_ind = [start_step==int(f[-11:-4]) for f in lfmFiles].index(True)
dates = []
vr = []
br = []
vr0= []
br0= []

matplotlib.rc('mathtext',fontset='stixsans',default='regular')
close('all')
fig=plt.figure(figsize=(12,15))
gs = gridspec.GridSpec(2,1,height_ratios=[6,4],hspace=0.2)
gs1 = gridspec.GridSpecFromSubplotSpec(2,1,subplot_spec=gs[1],hspace=0.1)
for i,f in enumerate(lfmFiles[start_ind:start_ind+1]):
    if i==0: 
        simtime0 = lfmhlib.get_time(f)
        R,theta,phi = lfmhlib.r_theta_phi_uniform(f)
        R/=6.96e10   # FIX ME HARD CODED UNITS

    simtime = lfmhlib.get_time(f)

    d = start_dati+datetime.timedelta(seconds=simtime-simtime0)
    dates.append(d)
    print(d)

    # look for the corresponding ACE record
    aceind = argmin([abs((ddd-d).total_seconds()) for ddd in ACE_dati])

    pace = (pi-Omega*(simtime-simtime0))%(2*pi)
    tace = 90.-ACE_theta[aceind]

    # look for the corresponding MSGR record
Ejemplo n.º 4
0
parser.add_argument('hdfFileName', help='LFM-helio file to use')
parser.add_argument('shell',
                    help='Radial shell in code units of distance.',
                    type=float)
#parser.add_argument('limits',help='',type=float)
parser.add_argument('Tsolar',
                    help='T solar rotation in code units.',
                    type=float,
                    default=25.38 * 24 * 3600,
                    nargs='?')
args = parser.parse_args()
#----------- PARSE ARGUMENTS ---------#

# get LFM stuff out
simtime = lfmhlib.get_time(args.hdfFileName)
R, theta, phi = lfmhlib.r_theta_phi_uniform(args.hdfFileName)
R /= 6.96e10  # FIX ME HARD CODED UNITS
islice = argmin(abs(R - args.shell))  # index of the desired radial distance

br = lfmhlib.read_var(args.hdfFileName, 'br')
vr = lfmhlib.read_var(args.hdfFileName, 'vr')
rho = lfmhlib.read_var(args.hdfFileName, 'rho')
c = lfmhlib.read_var(args.hdfFileName, 'c')

# shift to start of CR
br = lfmhlib.time_shift(simtime, br[:, :, islice], args.Tsolar)
vr = lfmhlib.time_shift(simtime, vr[:, :, islice], args.Tsolar)
rho = lfmhlib.time_shift(simtime, rho[:, :, islice], args.Tsolar)
c = lfmhlib.time_shift(simtime, c[:, :, islice], args.Tsolar)

# Plot
Ejemplo n.º 5
0
start_ind = [start_step==int(f[-11:-4]) for f in lfmFiles].index(True)
dates = []
vr = []
br = []
vr0= []
br0= []

matplotlib.rc('mathtext',fontset='stixsans',default='regular')
close('all')
fig=plt.figure(figsize=(12,15))
gs = gridspec.GridSpec(2,1,height_ratios=[6,4],hspace=0.2)
gs1 = gridspec.GridSpecFromSubplotSpec(2,1,subplot_spec=gs[1],hspace=0.1)
for i,f in enumerate(lfmFiles[start_ind:]):
    if i==0: 
        simtime0 = lfmhlib.get_time(f)
        R,theta,phi = lfmhlib.r_theta_phi_uniform(f)
        R/=6.96e10   # FIX ME HARD CODED UNITS

    simtime = lfmhlib.get_time(f)

    d = start_dati+datetime.timedelta(seconds=simtime-simtime0)
    dates.append(d)
    print(d)

    # look for the corresponding ACE record
    aceind = argmin([abs((ddd-d).total_seconds()) for ddd in ACE_dati])

    pace = (pi-Omega*(simtime-simtime0))%(2*pi)
    tace = 90.-ACE_theta[aceind]

    # look for the corresponding MSGR record
Ejemplo n.º 6
0
lfmFiles = sorted(glob.glob(os.path.join(lfmFileDir,'*.hdf')))
start_ind = [start_step==int(f[-11:-4]) for f in lfmFiles].index(True)

plt.style.use('publication')
plt.close('all')

## Note, we use analysis/summary below to make the plots. That
## function defines y-limits, but they may get overriden by the figure
## size below as mpl is trying to plot them with equal aspect ratio
## within the figure size constraints that we've given
fig = plt.figure(figsize=(30/6.,45./6.)) 

for i,f in enumerate(lfmFiles[start_ind:]):
    if i==0: 
        simtime0 = lfmhlib.get_time(lfmFiles[0])
        R,theta,phi,Rc,thetac,phic = lfmhlib.r_theta_phi_uniform(f)
        nk = phic.size

    simtime = lfmhlib.get_time(f)

    d = start_dati+datetime.timedelta(seconds=simtime-simtime0)
    print(d)
#    if ( abs((d-datetime.datetime(2008,1,12,3,51)).total_seconds())>300.): continue    # for staircase fix
    if ( abs((d-datetime.datetime(2008,1,25,5,7)).total_seconds())>300.): continue    # for staircase fix
#    if ( abs((d-datetime.datetime(2008,1,12,3,21)).total_seconds())>300.): continue
#    if ( abs((d-datetime.datetime(2008,1,25,5,16)).total_seconds())>300.): continue

    # look for the corresponding ACE record
    aceind = argmin([abs((ddd-d).total_seconds()) for ddd in ACE_dati])

    pace = (pi-Omega*(simtime-simtime0))%(2*pi)
Ejemplo n.º 7
0
parser.add_argument('hdfFileName',help='LFM-helio file to use')
parser.add_argument('crStartTime',help='CR start time (YYYY MM DD HH MM)')
parser.add_argument('shell',help='Radial shell in code units of distance.',type=float)
parser.add_argument('variable',help='What to plot')
args = parser.parse_args()
#----------- PARSE ARGUMENTS ---------#


# CR start time from umtof.umd.edu/pm/crn
import datetime
start_time=datetime.datetime.strptime(args.crStartTime,'%Y %m %d %H %M')


# get LFM stuff out
simtime = lfmhlib.get_time(args.hdfFileName)
R,theta,phi = lfmhlib.r_theta_phi_uniform(args.hdfFileName)
islice=argmin(abs(R-args.shell))   # index of the desired radial distance
var = lfmhlib.read_var(args.hdfFileName,args.variable)
var = 0.5*(var[:,(theta.shape[0]-1)/2-1,islice] +
           var[:,(theta.shape[0]-1)/2,islice])   # extract equatorial value  # extract equatorial value
lfmhlib.time_shift(simtime,var,25.38*24*3600)


# Plot
# ========== time dependence ==========
ut = lfmhlib.get_UT(simtime,phi)
ut=[start_time+datetime.timedelta(seconds=float(ttt)) for ttt in ut]

plt.plot(ut,var[::-1])
"""
matplotlib.rc('mathtext',fontset='stixsans',default='regular')
Ejemplo n.º 8
0
def plots(fName,shell,tsolar,gamma):
    # get LFM stuff out
    simtime = lfmhlib.get_time(fName)
    R,theta,phi = lfmhlib.r_theta_phi_uniform(fName)
    R/=6.96e10   # FIX ME HARD CODED UNITS
    islice=argmin(abs(R-shell))   # index of the desired radial distance


    br = lfmhlib.read_var(fName,'br')
    vr = lfmhlib.read_var(fName,'vr')
    rho = lfmhlib.read_var(fName,'rho')
    c = lfmhlib.read_var(fName,'c')

    # shift to start of CR
    br = lfmhlib.time_shift(simtime,br[:,:,islice],tsolar)
    vr = lfmhlib.time_shift(simtime,vr[:,:,islice],tsolar)
    rho = lfmhlib.time_shift(simtime,rho[:,:,islice],tsolar)
    c = lfmhlib.time_shift(simtime,c[:,:,islice],tsolar)


    # Plot
    gs = gridspec.GridSpec(4,2,width_ratios=[14,1])

    p1c = 0.5*(phi[1:]+phi[:-1])
    t1c = 0.5*(theta[1:]+theta[:-1])

    # Br
    ax1=plt.subplot(gs[0,0],aspect='equal')
    ax1_cb=plt.subplot(gs[0,1])
    p1=ax1.pcolormesh(phi*180/pi,(pi/2.-theta)*180./pi,br.T*1.e5,vmin=-120.,vmax=120.,cmap='RdBu_r',rasterized=True)
    plt.colorbar(p1,cax=ax1_cb).set_label(r'B$_r$, nT')
    ax1.contour(p1c*180./pi,(pi/2-t1c)*180/pi,br.T,[0.],colors='black')

    # Vr
    ax2=plt.subplot(gs[1,0],aspect='equal',sharex=ax1)
    ax2_cb=plt.subplot(gs[1,1])
    p2=ax2.pcolormesh(phi*180/pi,(pi/2.-theta)*180./pi,vr.T*1.e-5,vmin=200.,vmax=800.,rasterized=True)
    plt.colorbar(p2,cax=ax2_cb).set_label(r'V$_r$, km/s')
    plt.axhline(0)
    ax2.contour(p1c*180./pi,(pi/2-t1c)*180/pi,br.T,[0.],colors='white')

    # rho
    ax3=plt.subplot(gs[2,0],aspect='equal',sharex=ax1)
    ax3_cb=plt.subplot(gs[2,1])
#    p3=ax3.pcolormesh(phi*180/pi,(pi/2-theta)*180./pi,log10(rho.T/1.67e-24),vmin=0.4,vmax=1.5,rasterized=True)
    p3=ax3.pcolormesh(phi*180/pi,(pi/2-theta)*180./pi,rho.T/1.67e-24,vmin=200,vmax=1600,rasterized=True)
#    plt.colorbar(p3,cax=ax3_cb).set_label(r'log$_{10}(n\,\mathrm{cm}^{-3}$)')
    plt.colorbar(p3,cax=ax3_cb).set_label(r'n, cm$^{-3}$')
    ax3.contour(p1c*180./pi,(pi/2-t1c)*180/pi,br.T,[0.],colors='white')

    # temperature
    T=1./gamma*c**2*1.67e-24/1.38e-16 # T in K  # FIX ME HARD CODE UNITS AND GAMMA
    ax4=plt.subplot(gs[3,0],aspect='equal',sharex=ax1)
    ax4_cb=plt.subplot(gs[3,1])
#    p4=ax4.pcolormesh(phi*180/pi,(pi/2-theta)*180./pi,log10(T.T),vmin=4.5,vmax=5.4,rasterized=True)
    p4=ax4.pcolormesh(phi*180/pi,(pi/2-theta)*180./pi,T.T*1.e-6,vmin=0.1,vmax=2,rasterized=True)
#    plt.colorbar(p4,cax=ax4_cb).set_label(r'log$_{10}$(T, K)')
    plt.colorbar(p4,cax=ax4_cb).set_label(r'T, MK')
    ax4.contour(p1c*180./pi,(pi/2-t1c)*180/pi,br.T,[0.],colors='white')


    for ax in [ax1,ax2,ax3,ax4]:
        ax.set_ylabel(r'$\theta$')
        ax.set_xlim(0,360)
        ax.set_ylim(-90,90)

        if ax!=ax4:
            plt.setp(ax.get_xticklabels(), visible=False) 
        else:
            ax.set_xlabel(r'$\phi$')

    return(ax1,ax2,ax3,ax4)