def load_project(self): self.mdi_area.closeAllSubWindows() self.clear_project_data() project_folder = QFileDialog.getExistingDirectory( self, "Select a project folder") project_folder = str(project_folder) prj_name = os.path.basename(os.path.normpath(project_folder)) prj_filename = "".join([prj_name, '_data_collection.hdf5']) project = os.path.join(project_folder, prj_filename) if os.path.isfile(project): dictionary = h5i.load_dict_from_hdf5(project) dictionary['prj_folder'] = project_folder dictionary['prj_filename'] = prj_filename dictionary['prj_name'] = prj_name self._data = dictionary self.populate_project() else: choice = QMessageBox().question( self, 'Wrong Project Folder', 'The selected folder does not contains a valid project data collection.\n Do you want to select another folder?', QMessageBox.Yes | QMessageBox.No) if choice == QMessageBox.Yes: self.load_project() else: return -1
def load_data(self): current_case = str(self.cb_wec_t1.currentText()).replace(' ', '_') file_name = os.path.join(self._wec_db_folder, current_case, '{}_results.hdf5'.format(current_case)) description_file = os.path.join( self._wec_db_folder, current_case, '{}_description.html'.format(current_case)).replace("\\", "/") data_db = h5i.load_dict_from_hdf5(file_name) data_db['prj_filename'] = self._data['prj_filename'] data_db['prj_folder'] = self._data['prj_folder'] data_db['prj_name'] = self._data['prj_name'] data_db['inputs_hydrodynamic']['general_input'][ 'data_folder'] = os.path.join(self._wec_db_folder, current_case) print(os.path.join(self._wec_db_folder, current_case)) stat = check_wec_db_data(data_db) self.save_project() if stat[0]: self._data = data_db self.ww_wec.load(QUrl("file:///" + description_file)) print("Data loaded. It is possible to plot the data.") self.trigger_save.emit(self._data['inputs_hydrodynamic']) self.trigger_results.emit(self._data) else: print(stat[1])
def load_fitting_data(self, caseID): f_n = os.path.join(self.db_folder, 'case{}'.format(caseID), 'case{}_pmfit.h5'.format(caseID)) dic = h5i.load_dict_from_hdf5(f_n) self.c_ext = dic['c_ext'] self.k_ext = dic['k_ext'] self.c_fit = dic['c_fit'] self.k_fit = dic['k_fit'] self.c_pto = dic['c_pto'] self.k_mooring = dic['k_mooring'] self.te = dic['te'] self.tp = convert_te2tp(self.te.copy()) self.hm0 = dic['hm0'] self.wave_dir = convert_angle(dic['wave_dir'].copy()) self.scatter_diagram = dic['scatter_diagram']
def load_data(self): f_n = os.path.join(self.db_folder, 'case{}'.format(self.wec_ID), 'case{}_hyd.h5'.format(self.wec_ID)) dic = h5i.load_dict_from_hdf5(f_n) self.m_m = dic['m_m'] self.m_add = dic['m_add'] self.c_rad = dic['c_rad'] self.f_ex = dic['f_ex'] self.periods = dic['periods'] self.directions = dic['directions'] self.k_hst = dic['k_hst'] self.diffraction_tr_mat = dic['diffraction_tr_mat'] self.force_tr_mat = dic['force_tr_mat'] self.amplitude_coefficient_radiation = dic['amplitude_coefficient_radiation'] self.water_depth = dic['water_depth'] self.cyl_radius = dic['cyl_radius'] self.modes = dic['modes'] self.order = dic['max_order'] self.truncation_order = dic['truncation_order'] self.pto_dof = dic['pto_dof'] self.moor_dof = dic['mooring_dof']
fid.close() fid = open(mmx, 'w') for iel, el_k in enumerate(bodies): el = body_d[el_k] fid.write( "------- Body {} - modes description --------\n".format(iel)) fid.write("{} ! body ID\n".format(el['ID'][0])) fid.write('body mass\n') fid.write('{}\n'.format(el['mass'][0])) fid.write('inertia tensor\n') for rr in range(3): fid.write('{} {} {}\n'.format(*el['inertia'][rr, :])) fid.close() def get_outputs(self, res_obj): self.outputs = self.data_dic def __str__(self): return str(self.data_dic) if __name__ == "__main__": import dtocean_wave.utils.hdf5_interface as h5i data = h5i.load_dict_from_hdf5( r"C:\Users\francesco\Desktop\test_gui\test_prj\test_prj_data_collection.hdf5" ) dataobj = DataStructure(data) dataobj.set_inputs()