Skip to content

Commit

Permalink
Fixed style error
Browse files Browse the repository at this point in the history
  • Loading branch information
CEKrause committed Aug 29, 2017
2 parents 35fdc95 + 58dd915 commit 2f8c06c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 22 deletions.
4 changes: 2 additions & 2 deletions Utilities/KPDF.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@
***************/

#include "Python.h"
/*#include "Numeric/arrayobject.h"*/
#include "arrayobject.h"
/* #include "numpy/arrayobject.h" */
#include "arrayobject.h"

#include <math.h>
#include <stdlib.h>
Expand Down
6 changes: 2 additions & 4 deletions Utilities/columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ def colReadCSV(configFile, dataFile, source):
cols = config.get(source, 'Columns').split(delimiter)

usecols = [i for i, c in enumerate(cols) if c != 'skip']
names = [c for c in cols if c != 'skip']
try:
data = np.genfromtxt(dataFile, dtype=None, delimiter=delimiter,
usecols=usecols, comments=None,
skip_header=numHeadingLines,
usecols=usecols, names=names, skip_header=numHeadingLines,
autostrip=True)
except IOError:
log.exception("File not found: {0}".format(dataFile))
Expand All @@ -50,6 +50,4 @@ def colReadCSV(configFile, dataFile, source):
raise TypeError(("{0} is not a string, filehandle "
"or generator.").format(dataFile))

data.dtype.names = [c for c in cols if c != 'skip']

return data
23 changes: 14 additions & 9 deletions database/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ def processTracks(self):
if w < len(trackfiles):
pp.send((trackfiles[w], locations),
destination=d, tag=work_tag)
log.debug("Processing {0}".format(trackfiles[w]))
log.info("Processing {0}".format(trackfiles[w]))
log.debug("Processing track {0:d} of {1:d}".\
format(w, len(trackfiles)))
w += 1
Expand All @@ -619,15 +619,20 @@ def processTracks(self):
terminated = 0

while terminated < p:
result, status = pp.receive(pp.any_source, tag=result_tag,
return_status=True)
try:
result, status = pp.receive(pp.any_source, tag=result_tag,
return_status=True)
except:
log.warn("Problems recieving results on node 0")

if result:
log.debug("Inserting results into tblTracks")
self.insertTracks(result)
d = status.source
if w < len(trackfiles):
pp.send((trackfiles[w], locations),
destination=d, tag=work_tag)
log.info("Processing {0}".format(trackfiles[w]))
log.debug("Processing track {0:d} of {1:d}".\
format(w, len(trackfiles)))
w += 1
Expand All @@ -638,7 +643,7 @@ def processTracks(self):
elif (pp.size() > 1) and (pp.rank() != 0):
while True:
W = pp.receive(source=0, tag=work_tag)
log.debug("Received track on node {0}".format(pp.rank()))
log.info("Received track on node {0}".format(pp.rank()))
if W is None:
break

Expand All @@ -648,7 +653,7 @@ def processTracks(self):
elif pp.size() == 1 and pp.rank() == 0:
# No Pypar
for w, trackfile in enumerate(trackfiles):
log.debug("Processing trackfile {0:d} of {1:d}".\
log.info("Processing trackfile {0:d} of {1:d}".\
format(w, len(trackfiles)))
#if len(track.data) == 0:
# continue
Expand All @@ -671,17 +676,17 @@ def processTrack(self, trackfile, locations):
records = []
for track in tracks:
if len(track.data) == 0:
log.debug("Got an empty track: returning None")
log.info("Got an empty track: returning None")
continue #return None
distances = track.minimumDistance(points)
for (loc, dist) in zip(locations, distances):
locRecs = (loc[0], "%03d-%05d"%(track.trackId),
dist, None, None, "", datetime.now())

records.append(locRecs)
log.debug("Track {0}-{1} has {2} records".format(track.trackId[0],
track.trackId[1],
len(records)))
log.info("Track {0}-{1} has {2} records".format(track.trackId[0],
track.trackId[1],
len(records)))
return records

def insertTracks(self, trackRecords):
Expand Down
19 changes: 12 additions & 7 deletions wind/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ def dumpGustsFromTracks(self, trackiter, windfieldPath,
for track, result in results:
log.debug("Saving data for track {0:03d}-{1:05d}"\
.format(*track.trackId))
# issue 25 flip the lat axes
gust, bearing, Vx, Vy, P, lon, lat = result

dumpfile = pjoin(windfieldPath,
Expand All @@ -492,7 +493,11 @@ def dumpGustsFromTracks(self, trackiter, windfieldPath,
'gust.{0:03d}-{1:05d}.png'.\
format(*track.trackId))
self.saveGustToFile(track.trackfile,
(lat, lon, gust, Vx, Vy, P),
(np.flipud(lat), lon,
np.flipud(gust),
np.flipud(Vx),
np.flipud(Vy),
np.flipud(P)),
dumpfile)
#self.plotGustToFile((lat, lon, gust, Vx, Vy, P), plotfile)

Expand Down Expand Up @@ -543,7 +548,7 @@ def saveGustToFile(self, trackfile, result, filename):
0: {
'name': 'lat',
'values': lat,
'dtype': 'f',
'dtype': 'float64',
'atts': {
'long_name': 'Latitude',
'standard_name': 'latitude',
Expand All @@ -554,7 +559,7 @@ def saveGustToFile(self, trackfile, result, filename):
1: {
'name': 'lon',
'values': lon,
'dtype': 'f',
'dtype': 'float64',
'atts': {
'long_name': 'Longitude',
'standard_name': 'longitude',
Expand All @@ -569,7 +574,7 @@ def saveGustToFile(self, trackfile, result, filename):
'name': 'vmax',
'dims': ('lat', 'lon'),
'values': speed,
'dtype': 'f',
'dtype': 'float32',
'atts': {
'long_name': 'Maximum 0.2-second gust wind speed',
'standard_name': 'wind_speed_of_gust',
Expand All @@ -585,7 +590,7 @@ def saveGustToFile(self, trackfile, result, filename):
'name': 'ua',
'dims': ('lat', 'lon'),
'values': Vx,
'dtype': 'f',
'dtype': 'float32',
'atts': {
'long_name': 'Eastward component of maximum wind speed',
'standard_name': 'eastward_wind',
Expand All @@ -599,7 +604,7 @@ def saveGustToFile(self, trackfile, result, filename):
'name': 'va',
'dims': ('lat', 'lon'),
'values': Vy,
'dtype': 'f',
'dtype': 'float32',
'atts': {
'long_name': 'Northward component of maximim wind speed',
'standard_name': 'northward_wind',
Expand All @@ -613,7 +618,7 @@ def saveGustToFile(self, trackfile, result, filename):
'name': 'slp',
'dims': ('lat', 'lon'),
'values': P,
'dtype': 'f',
'dtype': 'float32',
'atts': {
'long_name': 'Minimum air pressure at sea level',
'standard_name': 'air_pressure_at_sea_level',
Expand Down

0 comments on commit 2f8c06c

Please sign in to comment.