本文整理汇总了Python中Utilities.config.ConfigParser.getfloat方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigParser.getfloat方法的具体用法?Python ConfigParser.getfloat怎么用?Python ConfigParser.getfloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Utilities.config.ConfigParser
的用法示例。
在下文中一共展示了ConfigParser.getfloat方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: historic
# 需要导入模块: from Utilities.config import ConfigParser [as 别名]
# 或者: from Utilities.config.ConfigParser import getfloat [as 别名]
def historic(self):
"""Load historic data and calculate histogram"""
config = ConfigParser()
config.read(self.configFile)
inputFile = config.get('DataProcess', 'InputFile')
if len(os.path.dirname(inputFile)) == 0:
inputFile = pjoin(self.inputPath, inputFile)
source = config.get('DataProcess', 'Source')
timestep = config.getfloat('TrackGenerator', 'Timestep')
interpHistFile = pjoin(self.inputPath, "interp_tracks.csv")
try:
tracks = interpolateTracks.parseTracks(self.configFile,
inputFile,
source,
timestep,
interpHistFile, 'linear')
except (TypeError, IOError, ValueError):
log.critical("Cannot load historical track file: {0}".format(inputFile))
raise
else:
startYr = 9999
endYr = 0
for t in tracks:
startYr = min(startYr, min(t.Year))
endYr = max(endYr, max(t.Year))
numYears = endYr - startYr
self.hist = self.calculate(tracks) / numYears
示例2: historic
# 需要导入模块: from Utilities.config import ConfigParser [as 别名]
# 或者: from Utilities.config.ConfigParser import getfloat [as 别名]
def historic(self):
"""Calculate historical rates of longitude crossing"""
log.info("Processing historical tracks for longitude crossings")
config = ConfigParser()
config.read(self.configFile)
inputFile = config.get("DataProcess", "InputFile")
source = config.get("DataProcess", "Source")
timestep = config.getfloat("TrackGenerator", "Timestep")
if len(os.path.dirname(inputFile)) == 0:
inputFile = pjoin(self.inputPath, inputFile)
try:
tracks = interpolateTracks.parseTracks(
self.configFile, inputFile, source, timestep, interpolation_type="linear"
)
except (TypeError, IOError, ValueError):
log.critical("Cannot load historical track file: {0}".format(inputFile))
raise
else:
self.lonCrossingHist, self.lonCrossingEWHist, self.lonCrossingWEHist = self.findCrossings(tracks)
return
示例3: __init__
# 需要导入模块: from Utilities.config import ConfigParser [as 别名]
# 或者: from Utilities.config.ConfigParser import getfloat [as 别名]
def __init__(self, configFile, autoCalc_gridLimit=None,
progressbar=None):
"""
Initialize the data and variables required for the interface
"""
self.configFile = configFile
config = ConfigParser()
config.read(configFile)
self.progressbar = progressbar
log.info("Initialising StatInterface")
self.kdeType = config.get('StatInterface', 'kdeType')
self.kde2DType = config.get('StatInterface','kde2DType')
minSamplesCell = config.getint('StatInterface', 'minSamplesCell')
self.kdeStep = config.getfloat('StatInterface', 'kdeStep')
self.outputPath = config.get('Output', 'Path')
self.processPath = pjoin(self.outputPath, 'process')
missingValue = cnfGetIniValue(self.configFile, 'StatInterface',
'MissingValue', sys.maxint)
gridLimitStr = cnfGetIniValue(self.configFile, 'StatInterface',
'gridLimit', '')
if gridLimitStr is not '':
try:
self.gridLimit = eval(gridLimitStr)
except SyntaxError:
log.exception('Error! gridLimit is not a dictionary')
else:
self.gridLimit = autoCalc_gridLimit
log.info('No gridLimit specified - using automatic' +
' selection: ' + str(self.gridLimit))
try:
gridSpace = config.geteval('Region', 'gridSpace')
gridInc = config.geteval('Region', 'gridInc')
except SyntaxError:
log.exception('Error! gridSpace or gridInc not dictionaries')
raise
self.generateDist = GenerateDistributions(self.configFile,
self.gridLimit,
gridSpace, gridInc,
self.kdeType,
minSamplesCell,
missingValue)
self.gridSpace = gridSpace
self.gridInc = gridInc
示例4: historic
# 需要导入模块: from Utilities.config import ConfigParser [as 别名]
# 或者: from Utilities.config.ConfigParser import getfloat [as 别名]
def historic(self):
"""Calculate historical rates of landfall"""
log.info("Processing landfall rates of historical tracks")
config = ConfigParser()
config.read(self.configFile)
inputFile = config.get('DataProcess', 'InputFile')
source = config.get('DataProcess', 'Source')
timestep = config.getfloat('TrackGenerator', 'Timestep')
if len(os.path.dirname(inputFile)) == 0:
inputFile = pjoin(self.inputPath, inputFile)
try:
tracks = loadTrackFile(self.configFile, inputFile, source)
except (TypeError, IOError, ValueError):
log.critical("Cannot load historical track file: {0}".format(inputFile))
raise
else:
self.historicLandfall, self.historicOffshore = self.processTracks(tracks)
return
示例5: run
# 需要导入模块: from Utilities.config import ConfigParser [as 别名]
# 或者: from Utilities.config.ConfigParser import getfloat [as 别名]
def run(configFile, callback=None):
"""
Run the wind field calculations.
:param str configFile: path to a configuration file.
:param func callback: optional callback function to track progress.
"""
log.info('Loading wind field calculation settings')
# Get configuration
config = ConfigParser()
config.read(configFile)
outputPath = config.get('Output', 'Path')
profileType = config.get('WindfieldInterface', 'profileType')
windFieldType = config.get('WindfieldInterface', 'windFieldType')
beta = config.getfloat('WindfieldInterface', 'beta')
beta1 = config.getfloat('WindfieldInterface', 'beta1')
beta2 = config.getfloat('WindfieldInterface', 'beta2')
thetaMax = config.getfloat('WindfieldInterface', 'thetaMax')
margin = config.getfloat('WindfieldInterface', 'Margin')
resolution = config.getfloat('WindfieldInterface', 'Resolution')
domain = config.get('WindfieldInterface', 'Domain')
windfieldPath = pjoin(outputPath, 'windfield')
trackPath = pjoin(outputPath, 'tracks')
windfieldFormat = 'gust-%i-%04d.nc'
gridLimit = None
if config.has_option('Region','gridLimit'):
gridLimit = config.geteval('Region', 'gridLimit')
if config.has_option('WindfieldInterface', 'gridLimit'):
gridLimit = config.geteval('WindfieldInterface', 'gridLimit')
if config.has_section('Timeseries'):
if config.has_option('Timeseries', 'Extract'):
if config.getboolean('Timeseries', 'Extract'):
from Utilities.timeseries import Timeseries
log.debug("Timeseries data will be extracted")
ts = Timeseries(configFile)
timestepCallback = ts.extract
else:
def timestepCallback(*args):
"""Dummy timestepCallback function"""
pass
thetaMax = math.radians(thetaMax)
# Attempt to start the track generator in parallel
global pp
pp = attemptParallel()
log.info('Running windfield generator')
wfg = WindfieldGenerator(config=config,
margin=margin,
resolution=resolution,
profileType=profileType,
windFieldType=windFieldType,
beta=beta,
beta1=beta1,
beta2=beta2,
thetaMax=thetaMax,
gridLimit=gridLimit,
domain=domain)
msg = 'Dumping gusts to %s' % windfieldPath
log.info(msg)
# Get the trackfile names and count
files = os.listdir(trackPath)
trackfiles = [pjoin(trackPath, f) for f in files if f.startswith('tracks')]
nfiles = len(trackfiles)
def progressCallback(i):
"""Define the callback function"""
callback(i, nfiles)
msg = 'Processing %d track files in %s' % (nfiles, trackPath)
log.info(msg)
# Do the work
pp.barrier()
wfg.dumpGustsFromTrackfiles(trackfiles, windfieldPath, windfieldFormat,
progressCallback, timestepCallback)
try:
ts.shutdown()
except NameError:
pass
pp.barrier()
#.........这里部分代码省略.........