Ejemplo n.º 1
0
def main():
    # This is the main process from mission to list of participating satellites

    # 1. Input a mission into the Knowledge Graph
    add_volcano_mission()

    # 2. Run Orekit simulation to obtain access times for all satellites that can participate (as in have the right
    # sensors) in the mission.
    access_intervals = obtain_access_times(1)

    # 3. Use the information from KG + simulation to generate outputs for Knowledge Reasoning (logic),
    # Sensing Framework (?), Verification (logic)

    # 4. Call the Knowledge Reasoning
    print_kg_reasoning_files(1, access_intervals)
    # Train the model
    final_path = train_uniker()
    # Perform inference
    satellite_list = merge_results(final_path)

    # 5. Call the Sensing Framework
    generate_fake_data(1, access_intervals)
    call_sensing_framework(satellite_list)

    # 6. Call the Verification module

    # 7. Run an Orekit simulation with the result to obtain metrics and final access times, save results in CZML
    generate_czml_data()

    # 8. Spin up an HTTP server, display Cesium results of the final simulation with FOVs and the ground station/s
    open_local_http_server()
def generate_volcano_simulations(quantity, event_fraction):
    int_path = Path("./int_files")
    simulations_path = int_path / "simulations"
    simulations_path.mkdir(parents=True, exist_ok=True)
    accesses_path = int_path / "accesses"

    eruption_length_range = [12., 120.]  # hours
    eruption_start_range = [0., 168.]  # hours since beginning of simulation
    location_range = ["Kilauea", "Etna", "Piton de la Fournaise", "Stromboli", "Merapi",
                "Erta Ale", "Ol Doinyo Lengai", "Mount Unzen", "Mount Yasur", "Ambrym"]
    speed_range = [0.1, 0.5]  # fraction of time until max eruption
    size_range = [200., 2000.]  # meter radius
    max_tir_temperature_range = [50., 80.]
    max_swir_temperature_range = [5., 15.]
    max_ash_cloud_range = [0.5, 0.9]
    max_terrain_displacement_range = [50., 150.]
    max_so2_levels_range = [1.0, 3.0]

    # For each simulation, sample a value for each parameter, create a simulation, save it under int_files
    for sim_number in range(quantity):
        # Create paths
        simulation_path = simulations_path / f"simulation_{sim_number}"
        if simulation_path.exists():
            shutil.rmtree(simulation_path)
        simulation_path.mkdir(parents=True, exist_ok=True)

        simulation_information_path = simulation_path / "simulation_information.json"
        data_streams_path = simulation_path / "data_streams"

        # Sample values
        eruption_length = random.uniform(*eruption_length_range)
        eruption_start = random.uniform(*eruption_start_range)
        location = random.choice(location_range)
        speed = random.uniform(*speed_range)
        size = random.uniform(*size_range)
        max_tir_temperature = random.uniform(*max_tir_temperature_range)
        max_swir_temperature = random.uniform(*max_swir_temperature_range)
        max_ash_cloud = random.uniform(*max_ash_cloud_range)
        max_terrain_displacement = random.uniform(*max_terrain_displacement_range)
        max_so2_levels = random.uniform(*max_so2_levels_range)

        # Create a mission in the KG
        mission_id = add_volcano_mission(location)

        # Generate accesses if not already there
        access_path = accesses_path / f"{location}.json"
        if not access_path.exists():
            access_times = obtain_access_times(mission_id)
        else:
            access_times = read_access_times(location)

        # Create simulation
        generate_volcano_simulation(mission_id, access_times, eruption_length, eruption_start, location, speed, size,
                            max_tir_temperature, max_swir_temperature, max_ash_cloud, max_terrain_displacement,
                            max_so2_levels, simulation_information_path, data_streams_path)
def generate_forest_fire_simulations(quantity, event_fraction):
    int_path = Path("./int_files")
    simulations_path = int_path / "simulations"
    simulations_path.mkdir(parents=True, exist_ok=True)
    accesses_path = int_path / "accesses"

    eruption_length_range = [12., 120.]  # hours
    eruption_start_range = [0., 168.]  # hours since beginning of simulation
    location_range = ["Spain", "Greece", "California", "Washington", "Kenya"]
    speed_range = [0.1, 0.5]  # fraction of time until max eruption
    size_range = [200., 2000.]  # meter radius
    max_temp_range = [80., 99.]
    max_fire_temp_range = [200., 300.]
    max_cloud_range = [0.5, 0.9]
    max_gases_range = [100, 200]

    # For each simulation, sample a value for each parameter, create a simulation, save it under int_files
    for sim_number in range(quantity):
        # Create paths
        simulation_path = simulations_path / f"simulation_{sim_number}"
        if simulation_path.exists():
            shutil.rmtree(simulation_path)
        simulation_path.mkdir(parents=True, exist_ok=True)

        simulation_information_path = simulation_path / "simulation_information.json"
        data_streams_path = simulation_path / "data_streams"

        # Sample values
        eruption_length = random.uniform(*eruption_length_range)
        eruption_start = random.uniform(*eruption_start_range)
        location = random.choice(location_range)
        speed = random.uniform(*speed_range)
        size = random.uniform(*size_range)
        max_temp = random.uniform(*max_temp_range)
        max_fire_temp = random.uniform(*max_fire_temp_range)
        max_cloud = random.uniform(*max_cloud_range)
        max_gases = random.uniform(*max_gases_range)
        # Create a mission in the KG
        mission_id = add_volcano_mission(location)

        # Generate accesses if not already there
        access_path = accesses_path / f"{location}.json"
        if not access_path.exists():
            access_times = obtain_access_times(mission_id)
        else:
            access_times = read_access_times(location)

        # Create simulation
        generate_forest_fire_simulation(mission_id, eruption_length, eruption_start, location, speed, size,
                                        max_temp, max_fire_temp, max_cloud, max_gases, simulation_information_path)
def generate_flood_simulations(quantity, event_fraction):
    int_path = Path("./int_files")
    simulations_path = int_path / "simulations"
    simulations_path.mkdir(parents=True, exist_ok=True)
    accesses_path = int_path / "accesses"

    eruption_length_range = [12., 120.]  # hours
    eruption_start_range = [0., 168.]  # hours since beginning of simulation
    location_range = ["India", "Bangladesh", "Texas", "Italy", "Brazil"]
    speed_range = [0.1, 0.5]  # fraction of time until max eruption
    size_range = [200., 2000.]  # meter radius
    max_soil_moisture_range = [80., 99.]
    max_precipitation_range = [200., 300.]
    max_land_range = [0.5, 0.9]

    # For each simulation, sample a value for each parameter, create a simulation, save it under int_files
    for sim_number in range(quantity):
        # Create paths
        simulation_path = simulations_path / f"simulation_{sim_number}"
        if simulation_path.exists():
            shutil.rmtree(simulation_path)
        simulation_path.mkdir(parents=True, exist_ok=True)

        simulation_information_path = simulation_path / "simulation_information.json"
        data_streams_path = simulation_path / "data_streams"

        # Sample values
        eruption_length = random.uniform(*eruption_length_range)
        eruption_start = random.uniform(*eruption_start_range)
        location = random.choice(location_range)
        speed = random.uniform(*speed_range)
        size = random.uniform(*size_range)
        max_soil_moisture = random.uniform(*max_soil_moisture_range)
        max_precipitation = random.uniform(*max_precipitation_range)
        max_land = random.uniform(*max_land_range)
        # Create a mission in the KG
        mission_id = add_volcano_mission(location)

        # Generate accesses if not already there
        access_path = accesses_path / f"{location}.json"
        if not access_path.exists():
            access_times = obtain_access_times(mission_id)
        else:
            access_times = read_access_times(location)

        # Create simulation
        generate_flood_simulation(mission_id, eruption_length, eruption_start, location, speed, size,
                            max_soil_moisture, max_precipitation, max_land, simulation_information_path)