Esempio n. 1
0
def plotplasmaoverlay(specdown,specup,t,fg,P):

    ax = fg.gca()

    ialt,alt = findnearest(specdown.srng.values,P['zlim_pl'])
#%%
    try:
        dBdown = 10*log10(specdown.sel(time=t)[ialt,:].values)
        if len(P['vlim_pl'])>=4 and P['vlim_pl'][2] is not None:
            dBdown += P['vlim_pl'][2]
    except AttributeError:
        pass
#%%
    try:
        dBup = 10*log10(specup.sel(time=t)[ialt,:].values)
        if len(P['vlim_pl'])>=4 and P['vlim_pl'][3] is not None:
            dBup += P['vlim_pl'][3]
    except AttributeError:
        pass

    ax.plot(-specdown.freq.values/1e6, dBdown)

    ax.plot(specup.freq.values/1e6, dBup)

    ax.set_ylabel('Power [dB]')
    ax.set_xlabel('frequency: $f_c + f$ [MHz]')

    ax.set_ylim(P['vlim_pl'][:2])
    ax.set_xlim(P['flim_pl'])

    fg.suptitle('Plasma line at {:.0f} km slant range {}'.format(alt, str(t.item)[:19]))
Esempio n. 2
0
def plotzslice(psd,zslice,vlim,azel,fn,dt,t,odir,stem,ttxt=None,flim=(None,None)):
    assert psd.ndim==2,'single time,  spectrum vs srng and freq'

    if psd.srng[-1]<100000: #km or m
        zslice = zslice / 1000 # NOT /= or it modifies original dict!!

    fg = figure()
    ax = fg.gca()

    iz = findnearest(psd.srng, zslice)[0]

    freq = psd.freq.values
    if absolute(freq).max() > 1000: # MHz
        freq /= 1e6
    if freq[freq.size//2]<0 and flim[0] is not None:
        flim = -flim

    ax.plot(freq,
            10*log10(absolute(psd.isel(srng=slice(iz[0],iz[1])).sum(dim='srng'))))



    ax.set_xlim(flim)
    if flim[-1] is not None and flim[-1]<0:
        ax.invert_xaxis() #have to do it here after set_xlim

    for v in vlim: # not is None doesn't work for numpy.array
        if v is not None:
            v+=10
    ax.set_ylim(vlim)

    ax.set_xlabel('frequency: $f_c + f$ [kHz]')
    ax.set_ylabel('Power [dB]')

    if ttxt is None:
        ttxt = expfn(fn)

    ax.set_title('Az,El {:.1f},{:.1f}  @ {}..{} km  {}  $T_s$: {} [sec.] \n {}'.format(azel[0],azel[1], zslice[0], zslice[1],ttxt, dt, str(t)[:-6]))

    writeplots(fg,t, odir, stem, ext='.eps')