def test__threepoints(): v1 = ppp.ThreePoints("test/data/v1.survey") v2 = ppp.ThreePoints("test/data/v2.survey") assert v1.startInline == v2.startInline assert v1.endInline == v2.endInline assert v1.stepInline == v2.stepInline assert v1.startCrline == v2.startCrline assert v1.endCrline == v2.endCrline assert v1.stepCrline == v2.stepCrline assert v1.startDepth == v2.startDepth assert v1.endDepth == v2.endDepth assert v1.stepDepth == v2.stepDepth assert v1.inline_A == v2.inline_A assert v1.crline_A == v2.crline_A assert v1.east_A == v2.east_A assert v1.north_A == v2.north_A assert v1.inline_B == v2.inline_B assert v1.crline_B == v2.crline_B assert v1.east_B == v2.east_B assert v1.north_B == v2.north_B assert v1.inline_C == v2.inline_C assert v1.crline_C == v2.crline_C assert v1.east_C == v2.east_C assert v1.north_C == v2.north_C
def read_survey_setting(json_file, parent_window): "read survey settings into import window widgets" threepoint = ppp.ThreePoints(json_file) parent_window.a_inline_text.setText(str(threepoint.inline_A)) parent_window.a_crline_text.setText(str(threepoint.crline_A)) parent_window.b_inline_text.setText(str(threepoint.inline_B)) parent_window.b_crline_text.setText(str(threepoint.crline_B)) parent_window.c_inline_text.setText(str(threepoint.inline_C)) parent_window.c_crline_text.setText(str(threepoint.crline_C)) parent_window.a_x_text.setText(str(threepoint.east_A)) parent_window.a_y_text.setText(str(threepoint.north_A)) parent_window.b_x_text.setText(str(threepoint.east_B)) parent_window.b_y_text.setText(str(threepoint.north_B)) parent_window.c_x_text.setText(str(threepoint.east_C)) parent_window.c_y_text.setText(str(threepoint.north_C)) parent_window.inline_0_spinBox.setValue(int(threepoint.startInline)) parent_window.inline_1_spinBox.setValue(int(threepoint.endInline)) parent_window.inline_step_spinBox.setValue(int(threepoint.stepInline)) parent_window.crline_0_spinBox.setValue(int(threepoint.startCrline)) parent_window.crline_1_spinBox.setValue(int(threepoint.endCrline)) parent_window.crline_step_spinBox.setValue(int(threepoint.stepCrline)) parent_window.z_0_spinBox.setValue(int(threepoint.startDepth)) parent_window.z_1_spinBox.setValue(int(threepoint.endDepth)) parent_window.z_step_spinBox.setValue(int(threepoint.stepDepth))
def test__threepoints(): # init with file v1 = ppp.ThreePoints("test/data/v1.survey") v2 = ppp.ThreePoints("test/data/v2.survey") # init with dict with open("test/data/v1.survey", 'r') as fl: dict_survey = json.load(fl) _ = ppp.ThreePoints(dict_survey) # test wrong version dict_survey.pop('inline') with pytest.raises(Invalid_threepoints_Exception) as excinfo: _ = ppp.ThreePoints(dict_survey) assert "Not valid three points file" in str(excinfo.value) # test None json file with pytest.raises(Exception) as excinfo: _ = ppp.ThreePoints() assert "json_file is None" in str(excinfo.value) # test properties assert v1.startInline == v2.startInline assert v1.endInline == v2.endInline assert v1.stepInline == v2.stepInline assert v1.startCrline == v2.startCrline assert v1.endCrline == v2.endCrline assert v1.stepCrline == v2.stepCrline assert v1.startDepth == v2.startDepth assert v1.endDepth == v2.endDepth assert v1.stepDepth == v2.stepDepth assert v1.inline_A == v2.inline_A assert v1.crline_A == v2.crline_A assert v1.east_A == v2.east_A assert v1.north_A == v2.north_A assert v1.inline_B == v2.inline_B assert v1.crline_B == v2.crline_B assert v1.east_B == v2.east_B assert v1.north_B == v2.north_B assert v1.inline_C == v2.inline_C assert v1.crline_C == v2.crline_C assert v1.east_C == v2.east_C assert v1.north_C == v2.north_C
def test__survey_setting(): survey = ppp.SurveySetting(ppp.ThreePoints("test/data/v2.survey")) assert tuple([int(a) for a in survey.line_2_coord(300, 800)]) == \ (618191, 6078903) assert tuple( [int(a) for a in survey.coord_2_line( (618191.04009555, 6078903.52942556))]) == (300, 800) assert ( np.array( survey.four_corner_on_canvas(400, 300)[0], dtype=np.float32) == \ np.array( [45.88527452, 280., 274.11472548, 40.], dtype=np.float32)).all()
def display_map_and_info(self): # get survey file path survey_folder = str(self.surveyListWidget.selectedItems()[0].text()) survey_file = Path(CONF.data_root, survey_folder, '.survey') # create new survey new_survey = ppp.SurveySetting(ppp.ThreePoints(newstr(survey_file))) # build survey info string for display info_string = \ "In-line range: {} - {} - {}\n".format( new_survey.startInline, new_survey.endInline, new_survey.stepInline) + \ "Cross-line range: {} - {} - {}\n".format( new_survey.startCrline, new_survey.endCrline, new_survey.stepCrline) + \ "Z range({}): {} - {} - {}\n".format( new_survey.startDepth, new_survey.endDepth, new_survey.stepDepth, new_survey.zType) + \ "Inl/Crl bin size (m/line): {}/{}\n".format( new_survey.inline_bin, new_survey.crline_bin) + \ "Area (sq km): {}; Survey type: Only 3D\n".format( new_survey.area) + \ "In-line Orientation: {:.2f} Degrees from N\n".format( new_survey.azimuth) + \ "Location: {}".format(str(Path(CONF.data_root, survey_folder))) self.surveyInfoTextEdit.setPlainText(info_string) # draw survey area plot inlines = [ new_survey.startInline, new_survey.startInline, new_survey.endInline, new_survey.endInline ] crlines = [ new_survey.startCrline, new_survey.endCrline, new_survey.endCrline, new_survey.startCrline ] x_c, y_c = new_survey.four_corner_on_canvas(self.survey_map.width(), self.survey_map.height()) self.survey_map.inlines = inlines self.survey_map.crlines = crlines self.survey_map.x_canvas = x_c self.survey_map.y_canvas = y_c self.survey_map.repaint()
def create_Section_View(self): if not hasattr(self, "tab_section_view"): self.tab_section_view = self.create_new_tab( "tab_section_view", "Section View") # add adtional info self.tab_section_view.view_type = "SectionView" layout = QGridLayout(self.tab_section_view) self.section_view = SectionView(self.tab_section_view) layout.addWidget(self.section_view) self.tabWidget.setCurrentWidget(self.tab_section_view) file_path = Path(CONF.data_root) / CONF.current_survey / ".survey" if file_path.exists(): survey_set = ppp.SurveySetting(ppp.ThreePoints(str(file_path))) inline_SpinBox = \ self.section_view.control_widget.inline_SpinBox inline_SpinBox.setMaximum(survey_set.endInline) inline_SpinBox.setMinimum(survey_set.startInline) inline_SpinBox.setSingleStep(survey_set.stepInline) inline_SpinBox.setValue(survey_set.startInline) crline_SpinBox = \ self.section_view.control_widget.crline_SpinBox crline_SpinBox.setMaximum(survey_set.endCrline) crline_SpinBox.setMinimum(survey_set.startCrline) crline_SpinBox.setSingleStep(survey_set.stepCrline) crline_SpinBox.setValue(survey_set.stepCrline) step_inline_SpinBox = \ self.section_view.control_widget.step_inline_SpinBox step_inline_SpinBox.setMinimum(survey_set.stepInline) step_inline_SpinBox.setMaximum(survey_set.stepInline * (survey_set.nEast - 1)) step_inline_SpinBox.setSingleStep(survey_set.stepInline) step_crline_SpinBox = \ self.section_view.control_widget.step_crline_SpinBox step_crline_SpinBox.setMinimum(survey_set.stepCrline) step_crline_SpinBox.setMaximum(survey_set.stepCrline * (survey_set.nEast - 1)) step_crline_SpinBox.setSingleStep(survey_set.stepCrline) # seis_path = Path(CONF.data_root) / \ # CONF.current_survey / "Seismics" / ".seismics" # self.section_view.load_data_list(seis_path) self.section_view.status.connect(self.show_section_view_status) else: self.statusBar().showMessage('Section View already opened.')
def init_map_view(self): file_path = Path(CONF.data_root) / CONF.current_survey / ".survey" if file_path.exists(): self.map_view.draw_map( ppp.SurveySetting(ppp.ThreePoints(str(file_path))))
def update_map_view(self): file_path = CONF.survey_dir / ".survey" if file_path.exists(): self.map_view.draw_map( ppp.SurveySetting( ppp.ThreePoints(str(file_path))))
def test__survey_setting(): survey = ppp.SurveySetting(ppp.ThreePoints("test/data/v2.survey"))