vtsuperdarn / davitpy

DEPRECATED The DaViT Python project
http://vtsuperdarn.github.com/davitpy/
GNU General Public License v3.0
37 stars 59 forks source link

overlayFan can't use beamData objects #255

Closed asreimer closed 8 years ago

asreimer commented 8 years ago

As reported in #254, running the code:

import datetime
import os
import davitpy.utils
import matplotlib.pyplot as plt
from davitpy import pydarn
from davitpy.pydarn.plotting import *

sTime = datetime.datetime(2016,5,7,1,36)
eTime = datetime.datetime(2016,5,7,1,41)
radar = 'rkn'
beam = 7
cp=None
filtered=False
src=None
fileType='fitex'
channel=None

myPtr=pydarn.sdio.radDataOpen(sTime,radar,eTime=eTime,channel=channel,bmnum=beam,cp=cp,fileType=fileType,filtered=filtered)
myBeam=pydarn.sdio.radDataReadRec(myPtr)

fig = plt.figure(figsize=(14,12))
ax=fig.add_subplot(111)

mObj=utils.plotUtils.mapObj(dateTime=sTime,lon_0=93.11,lat_0=72.6,showCoords='True',gridLabels='True',grid='True', height=11E6,width=11E6)
mObj.nightshade(sTime,alpha=0.1)
overlayRadar(mObj,codes='rkn',fontSize=12)
overlayFov(mObj,maxGate=75,codes='rkn',lineWidth=2)
site = pydarn.radar.site(radId=myBeam.stid, dt=sTime)
overlayFan(myBeam,mObj,fig,'power',site=site)
fig.show()

Produces the error:

AttributeError: beamData instance has no attribute '__getitem__'

Despite the overlayFan docstring stating that a beamData object can be passed to overlayFan.

A workaround for this is to wrap any beamData object in square brackets since a scanData object is just a list of beamData objects and overlayFan works fine with scanData objects. TL;DR: replace the offending line of code with:

overlayFan([myBeam],mObj,fig,'power',site=site)
asreimer commented 8 years ago

Bugfix is now available in #259.