How to use the pyuvsim.profiling.set_profiler function in pyuvsim

To help you get started, we’ve selected a few pyuvsim examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github RadioAstronomySoftwareGroup / pyuvsim / scripts / run_profile_pyuvsim.py View on Github external
params['config_path'] = os.path.dirname(paramsfile)

min_alt = 70  # Degrees

mpi.start_mpi()
rank = mpi.get_rank()

if rank == 0:
    t0 = pytime.time()

beam_list = None
beam_dict = None
input_uv = UVData()
mock_keywords = None
catalog = None
profiling.set_profiler(outfile_prefix=args.prof_out)

if rank == 0:
    print("{} freqs, {} times, {} bls, {} srcs, {} beam".format(
        args.Nfreqs, args.Ntimes, args.Nbls, args.Nsrcs, args.beam))
    params['freq']['Nfreqs'] = args.Nfreqs
    params['time']['Ntimes'] = args.Ntimes
    params['sources'] = {'catalog': 'mock'}

    input_uv, beam_list, beam_dict = simsetup.initialize_uvdata_from_params(params)

    if input_uv.Nbls < args.Nbls:
        raise ValueError('Cannot profile for more than {} baselines, requeted {}'.format(
            input_uv.Nbls, args.Nbls))

    # Baseline selection:
    input_uv.baseline_array = np.repeat(input_uv.baseline_array[:args.Nbls], args.Ntimes)
github RadioAstronomySoftwareGroup / pyuvsim / scripts / run_param_pyuvsim.py View on Github external
parser = argparse.ArgumentParser(
    description="A command-line script to execute a pyuvsim simulation from a parameter file."
)
parser.add_argument('paramsfile', type=str, help='Parameter yaml file.', default=None)
parser.add_argument('--profile', type=str, help='Time profiling output file name.')
parser.add_argument('--quiet', action='store_true', help='Suppress stdout printing.')
parser.add_argument('--raw_profile', help='Also save pickled LineStats data for line profiling.',
                    action='store_true')

args = parser.parse_args()

if args.paramsfile is None:
    raise ValueError("Parameter file required")

if args.profile is not None:
    pyuvsim.profiling.set_profiler(outfile_prefix=args.profile, dump_raw=args.raw_profile)

if not os.path.isdir(os.path.dirname(args.paramsfile)):
    args.paramsfile = os.path.join('.', args.paramsfile)

t0 = pytime.time()

pyuvsim.uvsim.run_uvsim(args.paramsfile, quiet=args.quiet)

if args.profile:
    dt = pytime.time() - t0
    maxrss = pyuvsim.mpi.get_max_node_rss()
    rtime = str(timedelta(seconds=dt))
    if isinstance(maxrss, float):
        print('\tRuntime: {} \n\tMaxRSS: {:.3f} GiB'.format(
            rtime, maxrss
        ))