예제 #1
0
    # Immediate evaluation example
    import time

    start = time.time()
    results = pool.map(busybeaver, range(10))
    print "Time to queue the jobs:", time.time() - start
    start = time.time()
    # Casting the ppmap generator to a list forces each result to be
    # evaluated.  When done immediately after the jobs are submitted,
    # our program twiddles its thumbs while the work is finished.
    print list(results)
    print "Time to get the results:", time.time() - start

    # Delayed evaluation example
    start = time.time()
    results = pool.imap(busybeaver, range(10))
    print "Time to queue the jobs:", time.time() - start
    # In contrast with the above example, this time we're submitting a
    # batch of jobs then going off to do more work while they're
    # processing.  Maybe "time.sleep" isn't the most exciting example,
    # but it illustrates the point that our main program can do work
    # before ppmap() is finished.  Imagine that you're submitting some
    # heavyweight image processing jobs at the beginning of your
    # program, going on to do other stuff like fetching more work to
    # do from a remote server, then coming back later to handle the
    # results.
    time.sleep(5)
    start = time.time()
    print list(results)
    print "Time to get the first results:", time.time() - start
예제 #2
0
def sp_ant_size(
):  # this function runs the availability for a single point and shows a complete output
    with open('temp\\args.pkl', 'rb') as f:
        (site_lat, site_long, sat_long, freq, max_eirp, sat_height, max_bw,
         bw_util, modcod, pol, roll_off, ant_eff, lnb_gain, lnb_temp,
         aditional_losses, cable_loss, max_depoint, max_ant_size, min_ant_size,
         margin, cores) = pickle.load(f)
        f.close()

    #####################################
    ##### ground station parameters #####
    #####################################

    # creating a ground station object
    station = GroundStation(site_lat, site_long)

    ##############################
    ### satellite parameters ###
    ##############################

    data = pd.read_csv('models\\Modulation_dB.csv', sep=';')
    line = data.loc[(data.Modcod) == modcod]
    # tech = line['Tech'].values[0]
    mod = line['Modulation'].values[0]
    fec = line['FEC'].values[0]

    # criando o objeto satélite
    satellite = Satellite(sat_long, freq, max_eirp, sat_height, max_bw,
                          bw_util, 0, 0, mod, roll_off, fec)

    # atribuindo uma estação terrena à um satélite
    satellite.set_grstation(station)

    ##############################
    ### reception parametters ####
    ##############################

    polarization_loss = 3  # perda de polarização, em dB

    # criando o objeto receptor
    reception = Reception(None, ant_eff, aditional_losses, polarization_loss,
                          lnb_gain, lnb_temp, cable_loss, max_depoint)

    # atribuindo uma recepção à um enlace de satélite
    satellite.set_reception(
        reception)  # setando o receptor do link de satélite

    ###################################
    #########     OUTPUTS     #########
    ###################################

    ############ SNR target's calcullation ################

    step = 0.2
    interp_step = int(round((max_ant_size - min_ant_size) * 100))
    ant_size_vector = np.arange(min_ant_size, max_ant_size, step)
    ant_size_vector_interp = np.linspace(min_ant_size, max_ant_size,
                                         interp_step)

    # parallel loop for each antenna size
    pool = ParallelPool(nodes=round(cores / 2))  #ARRUMAR AQUI
    availability_vector = list(
        pool.imap(loop_graph_ant_size, [(satellite, margin, 1, ant_size)
                                        for ant_size in ant_size_vector]))
    pool.clear()

    ant_size_vector = np.array(ant_size_vector)
    availability_vector = np.array(availability_vector)
    ant_size_vector = ant_size_vector[availability_vector > 60]
    availability_vector = availability_vector[availability_vector > 60]

    # a_BSpline = interpolate.make_interp_spline(ant_size_vector, availability_vector, k=2)
    # availability_vector_interp = a_BSpline(ant_size_vector_interp)

    availability_vector_interp = 0
    with open('temp\\args.pkl', 'wb') as f:
        pickle.dump([
            ant_size_vector, ant_size_vector_interp, availability_vector,
            availability_vector_interp
        ], f)
        f.close()

    return
예제 #3
0
    # Immediate evaluation example
    import time
    start = time.time()
    results = pool.map(busybeaver, range(10))
    print('Time to queue the jobs: %s' % (time.time() - start))
    start = time.time()
    # Casting the ppmap generator to a list forces each result to be
    # evaluated.  When done immediately after the jobs are submitted,
    # our program twiddles its thumbs while the work is finished.
    print(list(results))
    print('Time to get the results: %s' % (time.time() - start))

    # Delayed evaluation example
    start = time.time()
    results = pool.imap(busybeaver, range(10))
    print('Time to queue the jobs: %s' % (time.time() - start))
    # In contrast with the above example, this time we're submitting a
    # batch of jobs then going off to do more work while they're
    # processing.  Maybe "time.sleep" isn't the most exciting example,
    # but it illustrates the point that our main program can do work
    # before ppmap() is finished.  Imagine that you're submitting some
    # heavyweight image processing jobs at the beginning of your
    # program, going on to do other stuff like fetching more work to
    # do from a remote server, then coming back later to handle the
    # results.
    time.sleep(5)
    start = time.time()
    print(list(results))
    print('Time to get the first results: %s' % (time.time() - start))
예제 #4
0
def mp_ant_size():
    with open('temp\\args.pkl',
              'rb') as f:  # opening the input variables in the temp file
        (gr_station_path, sat_long, freq, max_eirp, sat_height, max_bw,
         bw_util, modcod, pol, roll_off, ant_eff, lnb_gain, lnb_temp,
         aditional_losses, cable_loss, max_depoint, availability_target,
         snr_relaxation, margin, threads) = pickle.load(f)
        f.close()

    # reading the input table
    # dir = 'models\\'
    # file = 'CitiesBrazil'
    # cities = pd.read_csv(dir + file + '.csv', sep=';', encoding='latin1')
    # cities['availability'] = np.nan  # creating an empty results column

    point_list = pd.read_csv(
        gr_station_path, sep=';',
        encoding='latin1')  # creating a point dataframe from csv file

    data = pd.read_csv('models\\Modulation_dB.csv', sep=';')
    line = data.loc[data.Modcod == modcod]
    # tech = line['Tech'].values[0]
    mod = line['Modulation'].values[0]
    fec = line['FEC'].values[0]

    # creating the satellite object
    sat = Satellite(sat_long, freq, max_eirp, sat_height, max_bw, bw_util, 0,
                    0, mod, roll_off, fec)

    polarization_loss = 3

    reception = Reception(None, ant_eff, aditional_losses, polarization_loss,
                          lnb_gain, lnb_temp, cable_loss,
                          max_depoint)  # creating the receptor object

    # ======================== PARALLEL POOL =============================

    pool = ParallelPool(nodes=threads)  # creating the parallelPoll

    sys.stderr = open('temp\\out.txt', 'w')  # to print the output dynamically

    print('initializing . . .', file=sys.stderr)

    # running the parallel pool
    data = list(
        tqdm.tqdm(pool.imap(point_ant_size,
                            [(point, sat, reception, margin, snr_relaxation,
                              availability_target)
                             for index, point in point_list.iterrows()]),
                  total=len(point_list)))
    pool.clear()

    point_list.drop(point_list.index, inplace=True)
    point_list = point_list.append(data, ignore_index=True)

    # saving the results into a csv file

    dir = 'results'
    if not os.path.exists(dir):
        os.makedirs(dir)

    point_list.to_csv(dir + '\\' + 'results_ant ' +
                      datetime.datetime.now().strftime('%y-%m-%d_%H-%M-%S') +
                      '.csv',
                      sep=';',
                      encoding='latin1')

    print('Complete!!!', file=sys.stderr)

    sys.stderr.close()

    return