Ejemplo n.º 1
0
def parse_args(argument_adder, from_commandline=False, **kwargs):
    """
    Return Namespace of arguments.

    If from_commandline, the arguments are parsed from sys.argv;
    otherwise, defaults are returned.

    argument_adder is a function which modifies an argparse.ArgumentParser
    to give it simulation-specific arguments.

    Optional kwargs allow overriding default argument values.

    """
    # set up default arguments common to all simulations
    parser = anuga.create_standard_parser()
    
    # add any benchmark-specific arguments
    argument_adder(parser)

    # override default argument values
    parser.set_defaults(**kwargs)

    if from_commandline:
        return parser.parse_args()
    else:
        return parser.parse_args([])
Ejemplo n.º 2
0
def parse_args_and_parameters(argument_adder=None, from_commandline=False, **kwargs):
    """
    Return Namespace of arguments.

    If from_commandline, the arguments are parsed from sys.argv;
    otherwise, defaults are returned.

    argument_adder is a function which modifies an argparse.ArgumentParser
    to give it simulation-specific arguments.

    Optional kwargs allow overriding default argument values. 
       
    Combine with local variables from project.py 
    """
    

    
    parser = anuga.create_standard_parser()
    
    try:
        import project

        # Make variables in project.py into a dictionary
        project_dict = vars(project)
        del project_dict['__builtins__']
        del project_dict['__doc__']
        del project_dict['__file__']
        del project_dict['__name__']
        del project_dict['__package__']
        del project_dict['join']
    except:
        project_dict = {}

    # add any benchmark-specific arguments
    if argument_adder:
        argument_adder(parser)

    # override default argument values from project.py
    parser.set_defaults(**project_dict)
    
    # override default argument values
    parser.set_defaults(**kwargs)

    if from_commandline:
        return parser.parse_args()
    else:
        return parser.parse_args([])
Ejemplo n.º 3
0
"""
    Quick plot of the subcritical-flow outputs

"""

import anuga.utilities.plot_utils as util
import matplotlib

matplotlib.use("Agg")
from matplotlib import pyplot as pyplot
from analytical_supercritical import analytic_sol
from numpy import ones, arange

import anuga

parser = anuga.create_standard_parser()

parser.add_argument("-tid", type=int, default=-1, help="timestep id")
args = parser.parse_args()
tid = args.tid
verbose = args.verbose


if verbose:
    print "Read in swwfile"
p_st = util.get_output("supercritical.sww")
p2_st = util.get_centroids(p_st)

# v = p2_st.y[10]
# v2=(p2_st.y==v)
# v2=(p2_st.y>-1.0)
Ejemplo n.º 4
0
"""
    Quick plot of the subcritical-flow outputs

"""

import anuga.utilities.plot_utils as util
import matplotlib
matplotlib.use('Agg')
from matplotlib import pyplot as pyplot
from analytical_supercritical import analytic_sol
from numpy import ones, arange

import anuga
parser = anuga.create_standard_parser()

parser.add_argument('-tid', type=int, default=-1, help='timestep id')
args = parser.parse_args()
tid = args.tid
verbose = args.verbose

if verbose: print('Read in swwfile')
p_st = util.get_output('supercritical.sww')
p2_st = util.get_centroids(p_st)

#v = p2_st.y[10]
#v2=(p2_st.y==v)
#v2=(p2_st.y>-1.0)
v2 = arange(len(p2_st.y))

if verbose: print('Calculate analytical solution')
h, z = analytic_sol(p2_st.x[v2])