Example #1
0
 def testHeightArrays(self):
     self.createTempTestDir()
     temp_config = config.Windb2WrfConfigParser()
     temp_config.read('windb2-wrf.conf')
     self.assertEqual([str(item) for item in temp_config.get_float_list('INTERP', 'heights')],
                      config.Windb2WrfConfigParser.interp_heights.split(','))
     self.assertEqual([str(item) for item in temp_config.get_float_list('WINDB2', 'heights')],
                      config.Windb2WrfConfigParser.windb2_heights.split(','))
Example #2
0
 def testExisting(self):
     print('CWD=', os.getcwd())
     testing_config = config.Windb2WrfConfigParser()
     testing_config.read('test/windb2-wrf.conf')
     self.assertEqual([str(item) for item in testing_config.get_float_list('INTERP', 'heights')],
                      ['5.0', '10.0', '20.0', '60.0', '150.0'])
     self.assertEqual([str(item) for item in testing_config.get_float_list('WINDB2', 'heights')],
                      ['10.0', '60.0'])
Example #3
0
import re
dir = os.path.dirname(__file__)
sys.path.append(os.path.join(dir, '../'))

import argparse
from windb2.model.wrf import heightinterpfile
from windb2.model.wrf import config
import logging

# Get the command line opts
parser = argparse.ArgumentParser()
parser.add_argument("ncfile",
                    type=str,
                    help="WRF netCDF filename to interpolate")
args = parser.parse_args()
wrf_config = config.Windb2WrfConfigParser()
wrf_config.read('windb2-wrf.conf')

# Set up logging for InsertAbstract
logger = logging.getLogger('windb2')
logger.setLevel(logging.WARNING)
logging.basicConfig()

# Get rid of escaped colon characters that are often added in Unix shells
ncfile_cleansed = re.sub(r'[\\]', '', args.ncfile)

# Interpolate this file
try:
    heightinterpfile.HeightInterpFile(wrf_config).interp_file(ncfile_cleansed)
except configparser.NoSectionError:
    msg = 'Missing windb2-wrf.conf file. Please add a valid config file.'
Example #4
0
 def testContainsInterpVar(self):
     temp_config = config.Windb2WrfConfigParser()
     temp_config.read('test/windb2-wrf.conf')
     self.assertTrue(temp_config.contains_interp_var('UV'))
     self.assertFalse(temp_config.contains_interp_var('cannot find'))
Example #5
0
 def testInterpVarArray(self):
     self.createTempTestDir()
     temp_config = config.Windb2WrfConfigParser()
     temp_config.read('windb2-wrf.conf')
     self.assertEqual([str(item) for item in temp_config.get_str_list('INTERP', 'vars')],
                      config.Windb2WrfConfigParser.interp_vars.split(','))
Example #6
0
                   help="Existing domain key in the WinDB2")
group.add_argument("-n",
                   "--new",
                   action="store_false",
                   help="Create a new WinDB2 domain")
args = parser.parse_args()

# Connect to the WinDB
windb2 = windb2.WinDB2(args.db_host,
                       args.db_name,
                       dbUser=args.db_user,
                       port=args.port)
windb2.connect()

# Load a WinDB2 config file
windb2_config = config.Windb2WrfConfigParser('windb2-wrf.json')

# Set up logging
logger = logging.getLogger('windb2')
try:
    logger.setLevel(windb2_config.config['loglevel'])
except KeyError:
    logger.setLevel(logging.INFO)
logging.basicConfig()

# Create the inserter from this config
inserter = insert.InsertWRF(windb2, windb2_config)

# Get rid of escaped colon characters that are often added in Unix shells
ncfile_cleansed = re.sub(r'[\\]', '', args.ncfile)
Example #7
0
 def testExisting(self):
     # Just make sure this doesn't throw a schema exception
     config.Windb2WrfConfigParser(os.environ['WINDB2_HOME'] +
                                  '/config/windb2-wrf.json')