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

update mgmat

上级 97582b5b
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with NO BOM" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (install_pyproj)" project-jdk-type="Python SDK" />
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
......@@ -2,10 +2,9 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="edeb6f02-0e8c-4c72-8baa-b897be95e5dc" name="Default" comment="">
<change afterPath="$PROJECT_DIR$/mgpro/proj.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/modules.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/mgpro/mgmat.py" beforeDir="false" afterPath="$PROJECT_DIR$/mgpro/mgmat.py" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
......@@ -13,52 +12,12 @@
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FUSProjectUsageTrigger">
<session id="355405479">
<usages-collector id="statistics.lifecycle.project">
<counts>
<entry key="project.closed" value="3" />
<entry key="project.open.time.0" value="2" />
<entry key="project.open.time.15" value="1" />
<entry key="project.open.time.7" value="1" />
<entry key="project.opened" value="4" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.extensions.open">
<counts>
<entry key="dat" value="2" />
<entry key="eps" value="1" />
<entry key="py" value="5" />
<entry key="sh" value="1" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.types.open">
<counts>
<entry key="PLAIN_TEXT" value="4" />
<entry key="Python" value="5" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.extensions.edit">
<counts>
<entry key="Python Console" value="198" />
<entry key="py" value="1119" />
<entry key="sh" value="291" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.types.edit">
<counts>
<entry key="Bash" value="291" />
<entry key="Python" value="1317" />
</counts>
</usages-collector>
</session>
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<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="716">
<state relative-caret-position="880">
<caret line="47" selection-start-line="47" selection-end-line="47" />
<folding>
<element signature="e#0#16#0" expanded="true" />
......@@ -70,21 +29,17 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/mgpro/proj.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="42">
<state relative-caret-position="40">
<caret line="2" selection-start-line="2" selection-end-line="2" />
<folding>
<marker date="1547201904674" expanded="true" signature="94:99" ph="..." />
<marker date="1547201904674" expanded="true" signature="514:1586" 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$/mgpro/mgmat.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="70">
<caret line="7" column="27" lean-forward="true" selection-start-line="7" selection-start-column="27" selection-end-line="7" selection-end-column="27" />
<state relative-caret-position="474">
<caret line="120" column="20" selection-start-line="120" selection-start-column="20" selection-end-line="120" selection-end-column="20" />
<folding>
<element signature="e#0#18#0" expanded="true" />
</folding>
......@@ -92,37 +47,21 @@
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/../seispy/seispy/ccp.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="540">
<caret line="221" column="29" lean-forward="true" selection-start-line="221" selection-start-column="4" selection-end-line="221" selection-end-column="29" />
<folding>
<element signature="e#0#18#0" expanded="true" />
</folding>
</state>
</provider>
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/mag_up0_diff1.dat">
<provider selected="true" editor-type-id="text-editor" />
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/ps_proj.sh">
<entry file="file://$PROJECT_DIR$/mag_up10_diff1.dat">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="147">
<caret line="7" column="25" selection-start-line="7" selection-start-column="25" selection-end-line="7" selection-end-column="25" />
</state>
<state relative-caret-position="-38760" />
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<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 file="file://$PROJECT_DIR$/mag_geod.dat">
<provider selected="true" editor-type-id="LargeFileEditor" />
</entry>
</file>
</leaf>
......@@ -150,14 +89,18 @@
<option value="$USER_HOME$/Documents/GMT/geo3al/latlonconvert.py" />
<option value="$PROJECT_DIR$/ps_proj.sh" />
<option value="$PROJECT_DIR$/mgpro/proj.py" />
<option value="$PROJECT_DIR$/mgpro/mgmat.py" />
</list>
</option>
</component>
<component name="ProjectFrameBounds">
<option name="x" value="68" />
<option name="y" value="23" />
<option name="width" value="2492" />
<option name="height" value="1417" />
<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" />
</component>
<component name="ProjectLevelVcsManager">
<ConfirmationsSetting value="1" id="Add" />
</component>
<component name="ProjectView">
<navigator proportions="" version="1">
......@@ -185,7 +128,7 @@
</component>
<component name="PropertiesComponent">
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="settings.editor.selected.configurable" value="editor.preferences.fonts.default" />
<property name="settings.editor.selected.configurable" value="preferences.keymap" />
</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
......@@ -205,7 +148,7 @@
</list>
</option>
</component>
<component name="RunManager" selected="Python.proj">
<component name="RunManager" selected="Python.mgmat">
<configuration name="expand" type="PythonConfigurationType" factoryName="Python" temporary="true">
<module name="MGPro" />
<option name="INTERPRETER_OPTIONS" value="" />
......@@ -227,6 +170,27 @@
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="mgmat" type="PythonConfigurationType" factoryName="Python" temporary="true">
<module name="MGPro" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/mgpro" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/mgpro/mgmat.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="proj" type="PythonConfigurationType" factoryName="Python" temporary="true">
<module name="MGPro" />
<option name="INTERPRETER_OPTIONS" value="" />
......@@ -287,9 +251,11 @@
<item itemvalue="Python.xy2mat" />
<item itemvalue="Python.expand" />
<item itemvalue="Python.proj" />
<item itemvalue="Python.mgmat" />
</list>
<recent_temporary>
<list>
<item itemvalue="Python.mgmat" />
<item itemvalue="Python.proj" />
<item itemvalue="Python.xy2mat" />
<item itemvalue="Python.expand" />
......@@ -310,63 +276,42 @@
<servers />
</component>
<component name="ToolWindowManager">
<frame x="68" y="23" width="2492" height="1417" extended-state="0" />
<frame x="70" y="27" width="2490" height="1386" extended-state="6" />
<editor active="true" />
<layout>
<window_info active="true" 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.059610706" />
<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" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info anchor="bottom" id="Run" order="2" weight="0.3290566" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info anchor="bottom" id="Run" order="2" visible="true" weight="0.3282989" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.399841" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<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 anchor="bottom" id="Terminal" order="8" visible="true" weight="0.32830188" />
<window_info anchor="bottom" id="Terminal" order="8" weight="0.2154213" />
<window_info anchor="bottom" id="Event Log" order="9" side_tool="true" />
<window_info anchor="bottom" id="Python Console" order="10" weight="0.3290566" />
<window_info anchor="bottom" id="Python Console" order="10" weight="0.3282989" />
<window_info anchor="right" id="Commander" order="0" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
<window_info anchor="right" id="Data View" order="3" />
</layout>
</component>
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/mgpro/xy2mat.py" />
<entry file="file://$PROJECT_DIR$/mag_test.dat">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/new.dat">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/magproj.eps">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/../seispy/seispy/psrayp.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="703">
<caret line="62" column="125" lean-forward="true" selection-start-line="61" selection-start-column="4" selection-end-line="62" selection-end-column="125" />
<folding>
<element signature="e#0#9#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/ps_proj.sh">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="147">
<caret line="7" column="25" selection-start-line="7" selection-start-column="25" selection-end-line="7" selection-end-column="25" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/magproj.eps" />
<entry file="file://$PROJECT_DIR$/../seispy/seispy/psrayp.py" />
<entry file="file://$PROJECT_DIR$/ps_proj.sh" />
<entry file="file://$USER_HOME$/Documents/GMT/geo3al/latlonconvert.py" />
<entry file="file://$PROJECT_DIR$/../seispy/seispy/ccp.py" />
<entry file="file://$PROJECT_DIR$/mgpro/expand.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="716">
<state relative-caret-position="880">
<caret line="47" selection-start-line="47" selection-end-line="47" />
<folding>
<element signature="e#0#16#0" expanded="true" />
......@@ -374,46 +319,43 @@
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/Documents/GMT/geo3al/latlonconvert.py">
<entry file="file://$PROJECT_DIR$/mgpro/proj.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 relative-caret-position="40">
<caret line="2" selection-start-line="2" selection-end-line="2" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/../seispy/seispy/ccp.py">
<entry file="file://$PROJECT_DIR$/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">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="540">
<caret line="221" column="29" lean-forward="true" selection-start-line="221" selection-start-column="4" selection-end-line="221" selection-end-column="29" />
<folding>
<element signature="e#0#18#0" expanded="true" />
</folding>
<state relative-caret-position="563">
<caret line="229" selection-start-line="229" selection-end-line="229" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/mgpro/proj.py">
<entry file="file://$PROJECT_DIR$/mag_geod.dat">
<provider selected="true" editor-type-id="LargeFileEditor" />
</entry>
<entry file="file://$PROJECT_DIR$/mag_up10_diff1.dat">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="42">
<caret line="2" selection-start-line="2" selection-end-line="2" />
<folding>
<marker date="1547201904674" expanded="true" signature="94:99" ph="..." />
<marker date="1547201904674" expanded="true" signature="514:1586" ph="..." />
</folding>
</state>
<state relative-caret-position="-38760" />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/mgpro/mgmat.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="70">
<caret line="7" column="27" lean-forward="true" selection-start-line="7" selection-start-column="27" selection-end-line="7" selection-end-column="27" />
<state relative-caret-position="474">
<caret line="120" column="20" selection-start-line="120" selection-start-column="20" selection-end-line="120" selection-end-column="20" />
<folding>
<element signature="e#0#18#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/mag_up0_diff1.dat">
<provider selected="true" editor-type-id="text-editor" />
</entry>
</component>
</project>
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -3,6 +3,8 @@ from mgpro import expand
import matplotlib.pyplot as plt
import matplotlib.colors as colors
from scipy.fftpack import fft2, fftshift, ifft2, ifftshift
from scipy.interpolate import griddata
def cal_pos(max_len, len_x, len_y):
if max_len > 1 or max_len < 0:
......@@ -16,6 +18,23 @@ def cal_pos(max_len, len_x, len_y):
return width, hight
def xyz2grd(raw_data, dx, dy, xy_limit=None):
data = raw_data.copy()
data[:, [0, 1]] = data[:, [1, 0]]
if xy_limit is None:
xmin = np.min(raw_data[:, 0])
xmax = np.max(raw_data[:, 0])
ymin = np.min(raw_data[:, 1])
ymax = np.max(raw_data[:, 1])
else:
xmin, xmax, ymin, ymax = xy_limit
xrange = np.arange(xmin, xmax, dx)
yrange = np.arange(ymin, ymax, dy)
ymesh, xmesh = np.meshgrid(yrange, xrange, indexing='ij')
grid_data = griddata(data[:, 0:2], data[:, 2], (ymesh, xmesh))
return xrange, yrange, grid_data
class JetNormalize(colors.Normalize):
def __init__(self, vmin=None, vmax=None, midpoint=None, clip=False):
if midpoint is None:
......@@ -35,24 +54,28 @@ class JetNormalize(colors.Normalize):
class mgmat(object):
def __init__(self, file):
def __init__(self, file, dx, dy, xy_limit=None):
self.dx = dx
self.dy = dy
in_data = np.loadtxt(file)
self.x = np.unique(in_data[:, 0])
self.y = np.unique(in_data[:, 1])
len_x = self.x.shape[0]
len_y = self.y.shape[0]
self.dx = np.mean(np.diff(self.x))
self.dy = np.mean(np.diff(self.y))
self.data = np.zeros([len_y, len_x])
m = 0
for i in range(len_y):
for j in range(len_x):
self.data[i, j] = in_data[m, 2]
m += 1
# self.x = np.unique(in_data[:, 0])
# self.y = np.unique(in_data[:, 1])
# len_x = self.x.shape[0]
# len_y = self.y.shape[0]
# self.dx = np.mean(np.diff(self.x))
# self.dy = np.mean(np.diff(self.y))
# self.data = np.zeros([len_y, len_x])
# m = 0
# for i in range(len_y):
# for j in range(len_x):
# self.data[i, j] = in_data[m, 2]
# m += 1
self.x, self.y, self.data = xyz2grd(in_data, dx, dy, xy_limit=xy_limit)
self.data_expand, self.row_begin, self.row_end, self.col_begin, self.col_end = expand.expand(self.data)
self.data_sf = fftshift(fft2(self.data_expand))
self.h = None
self.order = None
self.result = np.array([])
def continuation(self, h, order):
self.h = h
......@@ -68,6 +91,7 @@ class mgmat(object):
H = np.sqrt(((col_mesh - col0)*dom_col)**2+((row_mesh - row0)*dom_row)**2) ** order \
* np.exp(h * np.sqrt(((col_mesh - col0)*dom_col)**2+((row_mesh - row0)*dom_row)**2))
self.result = np.real(ifft2(ifftshift(H * self.data_sf)))[self.row_begin: self.row_end + 1, self.col_begin: self.col_end + 1]
return self.result
def pltmap(self, fig, data, breakpoint=None):
f_width = fig.get_figwidth()
......@@ -77,26 +101,34 @@ class mgmat(object):
real_width *= frac_w
fig.clf()
ax_raw = fig.gca()
pcm = ax_raw.pcolor(data,
cmap='jet',
norm=JetNormalize(midpoint=breakpoint))
pcm = ax_raw.pcolor(data, cmap='jet')
# ax_raw.figure.canvas.draw()
cb = fig.colorbar(pcm, extend='both')
ax_raw.set_position([.1, .125, real_width, real_height], which='original')
cb.ax.set_position([.8, .1, real_height/6.27, real_height])
# ax_raw.set_position([.1, .125, real_width, real_height], which='original')
# cb.ax.set_position([.8, .1, real_height/6.27, real_height])
fig.canvas.draw()
def savetxt(self, filename):
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]))
if __name__ == '__main__':
filename = 'C:\\Users\\zxuxmij\\Documents\\MGPro\\mag_test.dat'
mg = mgmat(filename)
# mg.continuation(-0.01, 1)
f=plt.figure(figsize=(7, 5))
ax = f.gca()
pcm = ax.pcolor(mg.data)
print(ax.get_position())
cb = f.colorbar(pcm, extend='both')
ax.set_position([.1,.1] + list(cal_pos(0.7, len(mg.x), len(mg.y))), which='original')
cb.ax.set_position([.8, .1, 0.1250, 0.78375])
#mg.pltmap(breakpoint=[-8000, -800, 800, 8000])
plt.show()
filename = '../mag_geod.dat'
mg = mgmat(filename, 2000, 2000)
mg.continuation(0, 1)
mg.savetxt('../mag_up0_diff1.dat')
# f=plt.figure(figsize=(7, 5))
# mg.pltmap(f, mg.result)
# plt.show()
# ax = f.gca()
# pcm = ax.pcolor(mg.data)
#
# print(ax.get_position())
# cb = f.colorbar(pcm, extend='both')
# ax.set_position([.1,.1] + list(cal_pos(0.7, len(mg.x), len(mg.y))), which='original')
# cb.ax.set_position([.8, .1, 0.1250, 0.78375])
# #mg.pltmap(breakpoint=[-8000, -800, 800, 8000])
# plt.show()
支持 Markdown
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册