提交 0ecb16fc 编辑于 作者: Mijian Xu's avatar Mijian Xu 😷 提交者: Mijian Xu
浏览文件

update

上级 fdefb11a
......@@ -2,8 +2,12 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="edeb6f02-0e8c-4c72-8baa-b897be95e5dc" name="Default" comment="update">
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/emaple/mag_test.dat" beforeDir="false" afterPath="$PROJECT_DIR$/emaple/mag_test.dat" afterDir="false" />
<change beforePath="$PROJECT_DIR$/emaple/mag_geod.dat" beforeDir="false" afterPath="$PROJECT_DIR$/exmaple/mag_geod.dat" afterDir="false" />
<change beforePath="$PROJECT_DIR$/emaple/mag_proj.dat" beforeDir="false" afterPath="$PROJECT_DIR$/exmaple/mag_proj.dat" afterDir="false" />
<change beforePath="$PROJECT_DIR$/emaple/mag_test.dat" beforeDir="false" afterPath="$PROJECT_DIR$/exmaple/mag_test.dat" afterDir="false" />
<change beforePath="$PROJECT_DIR$/emaple/magproj.eps" beforeDir="false" afterPath="$PROJECT_DIR$/exmaple/magproj.eps" afterDir="false" />
<change beforePath="$PROJECT_DIR$/mgpro/expand.py" beforeDir="false" afterPath="$PROJECT_DIR$/mgpro/expand.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/mgpro/mgpro.py" beforeDir="false" afterPath="$PROJECT_DIR$/mgpro/mgpro.py" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
......@@ -17,23 +21,25 @@
<counts>
<entry key="dummy" value="3" />
<entry key="gitignore" value="43" />
<entry key="py" value="710" />
<entry key="txt" value="6" />
<entry key="py" value="718" />
<entry key="txt" value="10" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.types.edit">
<counts>
<entry key="PLAIN_TEXT" value="52" />
<entry key="Python" value="710" />
<entry key="PLAIN_TEXT" value="56" />
<entry key="Python" value="718" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.extensions.open">
<counts>
<entry key="dat" value="1" />
<entry key="py" value="1" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.types.open">
<counts>
<entry key="PLAIN_TEXT" value="1" />
<entry key="Python" value="1" />
</counts>
</usages-collector>
......@@ -44,11 +50,8 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/mgpro/expand.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="420">
<caret line="20" column="6" selection-start-line="20" selection-start-column="6" selection-end-line="20" selection-end-column="6" />
<folding>
<element signature="e#0#16#0" expanded="true" />
</folding>
<state relative-caret-position="42">
<caret line="2" column="7" selection-start-line="2" selection-start-column="7" selection-end-line="2" selection-end-column="7" />
</state>
</provider>
</entry>
......@@ -72,24 +75,31 @@
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/mgpro/mgpro.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="783">
<caret line="140" selection-start-line="140" selection-end-line="140" />
<state relative-caret-position="342">
<caret line="119" column="48" selection-start-line="119" selection-start-column="48" selection-end-line="119" selection-end-column="48" />
<folding>
<element signature="e#0#18#0" expanded="true" />
<marker date="1547291183375" expanded="true" signature="225:346" ph="..." />
<marker date="1547295254003" expanded="true" signature="225:346" ph="..." />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="true">
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/exmaple/mag_up0_diff2.dat">
<provider selected="true" editor-type-id="LargeFileEditor">
<state relative-caret-position="-51062" />
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/.gitignore">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="42">
<caret line="2" lean-forward="true" selection-start-line="2" selection-end-line="2" />
<state relative-caret-position="126">
<caret line="6" column="6" selection-start-line="6" selection-start-column="6" selection-end-line="6" selection-end-column="6" />
</state>
</provider>
</entry>
......@@ -158,18 +168,19 @@
<option value="$PROJECT_DIR$/ps_proj.sh" />
<option value="$PROJECT_DIR$/mgpro/proj.py" />
<option value="$PROJECT_DIR$/mag_up0_diff1.dat" />
<option value="$PROJECT_DIR$/mgpro/expand.py" />
<option value="$PROJECT_DIR$/mgpro/__init__.py" />
<option value="$PROJECT_DIR$/mgpro/mgmat.py" />
<option value="$PROJECT_DIR$/.gitignore" />
<option value="$PROJECT_DIR$/mgpro/expand.py" />
<option value="$PROJECT_DIR$/mgpro/mgpro.py" />
</list>
</option>
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="70" />
<option name="y" value="55" />
<option name="width" value="2227" />
<option name="height" value="1239" />
<option name="x" value="68" />
<option name="y" value="41" />
<option name="width" value="2492" />
<option name="height" value="1417" />
</component>
<component name="ProjectView">
<navigator proportions="" version="1">
......@@ -183,6 +194,11 @@
<item name="MGPro" type="b2602c69:ProjectViewProjectNode" />
<item name="MGPro" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="MGPro" type="b2602c69:ProjectViewProjectNode" />
<item name="MGPro" type="462c0819:PsiDirectoryNode" />
<item name="exmaple" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="MGPro" type="b2602c69:ProjectViewProjectNode" />
<item name="MGPro" type="462c0819:PsiDirectoryNode" />
......@@ -357,14 +373,21 @@
<option name="project" value="LOCAL" />
<updated>1547291492133</updated>
</task>
<option name="localTasksCounter" value="3" />
<task id="LOCAL-00003" summary="update">
<created>1547294919423</created>
<option name="number" value="00003" />
<option name="presentableId" value="LOCAL-00003" />
<option name="project" value="LOCAL" />
<updated>1547294919423</updated>
</task>
<option name="localTasksCounter" value="4" />
<servers />
</component>
<component name="ToolWindowManager">
<frame x="68" y="23" width="2492" height="1417" extended-state="0" />
<frame x="69" y="23" width="2492" height="1417" extended-state="6" />
<editor active="true" />
<layout>
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.06717928" />
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.06717928" />
<window_info id="Structure" order="1" weight="0.25" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
......@@ -375,7 +398,7 @@
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="bottom" id="Version Control" order="7" show_stripe_button="false" />
<window_info active="true" anchor="bottom" id="Terminal" order="8" visible="true" weight="0.21509434" />
<window_info anchor="bottom" id="Terminal" order="8" visible="true" weight="0.21509434" />
<window_info anchor="bottom" id="Event Log" order="9" side_tool="true" />
<window_info anchor="bottom" id="Python Console" order="10" weight="0.3282989" />
<window_info anchor="right" id="Commander" order="0" weight="0.4" />
......@@ -396,7 +419,7 @@
<entry file="file://$PROJECT_DIR$/new.dat">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/emaple/magproj.eps" />
<entry file="file://$PROJECT_DIR$/exmaple/magproj.eps" />
<entry file="file://$PROJECT_DIR$/../seispy/seispy/psrayp.py" />
<entry file="file://$PROJECT_DIR$/mgpro/ps_proj.sh">
<provider selected="true" editor-type-id="text-editor">
......@@ -405,16 +428,6 @@
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/Documents/GMT/geo3al/latlonconvert.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="672">
<caret line="32" column="106" selection-start-line="31" selection-start-column="11" selection-end-line="32" selection-end-column="106" />
<folding>
<element signature="e#0#13#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/../seispy/seispy/ccp.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="540">
......@@ -425,11 +438,11 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/emaple/mag_test.dat">
<entry file="file://$PROJECT_DIR$/exmaple/mag_test.dat">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$USER_HOME$/.pyenv/versions/anaconda3-5.2.0/lib/python3.6/site-packages/scipy/interpolate/ndgriddata.py" />
<entry file="file://$PROJECT_DIR$/emaple/mag_geod.dat">
<entry file="file://$PROJECT_DIR$/exmaple/mag_geod.dat">
<provider selected="true" editor-type-id="LargeFileEditor" />
</entry>
<entry file="file://$PROJECT_DIR$/mag_up10_diff1.dat">
......@@ -459,31 +472,43 @@
<entry file="file://$PROJECT_DIR$/mgpro/__init__.py">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/.gitignore">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="126">
<caret line="6" column="6" selection-start-line="6" selection-start-column="6" selection-end-line="6" selection-end-column="6" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/mgpro/expand.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="420">
<caret line="20" column="6" selection-start-line="20" selection-start-column="6" selection-end-line="20" selection-end-column="6" />
<folding>
<element signature="e#0#16#0" expanded="true" />
</folding>
<state relative-caret-position="42">
<caret line="2" column="7" selection-start-line="2" selection-start-column="7" selection-end-line="2" selection-end-column="7" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/mgpro/mgpro.py">
<entry file="file://$USER_HOME$/Documents/GMT/geo3al/latlonconvert.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="783">
<caret line="140" selection-start-line="140" selection-end-line="140" />
<state relative-caret-position="672">
<caret line="32" column="106" selection-start-line="31" selection-start-column="11" selection-end-line="32" selection-end-column="106" />
<folding>
<element signature="e#0#18#0" expanded="true" />
<marker date="1547291183375" expanded="true" signature="225:346" ph="..." />
<element signature="e#0#13#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/.gitignore">
<entry file="file://$PROJECT_DIR$/exmaple/mag_up0_diff2.dat">
<provider selected="true" editor-type-id="LargeFileEditor">
<state relative-caret-position="-51062" />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/mgpro/mgpro.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="42">
<caret line="2" lean-forward="true" selection-start-line="2" selection-end-line="2" />
<state relative-caret-position="342">
<caret line="119" column="48" selection-start-line="119" selection-start-column="48" selection-end-line="119" selection-end-column="48" />
<folding>
<element signature="e#0#18#0" expanded="true" />
<marker date="1547295254003" expanded="true" signature="225:346" ph="..." />
</folding>
</state>
</provider>
</entry>
......
import math as M
import numpy as np
from mgmat import mgmat
from mgpro import mgmat
import matplotlib.pyplot as plt
......
......@@ -117,7 +117,7 @@ class mgmat(object):
with open(filename, 'w') as f:
for i, x in enumerate(self.x):
for j, y in enumerate(self.y):
f.write('{:.4f}\t{:.4f}\t{:f}\n'.format(x, y, self.result[j, i]))
f.write('{:.4f}\t{:.4f}\t{:.10f}\n'.format(x, y, self.result[j, i]))
def exec():
......@@ -130,9 +130,9 @@ def exec():
arg = parser.parse_args()
try:
h, order = [float(v) for v in arg.c.split('/')]
dx, dy = [float(v) for v in arg.d.spllt('/')]
dx, dy = [float(v) for v in arg.d.split('/')]
if arg.R is not None:
arg.R = [float(v) for v in arg.R.spllt('/')]
arg.R = [float(v) for v in arg.R.split('/')]
except Exception as e:
raise ValueError('{}\nError in parsing arguments.'.format(e))
mg = mgmat(arg.in_file, dx, dy, xy_limit=arg.R)
......
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 13 12:54:06 2018
@author: Mijian Xu
"""
import sys
import os
from datetime import datetime
import numpy as np
from mgpro.mgpro import mgmat
from PyQt5.QtWidgets import QMainWindow, QApplication, \
QAction, QMenu, QFileDialog, QGridLayout,QLineEdit, QLabel, \
QWidget, QHBoxLayout, QPushButton, QVBoxLayout,QFrame, \
QTextEdit
from PyQt5.QtGui import QColor, QFont
from matplotlib.backends.backend_qt5agg import (
FigureCanvas, NavigationToolbar2QT as NavigationToolbar)
from matplotlib.figure import Figure
redColor = QColor(255, 0, 0)
class opts():
def __init__(self):
self.fname = ''
self.h = 0
self.order = 0
self.log = datetime.now().strftime('%Y/%m/%d %H:%M:%S: OK')
self.breakpoint = [0.2, 0.4, 0.6, 0.8]
class MGProUI(QMainWindow):
def __init__(self):
super().__init__()
self.opts = opts()
self.mg = None
self.initUI()
def initUI(self):
impAct = QAction('Import', self)
impAct.setShortcut('Ctrl+i')
impAct.triggered.connect(self.importFile)
menubar = self.menuBar()
fileMenu = menubar.addMenu('&File')
fileMenu.addAction(impAct)
self.filetitle = QLabel('Data file:', self)
self.filetitle.move(30, 40)
self.fileEdit = QLineEdit(self)
self.fileEdit.resize(300, 30)
self.fileEdit.move(100, 40)
self.fileEdit.textChanged[str].connect(self.onChanged)
self.draw_raw_data_Button = QPushButton('Draw Data', self)
self.draw_raw_data_Button.setCheckable(False)
self.draw_raw_data_Button.move(420, 40)
self.draw_raw_data_Button.clicked[bool].connect(self.draw_raw_data)
self.proFrame = QFrame(self)
self.proFrame.setFrameShape(QFrame.StyledPanel)
self.proFrame.resize(350, 200)
self.proFrame.move(600, 40)
grid = QGridLayout(self.proFrame)
grid.setSpacing(10)
continu_la = QLabel('Continuation:')
continuEdit = QLineEdit(self)
continuEdit.textChanged[str].connect(self.contiChanged)
# continuEdit.resize(30, 40)
deriv_la = QLabel('Derivative:')
derivEdit = QLineEdit(self)
derivEdit.textChanged[str].connect(self.derivChanged)
calButton = QPushButton('Calculate', self)
calButton.clicked[bool].connect(self.calculation)
drawButton = QPushButton('draw result', self)
drawButton.clicked[bool].connect(self.draw_result)
buttonbox = QWidget(self)
hbox = QHBoxLayout(buttonbox)
buttonbox.setLayout(hbox)
hbox.addWidget(calButton)
hbox.addWidget(drawButton)
calTitle = QLabel('Process', self)
calTitle.setFont(QFont("Roman times",15,QFont.Bold))
grid.addWidget(calTitle, 0, 0, 1, 2)
grid.addWidget(continu_la, 1, 0)
grid.addWidget(continuEdit, 1, 1)
grid.addWidget(deriv_la, 2, 0)
grid.addWidget(derivEdit, 2, 1)
grid.addWidget(buttonbox, 3, 1)
# grid.addWidget(calButton, 2, 0)
# grid.addWidget(drawButton, 2, 1)
# grid.addLayout(hbox)
self.logEdit = QTextEdit(self)
self.logEdit.resize(350, 375)
self.logEdit.move(600, 460)
self.logEdit.setReadOnly(True)
self.logEdit.append(self.opts.log)
self.figWid = QWidget(self)
self.figWid.resize(532, 380)
self.figWid.move(30, 80)
layoutf = QVBoxLayout(self.figWid)
self.figWid.setLayout(layoutf)
self.raw_canvas = FigureCanvas(Figure(figsize=(7, 5)))
layoutf.addWidget(self.raw_canvas)
# self.toolbar = NavigationToolbar(self.raw_canvas, self)
# self.toolbar.hide()
self.rstWid = QWidget(self)
self.rstWid.resize(532, 380)
self.rstWid.move(30, 460)
layoutd = QVBoxLayout(self.rstWid)
self.rstWid.setLayout(layoutd)
self.pro_canvas = FigureCanvas(Figure(figsize=(7, 5)))
layoutd.addWidget(self.pro_canvas)
self.colorset = QFrame(self)
self.colorset.setFrameShape(QFrame.StyledPanel)
self.colorset.resize(350, 130)
self.colorset.move(600, 250)
grid = QGridLayout(self.colorset)
self.colorset.setLayout(grid)
grid.setSpacing(5)
colorTitle = QLabel('Color Set', self)
colorTitle.setFont(QFont("Roman times",15,QFont.Bold))
color1 = QFrame(self)
color1.setStyleSheet("QWidget {background-color: rgb(62, 225, 95)}")
color1Edit = QLineEdit(self)
color1Edit.textChanged[str].connect(self.setcolor1)
color2 = QFrame(self)
color2.setStyleSheet("QWidget {background-color: rgb(255, 225, 95)}")
color2Edit = QLineEdit(self)
color2Edit.textChanged[str].connect(self.setcolor2)
color3 = QFrame(self)
color3.setStyleSheet("QWidget {background-color: rgb(62, 225, 255)}")
color3Edit = QLineEdit(self)
color3Edit.textChanged[str].connect(self.setcolor3)
color4 = QFrame(self)
color4.setStyleSheet("QWidget {background-color: rgb(255, 0, 95)}")
color4Edit = QLineEdit(self)
color4Edit.textChanged[str].connect(self.setcolor4)
grid.addWidget(colorTitle, 0,0, 1, 4)
grid.addWidget(color1, 1, 0)
grid.addWidget(color1Edit,2,0)
grid.addWidget(color2, 1, 1)
grid.addWidget(color2Edit,2,1)
grid.addWidget(color3, 1, 2)
grid.addWidget(color3Edit,2,2)
grid.addWidget(color4, 1, 3)
grid.addWidget(color4Edit,2,3)
'''
static_ax = self.raw_canvas.figure.subplots()
t = np.array([[1,2,3,4],[1,2,3,4]])
static_ax.pcolor(t)
'''
# self.grid.addWidget(static_canvas,2,0)
# self.statusBar().showMessage('Ready')
self.setGeometry(300, 300, 1000, 900)
self.setWindowTitle('MGPro')
self.show()
def contiChanged(self, text):
try:
self.opts.h = float(text)
except:
pass
def derivChanged(self, text):
try:
self.opts.order = float(text)
except:
pass
def importFile(self):
try:
fname = QFileDialog.getOpenFileName(self, 'Open grid dat file',
os.path.dirname(__file__))
self.writelog('Loading %s' % fname[0])
except:
self.writelog('Cannot open file', QColor(255,0,0))
return
self.opts.fname = fname[0]
self.fileEdit.setText(self.opts.fname)
try:
self.mg = mgmat(self.opts.fname)
except:
self.writelog('Error format of import file', QColor(255,0,0))
return
self.draw_raw_data_Button.setCheckable(True)
self.writelog('Loading done')
def onChanged(self, text):
self.opts.fname = text
def calculation(self):
self.writelog('Calculating: h=%5.2f order=%5.2f' % (self.opts.h, self.opts.order))
try:
self.mg.continuation(self.opts.h, self.opts.order)
self.writelog('Calculation done')
except Exception as e:
self.writelog('Error in calculating:\n%s' % e.args[0], QColor=(255,0,0))
def draw_result(self):
self.writelog('Drawing result')
try:
self.mg.pltmap(self.pro_canvas.figure, self.mg.result)
except Exception as e:
self.writelog('Error in mapping:\n%s' % e.args[0], QColor=(255,0,0))
def draw_raw_data(self):
if isinstance(self.mg, mgmat):
self.writelog('Drawing raw data')
try:
self.mg.pltmap(self.raw_canvas.figure, self.mg.data)
except Exception as e:
self.writelog('Error in mapping:\n%s' % e.args[0], QColor=(255,0,0))
else:
self.writelog('No data load', QColor)
def writelog(self, content, color=QColor(0,0,0)):
log = datetime.now().strftime('%Y/%m/%d %H:%M:%S')+': '+ content
self.logEdit.setTextColor(color)
self.logEdit.append(log)
def setcolor1(self, text):
self.opts.breakpoint[0] = float(text)
def setcolor2(self, text):
self.opts.breakpoint[1] = float(text)
def setcolor3(self, text):
self.opts.breakpoint[2] = float(text)
def setcolor4(self, text):
self.opts.breakpoint[3] = float(text)
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = MGProUI()
sys.exit(app.exec_())
支持 Markdown
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册