Skip to content

Commit

Permalink
Merge pull request #21 from edwardoughton/edit_rain_att
Browse files Browse the repository at this point in the history
Edit rain att
  • Loading branch information
edwardoughton committed Apr 7, 2021
2 parents 7a5e798 + b402082 commit 6e1ac44
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 56 deletions.
12 changes: 5 additions & 7 deletions scripts/inputs.py
Expand Up @@ -17,14 +17,13 @@
'total_area_earth_km_sq': 510000000, #Area of Earth in km^2
'altitude_km': 550, #Altitude of starlink satellites in km
'dl_frequency': 13.5*10**9, #Downlink frequency in Hertz
'dl_bandwidth': 0.25*10**9, #Downlink bandwidth in Hertz
'dl_bandwidth': 0.5*10**9, #Downlink bandwidth in Hertz
'speed_of_light': 3.0*10**8, #Speed of light in vacuum
'antenna_diameter': 0.7, #Metres
'antenna_efficiency': 0.6,
'power': 30, #dBw
'losses': 4, #dB
'receiver_gain': 38,
'rain_attenuation': 0, #Rain Attenuation
'earth_atmospheric_losses': 10, #Rain Attenuation
'all_other_losses': 0.53, #All other losses
'number_of_channels': 8, #Number of channels per satellite
'overbooking_factor': 20, # 1 in 20 users access the network
Expand All @@ -43,11 +42,10 @@
'antenna_diameter': 0.75, #Metres
'antenna_efficiency': 0.6,
'power': 30, #dBw
'losses': 4, #dB
'receiver_gain': 38,
'rain_attenuation': 0, #Rain Attenuation
'earth_atmospheric_losses': 10, #Rain Attenuation
'all_other_losses': 0.53, #All other losses
'number_of_channels': 16, #Number of channels per satellite
'number_of_channels': 8, #Number of channels per satellite
'overbooking_factor': 20, # 1 in 20 users access the network
},
'kuiper': {
Expand All @@ -65,7 +63,7 @@
'antenna_efficiency': 0.6,
'power': 30, #dBw
'receiver_gain': 39,
'rain_attenuation': 0, #Rain Attenuation
'earth_atmospheric_losses': 10, #Rain Attenuation
'all_other_losses': 0.53, #All other losses
'number_of_channels': 8, #Number of channels per satellite
'overbooking_factor': 20, # 1 in 20 users access the network
Expand Down
14 changes: 9 additions & 5 deletions scripts/run.py
Expand Up @@ -41,20 +41,24 @@ def process_capacity_data(data, constellations):
max_satellites = max(list(max_satellites_set)) #max density
coverage_area = min(list(coverage_area_set)) #minimum coverage area

capacity_results = []
channel_capacity_results = []
aggregate_capacity_results = []

for idx, item in data.iterrows():
if constellation.lower() == item['constellation'].lower():
if item['number_of_satellites'] == max_satellites:
capacity_results.append(item['capacity']) #append to list
channel_capacity_results.append(item['channel_capacity']) #append to list
aggregate_capacity_results.append(item['aggregate_capacity']) #append to list

mean_capacity = sum(capacity_results) / len(capacity_results)
mean_channel_capacity = sum(channel_capacity_results) / len(channel_capacity_results)
mean_agg_capacity = sum(aggregate_capacity_results) / len(aggregate_capacity_results)

output[constellation] = {
'number_of_satellites': max_satellites,
'satellite_coverage_area': coverage_area,
'capacity': mean_capacity,
'capacity_kmsq': mean_capacity / coverage_area,
'channel_capacity': mean_channel_capacity,
'aggregate_capacity': mean_agg_capacity,
'capacity_kmsq': mean_agg_capacity / coverage_area,
}


Expand Down
48 changes: 35 additions & 13 deletions src/globalsat/sim.py
Expand Up @@ -62,7 +62,7 @@ def system_capacity(constellation, number_of_satellites, params, lut):

eirp = calc_eirp(params['power'], antenna_gain)

losses = calc_losses(params['rain_attenuation'], params['all_other_losses'])
losses = calc_losses(params['earth_atmospheric_losses'], params['all_other_losses'])

noise = calc_noise()

Expand All @@ -72,8 +72,9 @@ def system_capacity(constellation, number_of_satellites, params, lut):

spectral_efficiency = calc_spectral_efficiency(cnr, lut)

capacity = calc_capacity(spectral_efficiency, params['dl_bandwidth'],
params['number_of_channels'])
channel_capacity = calc_capacity(spectral_efficiency, params['dl_bandwidth'])

agg_capacity = calc_agg_capacity(channel_capacity, params['number_of_channels'])

results.append({
'constellation': constellation,
Expand All @@ -89,8 +90,9 @@ def system_capacity(constellation, number_of_satellites, params, lut):
'noise': noise,
'cnr': cnr,
'spectral_efficiency': spectral_efficiency,
'capacity': capacity,
'capacity_kmsq': capacity / satellite_coverage_area_km,
'channel_capacity': channel_capacity,
'aggregate_capacity': agg_capacity,
'capacity_kmsq': agg_capacity / satellite_coverage_area_km,
})

return results
Expand Down Expand Up @@ -265,13 +267,13 @@ def calc_eirp(power, antenna_gain):
return eirp


def calc_losses(rain_attenuation, all_other_losses):
def calc_losses(earth_atmospheric_losses, all_other_losses):
"""
Estimates the transmission signal losses.
Parameters
----------
rain_attentuation : int
earth_atmospheric_losses : int
Signal losses from rain attenuation.
all_other_losses : float
All other signal losses.
Expand All @@ -282,7 +284,7 @@ def calc_losses(rain_attenuation, all_other_losses):
The estimated transmission signal losses.
"""
losses = rain_attenuation + all_other_losses
losses = earth_atmospheric_losses + all_other_losses

return losses

Expand Down Expand Up @@ -418,7 +420,7 @@ def calc_spectral_efficiency(cnr, lut):
return spectral_efficiency


def calc_capacity(spectral_efficiency, dl_bandwidth, number_of_channels):
def calc_capacity(spectral_efficiency, dl_bandwidth):
"""
Calculate the channel capacity.
Expand All @@ -428,18 +430,38 @@ def calc_capacity(spectral_efficiency, dl_bandwidth, number_of_channels):
The number of bits per Hertz able to be transmitted.
dl_bandwidth: float
The channel bandwidth in Hetz.
Returns
-------
channel_capacity : float
The channel capacity in Mbps.
"""
channel_capacity = spectral_efficiency * dl_bandwidth / (10**6)

return channel_capacity


def calc_agg_capacity(channel_capacity, number_of_channels):
"""
Calculate the aggregate capacity.
Parameters
----------
channel_capacity : float
The channel capacity in Mbps.
number_of_channels : int
The number of user channels per satellite.
Returns
-------
capacity : float
The channel capacity in Mbps.
agg_capacity : float
The aggregate capacity in Mbps.
"""
capacity = spectral_efficiency * dl_bandwidth * number_of_channels / (10**6)
agg_capacity = channel_capacity * number_of_channels

return capacity
return agg_capacity


def pairwise(iterable):
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Expand Up @@ -19,7 +19,7 @@ def setup_params():
'power': 30, #dBw
'losses': 4, #dB
'receiver_gain': 38, #dB
'rain_attenuation': 10, #Rain Attenuation
'earth_atmospheric_losses': 10, #Rain Attenuation
'all_other_losses': 0.53, #All other losses
'number_of_channels': 1,
}
Expand Down
20 changes: 15 additions & 5 deletions tests/test_sim.py
Expand Up @@ -12,6 +12,7 @@
calc_cnr,
calc_spectral_efficiency,
calc_capacity,
calc_agg_capacity
)


Expand All @@ -35,7 +36,7 @@ def test_system_capacity(setup_params, setup_lut):
assert round(results['noise']) == -90
assert round(results['cnr']) == 49.0
assert results['spectral_efficiency'] == 5.768987
assert round(results['capacity']) == 1442
assert round(results['channel_capacity']) == 1442
assert round(results['capacity_kmsq']) == 144


Expand All @@ -51,7 +52,6 @@ def test_calc_geographic_metrics():

params = {
'total_area_earth_km_sq': 100,
# 'portion_of_earth_covered': 0.8,
'altitude_km': 10,
}

Expand Down Expand Up @@ -173,7 +173,7 @@ def test_calc_cnr():

def test_calc_spectral_efficiency(setup_lut):
"""
Unit test for finding the spectral efficnecy.
Unit test for finding the spectral efficiency.
"""
#using actual lut
Expand All @@ -186,11 +186,21 @@ def test_calc_spectral_efficiency(setup_lut):

def test_calc_capacity():
"""
Unit test for finding the spectral efficnecy.
Unit test for calculating the channel capacity.
"""
spectral_efficiency = 1 # bits per Hertz
dl_bandwidth = 1e6 # Hertz

assert calc_capacity(spectral_efficiency, dl_bandwidth) == 1 #mbps


def test_calc_agg_capacity():
"""
Unit test for calculating the aggregate capacity.
"""
channel_capacity = 100
number_of_beams = 1

assert calc_capacity(spectral_efficiency, dl_bandwidth, number_of_beams) == 1 #mbps
assert calc_agg_capacity(channel_capacity, number_of_beams) == 100 #mbps
55 changes: 30 additions & 25 deletions vis/vis.py
Expand Up @@ -30,14 +30,17 @@ def plot_aggregated_engineering_metrics(data):
Create 2D engineering plots for system capacity model.
"""

data.columns = [
'Constellation', 'Number of Satellites','Asset Distance',
'Coverage Area', 'Iteration', 'Free Space Path Loss',
'Random Variation', 'Antenna Gain', 'EIRP',
'Received Power', 'Noise', 'Carrier-to-Noise-Ratio',
'Spectral Efficiency', 'Aggregate Channel Capacity', 'Area Capacity'
'Spectral Efficiency', 'Channel Capacity',
'Aggregate Channel Capacity', 'Area Capacity'
]

data['Channel Capacity'] = round(data['Channel Capacity'] / 1e3,2)
data['Aggregate Channel Capacity'] = round(data['Aggregate Channel Capacity'] / 1e3)

data = data[[
Expand All @@ -47,8 +50,8 @@ def plot_aggregated_engineering_metrics(data):
'Received Power',
'Carrier-to-Noise-Ratio',
'Spectral Efficiency',
'Channel Capacity',
'Aggregate Channel Capacity',
'Area Capacity'
]].reset_index()

data['Constellation'] = data['Constellation'].replace(regex='starlink', value='Starlink')
Expand All @@ -64,8 +67,8 @@ def plot_aggregated_engineering_metrics(data):
'Received Power',
'Carrier-to-Noise-Ratio',
'Spectral Efficiency',
'Channel Capacity',
'Aggregate Channel Capacity',
'Area Capacity'
]
)

Expand All @@ -77,7 +80,7 @@ def plot_aggregated_engineering_metrics(data):

plot = sns.relplot(
x="Number of Satellites", y='Value', linewidth=1.2, hue='Constellation',
col="Metric", col_wrap=2, #labels=['Starlink','Kuiper', 'OneWeb'],
col="Metric", col_wrap=2,
palette=sns.color_palette("bright", 3),
kind="line", data=long_data,
facet_kws=dict(sharex=False, sharey=False), legend='full'#, ax=ax
Expand All @@ -92,13 +95,13 @@ def plot_aggregated_engineering_metrics(data):
plot.axes[1].set_ylabel('Received Power (dB)')
plot.axes[0].set_xlabel('Number of Satellites')
plot.axes[1].set_xlabel('Number of Satellites')
plot.axes[2].set_ylabel('Signal-to-Noise-Ratio (dB)')
plot.axes[2].set_ylabel('Carrier-to-Noise-Ratio (dB)')
plot.axes[0].set_xlabel('Number of Satellites')
plot.axes[3].set_ylabel('Spectral Efficiency (Bps/Hz)')
plot.axes[0].set_xlabel('Number of Satellites')
plot.axes[4].set_ylabel('Aggregate Channel Capacity (Gbps)')
plot.axes[4].set_ylabel('Channel Capacity (Gbps)')
plot.axes[0].set_xlabel('Number of Satellites')
plot.axes[5].set_ylabel('Area Capacity (Mbps/km^2)')
plot.axes[5].set_ylabel('Aggregate Channel Capacity (Gbps)')
plot.axes[0].set_xlabel('Number of Satellites')

plt.savefig(os.path.join(VIS, 'engineering_metrics.png'), dpi=300)
Expand Down Expand Up @@ -135,7 +138,7 @@ def process_capacity_data(data):
for idx, item in data.iterrows():
if constellation.lower() == item['Constellation'].lower():
if item['Number of Satellites'] == max_satellites:
capacity_results.append(item['Aggregate Channel Capacity']) #append to list
capacity_results.append(item['Aggregate Channel Capacity'])

mean_capacity = sum(capacity_results) / len(capacity_results)

Expand Down Expand Up @@ -367,9 +370,11 @@ def plot_capacity_per_user_maps(data, regions):
axs[i].set_xlim(minx, maxx)
axs[i].set_ylim(miny, maxy)

regions_merged.plot(column='bin', ax=axs[i], cmap='inferno_r', linewidth=0, legend=True)
regions_merged.plot(column='bin', ax=axs[i], cmap='inferno_r',
linewidth=0, legend=True)

ctx.add_basemap(axs[i], crs=regions_merged.crs, source=ctx.providers.CartoDB.Voyager)
ctx.add_basemap(axs[i], crs=regions_merged.crs,
source=ctx.providers.CartoDB.Voyager)

letter = get_letter(constellation)

Expand Down Expand Up @@ -417,22 +422,22 @@ def get_letter(constellation):
print('Generating data for panel plots')
plot_panel_plot_of_per_user_metrics(capacity)

# print('Loading shapes')
# path = os.path.join(DATA_INTERMEDIATE, 'all_regional_shapes.shp')
# if not os.path.exists(path):
# shapes = get_regional_shapes()
# shapes.to_file(path)
# else:
# shapes = gpd.read_file(path, crs='epsg:4326')#[:1000]
print('Loading shapes')
path = os.path.join(DATA_INTERMEDIATE, 'all_regional_shapes.shp')
if not os.path.exists(path):
shapes = get_regional_shapes()
shapes.to_file(path)
else:
shapes = gpd.read_file(path, crs='epsg:4326')#[:1000]

# print('Loading data by pop density geotype')
# path = os.path.join(RESULTS, 'global_results.csv')
# global_results = pd.read_csv(path)#[:1000]
print('Loading data by pop density geotype')
path = os.path.join(RESULTS, 'global_results.csv')
global_results = pd.read_csv(path)#[:1000]

# # print('Plotting population density per area')
# # plot_regions_by_geotype(global_results, shapes)
print('Plotting population density per area')
plot_regions_by_geotype(global_results, shapes)

# print('Plotting capacity per user')
# plot_capacity_per_user_maps(global_results, shapes)
print('Plotting capacity per user')
plot_capacity_per_user_maps(global_results, shapes)

# print('Complete')
print('Complete')

0 comments on commit 6e1ac44

Please sign in to comment.