<s> import numpy as np <EOL> import matplotlib . pyplot as plt <EOL> import sys <EOL> import getopt <EOL> import mesh . patch as patch <EOL> def makeplot ( myd , var , outfile ) : <EOL> a = myd . grid <EOL> if var == "<STR_LIT>" : <EOL> vx = myd . get_var ( "<STR_LIT>" ) <EOL> vy = myd . get_var ( "<STR_LIT>" ) <EOL> v = myg . scratch_array ( ) <EOL> v [ a . ilo : a . ihi + <NUM_LIT:1> , a . jlo : a . jhi + <NUM_LIT:1> ] = <NUM_LIT:0.5> * ( vy [ a . ilo + <NUM_LIT:1> : a . ihi + <NUM_LIT:2> , a . jlo : a . jhi + <NUM_LIT:1> ] - <EOL> vy [ a . ilo - <NUM_LIT:1> : a . ihi , a . jlo : a . jhi + <NUM_LIT:1> ] ) / a . dx - <NUM_LIT:0.5> * ( vx [ a . ilo : a . ihi + <NUM_LIT:1> , a . jlo + <NUM_LIT:1> : a . jhi + <NUM_LIT:2> ] - <EOL> vx [ a . ilo : a . ihi + <NUM_LIT:1> , a . jlo - <NUM_LIT:1> : a . jhi ] ) / a . dy <EOL> else : <EOL> v = myd . get_var ( var ) <EOL> plt . figure ( num = <NUM_LIT:1> , figsize = ( <NUM_LIT> , <NUM_LIT> ) , dpi = <NUM_LIT:100> , facecolor = '<STR_LIT:w>' ) <EOL> plt . imshow ( np . transpose ( v [ a . ilo : a . ihi + <NUM_LIT:1> , a . jlo : a . jhi + <NUM_LIT:1> ] ) , <EOL> interpolation = "<STR_LIT>" , origin = "<STR_LIT>" , <EOL> extent = [ a . xmin , a . xmax , a . ymin , a . ymax ] ) <EOL> plt . axis ( "<STR_LIT>" ) <EOL> plt . subplots_adjust ( bottom = <NUM_LIT:0.0> , top = <NUM_LIT:1.0> , left = <NUM_LIT:0.0> , right = <NUM_LIT:1.0> ) <EOL> plt . savefig ( outfile ) <EOL> def usage ( ) : <EOL> usage = """<STR_LIT>""" <EOL> print usage <EOL> sys . exit ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> try : opts , next = getopt . getopt ( sys . argv [ <NUM_LIT:1> : ] , "<STR_LIT>" ) <EOL> except getopt . GetoptError : <EOL> sys . exit ( "<STR_LIT>" ) <EOL> outfile = "<STR_LIT>" <EOL> for o , a in opts : <EOL> if o == "<STR_LIT>" : usage ( ) <EOL> if o == "<STR_LIT>" : outfile = a <EOL> try : var = next [ <NUM_LIT:0> ] <EOL> except : usage ( ) <EOL> try : file = next [ <NUM_LIT:1> ] <EOL> except : usage ( ) <EOL> myg , myd = patch . read ( file ) <EOL> makeplot ( myd , var , outfile ) </s>
