Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update scripts to use python3 #3

Merged
merged 1 commit into from May 28, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/python3
"""
Creates a frame with a toolbar and graph for plotting
"""
@@ -106,7 +106,7 @@ def __init__(self, files, verbose=False,
self.xmax = xmax

if self.verbose:
print "xmin, xmax, ymin, ymax: ", self.xmin, self.xmax, self.ymin, self.ymax
print("xmin, xmax, ymin, ymax: ", self.xmin, self.xmax, self.ymin, self.ymax)

self.subplot = []
# Give the figure size in inches, and rez
@@ -159,7 +159,7 @@ def PlotFiles(self, file_list):

if self.verbose:

print "Processing %d files." % len(file_list)
print("Processing %d files." % len(file_list))

for f in file_list:

@@ -171,13 +171,13 @@ def PlotFiles(self, file_list):

self._PlotFile(this_file)

except Exception, e:
except Exception as e:

sys.exit("Error plotting files: %s" % e)

else:

print "File Error: '%s' is not found." % this_file
print("File Error: '%s' is not found." % this_file)

#----------------------------------------------------------------------

@@ -194,7 +194,7 @@ def _PlotFile(self, f):

if self.verbose:

print "Plotting file: %s" % f
print("Plotting file: %s" % f)


this_file = os.path.abspath(f)
@@ -223,9 +223,9 @@ def _PlotFile(self, f):

plot_data[indx].append(d)

except IndexError, e:
except IndexError as e:

print "Error processing data line for index %d" % indx
print("Error processing data line for index %d" % indx)

# Now we plot all of the data we collected.
t = plot_data[0]
@@ -236,12 +236,12 @@ def _PlotFile(self, f):

num_plots = len(plot_data[1:])

print "\tPlotting data set %d of %d" % (indx+1, num_plots)
print("\tPlotting data set %d of %d" % (indx+1, num_plots))
self._AddSubplot(t, x)

else:

print "File Error: '%s' is not found." % this_file
print("File Error: '%s' is not found." % this_file)

#----------------------------------------------------------------------

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/python3

# A prototype of a stand-alone application for plotting the output of
# GENESIS 3 models. This uses a basic wxPython frame to hold a matplotlib
@@ -226,10 +226,10 @@ def plot_data_files(self):
self.plot_file()
plotnum += 1
else:
print '*** Error: Incorrect file name or path specified'
print('*** Error: Incorrect file name or path specified')
# I need to do better error handling!
except:
print 'An error ocurred'
print('An error ocurred')
# sys.exit()
else:
# bring up a warning dialog
@@ -1,26 +1,26 @@
#!/usr/bin/env python
#!/usr/bin/python3

import sys, os
import pylab

def process_file():
print 'Reading %s' % filename
print('Reading %s' % filename)
fp = open(filename, 'r')
for line in fp.readlines():
data = line.split()
# print data
for x in data:
print x,
print
print "Processing finished"
print(x, end=' ')
print()
print("Processing finished")

if __name__ == "__main__":
try:
filename = sys.argv[1]
if os.path.exists(filename):
process_file()
else:
print '**Error: Incorrect file name!'
print('**Error: Incorrect file name!')
except:
print '**Error: Exception raised!'
print('**Error: Exception raised!')
sys.exit()
@@ -1,10 +1,10 @@
#!/usr/bin/env python
#!/usr/bin/python3

import sys, os
import pylab

def plot(filename):
print 'Plotting %s' % filename
print('Plotting %s' % filename)
pylab.plotfile(filename, cols=(0,1), delimiter=' ',
subplots=False)
pylab.show()
@@ -15,9 +15,9 @@ def plot(filename):
if os.path.exists(filename):
plot(filename)
else:
print '**Error: Incorrect file name or path!'
print('**Error: Incorrect file name or path!')
except:
print '**Error: Exception raised!'
print('**Error: Exception raised!')
sys.exit()


@@ -1,10 +1,10 @@
#!/usr/bin/env python
#!/usr/bin/python3

import sys, os
import pylab

def plot(filename):
print 'Plotting %s' % filename
print('Plotting %s' % filename)
pylab.plotfile(filename, cols=(0,1), delimiter=' ', subplots=False)
pylab.show()

@@ -14,9 +14,9 @@ def plot(filename):
if os.path.exists(filename):
plot(filename)
else:
print '**Error: Incorrect file name or path specified.'
print('**Error: Incorrect file name or path specified.')
except:
print 'incorrect filename'
print('incorrect filename')
sys.exit()


@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/python3
"""
Creates a frame with a toolbar and graph for plotting
"""
@@ -106,7 +106,7 @@ def __init__(self, files, verbose=False,
self.xmax = xmax

if self.verbose:
print "xmin, xmax, ymin, ymax: ", self.xmin, self.xmax, self.ymin, self.ymax
print("xmin, xmax, ymin, ymax: ", self.xmin, self.xmax, self.ymin, self.ymax)

self.subplot = []
# Give the figure size in inches, and rez
@@ -159,7 +159,7 @@ def PlotFiles(self, file_list):

if self.verbose:

print "Processing %d files." % len(file_list)
print("Processing %d files." % len(file_list))

for f in file_list:

@@ -171,13 +171,13 @@ def PlotFiles(self, file_list):

self._PlotFile(this_file)

except Exception, e:
except Exception as e:

sys.exit("Error plotting files: %s" % e)

else:

print "File Error: '%s' is not found." % this_file
print("File Error: '%s' is not found." % this_file)

#----------------------------------------------------------------------

@@ -194,7 +194,7 @@ def _PlotFile(self, f):

if self.verbose:

print "Plotting file: %s" % f
print("Plotting file: %s" % f)


this_file = os.path.abspath(f)
@@ -223,9 +223,9 @@ def _PlotFile(self, f):

plot_data[indx].append(d)

except IndexError, e:
except IndexError as e:

print "Error processing data line for index %d" % indx
print("Error processing data line for index %d" % indx)

# Now we plot all of the data we collected.
t = plot_data[0]
@@ -236,12 +236,12 @@ def _PlotFile(self, f):

num_plots = len(plot_data[1:])

print "\tPlotting data set %d of %d" % (indx+1, num_plots)
print("\tPlotting data set %d of %d" % (indx+1, num_plots))
self._AddSubplot(t, x)

else:

print "File Error: '%s' is not found." % this_file
print("File Error: '%s' is not found." % this_file)

#----------------------------------------------------------------------

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/python3

# Basic wxPython frame to hold a matplotlib figure for plotting
# It defines some basic menu items with bindings to functions to execute
@@ -314,8 +314,8 @@ def get_data_params(self):
self.dt = float(pdentry.dt_dialog.entry.GetValue())
self.NX = int(pdentry.NX_dialog.entry.GetValue())
self.NY = int(pdentry.NY_dialog.entry.GetValue())
print 'Ntimes = ', self.Ntimes, ' t_min = ', self.t_min
print 'NX = ', self.NX, ' NY = ', self.NY
print('Ntimes = ', self.Ntimes, ' t_min = ', self.t_min)
print('NX = ', self.NX, ' NY = ', self.NY)
pdentry.Destroy()
self.t_max = (self.Ntimes - 1)*self.dt
# reset slider max and min
@@ -397,7 +397,7 @@ def get_xyt_data(self):
# imshow expects the data to be scaled to range 0-1.
Vmin = xydata.min()
Vmax = xydata.max()
print 'Vmax = ', Vmax
print('Vmax = ', Vmax)
# Hack for EPSC data - most points are < 2 nA, but a few are large
# Scale data to a more reasonable range
Vmax = 2.0e-09
@@ -443,7 +443,7 @@ def plot_data(self):
# axes legends, etc. The draw_artist(artist), and blit
# are much faster than canvas.draw() and are sufficient.

print 'system time (seconds) = ', time.time()
print('system time (seconds) = ', time.time())

# round frame_min down and frame_max up for the time window
frame_min = int(self.t_min/self.dt)
@@ -472,7 +472,7 @@ def plot_data(self):
self.axes.draw_artist(self.im)
self.canvas.blit(self.axes.bbox)

print 'system time (seconds) = ', time.time()
print('system time (seconds) = ', time.time())

# ------------------------------------------------------------------
# Define the classes and functions for getting parameter values
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/python3

# Basic wxPython frame to hold a matplotlib figure for plotting
# It defines some basic menu items with bindings to functions to execute
@@ -314,8 +314,8 @@ def get_data_params(self):
self.dt = float(pdentry.dt_dialog.entry.GetValue())
self.NX = int(pdentry.NX_dialog.entry.GetValue())
self.NY = int(pdentry.NY_dialog.entry.GetValue())
print 'Ntimes = ', self.Ntimes, ' t_min = ', self.t_min
print 'NX = ', self.NX, ' NY = ', self.NY
print('Ntimes = ', self.Ntimes, ' t_min = ', self.t_min)
print('NX = ', self.NX, ' NY = ', self.NY)
pdentry.Destroy()
self.t_max = (self.Ntimes - 1)*self.dt
# reset slider max and min
@@ -439,7 +439,7 @@ def plot_data(self):
# axes legends, etc. The draw_artist(artist), and blit
# are much faster than canvas.draw() and are sufficient.

print 'system time (seconds) = ', time.time()
print('system time (seconds) = ', time.time())

# round frame_min down and frame_max up for the time window
frame_min = int(self.t_min/self.dt)
@@ -468,7 +468,7 @@ def plot_data(self):
self.axes.draw_artist(self.im)
self.canvas.blit(self.axes.bbox)

print 'system time (seconds) = ', time.time()
print('system time (seconds) = ', time.time())

# ------------------------------------------------------------------
# Define the classes and functions for getting parameter values
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.