From 6e4b1d4590e99ce5cae058c05059ab74651875d1 Mon Sep 17 00:00:00 2001 From: edwardoughton Date: Wed, 7 Apr 2021 17:45:07 +0100 Subject: [PATCH 1/5] Edit rain attenuation + capacity calcs --- src/globalsat/sim.py | 48 ++++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/src/globalsat/sim.py b/src/globalsat/sim.py index d0f328b..1468726 100644 --- a/src/globalsat/sim.py +++ b/src/globalsat/sim.py @@ -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() @@ -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, @@ -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 @@ -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. @@ -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 @@ -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. @@ -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): From 05d7ea839563d037d4578f85a7917e6b5386cb05 Mon Sep 17 00:00:00 2001 From: edwardoughton Date: Wed, 7 Apr 2021 17:45:21 +0100 Subject: [PATCH 2/5] Edit rain and bandwidth --- scripts/inputs.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/scripts/inputs.py b/scripts/inputs.py index 01600f9..ef2256a 100644 --- a/scripts/inputs.py +++ b/scripts/inputs.py @@ -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 @@ -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': { @@ -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 From 573fbe6f0b6ed7eb0637aa8c4ec551ac66e3e6ff Mon Sep 17 00:00:00 2001 From: edwardoughton Date: Wed, 7 Apr 2021 17:45:32 +0100 Subject: [PATCH 3/5] Adopt for two capacity types --- scripts/run.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/run.py b/scripts/run.py index 9411901..3c4e24b 100644 --- a/scripts/run.py +++ b/scripts/run.py @@ -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, } From b3cd88600384d5e020a920cf1ea23e5fee9bc13f Mon Sep 17 00:00:00 2001 From: edwardoughton Date: Wed, 7 Apr 2021 17:45:46 +0100 Subject: [PATCH 4/5] Adopt for 2 capacity types + change labels --- vis/vis.py | 55 +++++++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/vis/vis.py b/vis/vis.py index a5a0a07..fafdea2 100644 --- a/vis/vis.py +++ b/vis/vis.py @@ -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[[ @@ -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') @@ -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' ] ) @@ -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 @@ -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) @@ -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) @@ -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) @@ -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') From b40208207384eace9392af7001d158362750fbb1 Mon Sep 17 00:00:00 2001 From: edwardoughton Date: Wed, 7 Apr 2021 17:51:38 +0100 Subject: [PATCH 5/5] Update tests --- tests/conftest.py | 2 +- tests/test_sim.py | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index e42d379..fc1912c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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, } diff --git a/tests/test_sim.py b/tests/test_sim.py index a6306bf..98437c8 100644 --- a/tests/test_sim.py +++ b/tests/test_sim.py @@ -12,6 +12,7 @@ calc_cnr, calc_spectral_efficiency, calc_capacity, + calc_agg_capacity ) @@ -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 @@ -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, } @@ -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 @@ -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