In [1]:
from pyssem.model import Model
import json
import cProfile
In [2]:
!pip show pyssem
Name: pyssem Version: 0.1.dev143 Summary: A detailed description of your project. Home-page: Author: Author-email: Indigo Brownhall <indigo.brownhall.20@ucl.ac.uk> License: MIT License Copyright (c) 2024 ARCLab Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Location: c:\users\it\anaconda3\envs\fspsim\lib\site-packages Requires: numpy, pandas, scipy, setuptools, sympy, tqdm Required-by:
In [3]:
with open('example-sim-simple.json') as f:
simulation_data = json.load(f)
scenario_props = simulation_data['scenario_properties']
# Create an instance of the pySSEM_model with the simulation parameters
model = Model(
start_date=scenario_props["start_date"].split("T")[0], # Assuming the date is in ISO format
simulation_duration=scenario_props["simulation_duration"],
steps=scenario_props["steps"],
min_altitude=scenario_props["min_altitude"],
max_altitude=scenario_props["max_altitude"],
n_shells=scenario_props["n_shells"],
launch_function=scenario_props["launch_function"],
integrator=scenario_props["integrator"],
density_model=scenario_props["density_model"],
LC=scenario_props["LC"],
v_imp=scenario_props["v_imp"],
launchfile = 'x0_launch_repeatlaunch_2018to2022_megaconstellationLaunches_Constellations.csv'
)
species = simulation_data["species"]
species_list = model.configure_species(species)
results = model.run_model()
resetting species Splitting species Su into 2 species with masses [260, 473]. Splitting species N into 4 species with masses [0.00141372, 0.567, 260, 473]. Added 2 active species, 4 debris species, and 0 rocket body species to the simulation. Pairing the following active species to debris classes for PMD modeling... ['Su_260kg', 'Su_473kg'] Matched species Su_260kg to debris species N_260kg. Matched species Su_473kg to debris species N_473kg. Name: N_0.00141372kg pmd_linked_species: [] Name: N_0.567kg pmd_linked_species: [] Name: N_260kg pmd_linked_species: ['Su_260kg'] Name: N_473kg pmd_linked_species: ['Su_473kg']
Creating collision pairs: 24%|██▍ | 5/21 [00:07<00:26, 1.64s/it]
In [3]:
import matplotlib.pyplot as plt
import numpy as np
n_species = 15
shells_per_species = 40
# Set up the figure and axes
fig, axes = plt.subplots(3, 5, figsize=(20, 12)) # Adjust the size as needed
# Loop over each species
for species_index in range(n_species):
ax = axes.flatten()[species_index] # Get the current axis
species_data = results.output.y[species_index*shells_per_species:(species_index+1)*shells_per_species]
# Plot each shell for this species
for shell_index in range(shells_per_species):
ax.plot(results.output.t, species_data[shell_index], label=f'Shell {shell_index+1}')
# Calculate and plot the sum of all shells for this species
total = np.sum(species_data, axis=0)
#ax.plot(output.t, total, label='Total', linestyle='--', color='black')
# Setting titles and labels
ax.set_title(f'{results.species_names[species_index]}')
ax.set_xlabel('Time')
ax.set_ylabel('Value')
# You may need to adjust or disable the legend if it's too crowded
# ax.legend()
plt.suptitle('Species 1 All Shells') # Set a super title for the entire figure
plt.tight_layout(rect=[0, 0.03, 1, 0.95]) # Adjust layout to make room for the super title
plt.show()