argv_parse(schema, argv) yields the tuple (unparsed_argv, params) where unparsed_argv is a list
      subset of argv that contains only those command line arguments that were not understood by
      the given argument schema and params is a dictionary of parameters as parsed by the given 
      schema. It is equivalent to argv_parser(schema)(argv). See also help(CommandLineParser) for
      information about the instructions format.
    argv_parse(plan, argv) yields a pimms IMap object whose parameters have been initialized from
      the arguments in argv using the given pimms calculation plan as a template for the argument
      schema; see help(to_argv_schema) for information about the way plans are interpreted as argv
      schemas. The plan is initialized with the additional parameters 'argv' and 'argv_parsed'. The
      'argv' parameter contains the command-line arguments in argv that were not interpreted by the
      command-line parser; the 'argv_parsed' parameter contains the parsed command-line parameters.
      To avoid the plan-specific behavior and instead only parse the arguments from a plan, use
      argv_parse(to_argv_schema(plan), argv).

    The following options may be given:
      * init (default: None) specifies that the given dictionary should be merged into either the
        resulting options dictionary (if schema is a schema and not a plan) or into the parameters
        initially provided to the plan (if schema is a plan).
      * arg_names (default: None) may be a dictionary that specifies explicity command-line
        argument names for the plan parameters; plan parameters should be keys and the argument
        names should be values. Any parameter not listed in this option will be interpreted
        according to the above rules. If a parameter is mapped to None then it will not be
        filled from the command-line arguments.
      * arg_abbrevs (default:None) may be a dictionary that is handled identically to that of
        arg_names except that its values must be single letters, which are used for the
        abbreviated flag names.
      * defaults (default: None) may specify the default values for the plan parameters; this
        dictionary overrides the default values of the plan itself.
      * value_parse (default: True) specifies whether the values are interpreted via the
        ast.literal_eval() function. This may be set to False to leave the values as strings or it
        may be set to a function that takes one argument and performs the parsing itself; such a
        function f must obey the syntax `parsed_val = f(string_val)`. The value_parse function is
        only called on arguments that have string values included. Note that by default the
        value_parse function interprets the string '...' as Ellipsis in addition to the typical
        ast.literal_eval() behavior.
      * filters (default: None) optionally specifies a dictionary of filter functions, each of which
        is passed the parsed value of the associated argument. Each filter function f must obey the
        syntax `final_value = f(parsed_value)`. The keys of this dictionary must be the entry names
        of the arguments. Note that filter functions are called on provided default values but the
        value_parse function is not called on these.

def argv_parse(schema, argv, init=None,
               arg_names=None, arg_abbrevs=None, value_parser=True, defaults=None, filters=None):
    '''
    argv_parse(schema, argv) yields the tuple (unparsed_argv, params) where unparsed_argv is a list
      subset of argv that contains only those command line arguments that were not understood by
      the given argument schema and params is a dictionary of parameters as parsed by the given 
      schema. It is equivalent to argv_parser(schema)(argv). See also help(CommandLineParser) for
      information about the instructions format.
    argv_parse(plan, argv) yields a pimms IMap object whose parameters have been initialized from
      the arguments in argv using the given pimms calculation plan as a template for the argument
      schema; see help(to_argv_schema) for information about the way plans are interpreted as argv
      schemas. The plan is initialized with the additional parameters 'argv' and 'argv_parsed'. The
      'argv' parameter contains the command-line arguments in argv that were not interpreted by the
      command-line parser; the 'argv_parsed' parameter contains the parsed command-line parameters.
      To avoid the plan-specific behavior and instead only parse the arguments from a plan, use
      argv_parse(to_argv_schema(plan), argv).

    The following options may be given:
      * init (default: None) specifies that the given dictionary should be merged into either the
        resulting options dictionary (if schema is a schema and not a plan) or into the parameters
        initially provided to the plan (if schema is a plan).
      * arg_names (default: None) may be a dictionary that specifies explicity command-line
        argument names for the plan parameters; plan parameters should be keys and the argument
        names should be values. Any parameter not listed in this option will be interpreted
        according to the above rules. If a parameter is mapped to None then it will not be
        filled from the command-line arguments.
      * arg_abbrevs (default:None) may be a dictionary that is handled identically to that of
        arg_names except that its values must be single letters, which are used for the
        abbreviated flag names.
      * defaults (default: None) may specify the default values for the plan parameters; this
        dictionary overrides the default values of the plan itself.
      * value_parse (default: True) specifies whether the values are interpreted via the
        ast.literal_eval() function. This may be set to False to leave the values as strings or it
        may be set to a function that takes one argument and performs the parsing itself; such a
        function f must obey the syntax `parsed_val = f(string_val)`. The value_parse function is
        only called on arguments that have string values included. Note that by default the
        value_parse function interprets the string '...' as Ellipsis in addition to the typical
        ast.literal_eval() behavior.
      * filters (default: None) optionally specifies a dictionary of filter functions, each of which
        is passed the parsed value of the associated argument. Each filter function f must obey the
        syntax `final_value = f(parsed_value)`. The keys of this dictionary must be the entry names
        of the arguments. Note that filter functions are called on provided default values but the
        value_parse function is not called on these.
    '''
    parser = argv_parser(schema,
                         arg_names=arg_names, arg_abbrevs=arg_abbrevs, defaults=defaults,
                         value_parser=value_parser, filters=filters)
    res = parser(argv)
    if is_plan(schema):
        init = {} if init is None else init
        init = pyr.pmap(init) if not is_pmap(init) else init
        return schema({'argv': tuple(res[0]), 'argv_parsed': pyr.pmap(res[1])}, res[1], init)
    else:
        return res if init is None else (res[0], dict(merge(res[1], init)))