jroplot_voltage.py
134 lines
| 3.8 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 | ||||
''' | ||||
CODE = 'scope' | ||||
plot_name = 'Scope' | ||||
plot_type = 'scatter' | ||||
|
r487 | |||
|
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): | ||||
|
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" | ||||
|
r487 | |||
|
r1285 | self.y = yreal | ||
self.x = x | ||||
self.xmin = min(x) | ||||
self.xmax = max(x) | ||||
|
r487 | |||
|
r1285 | 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,:]) | ||||
def plot_power(self, x, y, channelIndexList, thisDatetime, wintitle): | ||||
|
r487 | y = y[channelIndexList,:] * numpy.conjugate(y[channelIndexList,:]) | ||
yreal = y.real | ||||
|
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) | ||||
|
r487 | |||
|
r1285 | self.titles[0] = title | ||
for i,ax in enumerate(self.axes): | ||||
title = "Channel %d" %(i) | ||||
|
r487 | |||
|
r1285 | ychannel = yreal[i,:] | ||
|
r487 | |||
|
r1285 | if ax.firsttime: | ||
ax.plt_r = ax.plot(x, ychannel)[0] | ||||
else: | ||||
#pass | ||||
ax.plt_r.set_data(x, ychannel) | ||||
|
r487 | |||
|
r1285 | def plot(self): | ||
|
r487 | |||
|
r1285 | if self.channels: | ||
channels = self.channels | ||||
|
r487 | else: | ||
|
r1285 | channels = self.data.channels | ||
thisDatetime = datetime.datetime.utcfromtimestamp(self.data.times[-1]) | ||||
|
r487 | |||
|
r1285 | scope = self.data['scope'] | ||
|
r487 | |||
|
r1285 | if self.data.flagDataAsBlock: | ||
|
r742 | |||
|
r1285 | for i in range(self.data.nProfiles): | ||
wintitle1 = " [Profile = %d] " %i | ||||
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 | ||||
) | ||||
|
r742 | else: | ||
|
r1285 | wintitle = " [Profile = %d] " %self.data.profileIndex | ||
|
r742 | |||
|
r1285 | if self.type == "power": | ||
self.plot_power(self.data.heights, | ||||
scope, | ||||
channels, | ||||
thisDatetime, | ||||
wintitle | ||||
) | ||||
|
r742 | |||
|
r1285 | if self.type == "iq": | ||
self.plot_iq(self.data.heights, | ||||
scope, | ||||
channels, | ||||
thisDatetime, | ||||
wintitle | ||||
) | ||||