pydarn.sdio.dbUtils

Module: pydarn.sdio.dbUtils

Functions:
  • getServerConn()
  • getDbConn()
  • getDataConn()
  • updateDbDict()
  • readFromDb()
  • mapDbFit()
pydarn.sdio.dbUtils.getDataConn(username='sd_dbread', password='5d', dbAddress='sd-work9.ece.vt.edu:27017', dbName='radData', collName='beams')[source]

PACKAGE: pydarn.sdio.dbUtils FUNCTION: getDataConn([username],[password],[dbAddress],[dbName],[collName]) PURPOSE: gets a connection to the collection collName on the

mongodb server. This is the highetst level connection

NOTE: mongodb hierarchy goes SERVER->DATABASE->COLLECTION

INPUTS:
[username]: the username to connect with.
default is the read-only user defined in .bashrc
[password]: the password corresponding to the user username.
default is defined in .bashrc
[dbAddress]: the address of the database to be accessed,
eg sd-work9.ece.vt.edu:27017. Default is defined in .bashrc
[dbName]: the name of the database to connect to.
default is ‘radData’, where fit data is stored
[collName]: the name of the collection to connect to.
default is ‘beams’, where beam sounding data is stored
OUTPUTS:
dataConn: a connection to the database
EXAMPLES:
dataConn = getDbConn(username=’auser’,password=’apass’, dbAddress=’sd-work9.ece.vt.edu:27017’, dbName=’aDb’,collName=’acoll’)

Written by AJ 20130108

pydarn.sdio.dbUtils.getDbConn(username='sd_dbread', password='5d', dbAddress='sd-work9.ece.vt.edu:27017', dbName='radData')[source]

PACKAGE: pydarn.sdio.dbUtils FUNCTION: getDbConn([username],[password],[dbAddress],[dbName]) PURPOSE: gets a connection to the database ‘dbname’. on the

mongodb server This is the middle-tier connection. In order to actually access data, this connection must be used to get a data connection.

NOTE: mongodb hierarchy goes SERVER->DATABASE->COLLECTION

INPUTS:
[username]: the username to connect with.
default is the read-only user defined in .bashrc
[password]: the password corresponding to the user username.
default is defined in .bashrc
[dbAddress]: the address of the database to be accessed,
eg sd-work9.ece.vt.edu:27017. Default is defined in .bashrc
[dbName]: the name of the database to connect to.
default is ‘radData’, where fit data is stored
OUTPUTS:
dbConn: a connection to the database
EXAMPLES:
dbConn = getDbConn(username=’auser’,password=’apass’, dbAddress=’sd-work9.ece.vt.edu:27017’,dbname=’aDb’)

Written by AJ 20130108

pydarn.sdio.dbUtils.getServerConn(username='sd_dbread', password='5d', dbAddress='sd-work9.ece.vt.edu:27017')[source]

PACKAGE: pydarn.sdio.dbUtils FUNCTION: getServerConn([username],[password]) PURPOSE: gets a connection to the mongodb server. This is the

most basic connection. In order to actually access data, this connection must be used to get a database connection which can in turn be used to get a data connection.

NOTE: mongodb hierarchy goes SERVER->DATABASE->COLLECTION

INPUTS:
[username]: the username to connect with.
default is the read-only user defined in .bashrc
[password]: the password corresponding to the user username.
default is defined in .bashrc
[dbAddress]: the address of the database to be accessed,
eg sd-work9.ece.vt.edu:27017. Default is defined in .bashrc
OUTPUTS:
sConn: a connection to the mongodb server
EXAMPLES:
sConn = getServerConn(username=’auser’,password=’apass’, dbAddress=’sd-work9.ece.vt.edu:27017’)

Written by AJ 20130108

pydarn.sdio.dbUtils.mapDbFit(dateStr, rad, time=[0, 2400], fileType='fitex', vb=0)[source]

put dmap data into the mongodb database

NOTE: this is a write operation, so you must have DBWRITEUSER
and DBWRITEPASS defined in your ~/.bashrc. these can be obtained from the VT crew, as needed. most people will not need this capability
Args:
  • dateStr: the target date in ‘yyymmdd’ format
  • rad: the three letter radar code, e.g. ‘bks’
  • [time]: the time range to perform the operation in REDUCED hhmm format, ie [28,652] instead of [0028,0652]. default = [0,2400]
  • [fileType]: the file type for which to perform the operation. valid inputs are ‘fitex’ [default], ‘fitacf’, ‘lmfit’, ‘rawacf’ , ‘iqdat’
  • [vb]: a flag for verbose output. default = 0
Returns:
  • Nothing
Example:
mapDbFit('20110710', 'bks', time=[0,240], fileType='fitacf', vb=1):

Written by AJ 20130108

pydarn.sdio.dbUtils.readFromDb(sTime=None, eTime=None, stid=None, channel=None, bmnum=None, cp=None, fileType='fitex', exactFlg=False)[source]
PACKAGE: pydarn.sdio.dbUtils
FUNCTION: readFromDb([sTime],[eTime],[stid],[channel],[bmnum],[cp],| [fileType],[exactFlg])
PURPOSE: read some record(s) from the mongodb database

NOTE: I recommend making your query as specific as possible, as this
will speed up the read speeds. The biggest limiting factor is network speed,
so be specific. For even higher performance, consider writing your own
mongodb queries

INPUTS:
[sTime]: a datetime object with the time to start reading.
if this is None, sTime is defined as 00:00 UT on 1 Jan 2011.
default: None
[eTime]: a datetime object specifying the last record to read.
if this is none, the first record after sTime (within 24 hours,
provided it exists) will be read. defualt = None
[stid]: the station id of the radar we want data for. if this is
None, all available radars will be read. default = None
[channel]: the channel letter for which to read data. if this
is None, data from all channels will be read. default = None
[bmnum]: the beam number for which to read data. if this is None,
data from all beams will be read. default = None
[cp]: the control program for which to read data. if this is None,
data from all control programs will be read. default = None
[fileType]: the filetype for which to read data. valid inputs are:
‘fitex’ [default], ‘fitacf’, ‘lmfit’, ‘rawacf’, ‘iqdat’. if a fit file
type is specified but data is not found, the program will search for another
fit type.
[exactFlg]: a flag to indicate the we only want a record with EXACTLY
the params specified (including time, to the ms). this is useful for
updating records. default = False

OUTPUTS:
myData: a list of pydarn.sdio.beamData objects in chronological order

EXAMPLES: >>> myData = readFromDb(sTime=atime,stid=33,channel=’a’,bmnum=7,cp=153,fileType=’fitacf’,exactFlg=True)

Written by AJ 20130108
pydarn.sdio.dbUtils.updateDbDict(dbDict, dmapDict)[source]
PACKAGE: pydarn.sdio.dbUtils
FUNCTION: updateDbDict(dbDict,dmapDict)
PURPOSE: updates a mongodb dictionary with data
from a dmap dictionary

INPUTS:
dbDict: the dictionary for mongodb use
dmapDict: the dictionary read from the dmap file

OUTPUTS:
dbDict: a n updated dictionary for use int he mongodb database

EXAMPLES:
newDbDict = updateDbDict(oldDbDict,dmapDict)

Written by AJ 20130108
pydarn.sdio.dbUtils

alias of pydarn.sdio.dbUtils

Previous topic

pydarn.sdio.fitexfilter

Next topic

gme

This Page