Skip to content

Commit

Permalink
Pylint error fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wcarthur committed Sep 9, 2018
1 parent 8df6efe commit de22b05
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
28 changes: 14 additions & 14 deletions Evaluate/genesisDensity.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@

from PlotInterface.maps import FilledContourMapFigure, saveFigure, levels

LOG = logging.getLogger(__name__)
LOG.addHandler(logging.NullHandler())
log = logging.getLogger(__name__)
log.addHandler(logging.NullHandler())

def loadTracks(trackfile):
"""
Expand Down Expand Up @@ -73,7 +73,7 @@ def loadTracksFromPath(path):
files = os.listdir(path)
trackfiles = [pjoin(path, f) for f in files if f.startswith('tracks')]
msg = 'Processing %d track files in %s' % (len(trackfiles), path)
LOG.info(msg)
log.info(msg)
return loadTracksFromFiles(sorted(trackfiles))

class GenesisDensity(object):
Expand Down Expand Up @@ -166,7 +166,7 @@ def _calculate(self, tracks):
:param tracks: Collection of :class:`Track` objects.
"""
LOG.debug("Calculating PDF for set of {0:d} tracks".format(len(tracks)))
log.debug("Calculating PDF for set of {0:d} tracks".format(len(tracks)))

hist = ma.zeros((len(self.lon_range) - 1,
len(self.lat_range) - 1))
Expand Down Expand Up @@ -216,7 +216,7 @@ def calculateMeans(self):
@disableOnWorkers
def historic(self):
"""Load historic data and calculate histogram"""
LOG.info("Processing historic track records")
log.info("Processing historic track records")
config = ConfigParser()
config.read(self.configFile)
inputFile = config.get('DataProcess', 'InputFile')
Expand All @@ -229,7 +229,7 @@ def historic(self):
tracks = loadTrackFile(self.configFile, inputFile, source)

except (TypeError, IOError, ValueError):
LOG.critical("Cannot load historical track file: {0}".\
log.critical("Cannot load historical track file: {0}".\
format(inputFile))
raise
else:
Expand All @@ -239,7 +239,7 @@ def historic(self):
startYr = min(startYr, min(t.Year))
endYr = max(endYr, max(t.Year))
numYears = endYr - startYr
LOG.info("Range of years: %d - %d" % (startYr, endYr))
log.info("Range of years: %d - %d" % (startYr, endYr))
try:
self.hist = self._calculate(tracks)
#self.hist = self._calculate(tracks) / numYears
Expand All @@ -265,7 +265,7 @@ def synthetic(self):
n = 0
for d in range(1, pp.size()):
pp.send(trackfiles[w], destination=d, tag=work_tag)
LOG.debug("Processing track file {0:d} of {1:d}".\
log.debug("Processing track file {0:d} of {1:d}".\
format(w, len(trackfiles)))
w += 1

Expand All @@ -279,7 +279,7 @@ def synthetic(self):
d = status.source
if w < len(trackfiles):
pp.send(trackfiles[w], destination=d, tag=work_tag)
LOG.debug("Processing track file {0:d} of {1:d}".\
log.debug("Processing track file {0:d} of {1:d}".\
format(w, len(trackfiles)))
w += 1
else:
Expand All @@ -294,14 +294,14 @@ def synthetic(self):
if trackfile is None:
break

LOG.debug("Processing %s", trackfile)
log.debug("Processing %s", trackfile)
tracks = loadTracks(trackfile)
results = self._calculate(tracks) #/ self.synNumYears
pp.send(results, destination=0, tag=result_tag)

elif (pp.size() == 1) and (pp.rank() == 0):
for n, trackfile in enumerate(trackfiles):
LOG.debug("Processing track file {0:d} of {1:d}".\
log.debug("Processing track file {0:d} of {1:d}".\
format(n + 1, len(trackfiles)))
tracks = loadTracks(trackfile)
self.synHist[n, :, :] = self._calculate(tracks) #/ self.synNumYears
Expand All @@ -314,12 +314,12 @@ def save(self):

# Simple sanity check (should also include the synthetic data):
if not hasattr(self, 'hist'):
LOG.critical("No historical data available!")
LOG.critical(("Check that data has been processed "
log.critical("No historical data available!")
log.critical(("Check that data has been processed "
"before trying to save data"))
return

LOG.info('Saving genesis density data to {0}'.format(dataFile))
log.info('Saving genesis density data to {0}'.format(dataFile))
dimensions = {
0: {
'name': 'lat',
Expand Down
7 changes: 3 additions & 4 deletions ProcessMultipliers/processMultipliers.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,11 +501,11 @@ def processMult(wspd, uu, vv, lon, lat, working_dir, m4_max_file = 'm4_ne.tif'):

reprojectDataset(wind_raster, m4_max_file, wind_prj_file)
reprojectDataset(bear_raster, m4_max_file, bear_prj_file,
resampling_method = GRA_NearestNeighbour)
resampling_method = gdalconst.GRA_NearestNeighbour)
reprojectDataset(uu_raster, m4_max_file, uu_prj_file,
resampling_method = GRA_NearestNeighbour)
resampling_method = gdalconst.GRA_NearestNeighbour)
reprojectDataset(vv_raster, m4_max_file, vv_prj_file,
resampling_method = GRA_NearestNeighbour)
resampling_method = gdalconst.GRA_NearestNeighbour)

wind_prj_ds = gdal.Open(wind_prj_file, gdal.GA_ReadOnly)
wind_prj = wind_prj_ds.GetRasterBand(1)
Expand Down Expand Up @@ -666,7 +666,6 @@ def main(self):
gM.combineDirections(self.dirns, self.working_dir)

# Load the wind data:
from netCDF4 import Dataset
log.info("Loading regional wind data from {0}".format(self.gust_file))
ncobj = Dataset(self.gust_file, 'r')

Expand Down
4 changes: 3 additions & 1 deletion Utilities/get_multipliers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
from osgeo import gdal
from osgeo.gdalnumeric import *
from osgeo.gdalconst import *
from osgeo.gdal_array import BandReadAsArray, CopyDatasetInfo, BandWriteArray

import numpy as np
import numpy.ma as ma
import logging as log
Expand Down Expand Up @@ -228,7 +230,7 @@ def main(configFile):
type_mapping = {'shielding': 'Ms', 'terrain': 'Mz', 'topographic': 'Mt'}
dirns = ['e', 'n', 'ne', 'nw', 's', 'se', 'sw', 'w']

num_tiles = copyTranslateMultipliers(configFile, type_mapping, output_path)
copyTranslateMultipliers(configFile, type_mapping, output_path)
mergeWindMultipliers(type_mapping, dirns, output_path)
combineDirections(dirns, output_path)

Expand Down
2 changes: 1 addition & 1 deletion database/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def insertEvents(self, eventparams):
try:
self.execute(INSEVENTS, eventparams)

except IntegrityError as err:
except sqlite3.IntegrityError as err:
log.exception("Problem inserting events into tblEvents: ")
log.exception("Pre-existing event with the same eventNumber attribute")
log.exception("Check that you are not overwriting an existing database.")
Expand Down

0 comments on commit de22b05

Please sign in to comment.