def plot_and_cache(self,frameno): try: if frameno not in self.frames.keys(): frametools.plotframe(self.frameno, self.plotdata, simple=self.simple, refresh=True) self.frames[str(frameno)] = '' else: frametools.plotframe(self.frameno, self.plotdata, simple=self.simple, refresh=False) except IOError: print "Swallowing IOError to avoid crashing in interactive mode."
def plot_and_cache(self,frameno): try: if frameno not in list(self.frames.keys()): frametools.plotframe(self.frameno, self.plotdata, simple=self.simple, refresh=True) self.frames[str(frameno)] = '' else: frametools.plotframe(self.frameno, self.plotdata, simple=self.simple, refresh=False) except IOError as e: print(str(e))
def plot_and_cache(self, frameno): try: if frameno not in self.frames.keys(): frametools.plotframe(self.frameno, self.plotdata, simple=self.simple, refresh=True) self.frames[str(frameno)] = '' else: frametools.plotframe(self.frameno, self.plotdata, simple=self.simple, refresh=False) except IOError: print "Swallowing IOError to avoid crashing in interactive mode."
def plot_and_cache(self, frameno): try: if frameno not in list(self.frames.keys()): frametools.plotframe(self.frameno, self.plotdata, simple=self.simple, refresh=True) self.frames[str(frameno)] = '' else: frametools.plotframe(self.frameno, self.plotdata, simple=self.simple, refresh=False) except IOError as e: print(str(e))
def do_rr(self, rest): #self.plotdata.refresh_frames=True outdir = os.path.abspath(self.plotdata.outdir) key = (self.frameno, outdir) xxx = self.plotdata.framesoln_dict.pop(key, None) if xxx is None: print 'No frame data to clear for frame ', self.frameno else: print 'Cleared data for frame ', self.frameno print 'Reading data from outdir = ', self.plotdata.outdir self.current_data = frametools.plotframe(self.frameno, self.plotdata) self.plotdata.refresh_frames = False
def do_rr(self, rest): #self.plotdata.refresh_frames=True outdir = os.path.abspath(self.plotdata.outdir) key = (self.frameno, outdir) xxx = self.plotdata.framesoln_dict.pop(key,None) if xxx is None: print 'No frame data to clear for frame ',self.frameno else: print 'Cleared data for frame ',self.frameno print 'Reading data from outdir = ',self.plotdata.outdir self.current_data = frametools.plotframe(self.frameno, self.plotdata) self.plotdata.refresh_frames=False
def do_j(self, rest): try: newframeno = int(rest) except: newframeno = raw_input('\n Jump to which frame? ') if newframeno == 'n': self.do_n(rest) self.lastcmd = 'n' elif newframeno == 'p': self.do_p(rest) self.lastcmd = 'p' else: try: newframeno = int(newframeno) self.frameno = newframeno self.current_data = frametools.plotframe(self.frameno, self.plotdata) except: print '\n *** Error: frameno must be an integer, n, or p'
def preloop(self): print '\nInteractive plotting for Clawpack output... ' print '\nPlotting data from outdir = ', self.plotdata.outdir print 'Type ? at PLOTCLAW prompt for list of commands' startframeno = raw_input('\n Start at which frame [default=%i] ? '\ % self.prevframeno) makeplot = True if startframeno == '': self.frameno = self.prevframeno self.plotdata = self.prevplotdata if self.restart: replot = raw_input(' Replot data for frame %s [no] ? ' \ % self.frameno) if replot not in ['y', 'yes', 'Y']: makeplot = False if makeplot: reload = raw_input(' Reload data for frame %s [no] ? ' \ % self.frameno) if reload in ['y', 'yes', 'Y']: self.plotdata.refresh_frames = True else: self.plotdata.refresh_frames = False else: self.plotdata = self.prevplotdata try: self.frameno = int(startframeno) except: print '\n *** Error: frameno must be an integer, resetting to 0' self.frameno = 0 if makeplot: self.current_data = frametools.plotframe(self.frameno, self.plotdata) self.plotdata.refresh_frames = False #pylab.draw() self.lastcmd = 'n' self.restart = True
def preloop(self): print '\nInteractive plotting for Clawpack output... ' print '\nPlotting data from outdir = ', self.plotdata.outdir print 'Type ? at PLOTCLAW prompt for list of commands' startframeno = raw_input('\n Start at which frame [default=%i] ? '\ % self.prevframeno) makeplot = True if startframeno == '': self.frameno = self.prevframeno self.plotdata = self.prevplotdata if self.restart: replot = raw_input(' Replot data for frame %s [no] ? ' \ % self.frameno) if replot not in ['y','yes','Y']: makeplot = False if makeplot: reload = raw_input(' Reload data for frame %s [no] ? ' \ % self.frameno) if reload in ['y','yes','Y']: self.plotdata.refresh_frames = True else: self.plotdata.refresh_frames = False else: self.plotdata = self.prevplotdata try: self.frameno = int(startframeno) except: print '\n *** Error: frameno must be an integer, resetting to 0' self.frameno = 0 if makeplot: self.current_data = frametools.plotframe(self.frameno, self.plotdata) self.plotdata.refresh_frames=False #pylab.draw() self.lastcmd = 'n' self.restart = True
def do_j(self, rest): try: newframeno = int(rest) except: newframeno = raw_input('\n Jump to which frame? ') if newframeno == 'n': self.do_n(rest) self.lastcmd = 'n' elif newframeno == 'p': self.do_p(rest) self.lastcmd = 'p' else: try: newframeno = int(newframeno) self.frameno = newframeno self.current_data = frametools.plotframe( self.frameno, self.plotdata) except: print '\n *** Error: frameno must be an integer, n, or p'
def plotframe(self, frameno): from clawpack.visclaw import frametools frametools.plotframe(frameno, self)
def do_p(self, rest): #print ' frameno = ',self.frameno self.frameno = max(self.frameno - 1, 0) self.current_data = frametools.plotframe(self.frameno, self.plotdata)
def do_r(self, rest): self.current_data = frametools.plotframe(self.frameno, self.plotdata)
def do_p(self, rest): #print ' frameno = ',self.frameno self.frameno = max(self.frameno-1, 0) self.current_data = frametools.plotframe(self.frameno, self.plotdata)
def do_n(self, rest): from clawpack.visclaw import frametools, data #print ' frameno = ',self.frameno self.frameno = self.frameno+1 self.current_data = frametools.plotframe(self.frameno, self.plotdata) pylab.draw()
def do_n(self, rest): from clawpack.visclaw import frametools, data #print ' frameno = ',self.frameno self.frameno = self.frameno + 1 self.current_data = frametools.plotframe(self.frameno, self.plotdata) pylab.draw()
pd = setplot.setplot() pd.outdir=os.path.abspath('_output') savefig_ext = '.jpg' figdir = '../figures' os.system('mkdir -p %s' % figdir) def save_figure(fname): """Save figure to figdir with desired extension""" full_fname = os.path.join(figdir,fname) + savefig_ext savefig(full_fname, bbox_inches='tight') print('Created %s' % full_fname) frameno = 1 plotframe(frameno,pd) figure(0) #axis([-140,-122,40,50]) # set in setplot.py plotbox([-128,-123.5,43,45],kwargs={'color':'k','linewidth':1.5}) fname = 'pacific_f%s' % str(frameno).zfill(4) save_figure(fname) figure(1) plot([-127,-124],[44.4,44.4],'k') text(-126.9,44.45,'Transect A', fontsize=15, color='k') plot([-127,-124],[44.2,44.2],'b') text(-126.9,44.05,'Transect B', fontsize=15, color='b') xticks(range(-128,-123),fontsize=15) yticks(arange(43.2,45,0.4),fontsize=15) xlabel('longitude',fontsize=15) ylabel('latitude',fontsize=15)