示例#1
0
 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."
示例#2
0
 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))
示例#3
0
 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."
示例#4
0
 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))
示例#5
0
 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
示例#6
0
 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
示例#7
0
 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'
示例#8
0
    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
示例#9
0
    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 
示例#10
0
 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'
示例#11
0
 def plotframe(self, frameno):
     from clawpack.visclaw import frametools
     frametools.plotframe(frameno, self)
示例#12
0
文件: data.py 项目: jhkim2/visclaw
 def plotframe(self, frameno):
     from clawpack.visclaw import frametools
     frametools.plotframe(frameno, self)
示例#13
0
 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)
示例#14
0
 def do_r(self, rest):
     self.current_data = frametools.plotframe(self.frameno, self.plotdata)
示例#15
0
 def do_r(self, rest):
     self.current_data = frametools.plotframe(self.frameno, self.plotdata)
示例#16
0
 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)
示例#17
0
    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()
示例#18
0
 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)