Exemple #1
0
#------------------------------------------------------------------------------
#  Imports from WaveConnect libraries
#------------------------------------------------------------------------------
from wavecon import DBman

#------------------------------------------------------------------------------
#  Metadata, Object Classes and Other Constants
#------------------------------------------------------------------------------
BuoySource = DBman.accessTable(None, 'tblsource')
SourceTypeRecord = DBman.accessTable(None, 'tblsourcetype')
WindRecord = DBman.accessTable(None, 'tblwind')
WaveRecord = DBman.accessTable(None, 'tblwave')
SpectraRecord = DBman.accessTable(None, 'tblspectrabin')

_session = DBman.startSession()

# Import NDBC global variables
from .globals import BUOY_META


#------------------------------------------------------------------------------
#  Forming and Committing Database Records
#------------------------------------------------------------------------------
def formDatabaseRecords(NDBCrecords):
    recordType = NDBCrecords[0]['type']

    # Assuming all the records in the list are from the same buoy.
    buoyNum = NDBCrecords[0]['buoyNumber']
    buoyID = getBuoyID(buoyNum)
    buoyLocation = getBuoyLoc(buoyNum, asWKT=True)
Exemple #2
0
#---------------------------------------------------------------------
#  Metadata and Other Constants
#---------------------------------------------------------------------

HF_CURRENT_META = {
    '6km': {
        'url': 'http://sdf.ndbc.noaa.gov/thredds/dodsC/hfradar_uswc_6km'
    }
}

Source = DBman.accessTable(_DBconfig, 'tblsource')
SourceType = DBman.accessTable(_DBconfig, 'tblsourcetype')
CurrentRecord = DBman.accessTable(_DBconfig, 'tblcurrent')

_session = DBman.startSession(_DBconfig)


#---------------------------------------------------------------------
#  Data Retrieval
#---------------------------------------------------------------------
def fetchRecords(north,
                 south,
                 west,
                 east,
                 startTime,
                 stopTime,
                 resolution,
                 verbose=False):

    records = getData(north, south, west, east, startTime, stopTime,
Exemple #3
0
Fichier : DB.py Projet : serc/wave
#------------------------------------------------------------------------------
#  Imports from WaveConnect libraries
#------------------------------------------------------------------------------
from wavecon import DBman


#------------------------------------------------------------------------------
#  Metadata, Object Classes and Other Constants
#------------------------------------------------------------------------------
SourceTypeRecord = DBman.accessTable(None, 'tblsourcetype')
Source = DBman.accessTable(None, 'tblsource')
CurrentRecord = DBman.accessTable(None, 'tblcurrent')
WaveRecord = DBman.accessTable(None, 'tblwave')
SpectraRecord = DBman.accessTable(None, 'tblspectrabin' )

_session = DBman.startSession()


#------------------------------------------------------------------------------
#  Forming and Committing Database Records
#------------------------------------------------------------------------------
def CurrentDBrecordGenerator(current_data, model_run_id):
  records = (
    {
      'curid': uuid4(),
      'cursourceid': model_run_id,
      'curdatetime': record['timestamp'],
      'curspeed': record['speed'],
      'curdirection': record['direction'],
      'curlocation': 'SRID=4326;POINT({0} {1})'.format(*record['location'])
    }
Exemple #4
0
# Make sure the WaveConnect py/lib folder is on the search path so
# modules can be retrieved.
import sys
from os import path, system
scriptLocation = path.dirname(path.abspath(__file__))
waveLibs = path.abspath(path.join(scriptLocation, '..', 'lib'))
sys.path.insert(0, waveLibs)


from wavecon.config import DBconfig
from wavecon import DBman
from wavecon.NDBC.DB import getBuoyID

from datetime import datetime
from geoalchemy import WKTSpatialElement

Wind = DBman.accessTable(DBconfig, 'tblwind', 'tblwind')
session = DBman.startSession(DBconfig)

records = session.query(Wind).all()

if len(records) == 0:
  dbTest = path.abspath(path.join(scriptLocation, 'dbtest.py'))
  system('pythonw {0}'.format(dbTest))
  records = session.query(Wind).all()

record = records[0]

print record