Skip to content
Snippets Groups Projects

An example of the argparser usage.

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Marek Cieślar
    argparser.py 1.50 KiB
    if __name__ == "__main__":
        import argparse
    
        parser = argparse.ArgumentParser(description='A multiprocessing script for the computation of the 24h-sensitivity averaged |h|.')
        parser._action_groups.pop() #supress the -h desc.
        required = parser.add_argument_group('required arguments')
        required.add_argument('-i', action='store', dest='pop_file_name', help="the Indri's hdf population file", required=True)
        required.add_argument('-o', action='store', dest='out_file_name', help="the output hdf file", required=True)
        optional = parser.add_argument_group('optional arguments')
        optional.add_argument('-n', action='store', dest='NS_num', type=int, default=10000000, help="the number of NSs to cut from the input file")
        optional.add_argument('-t', action='store', dest='NS_per_thread', type=int, default=10000, help="the number of NSs to be computed in eah thread.")
        optional.add_argument('-p', action='store', dest='processes_count', type=int, default=20, help="the number of processes to use.")
        optional.add_argument("-r", action='store', dest='phase_resolution', type=int, default=1000, help="The resolution of the phase average.")
    
        args = parser.parse_args()
    
        NS_num = args.NS_num
        NS_per_thread = args.NS_per_thread
        g_phase_resolution = args.phase_resolution
        processes_count = args.processes_count
    
        File= args.pop_file_name
        OutFile = args.out_file_name
        print (NS_num, NS_per_thread, processes_count, g_phase_resolution)
        print (File, OutFile)
        exit()
        
    0% or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment