def print_master(string, args):
    comm = MPI.COMM_WORLD
    if comm.rank == 0:
        po.myprint('[' + str(comm.rank) + '] ' + string + '\n', args)
def print_mpi(string, args):
    comm = MPI.COMM_WORLD
    po.myprint('[' + str(comm.rank) + '] {'+subprocess.check_output(['uname -n'],shell=True)[:-1]+'} ' + string + '\n', args)
Esempio n. 3
0
        t_start = MPI.Wtime()  ### Start stopwatch ###

        ppv_local, ppv_u_local = po.makeobservable(
            cube, args, logbook, properties, core_start, core_end,
            prefix)  # performing operation on cube

        comm.Barrier()
        comm.Allreduce(MPI.IN_PLACE, ppv_local, op=MPI.SUM)
        comm.Allreduce(MPI.IN_PLACE, ppv_u_local, op=MPI.SUM)
        if rank == 0:
            ppv_local = np.ma.masked_where(ppv_local < 0., ppv_local)
            po.write_fits(logbook.fitsname, ppv_local, args)
            po.write_fits(logbook.fitsname_u, ppv_u_local, args)

        t_diff = MPI.Wtime() - t_start  ### Stop stopwatch ###
        print_master(
            'Parallely: time taken for make-observable of ' + str(nslice) +
            ' slices with ' + str(ncores) + ' cores= ' + str(t_diff / 60.) +
            ' min', args)
    else:
        po.myprint('Making slices to observables, in series...', args)
        time_temp = time.time()
        ppv, ppv_u = po.makeobservable(cube, args, logbook, properties, 0,
                                       nslice,
                                       '')  # performing operation on cube
        po.write_fits(logbook.fitsname, ppv, args)
        po.write_fits(logbook.fitsname_u, ppv_u, args)
        po.myprint(
            'Serially: time taken for make-observable of ' + str(nslice) +
            ' slices= ' + str((time.time() - time_temp) / 60.) + ' min', args)
Esempio n. 4
0
                      str(np.max(flam)) + ',' + str(np.min(flam)) + '\n', args)

        mapcube_local[i, j, :], errorcube_local[i, j, :] = po.fit_all_lines(
            args, logbook, wave, flam, flam_u, cont, i, j, z=0., z_err=0.0001)
        if not args.silent:            print_mpi('Fitted cell ' + str(k) + ' i.e. cell ' + str(i) + ',' + str(j) + ' of ' + str(core_end) + \
                      ' cells at: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now()), args)

    comm.Barrier()
    comm.Allreduce(MPI.IN_PLACE, mapcube_local, op=MPI.SUM)
    comm.Allreduce(MPI.IN_PLACE, errorcube_local, op=MPI.SUM)

    if rank == 0:
        if args.debug:
            po.myprint(
                'Deb120: Trying to calculate some statistics on the cube of shape ('
                + str(np.shape(mapcube_local)[0]) + ',' +
                str(np.shape(mapcube_local)[1]) + ',' +
                str(np.shape(mapcube_local)[2]) + '), please wait...', args)
            po.mydiag('Deb121: in ergs/s/pc^2: for mapcube', mapcube_local,
                      args)
            po.myprint(
                'Deb120: Trying to calculate some statistics on the cube of shape ('
                + str(np.shape(errorcube_local)[0]) + ',' +
                str(np.shape(errorcube_local)[1]) + ',' +
                str(np.shape(errorcube_local)[2]) + '), please wait...', args)
            po.mydiag('Deb121: in ergs/s/pc^2: for mapcube', errorcube_local,
                      args)
        po.write_fits(logbook.fittedcube, mapcube_local, args)
        po.write_fits(logbook.fittederror, errorcube_local, args)

    t_diff = MPI.Wtime() - t_start  ### Stop stopwatch ###
Esempio n. 5
0
        po.myexit(args)

    if args.X is not None:
        args.X = int(args.X)
    else:
        args.X = np.shape(
            properties.ppvcube
        )[0] / 2  # p-p values at which point to extract spectrum from the ppv cube

    if args.Y is not None:
        args.Y = int(args.Y)
    else:
        args.Y = np.shape(
            properties.ppvcube
        )[0] / 2  # p-p values at which point to extract spectrum from the ppv cube

    if not np.array(properties.ppvcube[args.X, args.Y, :]).any():
        po.myprint('Chosen spaxel is empty. Select another.', args)
        po.myprint('Non empty spaxels are:', args)
        for i in range(np.shape(properties.ppvcube)[0]):
            for j in range(np.shape(properties.ppvcube)[1]):
                if np.array(properties.ppvcube[i, j, :]).any():
                    print i, j

        po.myexit(args, text='Try again.')
    # -------------------------------------------------------------------------------------------
    flux, flux_errors = fitspaxel(args, logbook, properties)
    print np.shape(properties.ppvcube
                   ), args.X, args.Y, args.SNR_thresh, flux / flux_errors  #
    print 'Finished!'