def test_ArrayLeasePlotNumbers(core, project, tree): project = deepcopy(project) module_menu = ModuleMenu() project_menu = ProjectMenu() mod_name = "Mock Module" module_menu.activate(core, project, mod_name) project_menu.initiate_dataflow(core, project) mod_branch = tree.get_branch(core, project, mod_name) mod_branch.read_test_data(core, project, os.path.join(dir_path, "inputs_wp3.pkl")) # Force addition of lease area lease_area = Polygon([(0, 0), (1, 0), (1, 1), (0, 1)]) core.add_datastate(project, identifiers=["site.lease_boundary"], values=[lease_area]) layout = mod_branch.get_input_variable(core, project, "project.layout") layout.plot(core, project, "Lease Area Array Layout (With Device Numbers)") assert len(plt.get_fignums()) == 1 plt.close("all")
def test_auto_plot(core, project, tree): project = deepcopy(project) module_menu = ModuleMenu() project_menu = ProjectMenu() mod_name = "Mock Module" module_menu.activate(core, project, mod_name) project_menu.initiate_dataflow(core, project) hydro_branch = tree.get_branch(core, project, mod_name) hydro_branch.read_test_data(core, project, os.path.join(this_dir, "inputs_wp2_tidal.pkl")) cp_curve = hydro_branch.get_input_variable(core, project, "device.turbine_performance") cp_curve.plot(core, project) assert len(plt.get_fignums()) == 1 plt.close("all")
def test_PowerMatrixPlot(core, project, tree): project = deepcopy(project) module_menu = ModuleMenu() project_menu = ProjectMenu() mod_name = "Mock Module" module_menu.activate(core, project, mod_name) project_menu.initiate_dataflow(core, project) # Force addition of power matrix power_matrix_coords = [[0., 1], [0., 1], [0., 1]] matrix_xgrid = {"values": np.ones([2, 2, 2]), "coords": power_matrix_coords} core.add_datastate(project, identifiers=["device.wave_power_matrix"], values=[matrix_xgrid]) mod_branch = tree.get_branch(core, project, mod_name) power_matrix = mod_branch.get_output_variable(core, project, 'device.wave_power_matrix') power_matrix.plot(core, project, "Single Wave Device Power Matrix") assert len(plt.get_fignums()) == 1 plt.close("all")
def test_DesignBoundaryPlot(core, project, tree): project = deepcopy(project) module_menu = ModuleMenu() module_menu.activate(core, project, "Mock Module") project_menu = ProjectMenu() project_menu.initiate_dataflow(core, project) installation_branch = tree.get_branch(core, project, "Mock Module") installation_branch.read_test_data( core, project, os.path.join(dir_path, "inputs_boundary.pkl")) installation_branch.read_auto(core, project) # Add nogo area nogo_area = {"test": Polygon([(0, 0), (10, 0), (10, 10), (0, 10)])} core.add_datastate(project, identifiers=["farm.nogo_areas", "corridor.nogo_areas"], values=[nogo_area, nogo_area]) lease_entry = installation_branch.get_input_variable( core, project, "project.lease_area_entry_point") lease_entry.plot(core, project, "Design Boundaries") assert len(plt.get_fignums()) == 1 plt.close("all")
def test_auto_file_read(core, project, tree): mod_name = "Mock Module" var_id = "device.turbine_performance" project = deepcopy(project) module_menu = ModuleMenu() project_menu = ProjectMenu() module_menu.activate(core, project, mod_name) project_menu.initiate_dataflow(core, project) hydro_branch = tree.get_branch(core, project, mod_name) new_var = hydro_branch.get_input_variable(core, project, var_id) new_var.read_file(core, project, os.path.join(data_dir, "tidal_performance.csv")) inputs = hydro_branch.get_input_status(core, project) assert inputs[var_id] == 'satisfied'
def test_dump_datastate_archive(core, project, var_tree, tmpdir): project = deepcopy(project) project_menu = ProjectMenu() module_menu = ModuleMenu() theme_menu = ThemeMenu() module_menu.activate(core, project, "Mock Module") theme_menu.activate(core, project, "Mock Theme") project_menu.initiate_dataflow(core, project) hydro_branch = var_tree.get_branch(core, project, "Mock Module") hydro_branch.read_test_data(core, project, os.path.join(dir_path, "inputs_wp2_tidal.pkl")) eco_branch = var_tree.get_branch(core, project, "Mock Theme") eco_branch.read_test_data(core, project, os.path.join(dir_path, "inputs_economics.pkl")) datastate_file_name = "my_datastate.dts" datastate_file_path = os.path.join(str(tmpdir), datastate_file_name) core.dump_datastate(project, datastate_file_path) assert os.path.isfile(datastate_file_path)
def test_auto_write_file(core, project, tree): mod_name = "Mock Module" var_id = "device.turbine_performance" project = deepcopy(project) module_menu = ModuleMenu() project_menu = ProjectMenu() module_menu.activate(core, project, mod_name) project_menu.initiate_dataflow(core, project) hydro_branch = tree.get_branch(core, project, mod_name) new_var = hydro_branch.get_input_variable(core, project, var_id) new_var.set_file_interface(core, os.path.join(data_dir, "tidal_performance.csv")) new_var.read(core, project) output_path = os.path.join(data_dir, "tidal_performance_copy.csv") if os.path.exists(output_path): os.remove(output_path) new_var.write_file(core, project, output_path) assert os.path.exists(output_path)
def test_filter_interface(core, project, tree): project = deepcopy(project) data_menu = DataMenu() module_menu = ModuleMenu() project_menu = ProjectMenu() tree = Tree() data_menu.select_database(project, "local") project_menu.initiate_pipeline(core, project) project_menu.initiate_options(core, project) filter_branch = tree.get_branch(core, project, 'Database Filtering Interface') new_var = filter_branch.get_input_variable(core, project, "device.selected_name") new_var.set_raw_interface(core, "ExampleWaveDevice") new_var.read(core, project) module_menu.activate(core, project, "Hydrodynamics") project_menu.initiate_filter(core, project) assert True
def test_WaveOccurrencePlot(core, project, tree): project = deepcopy(project) module_menu = ModuleMenu() project_menu = ProjectMenu() mod_name = "Mock Module" module_menu.activate(core, project, mod_name) project_menu.initiate_dataflow(core, project) # Force addition of occurance matrix occurrence_matrix_coords = [[0., 1], [0., 1], [0., 1]] matrix_xgrid = {"values": np.ones([2, 2, 2]), "coords": occurrence_matrix_coords} core.add_datastate(project, identifiers=["farm.wave_occurrence"], values=[matrix_xgrid]) mod_branch = tree.get_branch(core, project, mod_name) wave_occurrence = mod_branch.get_output_variable(core, project, "farm.wave_occurrence") wave_occurrence.plot(core, project, "Wave Resource Occurrence Matrix") assert len(plt.get_fignums()) == 1 plt.close("all")
def test_ArrayLeasePlot_available(core, project, tree): project = deepcopy(project) module_menu = ModuleMenu() project_menu = ProjectMenu() mod_name = "Mock Module" module_menu.activate(core, project, mod_name) project_menu.initiate_dataflow(core, project) mod_branch = tree.get_branch(core, project, mod_name) mod_branch.read_test_data(core, project, os.path.join(dir_path, "inputs_wp3.pkl")) # Force addition of lease area lease_area = Polygon([(0, 0), (1, 0), (1, 1), (0, 1)]) core.add_datastate(project, identifiers=["site.lease_boundary"], values=[lease_area]) layout = mod_branch.get_input_variable(core, project, "project.layout") result = layout.get_available_plots(core, project) assert "Lease Area Array Layout" in result
def test_load_datastate_archive(core, project, var_tree, tmpdir): temp_project = deepcopy(project) project_menu = ProjectMenu() module_menu = ModuleMenu() theme_menu = ThemeMenu() module_menu.activate(core, temp_project, "Mock Module") theme_menu.activate(core, temp_project, "Mock Theme") project_menu.initiate_dataflow(core, temp_project) hydro_branch = var_tree.get_branch(core, temp_project, "Mock Module") hydro_branch.read_test_data(core, temp_project, os.path.join(dir_path, "inputs_wp2_tidal.pkl")) eco_branch = var_tree.get_branch(core, temp_project, "Mock Theme") eco_branch.read_test_data(core, temp_project, os.path.join(dir_path, "inputs_economics.pkl")) datastate_file_name = "my_datastate.dts" datastate_file_path = os.path.join(str(tmpdir), datastate_file_name) core.dump_datastate(temp_project, datastate_file_path) del(temp_project) assert os.path.isfile(datastate_file_path) new_root = os.path.join(str(tmpdir), "test") os.makedirs(new_root) move_file_path = os.path.join(str(tmpdir), "test", datastate_file_name) shutil.copy2(datastate_file_path, move_file_path) temp_project = deepcopy(project) project_menu = ProjectMenu() module_menu = ModuleMenu() theme_menu = ThemeMenu() module_menu.activate(core, temp_project, "Mock Module") project_menu.initiate_dataflow(core, temp_project) assert not core.has_data(temp_project, "device.turbine_interdistance") core.load_datastate(temp_project, move_file_path) assert temp_project.check_integrity() assert core.has_data(temp_project, "device.turbine_interdistance")
def test_ArrayCablesPlot(core, project, tree): project = deepcopy(project) module_menu = ModuleMenu() project_menu = ProjectMenu() mod_name = "Mock Module" module_menu.activate(core, project, mod_name) project_menu.initiate_dataflow(core, project) # Need to provide these inputs: # "site.lease_boundary", # "corridor.landing_point", # "project.layout", # "project.cable_routes", # "project.substation_layout" lease_area = Polygon([(0, 0), (20, 0), (20, 50), (0, 50)]) landing_point = [10, 0] layout = {"device001": (10, 40)} substation = {"array": [10, 20]} cable_dict = {"Marker": [0, 0, 0, 1, 1, 1], "UTM X": [10, 10, 10, 10, 10, 10], "UTM Y": [40, 30, 20, 20, 10, 0], "Key Identifier": [None, None, None, None, None, None], "Depth": [None, None, None, None, None, None], "Burial Depth": [None, None, None, None, None, None], "Sediment": [None, None, None, None, None, None], "Split Pipe": [None, None, None, None, None, None]} cable_df = pd.DataFrame(cable_dict) core.add_datastate(project, identifiers=["site.lease_boundary", "corridor.landing_point", "project.layout", "project.substation_layout", "project.cable_routes"], values=[lease_area, landing_point, layout, substation, cable_df]) mod_branch = tree.get_branch(core, project, mod_name) cables = mod_branch.get_output_variable(core, project, "project.cable_routes") cables.plot(core, project, "Array Cable Layout") assert len(plt.get_fignums()) == 1 plt.close("all")
def test_NumpyLine_has_plot(core, project): project = deepcopy(project) module_menu = ModuleMenu() project_menu = ProjectMenu() module_menu.activate(core, project, "Mock Module") project_menu.initiate_dataflow(core, project) test = InputVariable("device.turbine_performance") result = test._find_receiving_interface(core, "AutoPlot") assert 'device.turbine_performance AutoPlot Interface' == result.get_name()
def test_dump_datastate_nodir(core, project, var_tree): project = deepcopy(project) project_menu = ProjectMenu() module_menu = ModuleMenu() theme_menu = ThemeMenu() module_menu.activate(core, project, "Mock Module") theme_menu.activate(core, project, "Mock Theme") project_menu.initiate_dataflow(core, project) with pytest.raises(ValueError): core.dump_datastate(project, "some_path")
def test_load_project_archive(core, project, var_tree, tmpdir): project = deepcopy(project) project_menu = ProjectMenu() module_menu = ModuleMenu() theme_menu = ThemeMenu() module_menu.activate(core, project, "Mock Module") theme_menu.activate(core, project, "Mock Theme") project_menu.initiate_dataflow(core, project) hydro_branch = var_tree.get_branch(core, project, "Mock Module") hydro_branch.read_test_data(core, project, os.path.join(dir_path, "inputs_wp2_tidal.pkl")) eco_branch = var_tree.get_branch(core, project, "Mock Theme") eco_branch.read_test_data(core, project, os.path.join(dir_path, "inputs_economics.pkl")) project_file_name = "my_project.prj" project_file_path = os.path.join(str(tmpdir), project_file_name) core.dump_project(project, project_file_path) del(project) assert os.path.isfile(project_file_path) new_root = os.path.join(str(tmpdir), "test") os.makedirs(new_root) move_file_path = os.path.join(str(tmpdir), "test", project_file_name) shutil.copy2(project_file_path, move_file_path) loaded_project = core.load_project(move_file_path) active_sim = loaded_project.get_simulation() assert loaded_project.check_integrity() assert active_sim.get_title() == "Default" assert "Mock Module" in module_menu.get_scheduled(core, loaded_project)
def test_OrderedSim_get_output_ids_valid_statuses(core, project): project = deepcopy(project) project_menu = ProjectMenu() module_menu = ModuleMenu() theme_menu = ThemeMenu() module_menu.activate(core, project, "Mock Module") theme_menu.activate(core, project, "Mock Theme") project_menu.initiate_dataflow(core, project) test = project.get_simulation() result = test.get_output_ids(valid_statuses=["satisfied"]) assert set(result) == set(['hidden.pipeline_active'])
def test_CombinedBathyPlot_available(core, project, tree): project = deepcopy(project) module_menu = ModuleMenu() project_menu = ProjectMenu() mod_name = "Mock Module" module_menu.activate(core, project, mod_name) project_menu.initiate_dataflow(core, project) mod_branch = tree.get_branch(core, project, mod_name) mod_branch.read_test_data(core, project, os.path.join(dir_path, "inputs_wp3.pkl")) bathy = mod_branch.get_input_variable(core, project, "bathymetry.layers") result = bathy.get_available_plots(core, project) assert "Combined Bathymetry" in result
def test_TidalPowerPerformancePlot_available(core, project, tree): project = deepcopy(project) module_menu = ModuleMenu() project_menu = ProjectMenu() mod_name = "Mock Module" module_menu.activate(core, project, mod_name) project_menu.initiate_dataflow(core, project) hydro_branch = tree.get_branch(core, project, mod_name) hydro_branch.read_test_data(core, project, os.path.join(dir_path, "inputs_wp2_tidal.pkl")) ct_curve = hydro_branch.get_input_variable(core, project, "device.turbine_performance") result = ct_curve.get_available_plots(core, project) assert 'Tidal Power Performance' in result
def test_load_datastate_bad_id(core, project, var_tree, tmpdir): project = deepcopy(project) project_menu = ProjectMenu() module_menu = ModuleMenu() theme_menu = ThemeMenu() module_menu.activate(core, project, "Mock Module") theme_menu.activate(core, project, "Mock Theme") project_menu.initiate_dataflow(core, project) hydro_branch = var_tree.get_branch(core, project, "Mock Module") hydro_branch.read_test_data(core, project, os.path.join(dir_path, "inputs_wp2_tidal.pkl")) eco_branch = var_tree.get_branch(core, project, "Mock Theme") eco_branch.read_test_data(core, project, os.path.join(dir_path, "inputs_economics.pkl")) core.dump_datastate(project, str(tmpdir)) # Modify the json file with an entry not in the catalogue datastate_file_path = os.path.join(str(tmpdir), "datastate_dump.json") with open(datastate_file_path, 'r') as f: data = json.load(f) data["data"]["fake.entry"] = "" # Rewrite the file os.remove(datastate_file_path) with open(datastate_file_path, 'w') as f: json.dump(data, f) # Try to load the datastate core.load_datastate(project, str(tmpdir)) assert True
def test_OrderedSim_get_output_ids_hub_id(core, project): project = deepcopy(project) project_menu = ProjectMenu() module_menu = ModuleMenu() theme_menu = ThemeMenu() module_menu.activate(core, project, "Mock Module") theme_menu.activate(core, project, "Mock Theme") project_menu.initiate_dataflow(core, project) test = project.get_simulation() result = test.get_output_ids(hub_id="modules") assert set(result) == set(['project.annual_energy', 'project.number_of_devices', 'project.layout'])
def test_TidalVelocityPlot_available(core, project, tree): project = deepcopy(project) module_menu = ModuleMenu() project_menu = ProjectMenu() mod_name = "Mock Module" module_menu.activate(core, project, mod_name) project_menu.initiate_dataflow(core, project) hydro_branch = tree.get_branch(core, project, mod_name) hydro_branch.read_test_data(core, project, os.path.join(dir_path, "inputs_wp2_tidal.pkl")) currents = hydro_branch.get_input_variable(core, project, "farm.tidal_series") result = currents.get_available_plots(core, project) assert "Tidal Currents" in result
def test_CombinedSedimentPlot(core, project, tree): project = deepcopy(project) module_menu = ModuleMenu() project_menu = ProjectMenu() mod_name = "Mock Module" module_menu.activate(core, project, mod_name) project_menu.initiate_dataflow(core, project) mod_branch = tree.get_branch(core, project, mod_name) mod_branch.read_test_data(core, project, os.path.join(dir_path, "inputs_wp3.pkl")) bathy = mod_branch.get_input_variable(core, project, "bathymetry.layers") bathy.plot(core, project, "Combined Sediment (First Layer)") assert len(plt.get_fignums()) == 1 plt.close("all")
def test_get_file_output_interfaces(core, project, tree): mod_name = "Mock Module" var_id = "device.turbine_performance" project = deepcopy(project) module_menu = ModuleMenu() project_menu = ProjectMenu() module_menu.activate(core, project, mod_name) project_menu.initiate_dataflow(core, project) hydro_branch = tree.get_branch(core, project, mod_name) new_var = hydro_branch.get_input_variable(core, project, var_id) new_var.get_file_output_interfaces(core, project) assert new_var
def test_set_auto_raw(core, project, tree): mod_name = "Mock Module" var_id = "device.system_type" project = deepcopy(project) module_menu = ModuleMenu() project_menu = ProjectMenu() module_menu.activate(core, project, mod_name) project_menu.initiate_dataflow(core, project) hydro_branch = tree.get_branch(core, project, mod_name) new_var = hydro_branch.get_input_variable(core, project, var_id) new_var.set_raw_interface(core, 'Tidal Fixed') assert new_var._interface.data.result == 'Tidal Fixed'
def test_TidalVelocityPlot(core, project, tree): project = deepcopy(project) module_menu = ModuleMenu() project_menu = ProjectMenu() mod_name = "Mock Module" module_menu.activate(core, project, mod_name) project_menu.initiate_dataflow(core, project) hydro_branch = tree.get_branch(core, project, mod_name) hydro_branch.read_test_data(core, project, os.path.join(dir_path, "inputs_wp2_tidal.pkl")) currents = hydro_branch.get_input_variable(core, project, "farm.tidal_series") currents.plot(core, project, "Tidal Currents") assert len(plt.get_fignums()) == 1 plt.close("all")
def test_DesignBoundaryPlot_available(core, project, tree): project = deepcopy(project) module_menu = ModuleMenu() module_menu.activate(core, project, "Mock Module") project_menu = ProjectMenu() project_menu.initiate_dataflow(core, project) installation_branch = tree.get_branch(core, project, "Mock Module") installation_branch.read_test_data( core, project, os.path.join(dir_path, "inputs_boundary.pkl")) installation_branch.read_auto(core, project) lease_entry = installation_branch.get_input_variable( core, project, "project.lease_area_entry_point") result = lease_entry.get_available_plots(core, project) assert "Design Boundaries" in result
def test_TeHm0Plot_available(core, project, tree): project = deepcopy(project) module_menu = ModuleMenu() project_menu = ProjectMenu() mod_name = "Mock Module" module_menu.activate(core, project, mod_name) project_menu.initiate_dataflow(core, project) mod_branch = tree.get_branch(core, project, mod_name) mod_branch.read_test_data(core, project, os.path.join(dir_path, "inputs_wp2_wave.pkl")) wave_series = mod_branch.get_input_variable(core, project, "farm.wave_series") result = wave_series.get_available_plots(core, project) assert "Te & Hm0 Time Series" in result
def test_TeHm0Plot(core, project, tree): project = deepcopy(project) module_menu = ModuleMenu() project_menu = ProjectMenu() mod_name = "Mock Module" module_menu.activate(core, project, mod_name) project_menu.initiate_dataflow(core, project) mod_branch = tree.get_branch(core, project, mod_name) mod_branch.read_test_data(core, project, os.path.join(dir_path, "inputs_wp2_wave.pkl")) wave_series = mod_branch.get_input_variable(core, project, "farm.wave_series") wave_series.plot(core, project, "Te & Hm0 Time Series") assert len(plt.get_fignums()) == 1 plt.close("all")
def test_InstallationGanttChartPlot(core, project, tree): project = deepcopy(project) module_menu = ModuleMenu() project_menu = ProjectMenu() mod_name = "Mock Module" module_menu.activate(core, project, mod_name) project_menu.initiate_dataflow(core, project) mod_branch = tree.get_branch(core, project, mod_name) plan = [ 'Installation of support structure', 'Installation of driven piles anchors/foundations', 'Installation of mooring systems with direct-embedment anchors', 'Installation of gravity based foundations', 'Installation of mooring systems with pile anchors', 'Installation of mooring systems with drag-embedment anchors', 'Installation of mooring systems with suction-embedment anchors', 'Installation of collection point (surface piercing)', 'Installation of collection point (seabed)', 'Installation of dynamic cables', 'Installation of static export cables', 'Installation of static array cables', 'Installation of external cable protection', 'Installation of devices' ] install_support_structure_dates = { 'Start': dt.datetime( 2000, 6, 25, 4, 55, 31, ), 'End': dt.datetime(2000, 7, 29, 3, 24, 19), 'Depart': dt.datetime(2000, 7, 25, 7, 55, 31) } install_devices_dates = { 'Start': dt.datetime( 2000, 6, 25, 4, 55, 31, ), 'End': dt.datetime(2000, 7, 29, 3, 24, 19), 'Depart': dt.datetime(2000, 7, 25, 7, 55, 31) } install_dynamic_cable_dates = { 'Start': dt.datetime(2000, 5, 2, 19, 11, 47), 'End': dt.datetime(2000, 6, 18, 19, 12, 9), 'Depart': dt.datetime(2000, 6, 14, 15, 11, 47) } install_export_cable_dates = { 'Start': dt.datetime(2000, 5, 2, 19, 11, 47), 'End': dt.datetime(2000, 6, 18, 19, 12, 9), 'Depart': dt.datetime(2000, 6, 14, 15, 11, 47) } install_array_cable_dates = { 'Start': dt.datetime(2000, 5, 2, 21, 48, 59), 'End': dt.datetime(2000, 6, 19, 0, 55, 31), 'Depart': dt.datetime(2000, 6, 14, 15, 48, 59) } install_surface_piercing_substation_dates = { 'Start': dt.datetime(2000, 1, 5, 1, 0), 'End': dt.datetime(2000, 4, 30, 17, 42, 6), 'Depart': dt.datetime(2000, 4, 26, 7, 0) } install_subsea_collection_point_dates = { 'Start': dt.datetime(2000, 1, 5, 1, 0), 'End': dt.datetime(2000, 4, 30, 17, 42, 6), 'Depart': dt.datetime(2000, 4, 26, 7, 0) } install_cable_protection_dates = { 'Start': dt.datetime(2000, 1, 5, 1, 0), 'End': dt.datetime(2000, 4, 30, 17, 42, 6), 'Depart': dt.datetime(2000, 4, 26, 7, 0) } install_driven_piles_dates = { 'Start': dt.datetime(2000, 1, 3, 5, 0), 'End': dt.datetime(2000, 2, 11, 5, 4, 21), 'Depart': dt.datetime(2000, 2, 4, 15, 0) } install_direct_embedment_dates = { 'Start': dt.datetime(2000, 1, 3, 5, 0), 'End': dt.datetime(2000, 2, 11, 5, 4, 21), 'Depart': dt.datetime(2000, 2, 4, 15, 0) } install_gravity_based_dates = { 'Start': dt.datetime(2000, 1, 3, 5, 0), 'End': dt.datetime(2000, 2, 11, 5, 4, 21), 'Depart': dt.datetime(2000, 2, 4, 15, 0) } install_pile_anchor_dates = { 'Start': dt.datetime(2000, 1, 3, 5, 0), 'End': dt.datetime(2000, 2, 11, 5, 4, 21), 'Depart': dt.datetime(2000, 2, 4, 15, 0) } install_drag_embedment_dates = { 'Start': dt.datetime(2000, 1, 3, 5, 0), 'End': dt.datetime(2000, 2, 11, 5, 4, 21), 'Depart': dt.datetime(2000, 2, 4, 15, 0) } install_suction_embedment_dates = { 'Start': dt.datetime(2000, 1, 3, 5, 0), 'End': dt.datetime(2000, 2, 11, 5, 4, 21), 'Depart': dt.datetime(2000, 2, 4, 15, 0) } install_device_times = pd.DataFrame({ 'Preparation': { 0: 148.0, 1: 100 }, 'Operations': { 0: 32.0, 1: 30 }, 'Transit': { 0: 59.480022782839399, 1: 60 }, 'Component': { 0: 'Device', 1: 'Support Structure' }, 'Waiting': { 0: 0, 1: 0 } }) install_electrical_times = pd.DataFrame({ 'Preparation': { 0: 49.49, 1: 52.11, 2: 97.0, 3: 90, 4: 10 }, 'Operations': { 0: 7.48, 1: 12.72, 2: 21.0, 3: 20, 4: 50 }, 'Transit': { 0: 92.51, 1: 92.38, 2: 85.70, 3: 80, 4: 90 }, 'Component': { 0: 'Export Cables', 1: 'Inter-Array Cables', 2: 'Collection Points', 3: 'Dynamic Cables', 4: 'External Cable Protection' }, 'Waiting': { 0: 0, 1: 0, 2: 0, 3: 0, 4: 0 } }) install_mooring_times = pd.DataFrame({ 'Preparation': { 0: 53.0, 1: 53.0, 2: 53.0, 3: 53.0, 4: 53.0, 5: 53.0 }, 'Operations': { 0: 83.00, 1: 83.00, 2: 83.00, 3: 83.00, 4: 83.00, 5: 83.00 }, 'Transit': { 0: 75.06, 1: 75.06, 2: 75.06, 3: 75.06, 4: 75.06, 5: 75.06 }, 'Component': { 0: 'Driven Piles', 1: "Direct-Embedment Anchors", 2: "Gravity Based Foundations", 3: "Pile Anchors", 4: "Drag-Embedment Anchors", 5: "Suction-Caisson Anchors" }, 'Waiting': { 0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0 } }) identifiers = [ "project.installation_plan", "project.install_support_structure_dates", "project.install_devices_dates", "project.install_dynamic_cable_dates", "project.install_export_cable_dates", "project.install_array_cable_dates", "project.install_surface_piercing_substation_dates", "project.install_subsea_collection_point_dates", "project.install_cable_protection_dates", "project.install_driven_piles_dates", "project.install_direct_embedment_dates", "project.install_gravity_based_dates", "project.install_pile_anchor_dates", "project.install_drag_embedment_dates", "project.install_suction_embedment_dates", "project.device_phase_installation_times", "project.electrical_phase_installation_times", "project.mooring_phase_installation_times" ] # Force addition of variables core.add_datastate( project, identifiers=identifiers, values=[ plan, install_support_structure_dates, install_devices_dates, install_dynamic_cable_dates, install_export_cable_dates, install_array_cable_dates, install_surface_piercing_substation_dates, install_subsea_collection_point_dates, install_cable_protection_dates, install_driven_piles_dates, install_direct_embedment_dates, install_gravity_based_dates, install_pile_anchor_dates, install_drag_embedment_dates, install_suction_embedment_dates, install_device_times, install_electrical_times, install_mooring_times ]) gantt = mod_branch.get_output_variable(core, project, "project.installation_plan") gantt.plot(core, project, "Installation Gantt Chart") assert len(plt.get_fignums()) == 1 plt.close("all")
def test_ArrayFoundationsPlot(core, project, tree, soiltype): project = deepcopy(project) module_menu = ModuleMenu() project_menu = ProjectMenu() mod_name = "Mock Module" module_menu.activate(core, project, mod_name) project_menu.initiate_dataflow(core, project) # Need to provide these inputs: # "site.lease_boundary", # "project.layout", # "project.substation_layout" # "project.foundations_component_data" lease_area = Polygon([(0, 0), (20, 0), (20, 50), (0, 50)]) layout = {"device001": (10, 40)} substation = {"array": [10, 20]} foundations_dict = {u'Depth': {0: -38.520000000000003, 1: -40.299999999999997, 2: -36.780000000000001, 8: -37.850000000000001}, u'Dry Mass': {0: 107506.9289256667, 1: 53351.541402463197, 2: 126780.5181144721, 8: 6435.3313852360807}, u'Grout Type': {0: u'n/a', 1: u'n/a', 2: u'n/a', 8: u'grout'}, u'Grout Volume': {0: 0.0, 1: 0.0, 2: 0.0, 8: 1.065569984623332}, u'Height': {0: 1.409402628668293, 1: 0.92718879062712711, 2: 1.4890425199298569, 8: 19.0}, u'Installation Depth': {0: np.nan, 1: np.nan, 2: np.nan, 8: 19.0}, u'Length': {0: 5.637610514673173, 1: 3.708755162508508, 2: 5.9561700797194286, 8: 0.81299999999999994}, u'Marker': {0: 0, 1: 1, 2: 2, 8: 8}, u'Sub-Type': {0: u'concrete/steel composite structure', 1: u'concrete/steel composite structure', 2: u'concrete/steel composite structure', 8: u'something'}, u'Type': {0: u'gravity', 1: u'gravity', 2: u'gravity', 8: soiltype}, u'UTM X': {0: 5, 1: 10, 2: 15, 8: 10}, u'UTM Y': {0: 40, 1: 45, 2: 40, 8: 20}, u'Width': {0: 5.637610514673173, 1: 3.708755162508508, 2: 5.9561700797194286, 8: 0.81299999999999994}} foundations_df = pd.DataFrame(foundations_dict) core.add_datastate(project, identifiers=["site.lease_boundary", "project.layout", "project.substation_layout", "project.foundations_component_data"], values=[lease_area, layout, substation, foundations_df]) mod_branch = tree.get_branch(core, project, mod_name) foundations = mod_branch.get_output_variable( core, project, "project.foundations_component_data") foundations.plot(core, project, "Array Foundations Layout") assert len(plt.get_fignums()) == 1 plt.close("all")