vtsuperdarn/davitpy — pull request #105 by w2naf (2014-09-25 18:28:52+00:00)
Title: Bugfix read scan

**Summary:** A bug in pydarn.sdio.readScan() results in an error when looping through all scans until the end of the data file. This pull request fixes this bug. readScan() has also been re-tabbed for PEP8.

To see the bug, please use the develop branch to run the MUSIC.ipynb notebook or execute the following code:

```python
import datetime
import pydarn
rad = 'wal'
sTime = datetime.datetime(2011,5,9,8)
eTime = datetime.datetime(2011,5,9,19)
myPtr = pydarn.sdio.radDataOpen(sTime,rad,eTime=eTime)
dataObj = pydarn.proc.music.musicArray(myPtr,fovModel='GS')
```

Under the develop branch, you will see:

```
In [1]: run music_test.py
Found cached file: /tmp/sd/20110509.080000.20110509.190000.wal.fitex

reached end of data

reached end of data
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/home/w2naf/music_test.py in ()
5 eTime = datetime.datetime(2011,5,9,19)
6 myPtr = pydarn.sdio.radDataOpen(sTime,rad,eTime=eTime)
----> 7 dataObj = pydarn.proc.music.musicArray(myPtr,fovModel='GS')

/usr/local/lib/python2.7/dist-packages/davitpy-0.2-py2.7-linux-x86_64.egg/pydarn/proc/music/music.pyc in __init__(self, myPtr, sTime, eTime, param, gscat, fovElevation, fovModel, fovCoords)
520 while beamTime < eTime:
521 #Load one scan into memory.
--> 522 myScan = pydarn.sdio.radDataRead.radDataReadScan(myPtr)
523 if myScan == None: break
524

/usr/local/lib/python2.7/dist-packages/davitpy-0.2-py2.7-linux-x86_64.egg/pydarn/sdio/radDataRead.pyc in radDataReadScan(myPtr)
172 assert(isinstance(myPtr,radDataPtr)),\
173 'error, input must be of type radDataPtr'
--> 174 return myPtr.readScan()
175
176 def radDataCreateIndex(myPtr):

/usr/local/lib/python2.7/dist-packages/davitpy-0.2-py2.7-linux-x86_64.egg/pydarn/sdio/radDataTypes.pyc in readScan(self)
500 myScan = scanData()
501 myBeam=self.readRec()
--> 502 if(myBeam.prm.scan == 1):
503 firstflg=True
504 myScan.append(myBeam)

AttributeError: 'NoneType' object has no attribute 'prm'
```

**Testing:** To test this bugfix, please run the MUSIC.ipynb notebook or the above code.