Closed GWPerryNJIT closed 8 years ago
There are just some problems with how you are using davitpy. For example, your line:
mObj=utils.plotUtils.mapObj(dateTime=sTime,lon_0=93.11,lat_0=72.6,showCoords='True',gridLabels='True',grid='True', height=111E340,width=111E340)
Notice the E340. That's way too big. I've changed this to 11E6 in my running of the code.
As of #239 you don't need the line mObj.ax=ax
anymore. Also, this line:
overlayFan(myBeam.fit.p_l,mObj,fig,param,site=myBeam.stid)
The param
variable is not defined. I set this to 'power'
instead. And was able to reproduce your error.
The problem is that you are using overlayFan incorrectly. From the docstring:
Signature: overlayFan(myData, myMap, myFig, param, coords='geo', gsct=0, site=None, fov=None, gs_flg=[], fill=True, velscl=1000.0, dist=1000.0, cmap=None, norm=None, alpha=1)
A function of overlay radar scan data on a map
Parameters
----------
myData : pydarn.sdio.radDataTypes.scanData or
pydarn.sdio.radDataTypes.beamData or
list of pydarn.sdio.radDataTypes.beamData objects
A radar beam object, a radar scanData object, or simply a list of
radar beams
...
The myData variable needs to be a scanData object. A scanData object is just a list of beamData objects, so you should use [myBeam]
instead of myBeam.fit.p_l
. Also, the site variable needs to be a site object, not the station id.
Try this instead:
site = pydarn.radar.site(radId=myBeam.stid, dt=sTime)
overlayFan([myBeam],mObj,fig,'power',site=site)
Here's my working version of your 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()
I did find that there's an unrelated bug in overlayFan
. The docstring says you can pass a beamData
object to overlayFan
, but if you try that, the code spits out the error:
AttributeError: beamData instance has no attribute '__getitem__'
Bug report filed here: #255
Hi all,
I'm trying to overlay some fan data onto an existing map. Here's my code (I'm a newbie by the way):
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=111E3_40,width=111E3_40) mObj.ax=ax
mObj.nightshade(sTime,alpha=0.1)
overlayRadar(mObj,codes='rkn',fontSize=12)
overlayFov(mObj,maxGate=75,codes='rkn',lineWidth=2)
overlayFan(myBeam.fit.p_l,mObj,fig,param,site=myBeam.stid)
The program barfs out:
AttributeError Traceback (most recent call last)