Example #1
0
    def set_reception(self,
                      reception: Reception):  # set the link's reception system
        reception.set_parameters(self.freq, self.get_elevation(
        ))  # parameters used in some functions in Reception
        self.reception = reception

        pass
Example #2
0
def calc_atm_atnn():
    with open('temp\\args.pkl', 'rb') as f:
        p, site_lat, site_long, ant_size, ant_eff, sat_long, freq, method = pickle.load(f)
        f.close()

    sys.stdout = open('temp\\out.txt', 'w')  # creating a output file to show in the interface
    gr_station = GroundStation(site_lat, site_long)
    satellite = Satellite(sat_long, freq)
    reception = Reception(ant_size, ant_eff)

    satellite.set_grstation(gr_station)
    satellite.set_reception(reception)

    start = time.time()
    # running the atmospheric attenuation calculations and storing the results
    a_fs, a_dep, a_g, a_c, a_r, a_s, a_t, a_tot = satellite.get_link_attenuation(p, method)

    # preparing the outputs
    # ====== REMEMBER TO ADJUST TO 3 DECIMALS ALL OUTPUTS!!!!! =======
    print('RESULTS', file=sys.stdout)
    print('', file=sys.stdout)
    print('Reception characteristics:', file=sys.stdout)
    print('', file=sys.stdout)
    print('Earth\'s radius in lat/long: ', np.round(satellite.grstation.get_earth_radius(),3), ' km', file=sys.stdout)
    print('Elevation angle: ', np.round(satellite.get_elevation(), 3), ' degress', file=sys.stdout)
    print('Link length: ', np.round(satellite.get_distance(), 3), 'km', file=sys.stdout)
    print('Ground noise temperature: ', np.round(satellite.reception.get_ground_temp(), 3), ' K', file=sys.stdout)
    print('Sky brightness temperature', np.round(satellite.reception.get_brightness_temp(), 3), ' K', file=sys.stdout)
    print('', file=sys.stdout)
    print('', file=sys.stdout)

    print('Link budget Aaalysis:', file=sys.stdout)
    print('', file=sys.stdout)
    print("Gaseous attenuation: ", np.round(a_g, 3), file=sys.stdout)
    print("Cloud attenuation: ", np.round(a_c, 3), file=sys.stdout)
    print("Rain attenuation: ", np.round(a_r, 3), file=sys.stdout)
    print("Scintillation attenuation: ", np.round(a_s, 3), file=sys.stdout)
    print("Total atmospheric attenuation: ", np.round(a_t, 3), file=sys.stdout)
    print('Free space attenuation: ', np.round(a_fs, 3), file=sys.stdout)
    print('Free space + atmospheric + depointing attenuation: ', np.round(a_tot, 3), ' dB', file=sys.stdout)

    print('', file=sys.stdout)
    print('Runtime: ', np.round(time.time() - start, 2), ' s', file=sys.stdout)

    if os.path.exists('temp\\args.pkl'):  # deleting the input variables temp file
        os.remove('temp\\args.pkl')

    sys.stdout.close()

    return
Example #3
0
    # creating the satellite object
    sat = Satellite(sat_long, freq, eirp, hsat, b_transponder, b_util, backoff,
                    contour, mod, rolloff, fec)

    # reception parameters
    ant_size = 1.2  # reception antenna diameter [m]
    ant_eff = 0.6  # reception antenna efficiency
    coupling_loss = 0  # [dB]
    polarization_loss = 3  # [dB]
    lnb_gain = 55  # [dB]
    lnb_noise_temp = 20  # [dB]
    cable_loss = 4  # [dB]
    max_depoint = 0.1  # maximum depointing angle [degrees]

    # creating a reception object
    reception = Reception(ant_size, ant_eff, coupling_loss, polarization_loss,
                          lnb_gain, lnb_noise_temp, cable_loss, max_depoint)

    cores = multiprocessing.cpu_count() - 2

    p = multiprocessing.Pool(processes=cores)

    # calculation loop
    start_time = time.time()

    data = list(
        tqdm.tqdm(p.imap_unordered(point_ant_size,
                                   [(city, sat, reception)
                                    for index, city in point_list.iterrows()]),
                  total=len(point_list)))
    p.close()
Example #4
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
Example #5
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
Example #6
0
def sp_link_performance(
):  # this function runs the availability for a single point and shows a complete output
    path = convert_path_os('temp\\args.pkl')
    with open(path, 'rb') as f:
        (site_lat, site_long, sat_long, freq, max_eirp, sat_height, max_bw,
         bw_util, modcod, pol, roll_off, ant_size, ant_eff, lnb_gain, lnb_temp,
         coupling_loss, cable_loss, max_depoint, snr_relaxation,
         margin) = pickle.load(f)
        f.close()

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

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

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

    path = convert_path_os('models\\Modulation_dB.csv')
    data = pd.read_csv(path, 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
    satelite = 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
    satelite.set_grstation(station)

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

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

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

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

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

    ############ SNR target's calcullation ################
    path = convert_path_os('temp\\out.txt')
    sys.stdout = open(path, 'w')

    start = time.time()
    print('RESULTS', file=sys.stdout)
    print('', file=sys.stdout)
    print('Link budget at 0.001%:', file=sys.stdout)
    print('', file=sys.stdout)
    print('C/N0: ', satelite.get_c_over_n0(0.001), ' dB')
    print('SNR: ', satelite.get_snr(0.001), ' dB')
    print('', file=sys.stdout)
    print('', file=sys.stdout)

    print('Actual SNR target\'s availability: ',
          satelite.get_availability(margin, snr_relaxation),
          '%',
          file=sys.stdout)
    print('', file=sys.stdout)

    print('Reception characteristics:', file=sys.stdout)
    print('', file=sys.stdout)

    print('Earth\'s radius in lat/long: ',
          np.round(satelite.grstation.get_earth_radius(), 3),
          ' km',
          file=sys.stdout)
    print('Elevation angle: ',
          np.round(satelite.get_elevation(), 3),
          ' degrees',
          file=sys.stdout)
    print('Link length: ',
          np.round(satelite.get_distance(), 3),
          'km',
          file=sys.stdout)
    print('Ground noise temperature: ',
          np.round(satelite.reception.get_ground_temp(), 3),
          ' K',
          file=sys.stdout)
    print('Sky brightness temperature',
          np.round(satelite.reception.get_brightness_temp(), 3),
          ' K',
          file=sys.stdout)
    print('Antenna noise temperature: ',
          np.round(satelite.reception.get_antenna_noise_temp(), 3),
          ' K',
          file=sys.stdout)
    print('Antenna noise temperature w/ rain:',
          np.round(satelite.get_antenna_noise_rain(), 3),
          ' K',
          file=sys.stdout)
    print('Total noise temperature: ',
          np.round(satelite.get_total_noise_temp(), 3),
          ' K',
          file=sys.stdout)
    print('Reception antenna gain: ',
          np.round(satelite.reception.get_antenna_gain(), 3),
          ' dBi',
          file=sys.stdout)
    print('Reception antenna 3dB beamwidth: ',
          np.round(satelite.reception.get_beamwidth(), 3),
          ' degrees',
          file=sys.stdout)
    print('Figure of Merit: ',
          np.round(satelite.get_figure_of_merit(), 3),
          file=sys.stdout)
    print('', file=sys.stdout)
    print('', file=sys.stdout)

    a_fs, a_dep, a_g, a_c, a_r, a_s, a_t, a_tot = satelite.get_link_attenuation(
        satelite.p)

    print('Link budget Analysis:', file=sys.stdout)
    print('', file=sys.stdout)

    print("Gaseous attenuation: ", np.round(a_g, 3), file=sys.stdout)
    print("Cloud attenuation: ", np.round(a_c, 3), file=sys.stdout)
    print("Rain attenuation: ", np.round(a_r, 3), file=sys.stdout)
    print("Scintillation attenuation: ", np.round(a_s, 3), file=sys.stdout)
    print("Total atmospheric attenuation: ", np.round(a_t, 3), file=sys.stdout)
    print('Free space attenuation: ', np.round(a_fs, 3), file=sys.stdout)
    print('Free space + atmospheric + depointing attenuation: ',
          np.round(a_tot, 3),
          ' dB',
          file=sys.stdout)

    print('Reception threshold (SNR): ',
          np.round(satelite.get_reception_threshold(), 3),
          ' dB',
          file=sys.stdout)

    print('', file=sys.stdout)
    print('Runtime: ', np.round(time.time() - start, 2), ' s', file=sys.stdout)

    sys.stdout.close()

    path = convert_path_os('temp\\args.pkl')

    if os.path.exists(path):
        os.remove(path)

    return