Radar data read functions


In this notebook, we will explore how to read radar data. The necessary routines are in pydarn.sdio


In [1]:
%pylab inline
from davitpy import pydarn
import davitpy.pydarn.sdio
import datetime as dt


Populating the interactive namespace from numpy and matplotlib
Loaded davitpyrc file from DaViTpy installation directory. Path: /usr/local/lib/python2.7/dist-packages/davitpy-0.5-py2.7-linux-x86_64.egg/davitpy
problem importing musicPlot:  No module named pydarn.proc.sam.cs10
problem importing proc:  No module named pydarn.proc.sam.cs10

In [2]:
#the first routine we will call is radDataOpen, which
#establishes a data piepeline.  we will now set up the args.

#sTime is the time we want to start reading (reqd input)
sTime = dt.datetime(2011,1,1,1,0)
print sTime

#rad is the 3-letter radar code for the radar we want (reqd input)
rad='bks'

#NOTE:the rest of the inputs are optional
#eTime is the end time we want to read until
eTime = dt.datetime(2011,1,1,2,0)
print eTime

#channel is the radar channel we want data from
#By default this is set to None.
#Note: For certain radars, like the UAF radars, the channel must
#be explicitly identified such as 'a'.
channel=None

#bmnum is the beam number we want data from.  by default this is
#None, which will read data from all beams
bmnum=7

#cp is the control program id number which we want data from
#by default, this is set to None which reads data from all cpids
cp=None

#fileType specifies the type of data we want.  valid inputs are
#'fitex','fitacf','lmfit','rawacf'.  by default this is 'fitex'
#if a fit type is requested but not found, the code will automatically
#look for other fit types
fileType='fitacf'

#filter is a boolean indicating whether to boxcar filter the data.
#this is onyl valid for fit types, and wont work on mongo data
filtered=False

#src is a string indicating the desired data source.  valid
#inputs are 'mongo','local','sftp'.  by default this is set to
#None which will sequentially try all sources
src=None


2011-01-01 01:00:00
2011-01-01 02:00:00

In [3]:
# Okay, now lets get the data connection
myPtr = pydarn.sdio.radDataOpen(sTime,rad,eTime=eTime,channel=channel,bmnum=bmnum,cp=cp,fileType=fileType,filtered=filtered, src=src)


Found cached file: /tmp/sd/20110101.010000.20110101.020000.bks.fitacf

In [4]:
# Note that the output or radDataOpen is of type radDataPtr
# Let's explore its contents

for key,val in myPtr.__dict__.iteritems():
    print 'myPtr.'+key+' = '+str(val)


myPtr.bmnum = 7
myPtr._radDataPtr__fd = 44
myPtr.dType = dmap
myPtr.stid = 33
myPtr.recordIndex = None
myPtr.eTime = 2011-01-01 02:00:00
myPtr.fBeam = None
myPtr.fType = fitacf
myPtr.sTime = 2011-01-01 01:00:00
myPtr._radDataPtr__ptr = <open file '<fdopen>', mode 'r' at 0x7f18775b0f60>
myPtr._radDataPtr__nocache = False
myPtr._radDataPtr__src = None
myPtr.cp = None
myPtr._radDataPtr__filtered = False
myPtr._radDataPtr__filename = /tmp/sd/20110101.010000.20110101.020000.bks.fitacf
myPtr.channel = None
myPtr.scanStartIndex = None

In [5]:
# Okay, now that we have our radDataPtr, we can use it to read data
# this is done with the command radDataReadRec
# this same command can be used for any type of data

myBeam = pydarn.sdio.radDataReadRec(myPtr)

In [6]:
#print myBeam
myBeam.time


Out[6]:
datetime.datetime(2011, 1, 1, 1, 0, 24, 789000)

In [7]:
# The output is of type beamData
# a beamData object can store fit data as well as rawacf and iqdat data
# let's look at the contents of myBeam
for key,val in myBeam.__dict__.iteritems():
    print 'myBeam.'+key+' = '+str(val)


myBeam.bmnum = 7
myBeam.fPtr = radDataPtr: 
bmnum = 7 
_radDataPtr__fd = 42 
dType = dmap 
stid = 33 
recordIndex = None 
eTime = 2011-01-01 02:00:00 
fBeam = None 
fType = fitacf 
sTime = 2011-01-01 01:00:00 
_radDataPtr__ptr = <open file '<fdopen>', mode 'r' at 0x5055540> 
_radDataPtr__nocache = False 
_radDataPtr__src = None 
cp = None 
_radDataPtr__filtered = False 
_radDataPtr__filename = /tmp/sd/20110101.010000.20110101.020000.bks.fitacf 
channel = None 
scanStartIndex = None 

myBeam.fitex = None
myBeam.fit = Fit data: 
pwr0 = [-0.21833011507987976, 0.13968463242053986, 0.30820024013519287, -0.9260621070861816, -1.1514275074005127, -0.5076453685760498, 0.18243050575256348, -0.711816668510437, 9.412342071533203, 16.95236587524414, 17.878822326660156, 12.581954002380371, 17.12259292602539, 9.397078514099121, 8.235315322875977, 13.186558723449707, 11.812653541564941, 7.72720193862915, 1.5565544366836548, 0.47042059898376465, 1.1336286067962646, -0.4580678343772888, 0.22475972771644592, -3.086376190185547, -0.711816668510437, -0.03563461825251579, -0.8176183700561523, -0.9260621070861816, -2.1919519901275635, -0.4580678343772888, -2.1919519901275635, 1.8848177194595337, -2.656881809234619, -3.9860594272613525, -1.093980312347412, -0.711816668510437, -1.1514275074005127, 0.30820024013519287, 0.5493136644363403, -1.268653154373169, 1.1336286067962646, 1.4625476598739624, -1.38913094997406, 0.5493136644363403, -4.980223178863525, 0.26668038964271545, -10.822977066040039, -0.4090498685836792, 0.5493136644363403, -1.6406017541885376, -0.21833011507987976, 1.2349460124969482, -0.9813165664672852, 0.5493136644363403, -0.711816668510437, 0.43043002486228943, 0.81467205286026, -0.3126431405544281, -0.21833011507987976, -2.047414779663086, -2.2660655975341797, -3.8763833045959473, -2.2660655975341797, -1.976910948753357, 0.22475972771644592, -50.0, -50.0, -50.0, 0.18243050575256348, -2.656881809234619] 
slist = [2, 8, 10, 11, 12, 13, 14, 15, 16, 17, 20, 22] 
w_l = [138.74026489257812, 43.539024353027344, 0.6493353247642517, 1.6484230756759644, -4.412018299102783, 9.254546165466309, 6.942862510681152, 7.636826038360596, 3.0262320041656494, 40.602718353271484, 643.6322631835938, 523.4571533203125] 
elv = [32.59687423706055, 26.37795639038086, 0.0, 24.54866600036621, 26.934911727905273, 28.57805633544922, 22.562835693359375, 22.156665802001953, 22.459936141967773, 21.954513549804688, 15.785314559936523, 55.064029693603516] 
npnts = None 
w_l_e = [5.953930377960205, 5.19649076461792, 5.158806324005127, 1.4379761219024658, 1.189875841140747, 2.1057329177856445, 1.908123254776001, 1.4389525651931763, 1.0569854974746704, 7.321878910064697, inf, inf] 
p_l = [2.670034885406494, 9.25997257232666, 18.01845932006836, 13.3980131149292, 16.81332778930664, 9.297369003295898, 8.088324546813965, 12.664401054382324, 12.118977546691895, 7.706979751586914, 3.2016682624816895, 2.6457300186157227] 
phi0_e = [0.46479469537734985, 0.27907952666282654, 0.0, 0.12355443835258484, 0.11108725517988205, 0.16809140145778656, 0.07972008734941483, 0.11370379477739334, 0.12237101793289185, 0.23927801847457886, 0.18395373225212097, 0.25038155913352966] 
p_s = [2.603121519088745, 8.9829683303833, 18.04033851623535, 13.365021705627441, 16.855609893798828, 9.230310440063477, 8.001919746398926, 12.606446266174316, 12.087944984436035, 7.4527997970581055, 3.2016682624816895, 2.6457300186157227] 
v_e = [43553.6171875, 0.5101032853126526, 4.642399311065674, 0.23154915869235992, 0.22681516408920288, 0.5481838583946228, 0.7038559913635254, 0.32628875970840454, 0.49605968594551086, 44571.22265625, 43811.37109375, 43045.87890625] 
p_l_e = [0.09204581379890442, 0.11987489461898804, 0.03923894464969635, 0.0366370752453804, 0.03165866807103157, 0.0543171688914299, 0.04633307084441185, 0.033681996166706085, 0.024508172646164894, 0.14297817647457123, inf, inf] 
phi0 = [-1.9876309633255005, -2.6518728733062744, 0.0, -2.819774627685547, -2.598233699798584, -2.433204174041748, -2.9875330924987793, -3.0199666023254395, -2.9958102703094482, -3.035869836807251, 2.8393986225128174, 1.4915300607681274] 
v = [-48.64402389526367, -0.4383976459503174, -0.3681160807609558, -0.2367650419473648, 0.20885761082172394, -0.16632406413555145, 9.907879829406738, -0.7963374853134155, -6.197230339050293, -1.216323971748352, -47.048763275146484, -18.96500015258789] 
w_s_e = [10.72645378112793, 8.419829368591309, 33.533241271972656, 47.87622833251953, 5.638611316680908, 6.164793491363525, 8.265538215637207, 4.823324203491211, 6.33505916595459, 14.227460861206055, inf, inf] 
qflg = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] 
p_s_e = [0.1793357878923416, 0.11352382600307465, 0.0321536511182785, 0.0308969859033823, 0.027072491124272346, 0.04503723233938217, 0.03752046450972557, 0.027695685625076294, 0.019984036684036255, 0.14293405413627625, inf, inf] 
gflg = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0] 
nlag = [5, 9, 5, 14, 13, 13, 17, 18, 17, 7, 5, 6] 
w_s = [247.65158081054688, 110.34780883789062, 73.43885803222656, 4.27560567855835, -30.78844451904297, 48.869529724121094, 33.05845642089844, 43.701499938964844, 23.759803771972656, 105.42868041992188, 464.567626953125, 382.4546813964844] 

myBeam.prm = Prm data: 
ptab  = [0, 9, 12, 20, 22, 26, 27] 
mplgs  = 18 
nave  = 29 
noisesearch  = 21.1200447083 
scan  = 0 
smsep  = 300 
mplgexs  = 0 
xcf  = 1 
noisesky  = 97.9000015259 
rsep  = 45 
mppul  = 7 
txpl  = 300 
inttsc  = 3 
frang  = 180 
bmazm  = -33.9300003052 
lagfr  = 1200 
ifmode  = -1 
noisemean  = 0.0 
tfreq  = 10954 
inttus  = 0 
rxrise  = 100 
ltab  = [[0, 0], [26, 27], [20, 22], [9, 12], [22, 26], [22, 27], [20, 26], [20, 27], [0, 9], [12, 22], [9, 20], [0, 12], [9, 22], [12, 26], [12, 27], [9, 26], [9, 27], [27, 27]] 
mpinc  = 2400 
nrang  = 70 

myBeam.recordDict = {'x_p_l': [-0.6410897374153137, 6.755218029022217, -50.0, 11.285459518432617, 16.9647274017334, 6.894476413726807, 5.198225498199463, 10.58592700958252, 10.541553497314453, 4.920353889465332, -0.019550831988453865, -2.353917121887207], 'origin.command': 'make_fit -new', 'mplgs': 18, 'txpow': 9000, 'nave': 29, 'x_gflg': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 'x_sd_phi': [0.6285284757614136, 0.41949689388275146, 0.0, 0.230211541056633, 0.24607683718204498, 0.3132384717464447, 0.17750707268714905, 0.2575702369213104, 0.260303795337677, 0.3601974546909332, 0.41656583547592163, 0.30354368686676025], 'scan': 0, 'time': 1293843624.789, 'atten': 0, 'noise.vel': 0.0, 'smsep': 300, 'stat.lopwr': 0, 'v_e': [43553.6171875, 0.5101032853126526, 4.642399311065674, 0.23154915869235992, 0.22681516408920288, 0.5481838583946228, 0.7038559913635254, 0.32628875970840454, 0.49605968594551086, 44571.22265625, 43811.37109375, 43045.87890625], 'x_v_e': [52.452022552490234, 22.756593704223633, 0.0, 10.631864547729492, 9.5885648727417, 13.371294975280762, 6.733257293701172, 10.805153846740723, 10.800495147705078, 23.61043930053711, 20.962448120117188, 22.969240188598633], 'x_w_s': [86.8845443725586, -79.5556640625, 0.0, -42.49301528930664, 12.521016120910645, -58.494205474853516, -60.04588317871094, 41.278350830078125, -81.48512268066406, -105.023193359375, 131.03466796875, -108.64240264892578], 'mplgexs': 0, 'x_p_s': [-0.6986252069473267, 6.903881072998047, -50.0, 11.45840835571289, 16.924001693725586, 6.852689743041992, 5.272835731506348, 10.554282188415527, 10.548338890075684, 5.219995021820068, -0.19322027266025543, -1.832720160484314], 'radar.revision.minor': '\x02', 'xcf': 1, 'nlag': [5, 9, 5, 14, 13, 13, 17, 18, 17, 7, 5, 6], 'cp': 153, 'gflg': [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0], 'p_s': [2.603121519088745, 8.9829683303833, 18.04033851623535, 13.365021705627441, 16.855609893798828, 9.230310440063477, 8.001919746398926, 12.606446266174316, 12.087944984436035, 7.4527997970581055, 3.2016682624816895, 2.6457300186157227], 'w_s': [247.65158081054688, 110.34780883789062, 73.43885803222656, 4.27560567855835, -30.78844451904297, 48.869529724121094, 33.05845642089844, 43.701499938964844, 23.759803771972656, 105.42868041992188, 464.567626953125, 382.4546813964844], 'p_l': [2.670034885406494, 9.25997257232666, 18.01845932006836, 13.3980131149292, 16.81332778930664, 9.297369003295898, 8.088324546813965, 12.664401054382324, 12.118977546691895, 7.706979751586914, 3.2016682624816895, 2.6457300186157227], 'origin.code': '\x00', 'pwr0': [-0.21833011507987976, 0.13968463242053986, 0.30820024013519287, -0.9260621070861816, -1.1514275074005127, -0.5076453685760498, 0.18243050575256348, -0.711816668510437, 9.412342071533203, 16.95236587524414, 17.878822326660156, 12.581954002380371, 17.12259292602539, 9.397078514099121, 8.235315322875977, 13.186558723449707, 11.812653541564941, 7.72720193862915, 1.5565544366836548, 0.47042059898376465, 1.1336286067962646, -0.4580678343772888, 0.22475972771644592, -3.086376190185547, -0.711816668510437, -0.03563461825251579, -0.8176183700561523, -0.9260621070861816, -2.1919519901275635, -0.4580678343772888, -2.1919519901275635, 1.8848177194595337, -2.656881809234619, -3.9860594272613525, -1.093980312347412, -0.711816668510437, -1.1514275074005127, 0.30820024013519287, 0.5493136644363403, -1.268653154373169, 1.1336286067962646, 1.4625476598739624, -1.38913094997406, 0.5493136644363403, -4.980223178863525, 0.26668038964271545, -10.822977066040039, -0.4090498685836792, 0.5493136644363403, -1.6406017541885376, -0.21833011507987976, 1.2349460124969482, -0.9813165664672852, 0.5493136644363403, -0.711816668510437, 0.43043002486228943, 0.81467205286026, -0.3126431405544281, -0.21833011507987976, -2.047414779663086, -2.2660655975341797, -3.8763833045959473, -2.2660655975341797, -1.976910948753357, 0.22475972771644592, -50.0, -50.0, -50.0, 0.18243050575256348, -2.656881809234619], 'stat.agc': 0, 'intt.sc': 3, 'noise.mean': 0.0, 'intt.us': 0, 'x_w_l_e': [18.16196632385254, 12.141814231872559, 0.0, 2.9888112545013428, 1.612946629524231, 3.4955859184265137, 4.086426734924316, 2.9291563034057617, 3.4245424270629883, 10.398457527160645, 20.533992767333984, 23.3641357421875], 'stid': 33, 'mxpwr': 1073741824, 'slist': [2, 8, 10, 11, 12, 13, 14, 15, 16, 17, 20, 22], 'x_sd_l': [0.1088167130947113, 0.1119116023182869, 0.0, 0.032358333468437195, 0.020696988329291344, 0.04094412922859192, 0.05386469140648842, 0.03491220623254776, 0.04126761853694916, 0.07931867986917496, 0.17206992208957672, 0.13924650847911835], 'noise.lag0': 0.0, 'p_s_e': [0.1793357878923416, 0.11352382600307465, 0.0321536511182785, 0.0308969859033823, 0.027072491124272346, 0.04503723233938217, 0.03752046450972557, 0.027695685625076294, 0.019984036684036255, 0.14293405413627625, inf, inf], 'w_l_e': [5.953930377960205, 5.19649076461792, 5.158806324005127, 1.4379761219024658, 1.189875841140747, 2.1057329177856445, 1.908123254776001, 1.4389525651931763, 1.0569854974746704, 7.321878910064697, inf, inf], 'x_sd_s': [0.10849948227405548, 0.11171045899391174, 0.0, 0.0341142974793911, 0.020855767652392387, 0.03846437484025955, 0.0537739172577858, 0.034912411123514175, 0.0374005064368248, 0.08623339235782623, 0.18541020154953003, 0.14392593502998352], 'rsep': 45, 'p_l_e': [0.09204581379890442, 0.11987489461898804, 0.03923894464969635, 0.0366370752453804, 0.03165866807103157, 0.0543171688914299, 0.04633307084441185, 0.033681996166706085, 0.024508172646164894, 0.14297817647457123, inf, inf], 'mppul': 7, 'ercod': 0, 'fitacf.revision.minor': 0, 'radar.revision.major': '\x01', 'channel': 1, 'ltab': [[0, 0], [26, 27], [20, 22], [9, 12], [22, 26], [22, 27], [20, 26], [20, 27], [0, 9], [12, 22], [9, 20], [0, 12], [9, 22], [12, 26], [12, 27], [9, 26], [9, 27], [27, 27]], 'elv_high': [28.3917179107666, 23.25302505493164, 0.0, 23.103954315185547, 25.767471313476562, 26.9034423828125, 21.549495697021484, 20.663501739501953, 20.87383460998535, 18.619041442871094, 11.761178970336914, 53.71719741821289], 'frang': 180, 'bmazm': -33.93000030517578, 'x_qflg': [1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1], 'noise.sky': 97.9000015258789, 'x_w_s_e': [40.39364242553711, 20.506874084472656, 0.0, 10.931352615356445, 18.244220733642578, 7.732712745666504, 9.238903999328613, 10.459458351135254, 5.478457450866699, 19.448078155517578, 29.731237411499023, 39.57997131347656], 'fitacf.revision.major': 5, 'lagfr': 1200, 'x_v': [-5.7442731857299805, 0.7775803804397583, 0.0, 5.212981700897217, -0.11861176788806915, 1.1657949686050415, 23.32044792175293, 1.643282413482666, -5.962759494781494, 3.1376476287841797, -334.80169677734375, -346.0870056152344], 'lvmax': 20000, 'sd_l': [0.036861591041088104, 0.04912198334932327, 0.011641356162726879, 0.018592868000268936, 0.014480962418019772, 0.024991372600197792, 0.024652812629938126, 0.019337262958288193, 0.013934565708041191, 0.05689113214612007, inf, inf], 'w_s_e': [10.72645378112793, 8.419829368591309, 33.533241271972656, 47.87622833251953, 5.638611316680908, 6.164793491363525, 8.265538215637207, 4.823324203491211, 6.33505916595459, 14.227460861206055, inf, inf], 'x_p_l_e': [0.34947502613067627, 0.32333940267562866, 0.0, 0.07542263716459274, 0.040577467530965805, 0.09542152285575867, 0.10506077110767365, 0.06693308800458908, 0.08425424247980118, 0.22883474826812744, 0.3964177370071411, 0.5530440807342529], 'phi0': [-1.9876309633255005, -2.6518728733062744, 0.0, -2.819774627685547, -2.598233699798584, -2.433204174041748, -2.9875330924987793, -3.0199666023254395, -2.9958102703094482, -3.035869836807251, 2.8393986225128174, 1.4915300607681274], 'ifmode': -1, 'offset': 400, 'sd_s': [0.07252834737300873, 0.054977331310510635, 0.011208303272724152, 0.018665030598640442, 0.014780092053115368, 0.025271687656641006, 0.025084685534238815, 0.019573966041207314, 0.014059769921004772, 0.06592302024364471, inf, inf], 'bmnum': 7, 'x_p_s_e': [0.2987150251865387, 0.25673604011535645, 0.0, 0.06497453153133392, 0.034711599349975586, 0.07869884371757507, 0.08476383239030838, 0.05498400703072548, 0.06607280671596527, 0.21483230590820312, 0.4145508110523224, 0.4802868962287903], 'elv_low': [36.323150634765625, 29.155765533447266, 0.0, 25.908018112182617, 28.05190086364746, 30.157596588134766, 23.529001235961914, 23.547365188598633, 23.932653427124023, 24.809743881225586, 18.8524227142334, 56.38681411743164], 'noise.search': 21.120044708251953, 'tfreq': 10954, 'ptab': [0, 9, 12, 20, 22, 26, 27], 'txpl': 300, 'elv': [32.59687423706055, 26.37795639038086, 0.0, 24.54866600036621, 26.934911727905273, 28.57805633544922, 22.562835693359375, 22.156665802001953, 22.459936141967773, 21.954513549804688, 15.785314559936523, 55.064029693603516], 'origin.time': 'Wed Feb  1 14:00:22 2012', 'x_w_l': [18.689571380615234, -23.047637939453125, 0.0, -12.588224411010742, 2.4633755683898926, -7.912283420562744, -12.816840171813965, 5.781503200531006, -17.92015838623047, -40.646244049072266, 59.4931755065918, -51.06681442260742], 'phi0_e': [0.46479469537734985, 0.27907952666282654, 0.0, 0.12355443835258484, 0.11108725517988205, 0.16809140145778656, 0.07972008734941483, 0.11370379477739334, 0.12237101793289185, 0.23927801847457886, 0.18395373225212097, 0.25038155913352966], 'w_l': [138.74026489257812, 43.539024353027344, 0.6493353247642517, 1.6484230756759644, -4.412018299102783, 9.254546165466309, 6.942862510681152, 7.636826038360596, 3.0262320041656494, 40.602718353271484, 643.6322631835938, 523.4571533203125], 'rxrise': 100, 'combf': 'A SuperDARN', 'v': [-48.64402389526367, -0.4383976459503174, -0.3681160807609558, -0.2367650419473648, 0.20885761082172394, -0.16632406413555145, 9.907879829406738, -0.7963374853134155, -6.197230339050293, -1.216323971748352, -47.048763275146484, -18.96500015258789], 'mpinc': 2400, 'qflg': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 'nrang': 70, 'sd_phi': [0.1615460366010666, 0.016509881243109703, 0.03636876493692398, 0.0101867550984025, 0.010033167898654938, 0.023569706827402115, 0.03260679915547371, 0.014968696050345898, 0.02187310717999935, 0.03707275539636612, 0.2356281280517578, 0.1499413549900055]}
myBeam.stid = 33
myBeam.lmfit = None
myBeam.exflg = None
myBeam.iqflg = None
myBeam.offset = 5075345
myBeam.rawacf = Raw data: 
pwr0 = [] 
acfd = [] 
xcfd = [] 
parent = Beam record FROM: 2011-01-01 01:00:24.789000
bmnum  = 7 
fPtr  = object 
fitex  = None 
fit  = object 
prm  = object 
recordDict  = object 
stid  = 33 
lmfit  = None 
exflg  = None 
iqflg  = None 
offset  = 5075345 
rawacf  = object 
lmflg  = None 
rawflg  = None 
fType  = fitacf 
time  = 2011-01-01 01:00:24.789000 
acflg  = None 
cp  = 153 
iqdat  = object 
fitacf  = None 
channel  = 1 
 

myBeam.lmflg = None
myBeam.rawflg = None
myBeam.fType = fitacf
myBeam.time = 2011-01-01 01:00:24.789000
myBeam.acflg = None
myBeam.cp = 153
myBeam.iqdat = IQ data: 
chnnum = None 
badtr = None 
tsze = None 
skpnum = None 
seqnum = None 
smpnum = None 
tus = None 
tsc = None 
intData = [] 
tbadtr = None 
mainData = [] 
toff = None 
tnoise = None 
tatten = None 
btnum = None 

myBeam.fitacf = None
myBeam.channel = 1

In [8]:
# See that the rawacf, fit, and prm attributes are objects
# the rawacf object is empty, since we read fitacf data
# lets look at the prm object
for key,val in myBeam.prm.__dict__.iteritems():
    print 'myBeam.prm.'+key+' = '+str(val)


myBeam.prm.ptab = [0, 9, 12, 20, 22, 26, 27]
myBeam.prm.mplgs = 18
myBeam.prm.nave = 29
myBeam.prm.noisesearch = 21.1200447083
myBeam.prm.scan = 0
myBeam.prm.smsep = 300
myBeam.prm.mplgexs = 0
myBeam.prm.xcf = 1
myBeam.prm.noisesky = 97.9000015259
myBeam.prm.rsep = 45
myBeam.prm.mppul = 7
myBeam.prm.txpl = 300
myBeam.prm.inttsc = 3
myBeam.prm.frang = 180
myBeam.prm.bmazm = -33.9300003052
myBeam.prm.lagfr = 1200
myBeam.prm.ifmode = -1
myBeam.prm.noisemean = 0.0
myBeam.prm.tfreq = 10954
myBeam.prm.inttus = 0
myBeam.prm.rxrise = 100
myBeam.prm.ltab = [[0, 0], [26, 27], [20, 22], [9, 12], [22, 26], [22, 27], [20, 26], [20, 27], [0, 9], [12, 22], [9, 20], [0, 12], [9, 22], [12, 26], [12, 27], [9, 26], [9, 27], [27, 27]]
myBeam.prm.mpinc = 2400
myBeam.prm.nrang = 70

In [9]:
# And lets look at whats in the fit object
for key in myBeam.fit.__dict__.keys():
    print 'myBeam.fit.'+key


myBeam.fit.pwr0
myBeam.fit.slist
myBeam.fit.w_l
myBeam.fit.elv
myBeam.fit.npnts
myBeam.fit.w_l_e
myBeam.fit.p_l
myBeam.fit.phi0_e
myBeam.fit.p_s
myBeam.fit.v_e
myBeam.fit.p_l_e
myBeam.fit.phi0
myBeam.fit.v
myBeam.fit.w_s_e
myBeam.fit.qflg
myBeam.fit.p_s_e
myBeam.fit.gflg
myBeam.fit.nlag
myBeam.fit.w_s

In [10]:
# we can read to the end of the specified time period, like so:
vel, t = [], []
while(myBeam != None):
    vel.append( myBeam.fit.v )
    t.append( myBeam.time )
    myBeam = pydarn.sdio.radDataReadRec(myPtr)


reached end of data

In [11]:
# For instance, we could look at the velocity distribution during that period
ax = gca()
for i in range(len(t)):
    if not vel[i]: continue
    scatter([date2num(t[i])]*len(vel[i]), vel[i], s=1)
ylim([-400, 400])
xlim([date2num(sTime), date2num(eTime)])
tloc = MinuteLocator(interval=10)
tfmt = DateFormatter('%H:%M')
ax.xaxis.set_major_locator(tloc)
ax.xaxis.set_major_formatter(tfmt)
ylabel('Velocity [m/s]')
grid()



In [12]:
# Now, let's try and example where we read rawacf data (this is slow)
myPtr = pydarn.sdio.radDataOpen(sTime,rad,eTime=eTime,channel=channel,bmnum=bmnum,cp=cp,fileType='rawacf',filtered=filtered, src=src)
myBeam = pydarn.sdio.radDataReadRec(myPtr)
print '\n'
for key in myBeam.rawacf.__dict__.keys():
    print 'myBeam.rawacf.'+key


Looking locally for rawacf files with radcode: bks channel: None
found rawacf data in local files
Concatenating all the files in to one
cat /tmp/sd/20110101.0001.00.bks.rawacf /tmp/sd/20110101.0201.00.bks.rawacf > /tmp/sd/20110101.010000.20110101.020000.bks.rawacf
rm /tmp/sd/20110101.0001.00.bks.rawacf
rm /tmp/sd/20110101.0201.00.bks.rawacf


myBeam.rawacf.pwr0
myBeam.rawacf.acfd
myBeam.rawacf.xcfd
myBeam.rawacf.parent

In [13]:
# this is a little dense, so lets look at the ACF just for range gate 0, and the lag table
print myBeam.rawacf.acfd[0]
print myBeam.prm.ltab


[[191.6206817626953, 0.0], [-43.7931022644043, -21.517240524291992], [48.86206817626953, 74.68965148925781], [6.413793087005615, -49.034481048583984], [43.10344696044922, -1.482758641242981], [-53.89655303955078, -132.55172729492188], [-3.2413792610168457, -26.10344886779785], [66.96551513671875, -61.75862121582031], [-19.689655303955078, 36.517242431640625], [20.34482765197754, 70.03448486328125], [-31.931034088134766, 15.793103218078613], [-8.965517044067383, -35.75862121582031], [-43.75862121582031, -74.5862045288086], [1.137930989265442, 16.10344886779785], [38.482757568359375, -42.44827651977539], [-4.758620738983154, 29.413793563842773], [-0.9655172228813171, -34.2068977355957], [753.586181640625, 0.0]]
[[0, 0], [26, 27], [20, 22], [9, 12], [22, 26], [22, 27], [20, 26], [20, 27], [0, 9], [12, 22], [9, 20], [0, 12], [9, 22], [12, 26], [12, 27], [9, 26], [9, 27], [27, 27]]

In [14]:
# we can plot this, like so:
import matplotlib.pyplot as plt
lags,re,im = [],[],[]
for i in range(len(myBeam.prm.ltab)-1):
    lags.append(myBeam.prm.ltab[i][1]-myBeam.prm.ltab[i][0])
    re.append(myBeam.rawacf.acfd[0][i][0])
    im.append(myBeam.rawacf.acfd[0][i][1])
fig = plt.figure()
plt.plot(lags,re,'ro-')
plt.plot(lags,im,'bo-')
plt.show()



In [15]:
# And finally, lets try an iqdat file
# THIS IS VERY SLOOOOOW
myPtr = pydarn.sdio.radDataOpen(dt.datetime(2012,1,1,1,0),'fhe',eTime=dt.datetime(2012,1,1,1,30),channel=channel,bmnum=bmnum,cp=cp,fileType='iqdat',filtered=filtered, src=src)
myBeam = pydarn.sdio.radDataReadRec(myPtr)
for key in myBeam.iqdat.__dict__.keys():
    print 'myBeam.iqdat.'+key


Looking locally for iqdat files with radcode: fhe channel: None
found iqdat data in local files
Concatenating all the files in to one
cat /tmp/sd/20120101.0001.00.fhe.iqdat > /tmp/sd/20120101.010000.20120101.013000.fhe.iqdat
rm /tmp/sd/20120101.0001.00.fhe.iqdat
myBeam.iqdat.chnnum
myBeam.iqdat.badtr
myBeam.iqdat.tsze
myBeam.iqdat.skpnum
myBeam.iqdat.seqnum
myBeam.iqdat.smpnum
myBeam.iqdat.tus
myBeam.iqdat.tsc
myBeam.iqdat.intData
myBeam.iqdat.tbadtr
myBeam.iqdat.mainData
myBeam.iqdat.toff
myBeam.iqdat.tnoise
myBeam.iqdat.tatten
myBeam.iqdat.btnum

In [16]:
# again this is dense, lets plot a single pulse sequence iqdat
# we can plot this, like so:
samp = []
iq = [[],[]]
for i in range(myBeam.iqdat.smpnum):
    samp.append(i)
    iq[0].append(myBeam.iqdat.mainData[0][i][0])
    iq[1].append(myBeam.iqdat.mainData[0][i][1])
fig = plt.figure()
plt.plot(samp,iq[0],'r-')
plt.plot(samp,iq[1],'b-')
plt.show()



In [ ]:
# this concludes our tutorial on how to read radar data.

# ENJOY!