예제 #1
0
파일: GrStat.py 프로젝트: cfragoas/SatLink
    def get_brightness_temp(self, printer=False):
        if self.freq is None or self.e is None:
            sys.exit('Need to associate a reception to a satellite first. Try satellite.set_reception(reception)!!!')
        elif self.t_sky is not None:
            return self.t_sky
        else:
            path = util.convert_path_os('models\\ClearSkyTemp ITU 372.csv')
            data = pd.read_csv(path, sep=';', index_col=0)
            self.t_sky = util.curve_interpolation(self.freq, self.e, data)
        if printer:
            print('elevation: ', self.e, ' freq: ', self.freq, ' Tsky (brightness temperature): ', self.t_sky)

        return self.t_sky
예제 #2
0
    def get_reception_threshold(
        self
    ):  # returns the threshold for a given modulation scheme (modcod file)
        if self.modulation == '' or self.fec == '':
            sys.exit(
                'You need to create a satellite class with a technology, modulation and FEC to use this function!!!'
            )
        elif self.snr_threshold is not None:
            return self.snr_threshold

        path = convert_path_os('models\\Modulation_dB.csv')
        data = pd.read_csv(path, sep=';')
        # line = data.loc[(data.Tech == self.tech) & (data.Modulation == self.modulation) & (data.FEC == self.fec)]
        line = data.loc[(data.Modulation == self.modulation)
                        & (data.FEC == self.fec)]
        self.snr_threshold = line['C_over_N'].values[0]
        return self.snr_threshold
예제 #3
0
# Ground Station variables
st.subheader('Ground Station')
grstat_exp = st.expander(label='', expanded=True)
with grstat_exp:
    grstat_col1, grstat_col2 = st.columns(2)

    # grstat_lat.header("Latitude (degress)")
    site_lat = grstat_col1.number_input('Latitude (degrees)')

    # grstat_long.header("Longitude (degrees)")
    site_long = grstat_col2.number_input('Longitude (degrees)')

# Satellite variables
st.subheader('Satellite')
sat_exp = st.expander(label='', expanded=True)
path = convert_path_os('models\\Modulation_dB.csv')
mod_list = pd.read_csv(path, sep=';')['Modcod']  # to fill modulation combobox

with sat_exp:
    sat_col1, sat_col2, sat_col3, sat_col4, sat_col5 = st.columns(5)

    sat_long = sat_col1.number_input('Longitude (degress)')
    max_bw = sat_col1.number_input('Transponder s max bandwidith (MHz)')

    sat_height = sat_col2.number_input('Altitude (Km)')
    bw_util = sat_col2.number_input('Effective bandwith (MHz)')

    freq = sat_col3.number_input('Frequency (GHz)')
    roll_off = sat_col3.number_input('Roll-off')

    max_eirp = sat_col4.number_input('EIRP (dBW)')
예제 #4
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
예제 #5
0
def mp_link_performance():
    path = convert_path_os('temp\\args.pkl')
    with open(path, '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_size, ant_eff, lnb_gain, lnb_temp,
         coupling_loss, cable_loss, max_depoint, 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
    point_list['availability'] = np.nan  # creating an empty results column

    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]

    # 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(ant_size, ant_eff, coupling_loss, polarization_loss,
                          lnb_gain, lnb_temp, cable_loss,
                          max_depoint)  # creating the receptor object

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

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

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

    # running the parallel pool
    data = list(
        tqdm.tqdm(pool.imap(point_availability,
                            [(point, sat, reception, margin, snr_relaxation)
                             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)
    point_list['unavailability time (min)'] = round(
        ((100 - point_list['availability']) / 100) * 525600,
        0)  # calculating the availability in minutes

    # saving the results into a csv file

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

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

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

    sys.stderr.close()

    return