jroplot_voltage.py
302 lines
| 9.5 KiB
| text/x-python
|
PythonLexer
|
r487 | ''' | ||
|
r568 | Created on Jul 9, 2014 | ||
|
r487 | |||
|
r568 | @author: roj-idl71 | ||
''' | ||||
import os | ||||
|
r487 | import datetime | ||
import numpy | ||||
|
r1285 | from schainpy.model.graphics.jroplot_base import Plot, plt | ||
|
r1173 | |||
|
r1285 | |||
class ScopePlot(Plot): | ||||
''' | ||||
Plot for Scope | ||||
r1296 | ''' | |||
|
r1285 | |||
CODE = 'scope' | ||||
plot_name = 'Scope' | ||||
plot_type = 'scatter' | ||||
r1296 | ||||
|
r1285 | def setup(self): | ||
self.xaxis = 'Range (Km)' | ||||
self.ncols = 1 | ||||
self.nrows = 1 | ||||
self.nplots = 1 | ||||
self.ylabel = 'Intensity [dB]' | ||||
self.titles = ['Scope'] | ||||
self.colorbar = False | ||||
self.width = 6 | ||||
self.height = 4 | ||||
def plot_iq(self, x, y, channelIndexList, thisDatetime, wintitle): | ||||
r1296 | ||||
|
r487 | yreal = y[channelIndexList,:].real | ||
yimag = y[channelIndexList,:].imag | ||||
|
r1285 | title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y")) | ||
self.xlabel = "Range (Km)" | ||||
self.ylabel = "Intensity - IQ" | ||||
r1296 | ||||
|
r1285 | self.y = yreal | ||
self.x = x | ||||
self.xmin = min(x) | ||||
self.xmax = max(x) | ||||
|
r487 | |||
r1296 | ||||
self.titles[0] = title | ||||
|
r487 | |||
|
r1285 | for i,ax in enumerate(self.axes): | ||
title = "Channel %d" %(i) | ||||
if ax.firsttime: | ||||
ax.plt_r = ax.plot(x, yreal[i,:], color='b')[0] | ||||
ax.plt_i = ax.plot(x, yimag[i,:], color='r')[0] | ||||
else: | ||||
ax.plt_r.set_data(x, yreal[i,:]) | ||||
ax.plt_i.set_data(x, yimag[i,:]) | ||||
r1296 | ||||
|
r1285 | def plot_power(self, x, y, channelIndexList, thisDatetime, wintitle): | ||
|
r487 | y = y[channelIndexList,:] * numpy.conjugate(y[channelIndexList,:]) | ||
yreal = y.real | ||||
r1296 | yreal = 10*numpy.log10(yreal) | |||
|
r1285 | self.y = yreal | ||
title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y")) | ||||
self.xlabel = "Range (Km)" | ||||
self.ylabel = "Intensity" | ||||
self.xmin = min(x) | ||||
self.xmax = max(x) | ||||
r1296 | ||||
|
r1285 | self.titles[0] = title | ||
for i,ax in enumerate(self.axes): | ||||
title = "Channel %d" %(i) | ||||
r1296 | ||||
|
r1285 | ychannel = yreal[i,:] | ||
r1296 | ||||
if ax.firsttime: | ||||
|
r1285 | ax.plt_r = ax.plot(x, ychannel)[0] | ||
else: | ||||
#pass | ||||
ax.plt_r.set_data(x, ychannel) | ||||
r1296 | ||||
def plot_weatherpower(self, x, y, channelIndexList, thisDatetime, wintitle): | ||||
y = y[channelIndexList,:] | ||||
yreal = y.real | ||||
yreal = 10*numpy.log10(yreal) | ||||
self.y = yreal | ||||
title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | ||||
self.xlabel = "Range (Km)" | ||||
self.ylabel = "Intensity" | ||||
self.xmin = min(x) | ||||
self.xmax = max(x) | ||||
self.titles[0] =title | ||||
for i,ax in enumerate(self.axes): | ||||
title = "Channel %d" %(i) | ||||
ychannel = yreal[i,:] | ||||
if ax.firsttime: | ||||
ax.plt_r = ax.plot(x, ychannel)[0] | ||||
else: | ||||
#pass | ||||
ax.plt_r.set_data(x, ychannel) | ||||
def plot_weathervelocity(self, x, y, channelIndexList, thisDatetime, wintitle): | ||||
x = x[channelIndexList,:] | ||||
yreal = y | ||||
self.y = yreal | ||||
title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | ||||
self.xlabel = "Velocity (m/s)" | ||||
self.ylabel = "Range (Km)" | ||||
self.xmin = numpy.min(x) | ||||
self.xmax = numpy.max(x) | ||||
self.titles[0] =title | ||||
for i,ax in enumerate(self.axes): | ||||
title = "Channel %d" %(i) | ||||
xchannel = x[i,:] | ||||
if ax.firsttime: | ||||
ax.plt_r = ax.plot(xchannel, yreal)[0] | ||||
else: | ||||
#pass | ||||
ax.plt_r.set_data(xchannel, yreal) | ||||
|
r487 | |||
r1305 | def plot_weatherspecwidth(self, x, y, channelIndexList, thisDatetime, wintitle): | |||
x = x[channelIndexList,:] | ||||
yreal = y | ||||
self.y = yreal | ||||
title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | ||||
self.xlabel = "width " | ||||
self.ylabel = "Range (Km)" | ||||
self.xmin = numpy.min(x) | ||||
self.xmax = numpy.max(x) | ||||
self.titles[0] =title | ||||
for i,ax in enumerate(self.axes): | ||||
title = "Channel %d" %(i) | ||||
xchannel = x[i,:] | ||||
if ax.firsttime: | ||||
ax.plt_r = ax.plot(xchannel, yreal)[0] | ||||
else: | ||||
#pass | ||||
ax.plt_r.set_data(xchannel, yreal) | ||||
|
r1285 | def plot(self): | ||
if self.channels: | ||||
channels = self.channels | ||||
|
r487 | else: | ||
|
r1285 | channels = self.data.channels | ||
thisDatetime = datetime.datetime.utcfromtimestamp(self.data.times[-1]) | ||||
r1296 | if self.CODE == "pp_power": | |||
scope = self.data['pp_power'] | ||||
r1312 | elif self.CODE == "pp_signal": | |||
scope = self.data["pp_signal"] | ||||
r1296 | elif self.CODE == "pp_velocity": | |||
scope = self.data["pp_velocity"] | ||||
r1305 | elif self.CODE == "pp_specwidth": | |||
scope = self.data["pp_specwidth"] | ||||
r1296 | else: | |||
scope =self.data["scope"] | ||||
|
r1285 | if self.data.flagDataAsBlock: | ||
r1296 | ||||
|
r1285 | for i in range(self.data.nProfiles): | ||
wintitle1 = " [Profile = %d] " %i | ||||
r1296 | if self.CODE =="scope": | |||
if self.type == "power": | ||||
self.plot_power(self.data.heights, | ||||
scope[:,i,:], | ||||
channels, | ||||
thisDatetime, | ||||
wintitle1 | ||||
) | ||||
if self.type == "iq": | ||||
self.plot_iq(self.data.heights, | ||||
scope[:,i,:], | ||||
channels, | ||||
thisDatetime, | ||||
wintitle1 | ||||
|
r1285 | ) | ||
r1296 | if self.CODE=="pp_power": | |||
self.plot_weatherpower(self.data.heights, | ||||
scope[:,i,:], | ||||
channels, | ||||
thisDatetime, | ||||
wintitle | ||||
) | ||||
r1312 | if self.CODE=="pp_signal": | |||
self.plot_weatherpower(self.data.heights, | ||||
scope[:,i,:], | ||||
channels, | ||||
thisDatetime, | ||||
wintitle | ||||
) | ||||
r1296 | if self.CODE=="pp_velocity": | |||
self.plot_weathervelocity(scope[:,i,:], | ||||
self.data.heights, | ||||
channels, | ||||
thisDatetime, | ||||
wintitle | ||||
) | ||||
r1305 | if self.CODE=="pp_spcwidth": | |||
self.plot_weatherspecwidth(scope[:,i,:], | ||||
self.data.heights, | ||||
channels, | ||||
thisDatetime, | ||||
wintitle | ||||
) | ||||
r1296 | else: | |||
wintitle = " [Profile = %d] " %self.data.profileIndex | ||||
if self.CODE== "scope": | ||||
if self.type == "power": | ||||
self.plot_power(self.data.heights, | ||||
scope, | ||||
channels, | ||||
thisDatetime, | ||||
wintitle | ||||
) | ||||
|
r1285 | |||
if self.type == "iq": | ||||
r1296 | self.plot_iq(self.data.heights, | |||
scope, | ||||
channels, | ||||
thisDatetime, | ||||
wintitle | ||||
|
r1285 | ) | ||
r1296 | if self.CODE=="pp_power": | |||
self.plot_weatherpower(self.data.heights, | ||||
scope, | ||||
channels, | ||||
thisDatetime, | ||||
wintitle | ||||
) | ||||
r1312 | if self.CODE=="pp_signal": | |||
self.plot_weatherpower(self.data.heights, | ||||
scope, | ||||
channels, | ||||
thisDatetime, | ||||
wintitle | ||||
) | ||||
r1296 | if self.CODE=="pp_velocity": | |||
self.plot_weathervelocity(scope, | ||||
self.data.heights, | ||||
channels, | ||||
thisDatetime, | ||||
wintitle | ||||
) | ||||
r1305 | if self.CODE=="pp_specwidth": | |||
self.plot_weatherspecwidth(scope, | ||||
self.data.heights, | ||||
channels, | ||||
thisDatetime, | ||||
wintitle | ||||
) | ||||
r1296 | ||||
class PulsepairPowerPlot(ScopePlot): | ||||
''' | ||||
r1312 | Plot for P= S+N | |||
r1296 | ''' | |||
CODE = 'pp_power' | ||||
plot_name = 'PulsepairPower' | ||||
plot_type = 'scatter' | ||||
buffering = False | ||||
class PulsepairVelocityPlot(ScopePlot): | ||||
''' | ||||
r1312 | Plot for VELOCITY | |||
r1296 | ''' | |||
CODE = 'pp_velocity' | ||||
plot_name = 'PulsepairVelocity' | ||||
plot_type = 'scatter' | ||||
buffering = False | ||||
r1305 | ||||
class PulsepairSpecwidthPlot(ScopePlot): | ||||
''' | ||||
r1312 | Plot for WIDTH | |||
r1305 | ''' | |||
CODE = 'pp_specwidth' | ||||
plot_name = 'PulsepairSpecwidth' | ||||
plot_type = 'scatter' | ||||
buffering = False | ||||
r1312 | ||||
class PulsepairSignalPlot(ScopePlot): | ||||
''' | ||||
Plot for S | ||||
''' | ||||
CODE = 'pp_signal' | ||||
plot_name = 'PulsepairSignal' | ||||
plot_type = 'scatter' | ||||
buffering = False | ||||