# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# +
# #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Jun  7 16:21:49 2018
Use SKLearn function:
    extract_patches_2d
    reconstruct_from_patches_2d
    to transform raw seismic data into standard size(default: 100*100)
    
@author: maihao
CUP SiyuanCao Lab 2018
"""

'Here is Lina Seismic Playground'
__author__ = '<NAME>'

# +

#input necessary package
import segyio
import numpy as np
from shutil import copyfile

from sklearn.feature_extraction import image


# +
def ExtractSeisPatch(data,patch_size = (100,100)):
    # patch_size can not over half data size 
    # patch_size must <=  data.shape // 2
    # or reconstructed leak infomation (residual occur)
    return extract_patches_2d(data, patch_size= (100,100))

def ReconstructSeisPatch(data,patch_size):
    return reconstruct_from_patches_2d(data, patch_size)


# -

#main module
if  __name__ == '__main__':
    
    path = '/Users/maihao/Documents/Lab/DATA/marmousiUH/Kirchhoff_PoSDMsegy/'
    path = '/D:/MaiHao/DATA/DFB_DATA/'
    filename = 'Kirchhoff_PoSDM.segy'
    filename = 'ys250-300.sgy'
    file = 'D:\MaiHao\DATA\DFB_DATA\ys250-300.sgy'
    filename = 'name_of_your_file.sgy'
    with segyio.open(file, "r+",strict=False) as segyfile:
        segyfile.attributes(segyio.TraceField.INLINE_3D)[:]
    # Memory map file for faster reading (especially if file is big...)
        segyfile.mmap()

    # Print binary header info
        print(segyfile.bin)
        print(segyfile.bin[segyio.BinField.Traces])

    # Read headerword inline for trace 10
        print(segyfile.header[10][segyio.TraceField.INLINE_3D])

    # Print inline and crossline axis
        print(segyfile.xlines)
        print(segyfile.ilines)
    
    with segyio.open(file, "r") as f:
        print(f.ilines)
    #a simple example
    #data = ExtractSeisPatch(ascent,(200,60))
    #b = ReconstructSeisPatch(data,(401,120))
    

# +
import matplotlib.pyplot as plt # plt 用于显示图片
import matplotlib.image as mpimg # mpimg 用于读取图片
import numpy as np

lena = mpimg.imread('D:\MaiHao\Code\PYTHON\DeepLearnPractice\AugmentPic\Patches.jpg') 

lena.shape #(512, 512, 3)

plt.imshow(lena) # 显示图片
plt.axis('off') # 不显示坐标轴
plt.show()
# -

plt.show()

plt.imshow(lena)



StarcoderdataJupyterScriptsDedupFiltered