├── .gitignore ├── 1402_Smoothing_surfaces ├── 1402_Smoothing_surfaces.ipynb └── data │ └── Penobscot_HorB.txt ├── 1404_Euler_deconvolution ├── create_synthetic_data.ipynb ├── data │ ├── batholith.json │ ├── dike.json │ ├── metadata.json │ ├── model.pickle │ ├── sill.json │ └── synthetic_data.txt └── euler-deconvolution-examples.ipynb ├── 1406_Make_a_synthetic ├── Figure_1.png ├── How_to_make_a_synthetic.pdf ├── L-30.las ├── PenobXL_1155.txt ├── README.md ├── how_to_make_synthetic.ipynb ├── las.py └── tops.txt ├── 1408_Evaluate_and_compare_colormaps ├── How_to_evaluate_and_compare_colormaps.ipynb └── data │ ├── GIZA_X.txt │ ├── GIZA_Y.txt │ ├── GIZA_Z.txt │ ├── Linear_L_0-1.txt │ ├── Penobscot_HorB.txt │ └── Spectral_16-colours_Deuteranope.png ├── 1410_Phase ├── SegyMAT │ ├── CheckSegyTraceHeader.m │ ├── Contents.m │ ├── GUI │ │ ├── DIAAboutSegymat.fig │ │ ├── DIAAboutSegymat.m │ │ ├── DIAOpenSEGY.fig │ │ ├── DIAOpenSEGY.m │ │ ├── GUIEditSegyHeader.fig │ │ ├── GUIEditSegyHeader.m │ │ ├── GUIEditSegyTraceHeader.fig │ │ ├── GUIEditSegyTraceHeader.m │ │ ├── GUIEditTextualFileHeader.fig │ │ ├── GUIEditTextualFileHeader.m │ │ ├── GUIPlotXY.fig │ │ ├── GUIPlotXY.m │ │ ├── compile_segymat.m │ │ ├── segymat.fig │ │ └── segymat.m │ ├── GetSegyHeader.m │ ├── GetSegyHeaderBasics.m │ ├── GetSegyTrace.m │ ├── GetSegyTraceData.m │ ├── GetSegyTraceHeader.m │ ├── GetSegyTraceHeaderInfo.m │ ├── InitSegyTraceHeader.m │ ├── LICENSE │ ├── MakeXmlRef.m │ ├── MergeSegy.m │ ├── PutSegyHeader.m │ ├── PutSegyTrace.m │ ├── README_OCTAVE │ ├── README_STANDALONE_WIN32.txt │ ├── REVISION │ ├── ReadSegy.m │ ├── ReadSegyConstantTraceLength.m │ ├── ReadSegyFast.m │ ├── ReadSegyHeader.m │ ├── ReadSegyTrace.m │ ├── ReadSegyTraceHeaderValue.m │ ├── ReadSu.m │ ├── ReadSuFast.m │ ├── Sac2Segy.m │ ├── Segy2Su.m │ ├── SegyMAT_GAIN.m │ ├── SegyMATdemo1.m │ ├── SegymatHelp.m │ ├── SegymatRevision.m │ ├── SegymatVerbose.m │ ├── SegymatVersion.m │ ├── Su2Segy.m │ ├── TraceHeaderDef.m │ ├── WriteSegy.m │ ├── WriteSegyStructure.m │ ├── WriteSegyTraceHeaderValue.m │ ├── WriteSu.m │ ├── WriteSuStructure.m │ ├── ascii2ebcdic.m │ ├── cmap_rwb.m │ ├── ebcdic2ascii.m │ ├── f11_02673_45Hz.segy │ ├── gse2segy.m │ ├── ibm2num.m │ ├── isoctave.m │ ├── num2ibm.m │ ├── pick_line.m │ ├── progress_txt.m │ ├── read_gse_int.m │ ├── sac2mat.m │ ├── sacpc2mat.m │ ├── sacsun2mat.m │ ├── testWriteSegy.m │ └── wiggle.m ├── complex_attributes_on_section.m ├── configure_tutorial.m ├── data │ ├── penobscot_xl1155.sgy │ └── trace_il1190_xl1155.trace ├── environment.yml ├── ffthilbert.m ├── fftshifter.m ├── find_peaks.m ├── get_idealised_phase.m ├── load_abenaki.m ├── load_simple_trace.m ├── phase_and_hilbert_transform.ipynb ├── plot_complex_attributes_on_a_slice.m ├── plot_complex_attributes_on_a_trace.m ├── plot_phase_at_envelope_peaks_on_a_slice.m ├── plot_phase_at_envelope_peaks_on_a_trace.m ├── purves_tutorial_long.pdf └── readme.md ├── 1412_Tuning_and_AVO ├── Thin_beds_and_AVO__Draft.pdf ├── figure_1.png ├── figure_2.png ├── tuning_prestack.py ├── tuning_prestack_v2.py ├── tuning_wedge.py └── tuning_wedge_v2.py ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | 27 | # PyInstaller 28 | # Usually these files are written by a python script from a template 29 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 30 | *.manifest 31 | *.spec 32 | 33 | # Installer logs 34 | pip-log.txt 35 | pip-delete-this-directory.txt 36 | 37 | # Unit test / coverage reports 38 | htmlcov/ 39 | .tox/ 40 | .coverage 41 | .coverage.* 42 | .cache 43 | nosetests.xml 44 | coverage.xml 45 | *,cover 46 | .hypothesis/ 47 | 48 | # Translations 49 | *.mo 50 | *.pot 51 | 52 | # Django stuff: 53 | *.log 54 | local_settings.py 55 | 56 | # Flask stuff: 57 | instance/ 58 | .webassets-cache 59 | 60 | # Scrapy stuff: 61 | .scrapy 62 | 63 | # Sphinx documentation 64 | docs/_build/ 65 | 66 | # PyBuilder 67 | target/ 68 | 69 | # IPython Notebook 70 | .ipynb_checkpoints 71 | 72 | # pyenv 73 | .python-version 74 | 75 | # celery beat schedule file 76 | celerybeat-schedule 77 | 78 | # dotenv 79 | .env 80 | 81 | # virtualenv 82 | venv/ 83 | ENV/ 84 | 85 | # Spyder project settings 86 | .spyderproject 87 | 88 | # Rope project settings 89 | .ropeproject 90 | -------------------------------------------------------------------------------- /1404_Euler_deconvolution/data/batholith.json: -------------------------------------------------------------------------------- 1 | [[18046.875, 9921.875000000004], [19062.5, 10234.375000000004], [19765.625, 11093.750000000004], [20078.125, 12500.000000000004], [19843.75, 13515.625000000004], [18281.25, 14140.625000000004], [16640.625, 14140.625000000004], [15781.250000000002, 13671.875000000004], [15703.125000000002, 11718.750000000004], [15859.375000000002, 10390.625000000004], [16250.000000000002, 9843.750000000004]] -------------------------------------------------------------------------------- /1404_Euler_deconvolution/data/dike.json: -------------------------------------------------------------------------------- 1 | [[78.12500000000136, 17968.750000000004], [15156.250000000002, 19843.750000000004], [29843.75, 20781.250000000004], [29843.75, 21015.625000000004], [15078.125000000002, 20156.250000000004], [156.25000000000136, 18281.250000000004]] -------------------------------------------------------------------------------- /1404_Euler_deconvolution/data/metadata.json: -------------------------------------------------------------------------------- 1 | {"shape": [100, 100], "dec": 30, "inc": -15, "bounds": [0, 30000, 0, 30000, 0, 5000], "area": [5000, 25000, 5000, 25000]} -------------------------------------------------------------------------------- /1404_Euler_deconvolution/data/model.pickle: -------------------------------------------------------------------------------- 1 | (lp1 2 | ccopy_reg 3 | _reconstructor 4 | p2 5 | (cfatiando.mesher 6 | PolygonalPrism 7 | p3 8 | c__builtin__ 9 | object 10 | p4 11 | NtRp5 12 | (dp6 13 | S'nverts' 14 | p7 15 | I6 16 | sS'props' 17 | p8 18 | (dp9 19 | S'magnetization' 20 | p10 21 | I10 22 | ssS'y' 23 | cnumpy.core.multiarray 24 | _reconstruct 25 | p11 26 | (cnumpy 27 | ndarray 28 | p12 29 | (I0 30 | tS'b' 31 | tRp13 32 | (I1 33 | (I6 34 | tcnumpy 35 | dtype 36 | p14 37 | (S'f4' 38 | I0 39 | I1 40 | tRp15 41 | (I3 42 | S'<' 43 | NNNI-1 44 | I-1 45 | I0 46 | tbI00 47 | S'\x80a\x8cF\x80\x07\x9bF\x80Z\xa2F@/\xa4F\x80x\x9dF\x80\xd2\x8eF' 48 | tbsS'x' 49 | g11 50 | (g12 51 | (I0 52 | tS'b' 53 | tRp16 54 | (I1 55 | (I6 56 | tg15 57 | I00 58 | S"\x00@\x9cB\x00\xd1lF\x80'\xe9F\x80'\xe9F\x80\x98kF\x00@\x1cC" 59 | tbsS'z1' 60 | p17 61 | F0 62 | sS'z2' 63 | p18 64 | F5000 65 | sbag2 66 | (g3 67 | g4 68 | NtRp19 69 | (dp20 70 | g7 71 | I14 72 | sg8 73 | (dp21 74 | g10 75 | I10 76 | ssS'y' 77 | g11 78 | (g12 79 | (I0 80 | tS'b' 81 | tRp22 82 | (I1 83 | (I14 84 | tg15 85 | I00 86 | S"\x80\xf0\tF\x00\x9a\rF\x80<'F\x80S8F\x80jIF\x00gTF\x80\x81ZF\x80\x81ZF\x80\x81ZF\x002HF\x80S8F\x80x\x1dF\x80\x96\x18F\x00\x0b\x10F" 87 | tbsS'x' 88 | g11 89 | (g12 90 | (I0 91 | tS'b' 92 | tRp23 93 | (I1 94 | (I14 95 | tg15 96 | I00 97 | S'\x00@\x1cF\x00\xb1\x1eF\x80\x001F\x00\x8c9F\x80\xc4:F\x0092F\x00\xb1\x1eF\x00|\x12F\x00\x0b\x10F\x00\xd6\x03F\x00\x06\xf9E\x00\x06\xf9E\x00\x06\xf9E\x00G\x06F' 98 | tbsg17 99 | F1000 100 | sg18 101 | F1500 102 | sbag2 103 | (g3 104 | g4 105 | NtRp24 106 | (dp25 107 | g7 108 | I11 109 | sg8 110 | (dp26 111 | g10 112 | I2 113 | ssS'y' 114 | g11 115 | (g12 116 | (I0 117 | tS'b' 118 | tRp27 119 | (I1 120 | (I11 121 | tg15 122 | I00 123 | S'\x80\x07\x1bF\x80\xe9\x1fF\x00W-F\x00PCF\x80.SF\x80\xf2\\F\x80\xf2\\F\x80\x9fUF\x00\x1b7F\x80Z"F\x00\xcf\x19F' 124 | tbsS'x' 125 | g11 126 | (g12 127 | (I0 128 | tS'b' 129 | tRp28 130 | (I1 131 | (I11 132 | tg15 133 | I00 134 | S'\xc0\xfd\x8cF\x00\xed\x94F@k\x9aF@\xdc\x9cF\x80\x07\x9bF\x80\xd2\x8eF@\x01\x82F\x00\x95vF\x80\\uF\x80\xcdwF\x00\xe8}F' 135 | tbsg17 136 | F500 137 | sg18 138 | F4000 139 | sba. -------------------------------------------------------------------------------- /1404_Euler_deconvolution/data/sill.json: -------------------------------------------------------------------------------- 1 | [[10000.000000000002, 8828.125000000004], [10156.250000000002, 9062.500000000004], [11328.125000000002, 10703.125000000004], [11875.000000000002, 11796.875000000004], [11953.125000000002, 12890.625000000004], [11406.250000000002, 13593.750000000004], [10156.250000000002, 13984.375000000004], [9375.000000000002, 13984.375000000004], [9218.750000000002, 13984.375000000004], [8437.500000000002, 12812.500000000004], [7968.750000000002, 11796.875000000004], [7968.750000000002, 10078.125000000004], [7968.750000000002, 9765.625000000004], [8593.750000000002, 9218.750000000004]] -------------------------------------------------------------------------------- /1406_Make_a_synthetic/Figure_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seg/tutorials-2014/aab1cf917bc4b223e1061d2984aa1bce4bc41a1c/1406_Make_a_synthetic/Figure_1.png -------------------------------------------------------------------------------- /1406_Make_a_synthetic/How_to_make_a_synthetic.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seg/tutorials-2014/aab1cf917bc4b223e1061d2984aa1bce4bc41a1c/1406_Make_a_synthetic/How_to_make_a_synthetic.pdf -------------------------------------------------------------------------------- /1406_Make_a_synthetic/README.md: -------------------------------------------------------------------------------- 1 | **This project is part of a Leading Edge tutorial by Evan Bianco.** 2 | 3 | [See a rendered version of this Notebook.](http://nbviewer.org/github/seg/tutorials/blob/master/1406_Make_a_synthetic/how_to_make_synthetic.ipynb) 4 | 5 | A note about the data 6 | ==================== 7 | 8 | The LAS file was digitized by Neil Watson of Atlantic Petrohysics, Halifax, Nova Scotia. The data is shared to the community for knowledge sharing and with an understanding that it will not be used for any commercial purposes. 9 | 10 | dGB thanks the Nova Scotia Department of Energy and the Canada Nova Scotia Offshore Petroleum Board for making this dataset available for the Open Seismic Repository. We also acknowledge the M.Phil. research students namely Naveed Iqbal and Junaid Talha from Quaid-i-Azam University (Islamabad, Pakistan) for digitizing the wireline logs and sharing the dataset to the community. CNSOPB is hereby acknowledge for granting permission to publish the well data also. 11 | 12 | Seismic data and velocity functions: Owned by Nova Scotia Department of Energy. Distributed by permission. Derived volumes may be distributed if Nova Scotia Department of Energy is acknowledged as the owner of the original data. 13 | 14 | Interpretations and derived volumes: Created and released by dGB Earth Sciences B. V. under the Creative Common Attribution–ShareAlike license. 15 | -------------------------------------------------------------------------------- /1406_Make_a_synthetic/tops.txt: -------------------------------------------------------------------------------- 1 | # MD(m) TVD(m) TVDSS(m) Name 2 | 867.156 867.156 837.256 Wyandot 3 | 984.504 984.504 954.604 Dawson_Canyon 4 | 1136.904 1136.904 1107.004 Logan_Canyon 5 | 2251.253 2251.253 2221.353 U_Missisauga 6 | 2469.207 2469.207 2439.307 Base_O-Marker 7 | 3190.646 3190.646 3160.746 L_Missisauga 8 | 3404.311 3404.311 3374.411 Abenaki 9 | 3485.083 3485.083 3455.183 Mid_Baccaro 10 | 3964.534 3964.534 3934.634 L_Baccaro 11 | -------------------------------------------------------------------------------- /1408_Evaluate_and_compare_colormaps/data/Linear_L_0-1.txt: -------------------------------------------------------------------------------- 1 | 0.0143 0.0143 0.0143 0.0404 0.0125 0.0325 0.0516 0.0154 0.0443 0.0616 0.0184 0.0530 0.0699 0.0215 0.0615 0.0814 0.0229 0.0687 0.0857 0.0273 0.0763 0.0928 0.0305 0.0805 0.1008 0.0330 0.0846 0.1064 0.0356 0.0939 0.1110 0.0396 0.0979 0.1184 0.0415 0.1020 0.1224 0.0453 0.1062 0.1263 0.0489 0.1105 0.1308 0.0518 0.1150 0.1357 0.0541 0.1200 0.1413 0.0555 0.1256 0.1453 0.0590 0.1256 0.1506 0.0603 0.1309 0.1533 0.0637 0.1344 0.1569 0.0664 0.1385 0.1624 0.0678 0.1425 0.1654 0.0708 0.1471 0.1703 0.0729 0.1504 0.1742 0.0755 0.1542 0.1796 0.0768 0.1595 0.1809 0.0783 0.1775 0.1798 0.0807 0.1967 0.1783 0.0829 0.2159 0.1782 0.0843 0.2341 0.1765 0.0866 0.2514 0.1770 0.0886 0.2646 0.1761 0.0911 0.2782 0.1754 0.0933 0.2922 0.1773 0.0951 0.3026 0.1758 0.0972 0.3174 0.1751 0.0999 0.3290 0.1744 0.1025 0.3405 0.1735 0.1047 0.3534 0.1748 0.1071 0.3627 0.1747 0.1094 0.3739 0.1726 0.1122 0.3858 0.1731 0.1153 0.3940 0.1731 0.1175 0.4051 0.1731 0.1197 0.4161 0.1720 0.1224 0.4268 0.1730 0.1261 0.4330 0.1716 0.1285 0.4445 0.1710 0.1314 0.4540 0.1706 0.1340 0.4642 0.1664 0.1381 0.4739 0.1582 0.1482 0.4717 0.1487 0.1583 0.4683 0.1422 0.1653 0.4699 0.1352 0.1729 0.4694 0.1281 0.1796 0.4708 0.1254 0.1854 0.4719 0.1207 0.1904 0.4762 0.1167 0.1962 0.4773 0.1166 0.2004 0.4814 0.1147 0.2057 0.4823 0.1137 0.2093 0.4888 0.1091 0.2149 0.4904 0.1089 0.2190 0.4944 0.1074 0.2234 0.4984 0.1108 0.2270 0.5022 0.1096 0.2315 0.5056 0.1058 0.2367 0.5077 0.1048 0.2402 0.5145 0.1047 0.2444 0.5182 0.1068 0.2482 0.5223 0.1086 0.2521 0.5264 0.1067 0.2568 0.5290 0.1061 0.2607 0.5346 0.1059 0.2648 0.5386 0.1056 0.2690 0.5427 0.0969 0.2769 0.5343 0.0879 0.2847 0.5251 0.0832 0.2907 0.5218 0.0793 0.2972 0.5153 0.0686 0.3044 0.5068 0.0639 0.3106 0.5006 0.0586 0.3166 0.4955 0.0536 0.3227 0.4888 0.0388 0.3292 0.4817 0.0409 0.3343 0.4786 0.0345 0.3401 0.4722 0.0300 0.3458 0.4665 0.0290 0.3506 0.4647 0.0226 0.3564 0.4578 0.0154 0.3619 0.4529 0.0146 0.3670 0.4487 0.0169 0.3718 0.4464 0.0117 0.3773 0.4400 0.0055 0.3828 0.4334 0.0052 0.3873 0.4327 0.0008 0.3927 0.4267 0.0000 0.3977 0.4220 0.0003 0.4024 0.4200 0.0013 0.4072 0.4166 0.0000 0.4132 0.4107 0.0000 0.4179 0.4071 0.0000 0.4242 0.3977 0.0000 0.4302 0.3919 0.0000 0.4345 0.3890 0.0000 0.4395 0.3849 0.0000 0.4456 0.3776 0.0000 0.4508 0.3728 0.0000 0.4563 0.3666 0.0000 0.4613 0.3597 0.0000 0.4670 0.3542 0.0000 0.4716 0.3504 0.0000 0.4763 0.3464 0.0000 0.4820 0.3375 0.0000 0.4870 0.3331 0.0000 0.4918 0.3256 0.0000 0.4969 0.3198 0.0000 0.5024 0.3126 0.0000 0.5060 0.3101 0.0000 0.5118 0.3012 0.0000 0.5166 0.2938 0.0000 0.5214 0.2871 0.0000 0.5268 0.2816 0.0000 0.5315 0.2726 0.0000 0.5356 0.2675 0.0000 0.5407 0.2597 0.0000 0.5461 0.2552 0.0000 0.5519 0.2506 0.0000 0.5565 0.2469 0.0000 0.5624 0.2396 0.0000 0.5678 0.2360 0.0000 0.5727 0.2338 0.0000 0.5778 0.2287 0.0000 0.5829 0.2250 0.0000 0.5883 0.2180 0.0000 0.5931 0.2146 0.0000 0.5991 0.2089 0.0000 0.6036 0.2056 0.0000 0.6084 0.1999 0.0000 0.6138 0.1961 0.0000 0.6189 0.1899 0.0000 0.6239 0.1848 0.0000 0.6290 0.1759 0.0000 0.6345 0.1707 0.0000 0.6381 0.1638 0.0000 0.6438 0.1592 0.0000 0.6489 0.1519 0.0000 0.6536 0.1410 0.0000 0.6590 0.1322 0.0000 0.6645 0.1222 0.0000 0.6656 0.0909 0.0000 0.6644 0.0322 0.0351 0.6660 0.0000 0.0797 0.6703 0.0000 0.1129 0.6739 0.0000 0.1392 0.6776 0.0000 0.1566 0.6814 0.0000 0.1765 0.6847 0.0000 0.1890 0.6890 0.0000 0.2030 0.6928 0.0000 0.2167 0.6966 0.0000 0.2299 0.7003 0.0000 0.2391 0.7044 0.0000 0.2517 0.7081 0.0000 0.2574 0.7124 0.0000 0.2679 0.7162 0.0000 0.2790 0.7200 0.0000 0.2878 0.7240 0.0000 0.2965 0.7280 0.0000 0.3052 0.7319 0.0000 0.3101 0.7362 0.0000 0.3187 0.7402 0.0000 0.3272 0.7441 0.0000 0.3345 0.7482 0.0000 0.3406 0.7523 0.0000 0.3604 0.7549 0.0000 0.3898 0.7563 0.0000 0.4169 0.7574 0.0000 0.4461 0.7580 0.0000 0.4681 0.7594 0.0000 0.4900 0.7612 0.0000 0.5089 0.7627 0.0000 0.5304 0.7637 0.0000 0.5500 0.7649 0.0000 0.5698 0.7660 0.0000 0.5825 0.7688 0.0000 0.5999 0.7701 0.0000 0.6173 0.7713 0.0000 0.6314 0.7730 0.0000 0.6487 0.7741 0.0000 0.6632 0.7763 0.0000 0.6757 0.7782 0.0000 0.6912 0.7795 0.0000 0.7061 0.7808 0.0000 0.7222 0.7818 0.0000 0.7305 0.7852 0.0000 0.7442 0.7866 0.0000 0.7580 0.7880 0.0000 0.7709 0.7896 0.0000 0.7833 0.7915 0.0000 0.7872 0.7891 0.0951 0.7972 0.7903 0.1988 0.8072 0.7917 0.2560 0.8116 0.7949 0.3001 0.8211 0.7964 0.3397 0.8308 0.7980 0.3710 0.8350 0.8011 0.4028 0.8450 0.8026 0.4292 0.8548 0.8041 0.4555 0.8602 0.8073 0.4735 0.8658 0.8100 0.4993 0.8758 0.8116 0.5184 0.8856 0.8130 0.5402 0.8895 0.8164 0.5602 0.8994 0.8180 0.5775 0.9077 0.8202 0.5918 0.9106 0.8241 0.6094 0.9205 0.8257 0.6253 0.9284 0.8278 0.6420 0.9343 0.8307 0.6576 0.9415 0.8329 0.6762 0.9512 0.8348 0.6868 0.9549 0.8384 0.7026 0.9622 0.8408 0.7170 0.9712 0.8429 0.7287 0.9708 0.8482 0.7409 0.9713 0.8530 0.7555 0.9691 0.8591 0.7655 0.9699 0.8642 0.7746 0.9703 0.8691 0.7871 0.9710 0.8740 0.7999 0.9695 0.8800 0.8067 0.9696 0.8851 0.8188 0.9686 0.8908 0.8278 0.9681 0.8962 0.8378 0.9688 0.9013 0.8467 0.9696 0.9064 0.8557 0.9703 0.9115 0.8647 0.9708 0.9163 0.8773 0.9691 0.9224 0.8838 0.9692 0.9273 0.8961 0.9699 0.9323 0.9051 0.9693 0.9381 0.9108 0.9714 0.9425 0.9230 0.9712 0.9478 0.9311 0.9700 0.9537 0.9381 0.9707 0.9587 0.9470 0.9713 0.9638 0.9560 0.9726 0.9687 0.9648 0.9738 0.9738 0.9711 0.9780 0.9780 0.9780 0.9824 0.9824 0.9824 0.9868 0.9868 0.9868 0.9912 0.9912 0.9912 0.9956 0.9956 0.9956 1.0000 1.0000 1.0000 -------------------------------------------------------------------------------- /1408_Evaluate_and_compare_colormaps/data/Spectral_16-colours_Deuteranope.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seg/tutorials-2014/aab1cf917bc4b223e1061d2984aa1bce4bc41a1c/1408_Evaluate_and_compare_colormaps/data/Spectral_16-colours_Deuteranope.png -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/CheckSegyTraceHeader.m: -------------------------------------------------------------------------------- 1 | % SegyTraceHeader=CheckSegyTraceHeader(SegyTraceHeader); 2 | % 3 | % Checks that all fields of the SegyTraceHeader is set. 4 | % If not, they are initialized. 5 | % 6 | 7 | % 8 | % (C) 2004, Thomas Mejer Hansen, tmh@gfy.ku.dk/thomas@cultpenguin.com 9 | % 10 | % 11 | % 12 | % This program is free software; you can redistribute it and/or modify 13 | % it under the terms of the GNU General Public License as published by 14 | % the Free Software Foundation; either version 2 of the License, or 15 | % (at your option) any later version. 16 | % 17 | % This program is distributed in the hope that it will be useful, 18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | % GNU General Public License for more details. 21 | % 22 | % You should have received a copy of the GNU General Public License 23 | % along with this program; if not, write to the Free Software 24 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 25 | % 26 | function SegyTraceHeader=CheckSegyTraceHeader(SegyTraceHeader); 27 | %% SET UP SegyTraceHeader 28 | NA=0; 29 | 30 | if ~isfield(SegyTraceHeader,'TraceSequenceLine'), SegyTraceHeader.TraceSequenceLine=NA;end 31 | if ~isfield(SegyTraceHeader,'TraceSequenceFile'), SegyTraceHeader.TraceSequenceFile=NA;end 32 | if ~isfield(SegyTraceHeader,'FieldRecord'), SegyTraceHeader.FieldRecord=NA;end 33 | if ~isfield(SegyTraceHeader,'TraceNumber'), SegyTraceHeader.TraceNumber=NA;end 34 | if ~isfield(SegyTraceHeader,'EnergySourcePoint'), SegyTraceHeader.EnergySourcePoint=NA;end 35 | if ~isfield(SegyTraceHeader,'cdp'), SegyTraceHeader.cdp=NA;end 36 | if ~isfield(SegyTraceHeader,'cdpTrace'), SegyTraceHeader.cdpTrace=NA;end 37 | if ~isfield(SegyTraceHeader,'TraceIdenitifactionCode'), SegyTraceHeader.TraceIdenitifactionCode=NA;end 38 | if ~isfield(SegyTraceHeader,'NSummedTraces'), SegyTraceHeader.NSummedTraces=NA;end 39 | if ~isfield(SegyTraceHeader,'NStackedTraces'), SegyTraceHeader.NStackedTraces=NA;end 40 | if ~isfield(SegyTraceHeader,'DataUse'), SegyTraceHeader.DataUse=NA;end 41 | if ~isfield(SegyTraceHeader,'offset'), SegyTraceHeader.offset=NA;end 42 | if ~isfield(SegyTraceHeader,'ReceiverGroupElevation'), SegyTraceHeader.ReceiverGroupElevation=NA;end 43 | if ~isfield(SegyTraceHeader,'SourceSurfaceElevation'), SegyTraceHeader.SourceSurfaceElevation=NA;end 44 | if ~isfield(SegyTraceHeader,'SourceDepth'), SegyTraceHeader.SourceDepth=NA;end 45 | if ~isfield(SegyTraceHeader,'ReceiverDatumElevation'), SegyTraceHeader.ReceiverDatumElevation=NA;end 46 | if ~isfield(SegyTraceHeader,'SourceDatumElevation'), SegyTraceHeader.SourceDatumElevation=NA;end 47 | if ~isfield(SegyTraceHeader,'SourceWaterDepth'), SegyTraceHeader.SourceWaterDepth=NA;end 48 | if ~isfield(SegyTraceHeader,'GroupWaterDepth'), SegyTraceHeader.GroupWaterDepth=NA;end 49 | if ~isfield(SegyTraceHeader,'ElevationScalar'), SegyTraceHeader.ElevationScalar=NA;end 50 | % Multiply/divide next number for following 4 values 51 | if ~isfield(SegyTraceHeader,'SourceGroupScalar'), SegyTraceHeader.SourceGroupScalar=NA;end 52 | if ~isfield(SegyTraceHeader,'SourceX'), SegyTraceHeader.SourceX=NA;end 53 | if ~isfield(SegyTraceHeader,'SourceY'), SegyTraceHeader.SourceY=NA;end 54 | if ~isfield(SegyTraceHeader,'GroupX'), SegyTraceHeader.GroupX=NA;end 55 | if ~isfield(SegyTraceHeader,'GroupY'), SegyTraceHeader.GroupY=NA;end 56 | if ~isfield(SegyTraceHeader,'CoordinateUnits'), SegyTraceHeader.CoordinateUnits=NA;end 57 | if ~isfield(SegyTraceHeader,'WeatheringVelocity'), SegyTraceHeader.WeatheringVelocity=NA;end 58 | if ~isfield(SegyTraceHeader,'SubWeatheringVelocity'), SegyTraceHeader.SubWeatheringVelocity=NA;end 59 | if ~isfield(SegyTraceHeader,'SourceUpholeTime'), SegyTraceHeader.SourceUpholeTime=NA;end 60 | if ~isfield(SegyTraceHeader,'GroupUpholeTime'), SegyTraceHeader.GroupUpholeTime=NA;end 61 | if ~isfield(SegyTraceHeader,'SourceStaticCorrection'), SegyTraceHeader.SourceStaticCorrection=NA;end 62 | if ~isfield(SegyTraceHeader,'GroupStaticCorrection'), SegyTraceHeader.GroupStaticCorrection=NA;end 63 | if ~isfield(SegyTraceHeader,'TotalStaticApplied'), SegyTraceHeader.TotalStaticApplied=NA;end 64 | if ~isfield(SegyTraceHeader,'LagTimeA'), SegyTraceHeader.LagTimeA=NA;end 65 | if ~isfield(SegyTraceHeader,'LagTimeB'), SegyTraceHeader.LagTimeB=NA;end 66 | if ~isfield(SegyTraceHeader,'DelayRecordingTime'), SegyTraceHeader.DelayRecordingTime=NA;end 67 | if ~isfield(SegyTraceHeader,'MuteTimeStart'), SegyTraceHeader.MuteTimeStart=NA;end 68 | if ~isfield(SegyTraceHeader,'MuteTimeEND'), SegyTraceHeader.MuteTimeEND=NA;end 69 | if ~isfield(SegyTraceHeader,'ns'), SegyTraceHeader.ns=NA;end 70 | if ~isfield(SegyTraceHeader,'dt'), SegyTraceHeader.dt=NA;end 71 | if ~isfield(SegyTraceHeader,'GainType'), SegyTraceHeader.GainType=NA;end 72 | if ~isfield(SegyTraceHeader,'InstrumentGainConstant'), SegyTraceHeader.InstrumentGainConstant=NA;end 73 | if ~isfield(SegyTraceHeader,'InstrumentInitialGain'), SegyTraceHeader.InstrumentInitialGain=NA;end 74 | if ~isfield(SegyTraceHeader,'Correlated'), SegyTraceHeader.Correlated=NA;end 75 | if ~isfield(SegyTraceHeader,'SweepFrequenceStart'), SegyTraceHeader.SweepFrequenceStart=NA;end 76 | if ~isfield(SegyTraceHeader,'SweepFrequenceEnd'), SegyTraceHeader.SweepFrequenceEnd=NA;end 77 | if ~isfield(SegyTraceHeader,'SweepLength'), SegyTraceHeader.SweepLength=NA;end 78 | if ~isfield(SegyTraceHeader,'SweepType'), SegyTraceHeader.SweepType=NA;end 79 | if ~isfield(SegyTraceHeader,'SweepTraceTaperLengthStart'), SegyTraceHeader.SweepTraceTaperLengthStart=NA;end 80 | if ~isfield(SegyTraceHeader,'SweepTraceTaperLengthEnd'), SegyTraceHeader.SweepTraceTaperLengthEnd=NA;end 81 | if ~isfield(SegyTraceHeader,'TaperType'), SegyTraceHeader.TaperType=NA;end 82 | if ~isfield(SegyTraceHeader,'AliasFilterFrequency'), SegyTraceHeader.AliasFilterFrequency=NA;end 83 | if ~isfield(SegyTraceHeader,'AliasFilterSlope'), SegyTraceHeader.AliasFilterSlope=NA;end 84 | if ~isfield(SegyTraceHeader,'NotchFilterFrequency'), SegyTraceHeader.NotchFilterFrequency=NA;end 85 | if ~isfield(SegyTraceHeader,'NotchFilterSlope'), SegyTraceHeader.NotchFilterSlope=NA;end 86 | if ~isfield(SegyTraceHeader,'LowCutFrequency'), SegyTraceHeader.LowCutFrequency=NA;end 87 | if ~isfield(SegyTraceHeader,'HighCutFrequency'), SegyTraceHeader.HighCutFrequency=NA;end 88 | if ~isfield(SegyTraceHeader,'LowCutSlope'), SegyTraceHeader.LowCutSlope=NA;end 89 | if ~isfield(SegyTraceHeader,'HighCutSlope'), SegyTraceHeader.HighCutSlope=NA;end 90 | da=clock; 91 | if ~isfield(SegyTraceHeader,'YearDataRecorded'), SegyTraceHeader.YearDataRecorded=da(1);end 92 | DayOfYear=datenum(0,da(2),da(3)); % 22/7-2002 by Michael Toews (mwtoews@ucalgary.ca) 93 | if ~isfield(SegyTraceHeader,'DayOfYear'), SegyTraceHeader.DayOfYear=DayOfYear;end 94 | if ~isfield(SegyTraceHeader,'HourOfDay'), SegyTraceHeader.HourOfDay=da(4);end 95 | if ~isfield(SegyTraceHeader,'MinuteOfHour'), SegyTraceHeader.MinuteOfHour=da(5);end 96 | if ~isfield(SegyTraceHeader,'SecondOfMinute'), SegyTraceHeader.SecondOfMinute=round(da(6));end 97 | if ~isfield(SegyTraceHeader,'TimeBaseCode'), SegyTraceHeader.TimeBaseCode=NA;end 98 | if ~isfield(SegyTraceHeader,'TraceWeightningFactor'), SegyTraceHeader.TraceWeightningFactor=NA;end 99 | if ~isfield(SegyTraceHeader,'GeophoneGroupNumberRoll1'), SegyTraceHeader.GeophoneGroupNumberRoll1=NA;end 100 | if ~isfield(SegyTraceHeader,'GeophoneGroupNumberFirstTraceOrigField'), SegyTraceHeader.GeophoneGroupNumberFirstTraceOrigField=NA;end 101 | if ~isfield(SegyTraceHeader,'GeophoneGroupNumberLastTraceOrigField'), SegyTraceHeader.GeophoneGroupNumberLastTraceOrigField=NA;end 102 | if ~isfield(SegyTraceHeader,'GapSize'), SegyTraceHeader.GapSize=NA;end 103 | if ~isfield(SegyTraceHeader,'OverTravel'), SegyTraceHeader.OverTravel=NA;end 104 | if ~isfield(SegyTraceHeader,'cdpX'), SegyTraceHeader.cdpX=NA;end 105 | if ~isfield(SegyTraceHeader,'cdpY'), SegyTraceHeader.cdpY=NA;end 106 | if ~isfield(SegyTraceHeader,'Inline3D'), SegyTraceHeader.Inline3D=NA;end 107 | if ~isfield(SegyTraceHeader,'Crossline3D'), SegyTraceHeader.Crossline3D=NA;end 108 | if ~isfield(SegyTraceHeader,'ShotPoint'), SegyTraceHeader.ShotPoint=NA;end 109 | if ~isfield(SegyTraceHeader,'ShotPointScalar'), SegyTraceHeader.ShotPointScalar=NA;end 110 | if ~isfield(SegyTraceHeader,'TraceValueMeasurementUnit'), SegyTraceHeader.TraceValueMeasurementUnit=NA;end 111 | if ~isfield(SegyTraceHeader,'TransductionConstantMantissa'), SegyTraceHeader.TransductionConstantMantissa=NA;end 112 | if ~isfield(SegyTraceHeader,'TransductionConstantPower'), SegyTraceHeader.TransductionConstantPower=NA;end 113 | if ~isfield(SegyTraceHeader,'TransductionUnit'), SegyTraceHeader.TransductionUnit=NA;end 114 | if ~isfield(SegyTraceHeader,'TraceIdentifier'), SegyTraceHeader.TraceIdentifier=NA;end 115 | if ~isfield(SegyTraceHeader,'ScalarTraceHeader'), SegyTraceHeader.ScalarTraceHeader=NA;end 116 | 117 | 118 | if ~isfield(SegyTraceHeader,'SourceType'), SegyTraceHeader.SourceType=NA;end 119 | if ~isfield(SegyTraceHeader,'SourceEnergyDirectionMantissa'), SegyTraceHeader.SourceEnergyDirectionMantissa=NA;end 120 | if ~isfield(SegyTraceHeader,'SourceEnergyDirectionExponent'), SegyTraceHeader.SourceEnergyDirectionExponent=NA;end 121 | if ~isfield(SegyTraceHeader,'SourceMeasurementMantissa'), SegyTraceHeader.SourceMeasurementMantissa=NA;end 122 | if ~isfield(SegyTraceHeader,'SourceMeasurementExponent'), SegyTraceHeader.SourceMeasurementExponent=NA;end 123 | if ~isfield(SegyTraceHeader,'SourceMeasurementUnit'), SegyTraceHeader.SourceMeasurementUnit=NA;end 124 | 125 | if ~isfield(SegyTraceHeader,'UnassignedInt1'), SegyTraceHeader.UnassignedInt1=NA;end 126 | if ~isfield(SegyTraceHeader,'UnassignedInt2'), SegyTraceHeader.UnassignedInt2=NA;end 127 | 128 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/Contents.m: -------------------------------------------------------------------------------- 1 | % SegyMAT : A toolbox to read, write and manipulating SEG Y formatted files 2 | % Version 1.00 3 | % 4 | % New Features. 5 | % README 6 | % 7 | % Main 8 | % ReadSegy - Reads Segy File 9 | % ReadSegyHeader - Reads SegyHeader from Segy File 10 | % ReadSegyFast - Reads Segy File in fast mode. No header values will be read. 11 | % WriteSegy - Write Segy formatted data 12 | % WriteSegyStructure- Write Segy formatted data using SegyMAT data structures 13 | % 14 | % ReadSu - Reads a SU formatted file. 15 | % ReadSuFast - Reads a SU formatted file in fast mode. No header values will be read. 16 | % WriteSu - Write SU formatted data 17 | % WriteSuStructure - Write Su formatted data using SegyMAT data structures 18 | % 19 | % Lower Level IO 20 | % GetSegyHeader - Reads the segyheader of a SEGY Y formatted file 21 | % GetSegyHeaderBasics - Default Segy header settings 22 | % 23 | % GetSegyTrace.m - Read Segy Trace Header and Data from filehandle 24 | % GetSegyTraceHeader - Read Segy Trace Header from filehandle 25 | % GetSegyTraceData - Read Segy Trace Data from filehandle 26 | % 27 | % PutSegyHeader - Write Segy Header to filehandle 28 | % PutSegyTrace - Write Segy Trace Header and Data to filehandle 29 | % 30 | % InitSegyTraceHeader - Initalize all fields in the SegyTraceheader 31 | % CheckSegyTraceHeader.m - Check a SegyTraceHeader for all required fields 32 | % 33 | % 34 | % SU<-> SEG-Y conversion 35 | % Su2Segy - Convert SU formatted files to SEG Y 36 | % Segy2Su - Convert SEG Y formatted files to SU 37 | % 38 | % Plotting 39 | % wiggle - wiggle/variable area/image plotting of seismic data 40 | % 41 | % Misc 42 | % ibm2num - Convert IBM 32 bit floatto double 43 | % num2ibm - Convert IEEE 754 doubles to IBM 32 bit floating point format 44 | % ebcdic2ascii - convert ebcdic to ascii format 45 | % SegymatVerbose - controls amount of info written to screen 46 | % SegymatVersion - Return the current SegyMAT version 47 | % 48 | % 49 | % Seismic Processing : 50 | % SegyMAT_GAIN : 'agc' and 'power' gain. 51 | % 52 | % (C) 2001-2004 Thomas Mejer Hansen, tmh@gfy.ku.dk/thomas@cultpenguin.com 53 | % 54 | 55 | % 56 | % This program is free software; you can redistribute it and/or modify 57 | % it under the terms of the GNU General Public License as published by 58 | % the Free Software Foundation; either version 2 of the License, or 59 | % (at your option) any later version. 60 | % 61 | % This program is distributed in the hope that it will be useful, 62 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 63 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 64 | % GNU General Public License for more details. 65 | % 66 | % You should have received a copy of the GNU General Public License 67 | % along with this program; if not, write to the Free Software 68 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 69 | % 70 | 71 | % Demonstrations. 72 | % SegyMATdemo1 - Writes a Segy formatted filr, reads it and displays it 73 | % (NOT IMPLEMENTED) 74 | 75 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/GUI/DIAAboutSegymat.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seg/tutorials-2014/aab1cf917bc4b223e1061d2984aa1bce4bc41a1c/1410_Phase/SegyMAT/GUI/DIAAboutSegymat.fig -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/GUI/DIAAboutSegymat.m: -------------------------------------------------------------------------------- 1 | function varargout = DIAAboutSegymat(varargin) 2 | % DIAAboutSegymat Application M-file for DIAAboutSegymat.fig 3 | % FIG = DIAABOUTSEGYMAT launch DIAAboutSegymat GUI. 4 | % DIAABOUTSEGYMAT('callback_name', ...) invoke the named callback. 5 | 6 | % Last Modified by GUIDE v2.0 06-May-2002 10:38:58 7 | 8 | if nargin == 0 % LAUNCH GUI 9 | 10 | fig = openfig(mfilename,'reuse'); 11 | 12 | % Generate a structure of handles to pass to callbacks, and store it. 13 | handles = guihandles(fig); 14 | guidata(fig, handles); 15 | 16 | set(fig,'HandleVisibility','On') 17 | [ver,releasedate]=SegymatVersion; 18 | [rev]=SegymatRevision; 19 | set(handles.tVersion,'String',ver) 20 | set(handles.tReleaseDate,'String',releasedate) 21 | set(handles.lbRevision,'String',rev) 22 | set(fig,'HandleVisibility','CallBack') 23 | 24 | set(handles.fAboutSegymat,'Visible','on') 25 | 26 | % Wait for callbacks to run and window to be dismissed: 27 | uiwait(fig); 28 | 29 | if nargout > 0 30 | varargout{1} = fig; 31 | end 32 | 33 | elseif ischar(varargin{1}) % INVOKE NAMED SUBFUNCTION OR CALLBACK 34 | 35 | try 36 | if (nargout) 37 | [varargout{1:nargout}] = feval(varargin{:}); % FEVAL switchyard 38 | else 39 | feval(varargin{:}); % FEVAL switchyard 40 | end 41 | catch 42 | disp(lasterr); 43 | end 44 | 45 | end 46 | 47 | 48 | %| ABOUT CALLBACKS: 49 | %| GUIDE automatically appends subfunction prototypes to this file, and 50 | %| sets objects' callback properties to call them through the FEVAL 51 | %| switchyard above. This comment describes that mechanism. 52 | %| 53 | %| Each callback subfunction declaration has the following form: 54 | %| (H, EVENTDATA, HANDLES, VARARGIN) 55 | %| 56 | %| The subfunction name is composed using the object's Tag and the 57 | %| callback type separated by '_', e.g. 'slider2_Callback', 58 | %| 'figure1_CloseRequestFcn', 'axis1_ButtondownFcn'. 59 | %| 60 | %| H is the callback object's handle (obtained using GCBO). 61 | %| 62 | %| EVENTDATA is empty, but reserved for future use. 63 | %| 64 | %| HANDLES is a structure containing handles of components in GUI using 65 | %| tags as fieldnames, e.g. handles.figure1, handles.slider2. This 66 | %| structure is created at GUI startup using GUIHANDLES and stored in 67 | %| the figure's application data using GUIDATA. A copy of the structure 68 | %| is passed to each callback. You can store additional information in 69 | %| this structure at GUI startup, and you can change the structure 70 | %| during callbacks. Call guidata(h, handles) after changing your 71 | %| copy to replace the stored original so that subsequent callbacks see 72 | %| the updates. Type "help guihandles" and "help guidata" for more 73 | %| information. 74 | %| 75 | %| VARARGIN contains any extra arguments you have passed to the 76 | %| callback. Specify the extra arguments by editing the callback 77 | %| property in the inspector. By default, GUIDE sets the property to: 78 | %| ('', gcbo, [], guidata(gcbo)) 79 | %| Add any extra arguments after the last argument, before the final 80 | %| closing parenthesis. 81 | 82 | 83 | 84 | % -------------------------------------------------------------------- 85 | function varargout = listbox1_Callback(h, eventdata, handles, varargin) 86 | 87 | 88 | 89 | 90 | % -------------------------------------------------------------------- 91 | function varargout = pushbutton1_Callback(h, eventdata, handles, varargin) 92 | uiresume 93 | closereq -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/GUI/DIAOpenSEGY.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seg/tutorials-2014/aab1cf917bc4b223e1061d2984aa1bce4bc41a1c/1410_Phase/SegyMAT/GUI/DIAOpenSEGY.fig -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/GUI/GUIEditSegyHeader.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seg/tutorials-2014/aab1cf917bc4b223e1061d2984aa1bce4bc41a1c/1410_Phase/SegyMAT/GUI/GUIEditSegyHeader.fig -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/GUI/GUIEditSegyTraceHeader.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seg/tutorials-2014/aab1cf917bc4b223e1061d2984aa1bce4bc41a1c/1410_Phase/SegyMAT/GUI/GUIEditSegyTraceHeader.fig -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/GUI/GUIEditTextualFileHeader.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seg/tutorials-2014/aab1cf917bc4b223e1061d2984aa1bce4bc41a1c/1410_Phase/SegyMAT/GUI/GUIEditTextualFileHeader.fig -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/GUI/GUIPlotXY.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seg/tutorials-2014/aab1cf917bc4b223e1061d2984aa1bce4bc41a1c/1410_Phase/SegyMAT/GUI/GUIPlotXY.fig -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/GUI/GUIPlotXY.m: -------------------------------------------------------------------------------- 1 | function varargout = GUIEditSegyTraceHeader(varargin) 2 | % GUIPlotXY Application M-file for GUIEditSegyTraceHeader.fig 3 | % FIG = GUIPLOTXY launch GUIEditSegyTraceHeader GUI. 4 | % GUIPLOTXY('callback_name', ...) invoke the named callback. 5 | % 6 | % OBSOLETE ?? 7 | % 8 | 9 | 10 | % Last Modified by GUIDE v2.0 16-Jun-2002 11:41:23 11 | 12 | if (nargin == 0)|(isstruct(varargin{1})) % LAUNCH GUI 13 | 14 | fig = openfig(mfilename,'reuse'); 15 | 16 | % Use system color scheme for figure: 17 | set(fig,'Color',get(0,'defaultUicontrolBackgroundColor')); 18 | 19 | 20 | % Generate a structure of handles to pass to callbacks, and store it. 21 | handles = guihandles(fig); 22 | guidata(fig, handles); 23 | 24 | if nargin>0, 25 | data = guihandles(fig); % initialize it to contain handles 26 | data.H=varargin{1}; 27 | data.Hname=fieldnames(data.H(1)); 28 | 29 | data.NShowHeaders=7; % NUMBER OF HEADER VALUES TO LIST 30 | data.ShowNTraces=10; % NUMBER OF TRACES TO LIST 31 | data.StartTrace=1; 32 | 33 | set(handles.popX,'String',data.Hname); 34 | set(handles.popY,'String',data.Hname); 35 | 36 | set(handles.popX,'Value',2); 37 | set(handles.popY,'Value',4); 38 | 39 | guidata(fig,data); 40 | 41 | set(fig,'HandleVisibility','On') 42 | GUIPlotXY('actionPlotData',fig,handles) 43 | set(fig,'HandleVisibility','CallBack') 44 | 45 | end 46 | 47 | % Wait for callbacks to run and window to be dismissed: 48 | uiwait(fig); 49 | 50 | if nargout > 0 51 | data=guidata(fig); 52 | if isstruct(data.H) 53 | varargout{1}=data.H 54 | else 55 | varargout{1} = fig; 56 | end 57 | end 58 | 59 | close(handles.figure1); 60 | try;set(handles.figure1,'Visible','off');end 61 | 62 | 63 | elseif ischar(varargin{1}) % INVOKE NAMED SUBFUNCTION OR CALLBACK 64 | 65 | try 66 | if (nargout) 67 | [varargout{1:nargout}] = feval(varargin{:}); % FEVAL switchyard 68 | else 69 | feval(varargin{:}); % FEVAL switchyard 70 | end 71 | catch 72 | disp(lasterr); 73 | end 74 | 75 | end 76 | 77 | 78 | %| ABOUT CALLBACKS: 79 | %| GUIDE automatically appends subfunction prototypes to this file, and 80 | %| sets objects' callback properties to call them through the FEVAL 81 | %| switchyard above. This comment describes that mechanism. 82 | %| 83 | %| Each callback subfunction declaration has the following form: 84 | %| (H, EVENTDATA, HANDLES, VARARGIN) 85 | %| 86 | %| The subfunction name is composed using the object's Tag and the 87 | %| callback type separated by '_', e.g. 'slider2_Callback', 88 | %| 'figure1_CloseRequestFcn', 'axis1_ButtondownFcn'. 89 | %| 90 | %| H is the callback object's handle (obtained using GCBO). 91 | %| 92 | %| EVENTDATA is empty, but reserved for future use. 93 | %| 94 | %| HANDLES is a structure containing handles of components in GUI using 95 | %| tags as fieldnames, e.g. handles.figure1, handles.slider2. This 96 | %| structure is created at GUI startup using GUIHANDLES and stored in 97 | %| the figure's application data using GUIDATA. A copy of the structure 98 | %| is passed to each callback. You can store additional information in 99 | %| this structure at GUI startup, and you can change the structure 100 | %| during callbacks. Call guidata(h, handles) after changing your 101 | %| copy to replace the stored original so that subsequent callbacks see 102 | %| the updates. Type "help guihandles" and "help guidata" for more 103 | %| information. 104 | %| 105 | %| VARARGIN contains any extra arguments you have passed to the 106 | %| callback. Specify the extra arguments by editing the callback 107 | %| property in the inspector. By default, GUIDE sets the property to: 108 | %| ('', gcbo, [], guidata(gcbo)) 109 | %| Add any extra arguments after the last argument, before the final 110 | %| closing parenthesis. 111 | 112 | % -------------------------------------------------------------------- 113 | 114 | % -------------------------------------------------------------------- 115 | function varargout = popX_Callback(h, eventdata, handles, varargin) 116 | actionPlotData(h,handles) 117 | 118 | % -------------------------------------------------------------------- 119 | function varargout = popY_Callback(h, eventdata, handles, varargin) 120 | actionPlotData(h,handles) 121 | 122 | % -------------------------------------------------------------------- 123 | function varargout = figure1_ResizeFcn(h, eventdata, handles, varargin) 124 | 125 | 126 | % -------------------------------------------------------------------- 127 | function varargout = pbDone_Callback(h, eventdata, handles, varargin) 128 | uiresume; 129 | 130 | 131 | function actionPlotData(h,handles) 132 | data=guidata(h); 133 | Xv=get(handles.popX,'value'); 134 | Yv=get(handles.popY,'value'); 135 | 136 | Xheader=data.Hname(Xv); 137 | Yheader=data.Hname(Yv); 138 | 139 | X=[data.H.(char(Xheader))]; 140 | Y=[data.H.(char(Yheader))]; 141 | 142 | axes(handles.axMain); 143 | plot(X,Y,'k.'); 144 | xlabel(char(Xheader)) 145 | ylabel(char(Yheader)) 146 | zoom on 147 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/GUI/compile_segymat.m: -------------------------------------------------------------------------------- 1 | mcc -B sgl segymat 2 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/GUI/segymat.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seg/tutorials-2014/aab1cf917bc4b223e1061d2984aa1bce4bc41a1c/1410_Phase/SegyMAT/GUI/segymat.fig -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/GetSegyHeader.m: -------------------------------------------------------------------------------- 1 | % GetSegyHeader : Reads the segyheader of a SEGY Y formatted file 2 | % 3 | % Call : 4 | % [SegyHeader]=GetSegyHeader(segyid); 5 | % 6 | % segyid can be a filehandle or a filename 7 | % 8 | % 9 | % (C) 2001-2004 Thomas Mejer Hansen, tmh@gfy.ku.dk/thomas@cultpenguin.com 10 | % 11 | % 12 | % This program is free software; you can redistribute it and/or modify 13 | % it under the terms of the GNU General Public License as published by 14 | % the Free Software Foundation; either version 2 of the License, or 15 | % (at your option) any later version. 16 | % 17 | % This program is distributed in the hope that it will be useful, 18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | % GNU General Public License for more details. 21 | % 22 | % You should have received a copy of the GNU General Public License 23 | % along with this program; if not, write to the Free Software 24 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 25 | % 26 | function [SegyHeader]=GetSegyHeader(segyid,varargin); 27 | mfilename='GetSegyHeader'; 28 | SegymatVerbose([mfilename,' : Start'],90); 29 | ninput=nargin; 30 | % NEXT TWO LINES TO ENUSRE THAT VARARGIN CAN BE PASSED TO FUNCTION 31 | if ninput==2 32 | % CALL USING VARARGIN 33 | ninput=1+length(varargin{1}); 34 | varargin=varargin{1}; 35 | else 36 | % DIRECT CALL 37 | ninput=length(varargin); 38 | end 39 | 40 | 41 | % TRANSFORM VARARGING INTO PARAMETERS 42 | cargin=1; 43 | while (cargin0), 132 | SegymatVerbose(['---------------------------------------------------']) 133 | SegymatVerbose(['extended textual file headers are implemented ']) 134 | SegymatVerbose(['but have not been tested, since I(tmh@gfy.ku.dk) ']) 135 | SegymatVerbose(['have had no access to SEGY REV-1 files formatted ']) 136 | SegymatVerbose(['like this. Please contact me if you have such a ']) 137 | SegymatVerbose(['file to share ']) 138 | SegymatVerbose(['---------------------------------------------------']) 139 | 140 | txt=sprintf('%d Extended Textual File Headers',SegyHeader.NumberOfExtTextualHeaders); 141 | SegymatVerbose(txt); 142 | nChars=3200*SegyHeader.NumberOfExtTextualHeaders; 143 | SegyHeader.ExtTextualHeaders=fread(segyid,nChars,'schar'); % 3600 144 | else 145 | SegymatVerbose('NO extended textual file headers'); 146 | end 147 | SegyHeader.time=[1:1:SegyHeader.ns].*SegyHeader.dt./1e+6; 148 | Revision=SegyHeader.SegyFormatRevisionNumber; 149 | if Revision>0, Revision=1; end 150 | if (SegyHeader.DataSampleFormat>length(SegyHeader.Rev(Revision+1).DataSampleFormat)); 151 | SegymatVerbose([mfilename,' : WARNING : YOU HAVE SELECTED (OR THE FILE IS FORMATTED SUCH THAT) A DATASAMPLE FORMAT THAT IS NOT DEFINED. \nREMEBER IEEE IS NOT SPECIFIED IN THE SEGY REV0 STANDARD !']) 152 | 153 | if (Revision==0) 154 | SegymatVerbose([mfilename,' : TRYING TO USE REVISION 1 AS OPPOSED TO REVISION 0']) 155 | Revision=1; 156 | 157 | if (SegyHeader.DataSampleFormat>length(SegyHeader.Rev(Revision+1).DataSampleFormat)); 158 | SegymatVerbose([mfilename,' : FATAL ERROR : STILL THE DATASAMPLE FORMAT IS NOT SUPPRTED - EXITING (Report error to tmh@gfy.ku.dk)']) 159 | else 160 | SegymatVerbose([mfilename,' : APPARENT SUCCES CHANING FROM Revision 0 to 1 - Continuing']) 161 | SegyHeader.SegyFormatRevisionNumber=1; % FORCING REVISION TO BE 1 !!! 162 | end 163 | 164 | end 165 | 166 | end 167 | try 168 | Format=SegyHeader.Rev(Revision+1).DataSampleFormat(SegyHeader.DataSampleFormat).name; 169 | SegymatVerbose([mfilename,' : SegyRevision ',sprintf('%0.4g',Revision),', ',Format,'(',num2str(SegyHeader.DataSampleFormat),')']) 170 | catch 171 | end 172 | 173 | if ischar(segyid) 174 | fclose(segyid); 175 | end 176 | SegymatVerbose([mfilename,' : End'],90); 177 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/GetSegyTrace.m: -------------------------------------------------------------------------------- 1 | % GetSegyTrace : Reads a seg y trace, data and header 2 | % 3 | % [SegyTraceHeader,SegyData]=GetSegyTrace(segyid,TraceStart,DataFormat,ns); 4 | % 5 | 6 | % 7 | % (C) 2001-2004 Thomas Mejer Hansen, tmh@gfy.ku.dk/thomas@cultpenguin.com 8 | % 9 | % 10 | % This program is free software; you can redistribute it and/or modify 11 | % it under the terms of the GNU General Public License as published by 12 | % the Free Software Foundation; either version 2 of the License, or 13 | % (at your option) any later version. 14 | % 15 | % This program is distributed in the hope that it will be useful, 16 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | % GNU General Public License for more details. 19 | % 20 | % You should have received a copy of the GNU General Public License 21 | % along with this program; if not, write to the Free Software 22 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 | % 24 | 25 | function [SegyTraceHeader,SegyData]=GetSegyTrace(segyid,TraceStart,DataFormat,ns,SegyTraceHeader); 26 | 27 | if exist('DataFormat')==0, DataFormat='float32'; end 28 | if exist('TraceStart')==0, TraceStart=ftell(segyid); end 29 | 30 | if exist('SegyTraceHeader') 31 | if isempty('SegyTraceHeader'); 32 | clear SegyTraceHeader; 33 | end 34 | end 35 | 36 | [SegyTraceHeader]=GetSegyTraceHeader(segyid,TraceStart,DataFormat,ns); 37 | [SegyTraceData]=GetSegyDataTraceHeader(segyid,TraceStart,DataFormat,ns); 38 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/GetSegyTraceData.m: -------------------------------------------------------------------------------- 1 | % GetSegyTraceData : Get Segy trace data if filehandle 2 | % 3 | % Call : 4 | % 5 | % tracedata=GetSegyTraceData(segyid,ns,SegyHeader,SkipData 6 | % 7 | 8 | % 9 | % (C) 2001-2004 Thomas Mejer Hansen, tmh@gfy.ku.dk/thomas@cultpenguin.com 10 | % 11 | % This program is free software; you can redistribute it and/or modify 12 | % it under the terms of the GNU General Public License as published by 13 | % the Free Software Foundation; either version 2 of the License, or 14 | % (at your option) any later version. 15 | % 16 | % This program is distributed in the hope that it will be useful, 17 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | % GNU General Public License for more details. 20 | % 21 | % You should have received a copy of the GNU General Public License 22 | % along with this program; if not, write to the Free Software 23 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | % 25 | function tracedata=GetSegyTraceData(segyid,ns,SegyHeader,SkipData) 26 | % 27 | % Get Segy Trace Data. 28 | % 29 | % 30 | 31 | SkipData=[]; 32 | 33 | if nargin==0, 34 | SegymatVerbose(exist('segyid')) 35 | SegymatVerbose([mfilename,' : SEGYID not specified - exiting']) 36 | tracedata=[]; 37 | return 38 | end 39 | if nargin==1 40 | SegymatVerbose([mfilename,' : NS not specified - exiting']) 41 | tracedata=[]; 42 | return 43 | end 44 | if nargin==2 45 | SegyHeader.DataFormat='float32'; 46 | SegyHeader.BytesPerSample=32; 47 | SegyHeader.DataSampleFormat=5; % IEEE 48 | SegymatVerbose(['Dataformat not specified - dataformat->',SegyHeader.DataFormat]) 49 | end; 50 | 51 | if isempty(SkipData)==1, SkipData=0; end 52 | 53 | Revision=SegyHeader.SegyFormatRevisionNumber; 54 | if Revision>0, Revision=1; end 55 | Format=SegyHeader.Rev(Revision+1).DataSampleFormat(SegyHeader.DataSampleFormat).format; 56 | 57 | BPS=SegyHeader.Rev(Revision+1).DataSampleFormat(SegyHeader.DataSampleFormat).bps; 58 | if (SkipData==1) 59 | SkipBytes=ns*BPS/8; 60 | fseek(segyid,SkipBytes,'cof'); 61 | tracedata=[]; 62 | else 63 | % SegymatVerbose([mfilename,' : ',Format,'. ns=',num2str(ns)]) 64 | try 65 | tracedata=fread(segyid,ns,Format); 66 | catch 67 | SegymatVerbose([mfilename,' : Error using fread - Possibly ''ns'' is negative -' ... 68 | ' check byteorder-']) 69 | tracedata=[]; 70 | end 71 | 72 | 73 | if (strcmp(Format,'uint32')==1), % IBM FLOATING POINT 74 | % CONVERT FROM FLOATING POINT 75 | verbose=1; 76 | if verbose>1, SegymatVerbose([mfilename,'Converting from IBM, DataFormat :',SegyHeader.DataFormat]); end 77 | try 78 | tracedata=ibm2num(uint32(tracedata)); 79 | catch 80 | % SegymatVerbose([mfilename,' : SOMETHING BAD HAPPENED WHEN CONVERTING FROM IBM FLOATS TO IEEE. ARE YOU SURE DATA ARE IBM FLOAT FORMATTED ?' ]) 81 | % tracedata=0.*tracedata; 82 | % return 83 | 84 | end 85 | end; 86 | 87 | end 88 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/GetSegyTraceHeader.m: -------------------------------------------------------------------------------- 1 | % GetSegyTraceHeader : Reads a seg y trace, data and header 2 | % 3 | % [SegyTraceHeader]=GetSegyTraceHeader(segyid,TraceStart,DataFormat,ns); 4 | % 5 | % 6 | % (C) 2001-2004 Thomas Mejer Hansen, thomas.mejer.hansen@cultpenguin.com 7 | % 8 | % Revisions: 9 | % 07/2008 Kristian Stormark () : Reduce the 10 | % number of discoperations causing a significant speed up 11 | % 12 | 13 | % This program is free software; you can redistribute it and/or modify 14 | % it under the terms of the GNU General Public License as published by 15 | % the Free Software Foundation; either version 2 of the License, or 16 | % (at your option) any later version. 17 | % 18 | % This program is distributed in the hope that it will be useful, 19 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | % GNU General Public License for more details. 22 | % 23 | % You should have received a copy of the GNU General Public License 24 | % along with this program; if not, write to the Free Software 25 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 26 | % 27 | 28 | function [SegyTraceHeader]=GetSegyTraceHeader(segyid,TraceStart,DataFormat,ns,SegyTraceHeader); 29 | 30 | if exist('DataFormat')==0, DataFormat='float32'; end 31 | if exist('TraceStart')==0, TraceStart=ftell(segyid); end 32 | 33 | if exist('SegyTraceHeader') 34 | if isempty('SegyTraceHeader'); 35 | clear SegyTraceHeader; 36 | end 37 | end 38 | 39 | 40 | fseek(segyid,TraceStart,'bof'); 41 | 42 | % GET POSITION FOR EASY LATER LOCALIZATION 43 | SegyTraceHeader.SegyMAT_TraceStart = ftell(segyid); 44 | 45 | chunk = fread(segyid,7,'int32'); 46 | SegyTraceHeader.TraceSequenceLine = chunk(1); % 0 47 | SegyTraceHeader.TraceSequenceFile = chunk(2); % 4 48 | SegyTraceHeader.FieldRecord = chunk(3); % 8 49 | SegyTraceHeader.TraceNumber = chunk(4); % 12 50 | SegyTraceHeader.EnergySourcePoint = chunk(5); % 16 51 | SegyTraceHeader.cdp = chunk(6); % 20 52 | SegyTraceHeader.cdpTrace = chunk(7); % 24 53 | 54 | chunk = fread(segyid,4,'int16'); 55 | SegyTraceHeader.TraceIdenitifactionCode = chunk(1); % 28 56 | SegyTraceHeader.NSummedTraces = chunk(2); % 30 57 | SegyTraceHeader.NStackedTraces = chunk(3); % 32 58 | SegyTraceHeader.DataUse = chunk(4); % 34 59 | 60 | chunk = fread(segyid,8,'int32'); 61 | SegyTraceHeader.offset = chunk(1); %36 62 | SegyTraceHeader.ReceiverGroupElevation = chunk(2); %40 63 | SegyTraceHeader.SourceSurfaceElevation = chunk(3); %44 64 | SegyTraceHeader.SourceDepth = chunk(4); %48 65 | SegyTraceHeader.ReceiverDatumElevation = chunk(5); %52 66 | SegyTraceHeader.SourceDatumElevation = chunk(6); %56 67 | SegyTraceHeader.SourceWaterDepth = chunk(7); %60 68 | SegyTraceHeader.GroupWaterDepth = chunk(8); %64 69 | 70 | 71 | chunk = fread(segyid,2,'int16'); 72 | SegyTraceHeader.ElevationScalar = chunk(1); %68 73 | % Multiply/divide next number for following 4 values 74 | SegyTraceHeader.SourceGroupScalar = chunk(2); %70 75 | 76 | chunk = fread(segyid,4,'int32'); 77 | SegyTraceHeader.SourceX = chunk(1); %72 78 | SegyTraceHeader.SourceY = chunk(2); %76 79 | SegyTraceHeader.GroupX = chunk(3); %80 80 | SegyTraceHeader.GroupY = chunk(4); %84 81 | 82 | chunk = fread(segyid,13,'int16'); 83 | SegyTraceHeader.CoordinateUnits = chunk(1); %88 84 | SegyTraceHeader.WeatheringVelocity = chunk(2); %90 85 | SegyTraceHeader.SubWeatheringVelocity = chunk(3); %92 86 | SegyTraceHeader.SourceUpholeTime = chunk(4); %94 87 | SegyTraceHeader.GroupUpholeTime = chunk(5); %96 88 | SegyTraceHeader.SourceStaticCorrection = chunk(6); %98 89 | SegyTraceHeader.GroupStaticCorrection = chunk(7); %100 90 | SegyTraceHeader.TotalStaticApplied = chunk(8); %102 91 | SegyTraceHeader.LagTimeA = chunk(9); %104 92 | SegyTraceHeader.LagTimeB = chunk(10); %106 93 | SegyTraceHeader.DelayRecordingTime = chunk(11); %108 94 | SegyTraceHeader.MuteTimeStart = chunk(12); %110 95 | SegyTraceHeader.MuteTimeEND = chunk(13); %112 96 | 97 | chunk = fread(segyid,2,'uint16'); 98 | SegyTraceHeader.ns = chunk(1); %114 99 | SegyTraceHeader.dt = chunk(2); %116 100 | 101 | chunk = fread(segyid,31,'int16'); 102 | SegyTraceHeader.GainType = chunk(1); %118 103 | SegyTraceHeader.InstrumentGainConstant = chunk(2); %120 104 | SegyTraceHeader.InstrumentInitialGain = chunk(3); %%122 105 | SegyTraceHeader.Correlated = chunk(4); %124 106 | SegyTraceHeader.SweepFrequenceStart = chunk(5); %126 107 | SegyTraceHeader.SweepFrequenceEnd = chunk(6); %128 108 | SegyTraceHeader.SweepLength = chunk(7); %130 109 | SegyTraceHeader.SweepType = chunk(8); %132 110 | SegyTraceHeader.SweepTraceTaperLengthStart = chunk(9); %134 111 | SegyTraceHeader.SweepTraceTaperLengthEnd = chunk(10); %136 112 | SegyTraceHeader.TaperType = chunk(11); %138 113 | SegyTraceHeader.AliasFilterFrequency = chunk(12); %140 114 | SegyTraceHeader.AliasFilterSlope = chunk(13); %142 115 | SegyTraceHeader.NotchFilterFrequency = chunk(14); %144 116 | SegyTraceHeader.NotchFilterSlope = chunk(15); %146 117 | SegyTraceHeader.LowCutFrequency = chunk(16); %148 118 | SegyTraceHeader.HighCutFrequency = chunk(17); %150 119 | SegyTraceHeader.LowCutSlope = chunk(18); %152 120 | SegyTraceHeader.HighCutSlope = chunk(19); %154 121 | SegyTraceHeader.YearDataRecorded = chunk(20); %156 122 | SegyTraceHeader.DayOfYear = chunk(21); %158 123 | SegyTraceHeader.HourOfDay = chunk(22); %160 124 | SegyTraceHeader.MinuteOfHour = chunk(23); %162 125 | SegyTraceHeader.SecondOfMinute = chunk(24); %164 126 | SegyTraceHeader.TimeBaseCode = chunk(25); %166 127 | 128 | 129 | if SegyTraceHeader.TimeBaseCode==1, SegyTraceHeader.TimeBaseCodeText='Local'; 130 | elseif SegyTraceHeader.TimeBaseCode==2, SegyTraceHeader.TimeBaseCodeText='GMT'; 131 | elseif SegyTraceHeader.TimeBaseCode==3, SegyTraceHeader.TimeBaseCodeText='Other'; 132 | elseif SegyTraceHeader.TimeBaseCode==4, SegyTraceHeader.TimeBaseCodeText='UTC'; 133 | else SegyTraceHeader.TimeBaseCodeText=''; end 134 | 135 | 136 | SegyTraceHeader.TraceWeightningFactor = chunk(26); %168 137 | SegyTraceHeader.GeophoneGroupNumberRoll1 = chunk(27); %170 138 | SegyTraceHeader.GeophoneGroupNumberFirstTraceOrigField = chunk(28); %172 139 | SegyTraceHeader.GeophoneGroupNumberLastTraceOrigField = chunk(29); %174 140 | SegyTraceHeader.GapSize = chunk(30); %176 141 | SegyTraceHeader.OverTravel = chunk(31); %178 142 | 143 | chunk = fread(segyid,5,'int32'); 144 | SegyTraceHeader.cdpX = chunk(1); %180 145 | SegyTraceHeader.cdpY = chunk(2); %184 146 | SegyTraceHeader.Inline3D = chunk(3); %188 147 | SegyTraceHeader.Crossline3D = chunk(4); %192 148 | SegyTraceHeader.ShotPoint = chunk(5); %196 149 | 150 | SegyTraceHeader.ShotPointScalar=fread(segyid,1,'int16'); %200 151 | 152 | SegyTraceHeader.TraceValueMeasurementUnit=fread(segyid,1,'int16'); %202 153 | if SegyTraceHeader.TraceValueMeasurementUnit==-1, SegyTraceHeader.TraceValueMeasurementUnitText='Other'; 154 | elseif SegyTraceHeader.TraceValueMeasurementUnit==0, SegyTraceHeader.TraceValueMeasurementUnitText='Unknown'; 155 | elseif SegyTraceHeader.TraceValueMeasurementUnit==1, SegyTraceHeader.TraceValueMeasurementUnitText='Pascal (Pa)'; 156 | elseif SegyTraceHeader.TraceValueMeasurementUnit==2, SegyTraceHeader.TraceValueMeasurementUnitText='Volts (v)'; 157 | elseif SegyTraceHeader.TraceValueMeasurementUnit==3, SegyTraceHeader.TraceValueMeasurementUnitText='Millivolts (v)'; 158 | elseif SegyTraceHeader.TraceValueMeasurementUnit==4, SegyTraceHeader.TraceValueMeasurementUnitText='Amperes (A)'; 159 | elseif SegyTraceHeader.TraceValueMeasurementUnit==5, SegyTraceHeader.TraceValueMeasurementUnitText='Meters (m)'; 160 | elseif SegyTraceHeader.TraceValueMeasurementUnit==6, SegyTraceHeader.TraceValueMeasurementUnitText='Meters Per Second (m/s)'; 161 | elseif SegyTraceHeader.TraceValueMeasurementUnit==7, SegyTraceHeader.TraceValueMeasurementUnitText='Meters Per Second squared (m/&s2)Other'; 162 | elseif SegyTraceHeader.TraceValueMeasurementUnit==8, SegyTraceHeader.TraceValueMeasurementUnitText='Newton (N)'; 163 | elseif SegyTraceHeader.TraceValueMeasurementUnit==8, SegyTraceHeader.TraceValueMeasurementUnitText='Watt (W)'; 164 | else SegyTraceHeader.TraceValueMeasurementUnitText='Undefined'; end 165 | 166 | SegyTraceHeader.TransductionConstantMantissa=fread(segyid,1,'int32'); %204 167 | 168 | 169 | chunk = fread(segyid,5,'int16'); 170 | SegyTraceHeader.TransductionConstantPower = chunk(1);%208 171 | SegyTraceHeader.TransductionUnit = chunk(2); %210 172 | SegyTraceHeader.TraceIdentifier = chunk(3); %212 173 | SegyTraceHeader.ScalarTraceHeader = chunk(4); %214 174 | SegyTraceHeader.SourceType = chunk(5); %216 175 | 176 | 177 | SegyTraceHeader.SourceEnergyDirectionMantissa=fread(segyid,1,'int32'); %218 178 | SegyTraceHeader.SourceEnergyDirectionExponent=fread(segyid,1,'int16'); %222 179 | SegyTraceHeader.SourceMeasurementMantissa=fread(segyid,1,'int32'); %224 180 | 181 | chunk = fread(segyid,2,'int16'); 182 | SegyTraceHeader.SourceMeasurementExponent = chunk(1); %228 183 | SegyTraceHeader.SourceMeasurementUnit = chunk(2); %230 184 | 185 | chunk = fread(segyid,2,'int32'); 186 | SegyTraceHeader.UnassignedInt1 = chunk(1); %232 187 | SegyTraceHeader.UnassignedInt2 = chunk(2); %236 188 | 189 | 190 | if exist('ns')==0, 191 | ns=SegyTraceHeader.ns; 192 | end 193 | 194 | 195 | % GO TO POSITION OF DATA 196 | fseek(segyid,TraceStart+240,'bof'); 197 | SegyTraceHeader.SegyMAT_TraceDataStart = ftell(segyid); 198 | 199 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/GetSegyTraceHeaderInfo.m: -------------------------------------------------------------------------------- 1 | % GetSegyTraceHeaderInfo : Returns a array of a SEGY Y TraceHeader value 2 | % 3 | % Call : 4 | % [value]=GetSegyHeaderInfo(SegyTraceHeaders,header) 5 | % 6 | % header is a header value like 'cdp','dt','TraceNumber' 7 | % 8 | 9 | % 10 | % (C) 2001-2004, Thomas Mejer Hansen, tmh@gfy.ku.dk/thomas@cultpenguin.com 11 | % 12 | % 13 | % 14 | % This program is free software; you can redistribute it and/or modify 15 | % it under the terms of the GNU General Public License as published by 16 | % the Free Software Foundation; either version 2 of the License, or 17 | % (at your option) any later version. 18 | % 19 | % This program is distributed in the hope that it will be useful, 20 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | % GNU General Public License for more details. 23 | % 24 | % You should have received a copy of the GNU General Public License 25 | % along with this program; if not, write to the Free Software 26 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 27 | % 28 | function [value]=GetSegyTraceHeaderInfo(SegyTraceHeaders,header) 29 | 30 | try 31 | value=[SegyTraceHeaders.(header)]; 32 | catch 33 | SegymatVerbose(['Could not get ',header,' header information from supplied SegyTraceHeaders']); 34 | end 35 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/InitSegyTraceHeader.m: -------------------------------------------------------------------------------- 1 | % InitSegyTraceHeaders : returns an empty SegyTraceHeader structure 2 | % 3 | % EX: 4 | % SegyTraceHeader=InitSegyTraceHeader(ns,dt); 5 | % 6 | 7 | % 8 | % (C) 2001-2004, Thomas Mejer Hansen, tmh@gfy.ku.dk/thomas@cultpenguin.com 9 | % 10 | % This program is free software; you can redistribute it and/or modify 11 | % it under the terms of the GNU General Public License as published by 12 | % the Free Software Foundation; either version 2 of the License, or 13 | % (at your option) any later version. 14 | % 15 | % This program is distributed in the hope that it will be useful, 16 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | % GNU General Public License for more details. 19 | % 20 | % You should have received a copy of the GNU General Public License 21 | % along with this program; if not, write to the Free Software 22 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 | % 24 | function SegyTraceHeader=InitSegyTraceHeader(ns,dt); 25 | 26 | SegyTraceHeader=[]; 27 | 28 | if exist('ns')==0, 29 | SegymatVerbose([mfilename,' : ns not set !! returning'],0) 30 | return 31 | end 32 | 33 | if exist('dt')==0, 34 | dt=4000; 35 | SegymatVerbose([mfilename,' : dt not set. using dt=',num2str(dt)],0) 36 | end 37 | 38 | NA=0; 39 | da=clock; 40 | DayOfYear=datenum(0,da(2),da(3)); 41 | 42 | 43 | SegyTraceHeader.TraceSequenceLine=NA; 44 | SegyTraceHeader.TraceSequenceFile=NA; 45 | SegyTraceHeader.FieldRecord=NA; 46 | SegyTraceHeader.TraceNumber=NA;; 47 | SegyTraceHeader.EnergySourcePoint=NA; 48 | SegyTraceHeader.cdp=NA; 49 | SegyTraceHeader.cdpTrace=NA; 50 | SegyTraceHeader.TraceIdenitifactionCode=NA; 51 | SegyTraceHeader.NSummedTraces=NA; 52 | SegyTraceHeader.NStackedTraces=NA; 53 | SegyTraceHeader.DataUse=NA; 54 | SegyTraceHeader.offset=NA; 55 | SegyTraceHeader.ReceiverGroupElevation=NA; 56 | SegyTraceHeader.SourceSurfaceElevation=NA; 57 | SegyTraceHeader.SourceDepth=NA; 58 | SegyTraceHeader.ReceiverDatumElevation=NA; 59 | SegyTraceHeader.SourceDatumElevation=NA; 60 | SegyTraceHeader.SourceWaterDepth=NA; 61 | SegyTraceHeader.GroupWaterDepth=NA; 62 | SegyTraceHeader.ElevationScalar=NA; 63 | SegyTraceHeader.SourceGroupScalar=NA; 64 | SegyTraceHeader.SourceX=NA; 65 | SegyTraceHeader.SourceY=NA; 66 | SegyTraceHeader.GroupX=NA; 67 | SegyTraceHeader.GroupY=NA; 68 | SegyTraceHeader.CoordinateUnits=NA; 69 | SegyTraceHeader.WeatheringVelocity=NA; 70 | SegyTraceHeader.SubWeatheringVelocity=NA; 71 | SegyTraceHeader.SourceUpholeTime=NA; 72 | SegyTraceHeader.GroupUpholeTime=NA; 73 | SegyTraceHeader.SourceStaticCorrection=NA; 74 | SegyTraceHeader.GroupStaticCorrection=NA; 75 | SegyTraceHeader.TotalStaticApplied=NA; 76 | SegyTraceHeader.LagTimeA=NA; 77 | SegyTraceHeader.LagTimeB=NA; 78 | SegyTraceHeader.DelayRecordingTime=NA; 79 | SegyTraceHeader.MuteTimeStart=NA; 80 | SegyTraceHeader.MuteTimeEND=NA; 81 | SegyTraceHeader.ns=ns; 82 | SegyTraceHeader.dt=dt; 83 | SegyTraceHeader.GainType=NA; 84 | SegyTraceHeader.InstrumentGainConstant=NA; 85 | SegyTraceHeader.InstrumentInitialGain=NA; 86 | SegyTraceHeader.Correlated=NA; 87 | SegyTraceHeader.SweepFrequenceStart=NA; 88 | SegyTraceHeader.SweepFrequenceEnd=NA; 89 | SegyTraceHeader.SweepLength=NA; 90 | SegyTraceHeader.SweepType=NA; 91 | SegyTraceHeader.SweepTraceTaperLengthStart=NA; 92 | SegyTraceHeader.SweepTraceTaperLengthEnd=NA; 93 | SegyTraceHeader.TaperType=NA; 94 | SegyTraceHeader.AliasFilterFrequency=NA; 95 | SegyTraceHeader.AliasFilterSlope=NA; 96 | SegyTraceHeader.NotchFilterFrequency=NA; 97 | SegyTraceHeader.NotchFilterSlope=NA; 98 | SegyTraceHeader.LowCutFrequency=NA; 99 | SegyTraceHeader.HighCutFrequency=NA; 100 | SegyTraceHeader.LowCutSlope=NA; 101 | SegyTraceHeader.HighCutSlope=NA; 102 | 103 | SegyTraceHeader.YearDataRecorded=da(1); 104 | SegyTraceHeader.DayOfYear=DayOfYear; 105 | SegyTraceHeader.HourOfDay=da(4); 106 | SegyTraceHeader.MinuteOfHour=da(5); 107 | SegyTraceHeader.SecondOfMinute=round(da(6)); 108 | SegyTraceHeader.TimeBaseCode=NA; 109 | SegyTraceHeader.TraceWeightningFactor=NA; 110 | SegyTraceHeader.GeophoneGroupNumberRoll1=NA; 111 | SegyTraceHeader.GeophoneGroupNumberFirstTraceOrigField=NA; 112 | SegyTraceHeader.GeophoneGroupNumberLastTraceOrigField=NA; 113 | SegyTraceHeader.GapSize=NA; 114 | SegyTraceHeader.OverTravel=NA; 115 | SegyTraceHeader.cdpX=NA; 116 | SegyTraceHeader.cdpY=NA; 117 | SegyTraceHeader.Inline3D=NA; 118 | SegyTraceHeader.Crossline3D=NA; 119 | SegyTraceHeader.ShotPoint=NA; 120 | SegyTraceHeader.ShotPointScalar=NA; 121 | SegyTraceHeader.TraceValueMeasurementUnit=NA; 122 | SegyTraceHeader.TransductionConstantMantissa=NA; 123 | SegyTraceHeader.TransductionConstantPower=NA; 124 | SegyTraceHeader.TransductionUnit=NA; 125 | SegyTraceHeader.TraceIdentifier=NA; 126 | SegyTraceHeader.ScalarTraceHeader=NA; 127 | 128 | 129 | SegyTraceHeader.SourceType=NA; 130 | SegyTraceHeader.SourceEnergyDirectionMantissa=NA; 131 | SegyTraceHeader.SourceEnergyDirectionExponent=NA; 132 | SegyTraceHeader.SourceMeasurementMantissa=NA; 133 | SegyTraceHeader.SourceMeasurementExponent=NA; 134 | SegyTraceHeader.SourceMeasurementUnit=NA; 135 | 136 | SegyTraceHeader.UnassignedInt1=NA; 137 | SegyTraceHeader.UnassignedInt2=NA; 138 | 139 | 140 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/MakeXmlRef.m: -------------------------------------------------------------------------------- 1 | f{1}=dir('*.m') 2 | f{2}=dir('visim/*.m') 3 | 4 | fid=fopen('segymat-functions.xml','w'); 5 | 6 | fprintf(fid,'%s\n','reference','M-file Reference'); 7 | for ff=1:length(f) 8 | 9 | for i=1:length(f{ff}) 10 | [p,name,ext]=fileparts(f{ff}(i).name); 11 | disp(name) 12 | h=help(name); 13 | 14 | fprintf(fid,'%s\n',['_',name],name); 15 | fprintf(fid,'\n',h); 16 | fprintf(fid,'\n\n'); 17 | 18 | end 19 | 20 | end 21 | fprintf(fid,''); 22 | 23 | fclose(fid); 24 | 25 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/MergeSegy.m: -------------------------------------------------------------------------------- 1 | % MergeSegy : Merge multiple SEGY files 2 | % 3 | % Example : 4 | % MergeSegy('*.sgy','merge.sgy') 5 | % 6 | % f{1}='file1.sgy'; 7 | % f{2}='file2.sgy'; 8 | % f{3}='file3.sgy'; 9 | % MergeSegy(f,'merge.sgy') 10 | % 11 | % 12 | % Note: All imput segy files must have the same constant trace length 13 | % The SEGY header of the merged SEGY file will be the SEGY header 14 | % form the first input SEGY file. 15 | % 16 | % 17 | 18 | function [file_out,D,STH,SegyHeader]=MergeSegy(files,file_out) 19 | 20 | if nargin<2 21 | file_out='segymerge.sgy'; 22 | end 23 | 24 | if isstr(files) 25 | file_names=dir(files); 26 | end 27 | 28 | if iscell(files); 29 | for i=1:length(files); 30 | file_names(i).name=files{i}; 31 | end 32 | end 33 | 34 | for i=1:length(file_names); 35 | [Data,SegyTraceHeaders,SegyHeader]=ReadSegy(file_names(i).name); 36 | 37 | if i==1; 38 | ss=size(Data); 39 | else 40 | %check size 41 | if (length(find(ss==size(Data)))~=2) 42 | SegymatVerbose(sprintf('%s : Data sizes differs',mfilename),-1); 43 | end 44 | end 45 | 46 | if i==1; 47 | D=Data; 48 | STH=SegyTraceHeaders; 49 | else 50 | n_sth=length(STH); 51 | for j=1:length(SegyTraceHeaders) 52 | STH(j+n_sth)=SegyTraceHeaders(j); 53 | STH(j+n_sth).TraceNumber=j; 54 | end 55 | D=[D Data]; 56 | end 57 | 58 | end 59 | 60 | WriteSegyStructure(file_out,SegyHeader,STH,D); 61 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/PutSegyTrace.m: -------------------------------------------------------------------------------- 1 | % PutSegyTrace(segyid,tracedata,SegyTraceHeader,TraceStart); 2 | % 3 | % Write a SegyTrace to a filehandle 'segyid' 4 | % 5 | % (C) 2001-2004, Thomas Mejer Hansen, tmh@gfy.ku.dk/thomas@cultpenguin.com 6 | % 7 | 8 | % 9 | % This program is free software; you can redistribute it and/or modify 10 | % it under the terms of the GNU General Public License as published by 11 | % the Free Software Foundation; either version 2 of the License, or 12 | % (at your option) any later version. 13 | % 14 | % This program is distributed in the hope that it will be useful, 15 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | % GNU General Public License for more details. 18 | % 19 | % You should have received a copy of the GNU General Public License 20 | % along with this program; if not, write to the Free Software 21 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | % 23 | function PutSegyTrace(segyid,tracedata,SegyTraceHeader,SegyHeader); 24 | 25 | % *** DUE TO A BUG IN MATLAB 6.5 : Technical Solution Number: 31977 26 | 27 | % Enable next line if error messages show that not all 28 | % trace header values have been set. 29 | % Enabling this check will considerably slow down writing 30 | % with factor of about 6! 31 | % SegyTraceHeader=CheckSegyTraceHeader(SegyTraceHeader); 32 | 33 | 34 | 35 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 36 | %% WRITE SegyTraceHeader 37 | 38 | if ~exist('TraceStart')==1, TraceStart=ftell(segyid);end 39 | 40 | fseek(segyid,0,'bof');fseek(segyid,TraceStart,'bof'); % *** 41 | fwrite(segyid,ones(1,60),'int32'); 42 | fseek(segyid,0,'bof');fseek(segyid,TraceStart,'bof'); % *** 43 | 44 | WRITETRACEHEADER=1; 45 | if WRITETRACEHEADER==1, 46 | fseek(segyid,0,'bof'); 47 | fseek(segyid,TraceStart,'bof'); 48 | fwrite(segyid,SegyTraceHeader.TraceSequenceLine,'int32'); % 0 49 | fwrite(segyid,SegyTraceHeader.TraceSequenceFile,'int32'); % 4 50 | fwrite(segyid,SegyTraceHeader.FieldRecord,'int32'); % 8 51 | fwrite(segyid,SegyTraceHeader.TraceNumber,'int32'); % 12 52 | fwrite(segyid,SegyTraceHeader.EnergySourcePoint,'int32'); % 16 53 | fwrite(segyid,SegyTraceHeader.cdp,'int32'); % 20 54 | fwrite(segyid,SegyTraceHeader.cdpTrace,'int32'); % 24 55 | fwrite(segyid,SegyTraceHeader.TraceIdenitifactionCode,'int16'); % 28 56 | fwrite(segyid,SegyTraceHeader.NSummedTraces,'int16'); % 30 57 | fwrite(segyid,SegyTraceHeader.NStackedTraces,'int16'); % 32 58 | fwrite(segyid,SegyTraceHeader.DataUse,'int16'); % 34 59 | fwrite(segyid,SegyTraceHeader.offset,'int32'); %36 60 | fwrite(segyid,SegyTraceHeader.ReceiverGroupElevation,'int32'); %40 61 | fwrite(segyid,SegyTraceHeader.SourceSurfaceElevation,'int32'); %44 62 | fwrite(segyid,SegyTraceHeader.SourceDepth,'int32'); %48 63 | fwrite(segyid,SegyTraceHeader.ReceiverDatumElevation,'int32'); %52 64 | fwrite(segyid,SegyTraceHeader.SourceDatumElevation,'int32'); %56 65 | fwrite(segyid,SegyTraceHeader.SourceWaterDepth,'int32'); %60 66 | fwrite(segyid,SegyTraceHeader.GroupWaterDepth,'int32'); %64 67 | fwrite(segyid,SegyTraceHeader.ElevationScalar,'int16'); %68 68 | % Multiply/divide next number for following 4 values 69 | fwrite(segyid,SegyTraceHeader.SourceGroupScalar,'int16'); %70 70 | fwrite(segyid,SegyTraceHeader.SourceX,'int32'); %72 71 | fwrite(segyid,SegyTraceHeader.SourceY,'int32'); %76 72 | fwrite(segyid,SegyTraceHeader.GroupX,'int32'); %80 73 | fwrite(segyid,SegyTraceHeader.GroupY,'int32'); %84 74 | fwrite(segyid,SegyTraceHeader.CoordinateUnits,'int16'); %88 75 | fwrite(segyid,SegyTraceHeader.WeatheringVelocity,'int16'); %90 76 | fwrite(segyid,SegyTraceHeader.SubWeatheringVelocity,'int16'); %92 77 | fwrite(segyid,SegyTraceHeader.SourceUpholeTime,'int16'); %94 78 | fwrite(segyid,SegyTraceHeader.GroupUpholeTime,'int16'); %96 79 | fwrite(segyid,SegyTraceHeader.SourceStaticCorrection,'int16'); %98 80 | fwrite(segyid,SegyTraceHeader.GroupStaticCorrection,'int16'); %100 81 | fwrite(segyid,SegyTraceHeader.TotalStaticApplied,'int16'); %102 82 | fwrite(segyid,SegyTraceHeader.LagTimeA,'int16'); %104 83 | fwrite(segyid,SegyTraceHeader.LagTimeB,'int16'); %106 84 | fwrite(segyid,SegyTraceHeader.DelayRecordingTime,'int16'); %108 85 | fwrite(segyid,SegyTraceHeader.MuteTimeStart,'int16'); %110 86 | fwrite(segyid,SegyTraceHeader.MuteTimeEND,'int16'); %112 87 | fwrite(segyid,SegyTraceHeader.ns,'uint16'); %114 88 | fwrite(segyid,SegyTraceHeader.dt,'uint16'); %116 89 | fwrite(segyid,SegyTraceHeader.GainType,'int16'); %118 90 | fwrite(segyid,SegyTraceHeader.InstrumentGainConstant,'int16'); %120 91 | fwrite(segyid,SegyTraceHeader.InstrumentInitialGain,'int16'); %%122 92 | fwrite(segyid,SegyTraceHeader.Correlated,'int16'); %124 93 | fwrite(segyid,SegyTraceHeader.SweepFrequenceStart,'int16'); %126 94 | fwrite(segyid,SegyTraceHeader.SweepFrequenceEnd,'int16'); %128 95 | fwrite(segyid,SegyTraceHeader.SweepLength,'int16'); %130 96 | fwrite(segyid,SegyTraceHeader.SweepType,'int16'); %132 97 | fwrite(segyid,SegyTraceHeader.SweepTraceTaperLengthStart,'int16'); %134 98 | fwrite(segyid,SegyTraceHeader.SweepTraceTaperLengthEnd,'int16'); %136 99 | fwrite(segyid,SegyTraceHeader.TaperType,'int16'); %138 100 | fwrite(segyid,SegyTraceHeader.AliasFilterFrequency,'int16'); %140 101 | fwrite(segyid,SegyTraceHeader.AliasFilterSlope,'int16'); %142 102 | fwrite(segyid,SegyTraceHeader.NotchFilterFrequency,'int16'); %144 103 | fwrite(segyid,SegyTraceHeader.NotchFilterSlope,'int16'); %146 104 | fwrite(segyid,SegyTraceHeader.LowCutFrequency,'int16'); %148 105 | fwrite(segyid,SegyTraceHeader.HighCutFrequency,'int16'); %150 106 | fwrite(segyid,SegyTraceHeader.LowCutSlope,'int16'); %152 107 | fwrite(segyid,SegyTraceHeader.HighCutSlope,'int16'); %154 108 | fwrite(segyid,SegyTraceHeader.YearDataRecorded,'int16'); %156 109 | fwrite(segyid,SegyTraceHeader.DayOfYear,'int16'); %158 110 | fwrite(segyid,SegyTraceHeader.HourOfDay,'int16'); %160 111 | fwrite(segyid,SegyTraceHeader.MinuteOfHour,'int16'); %162 112 | fwrite(segyid,SegyTraceHeader.SecondOfMinute,'int16'); %164 113 | fwrite(segyid,SegyTraceHeader.TimeBaseCode,'int16'); %166 114 | fwrite(segyid,SegyTraceHeader.TraceWeightningFactor,'int16'); %170 115 | fwrite(segyid,SegyTraceHeader.GeophoneGroupNumberRoll1,'int16'); %172 116 | fwrite(segyid,SegyTraceHeader.GeophoneGroupNumberFirstTraceOrigField,'int16'); %174 117 | fwrite(segyid,SegyTraceHeader.GeophoneGroupNumberLastTraceOrigField,'int16'); %176 118 | fwrite(segyid,SegyTraceHeader.GapSize,'int16'); %178 119 | fwrite(segyid,SegyTraceHeader.OverTravel,'int16'); %178 120 | fwrite(segyid,SegyTraceHeader.cdpX,'int32'); %180 121 | fwrite(segyid,SegyTraceHeader.cdpY,'int32'); %184 122 | fwrite(segyid,SegyTraceHeader.Inline3D,'int32'); %188 123 | fwrite(segyid,SegyTraceHeader.Crossline3D,'int32'); %192 124 | fwrite(segyid,SegyTraceHeader.ShotPoint,'int32'); %196 125 | fwrite(segyid,SegyTraceHeader.ShotPointScalar,'int16'); %200 126 | fwrite(segyid,SegyTraceHeader.TraceValueMeasurementUnit,'int16'); %202 127 | fwrite(segyid,SegyTraceHeader.TransductionConstantMantissa,'int32'); %204 128 | fwrite(segyid,SegyTraceHeader.TransductionConstantPower,'int16'); %208 129 | fwrite(segyid,SegyTraceHeader.TransductionUnit,'int16'); %210 130 | fwrite(segyid,SegyTraceHeader.TraceIdentifier,'int16'); %212 131 | fwrite(segyid,SegyTraceHeader.ScalarTraceHeader,'int16'); %214 132 | fwrite(segyid,SegyTraceHeader.SourceType,'int16'); %216 133 | fwrite(segyid,SegyTraceHeader.SourceEnergyDirectionMantissa,'int32'); %218 134 | fwrite(segyid,SegyTraceHeader.SourceEnergyDirectionExponent,'int16'); %222 135 | fwrite(segyid,SegyTraceHeader.SourceMeasurementMantissa,'int32'); %224 136 | fwrite(segyid,SegyTraceHeader.SourceMeasurementExponent,'int16'); %228 137 | fwrite(segyid,SegyTraceHeader.SourceMeasurementUnit,'int16'); %230 138 | % WRITE UNASSIGNED CHARACTERS FOR THE REST 139 | fwrite(segyid,SegyTraceHeader.UnassignedInt1,'int32'); %232 140 | fwrite(segyid,SegyTraceHeader.UnassignedInt2,'int32'); %236 141 | %fwrite(segyid,zeros(1,4),'int16'); %230 142 | end 143 | % 217-240 Unassigned 144 | 145 | % go to end of header 146 | % Any of the nex to lines should work, with the first line being the fastest 147 | fseek(segyid,0,'cof'); fseek(segyid,240-216,'cof'); 148 | % fseek(segyid,0,'bof'); fseek(segyid,TraceStart+240,'bof'); 149 | 150 | 151 | Revision=SegyHeader.SegyFormatRevisionNumber; 152 | if Revision>0, Revision=1; end 153 | Format=SegyHeader.Rev(Revision+1).DataSampleFormat(SegyHeader.DataSampleFormat).format; 154 | BPS=SegyHeader.Rev(Revision+1).DataSampleFormat(SegyHeader.DataSampleFormat).bps; 155 | 156 | SegymatVerbose([mfilename,' SegyRevision ',sprintf('%0.4g',Revision),', ',Format],3); 157 | 158 | %% WRITE TRACE DATA; 159 | if (strcmp(Format,'uint32')==1)|(strcmp(Format,'uint16')==1), % IBM FLOATING POINT 160 | % CONVERT FROM FLOATING POINT 161 | SegymatVerbose([mfilename,'Converting from IBM, DataFormat :',SegyHeader.DataSampleFormat],2); 162 | tracedata=double(num2ibm(tracedata)); 163 | end; 164 | if SegyHeader.FixedLengthTraceFlag 165 | fwrite(segyid,tracedata,Format); 166 | else 167 | fwrite(segyid,tracedata(1:SegyTraceHeader.ns),Format); 168 | end 169 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/README_OCTAVE: -------------------------------------------------------------------------------- 1 | As of version 1.02 SegyMAT is intended to work with Octave version >2.1.64 2 | 3 | If you have an older octave version installed you may need to : 4 | 5 | 1) change line (app 399) in ReadSegy 6 | from : if (outtrace==1), 7 | to : if (outtrace==-1), 8 | 9 | 2) comment line (app 214) in ReadSegyFast : 10 | from : Data=ibm2num(uint32(Data)); 11 | to : % Data=ibm2num(uint32(Data)); 12 | 13 | These two changes have been successfully applied to octave version 2.1.57. 14 | 15 | _____________________________________ 16 | 17 | * A note on speed 18 | SegyMAT in Octave runs MUCH slower (about a factor 5) than in Matlab when reading in SEG-Y header values. If you just need to read the trace data try using : 19 | data=ReadSegy(filename), which makes use of ReadSegyFast. 20 | In any case (Matlab or octave) this is much faster, and specifically, Matlab and Octave performs equally well. -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/README_STANDALONE_WIN32.txt: -------------------------------------------------------------------------------- 1 | 1. Install the Matlab Component Libraray bu launching MCRInstaller.exe 2 | 2. Run matlab_1.03.exe 3 | 4 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/REVISION: -------------------------------------------------------------------------------- 1 | 1.5.1 : October 28, 2011 2 | Fixed 'too large preallocating' in ReadSegy casing a delay 3 | reading large files using the 'traces' option. 4 | 5 | 1.5 : October 27, 2011 6 | ReadSegy.m : Added option 'traces' that allow fast reading of specific 7 | traces. 8 | When the 'minmax' option is used, the corresponding traces 9 | are first located thorugh header files, and then data 10 | are read using the 'traces' options. 11 | For larger files this casues the readomh tme to decrease 12 | significantly when using the 'minmax' option. 13 | 14 | 1.4 : April 05, 2011 15 | ReadSegy.m : Corrected SH.time to reflect proper traveltime 16 | Disabled Waitbar 17 | ReadSegyHeader.m : Fixed 'SkipData' conflict with Robust Control Toolbox 18 | wiggle.m : Allowed specification of line color, 19 | allow overlaying wiggle plots 20 | allow NaN value in 'VA' style plotting 21 | ReadSu : Fixed typo in line 221 22 | MergeSegy.m : Added mfile to merge Segy Files 23 | 24 | 1.3 : January 20, 2010 25 | Added 'ReadSegyTraceHeaderValue' and 'WriteSegyTraceHeaderValue' 26 | that can be used to read and write the TraceHeaderValues one by 27 | one. Much faster that reading the whole dataset. 28 | 29 | 1.2 : January 07, 2009 30 | Updated GUI to work for Matlab R2008a 31 | enabled loading of partial segyfile (using time and header ranges) 32 | from GUI (ctrl X) 33 | enabled editing of the textual file header (both ASCII and EBCDIC) 34 | 35 | 1.11 : August 2008 36 | Kristian Stormark () contributed a change 37 | to GetSegyTraceHeader that reduce the number of discoperations 38 | causing a significant speed up 39 | 40 | 1.08 : March 2007 41 | Urs Boeniger contributed a patch that allows arbitrary 42 | SegyTraceHeaders to be specified for WriteSegy.m 43 | 44 | 1.06 : FIxed a bug taht casue a fixed length of 5011 samples in ReadSu 45 | 46 | 1.02 : Cleaning up code to work with Octave 2.1.57 47 | 48 | 1.01 : 'jump' related fixes 49 | 50 | 1.00 : Cleaning up some Matlab 7.0 specific bugs. 51 | 52 | 0.99 : Just cleaning up to prepare for a release 1.0 53 | 54 | 0.93 55 | ReadSegy : RAM is preallocated, causing a significant speed up 56 | when reading large files (>30%) 57 | 58 | 0.92 April 13, 2004 59 | DUE TO A BUG IN MATLAB 6.5 : Technical Solution Number: 31977, 60 | writing of segy files did not work in some windows version of 61 | matlab 6.5. A workaround have been implemeneted. 62 | fseek(segyid,'bof',0) did not always work ? 63 | 64 | disp statements have been replaced with SegymatVerbose, making 65 | it easier to control verbose output to the screen. The verbose level 66 | can be set in SegymatVerbose.m 67 | 68 | CheckSegyTraceHeader has been implemeneted as an m-file of its own. 69 | It was a part of PutSegyTrace but slowed down writing of segy files 70 | considerably. Now it is only run if you edit the m-files that write 71 | data to disc. This change gives great speed improvement. 72 | 73 | 74 | 0.91 Nov 21, 2003: 75 | Strange bug when using ReadSegy on one platform : 76 | "At compilation SkipData was an undefined variable or function.>> >> >> >> >> Function SkipData is now in context. To use a function that is>> >> >> >> >> not in context at compilation use FEVAL or EVAL. 77 | " 78 | Could not reprodice the error using the same SGY file on either Linux or Windows. 79 | 80 | 0.90 : 81 | GUI is reimplemented. 82 | Coded is prepared to be compiled. 83 | 84 | Support For Extended Textual File Headers. 85 | 86 | 87 | 0.45 : 88 | WriteSegy : 'dt' was always reported as not set, even if it were. 89 | It did not affect the written SEGY file though. 90 | 91 | 0.44 : 92 | ibm2num : simpler error message when transformation fails. 93 | 94 | 0.43 : June 19, 2003 95 | ReadSegy : Crashed when SegyHeader sais Rev0 and DFS=5, since 96 | DFS=5 is not defined for Rev0. Now, if DFS=5 is chosen Revision 97 | is automatically set to 1. 98 | 99 | 0.42 : 100 | GUIEditSegyHeader : Updated to handle the complete SegyHeader (30/03/2003) 101 | GUIEditTextualFileHeader : Updated to give warning when wrong format is chosen. 102 | ReadSegy : Rev0, data sample format 2 and 3 are now set to 2 and 4 byte signed integers. 103 | 104 | 0.41 : 105 | ReadSegy : Fixed bug that caused ReadSegy to crash when no data was returned. 106 | 107 | 0.40 : Jan-22-2003 108 | ReadSegy : -fixed 'endian' big introduced in version 0.39 109 | -Implemented more robust reading of traces with varying trace lengths 110 | Now the code will not stop running, simply return an error message. 111 | - re-implemented the 'SkipData' option that somehow had been removed from the code 112 | 113 | ReadSegyHeader : fixed 'endian' big introduced in version 0.39 114 | 115 | 0.39 : Jan-20-2003 116 | 117 | ReadSegy : option to read little endian formatted data 118 | 119 | ReadSegyHeader : Reads only the Segy Binary Header 120 | 121 | ReadSuFast/ReadSegyFast 122 | If headers are not required, fast version of the reading algorithms 123 | is now available. These are up to 20 times faster. 124 | 125 | EBCDIC support 126 | 127 | GUIEditTextualFileHeader 128 | GUI to display/edit the Textual Segy Header in EBCDIC/ASCII format. 129 | 130 | 131 | 132 | 133 | 0.38 : September 6-2002 134 | WriteSegy : takes options 'revision' and 'dsf' 135 | to set SEG-Y revision number and 136 | Data Sample Format 137 | WriteSegyStructure : 138 | takes options 'revision' and 'dsf' 139 | to set SEG-Y revision number and 140 | Data Sample Format 141 | ReadSegy : Takes option 'dsf' to force DataSamplingFormat 142 | SegyHeader.FixedLengthTraceFlag is no longer forced to be 1 ! 143 | 144 | Thus now all Read and Write routines takes the options 145 | 'revsision' and 'dsf' 146 | 147 | SegyHeader: Two fields were added that contains unassigned header values 148 | SegyHeader.Unassigned1 : byte 3261-3500 149 | SegyHeader.Unassigned2 : byte 3507-3600 150 | 151 | SegyTraceheaders : Added two fields for unassigned values : 152 | SegyTraceHeader.UnassignedInt1 : int32, Byte 232+4 153 | SegyTraceHeader.UnassignedInt1 : Int32, Byte 236+4 154 | 155 | 0.37 : August 23-2002 156 | Format of dt and ns changed to unsigned integers. 157 | 158 | 0.36 : August 15-2002 159 | ReadSegy was corrupted in 0.35. Bug Fix release. 160 | 161 | 162 | 0.35 : June 16-2002 163 | Correct DayOfYear in PutSegyTrace.m, 164 | - thanks to Michael Toews (mwtoews@ucalgary.ca) 165 | Minor bugfixes. Released as a release on Sourceforge. 166 | 167 | 0.33 : June 03-2002 168 | Added Rading and writing SU and SEGY to GUI. 169 | 170 | 0.32 : May 15-2002 171 | Colormaps and gain control is added. 172 | 173 | 0.31 : May 04-2002 174 | GUI Segy Reader useable. 175 | 176 | 0.3 : May 01-2002 177 | Added fascility to read in parts of a SEG-Y file 178 | 179 | 0.2 : Added 'SkipData', so that only header values are read 180 | 181 | 0.1 : Initial release 182 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/ReadSegyFast.m: -------------------------------------------------------------------------------- 1 | % ReadSegyFast : Reads a SEG Y rev 1 formatted file, without header values (faster than ReadSegy) 2 | % 3 | % Call : 4 | % [Data]=ReadSegyFast(filename); 5 | % and equivalent to : 6 | % [Data]=ReadSegy(filename); 7 | % 8 | % 9 | % Read only the data of a SegFile - NOT Their headers. 10 | % Much faster than ReadSegy 11 | % 12 | % 'minmax', 'skip' 13 | % 14 | 15 | 16 | % Implemented using the syntax of the SEG-Y revised format : 17 | % SEGY-Y rev 0, SEG-Y rev 1 as described in 18 | % http://seg.org/publications/tech-stand/ 19 | % 20 | % Extended Textual Header is not yet tested 21 | % If you would like it implemented, please send me an SEGY file with 22 | % that sort of information, as well as a description of the segy file 23 | % 24 | % 25 | % (C) 2001, Thomas Mejer Hansen, thomas@cultpenguin.com 26 | % 27 | % This program is free software; you can redistribute it and/or modify 28 | % it under the terms of the GNU General Public License as published by 29 | % the Free Software Foundation; either version 2 of the License, or 30 | % (at your option) any later version. 31 | % 32 | % This program is distributed in the hope that it will be useful, 33 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 34 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 35 | % GNU General Public License for more details. 36 | % 37 | % You should have received a copy of the GNU General Public License 38 | % along with this program; if not, write to the Free Software 39 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 40 | % 41 | % 42 | % 43 | % 44 | function [Data]=ReadSegyFast(filename,varargin); 45 | 46 | mfilename='ReadSegyFast'; 47 | 48 | if nargin==0, 49 | SegymatVerbose([mfilename,' : ', filename,' does not exist !']) 50 | Data=[];SegyTraceHeaders=[];SegyHeader=[];HeaderInfo=[]; 51 | return 52 | end 53 | 54 | % Initialize varargin values 55 | dsf=[]; 56 | revision=[]; 57 | endian_tight=[]; 58 | tmin=[];tmax=[]; 59 | headermin=[];headermax=[];header=[]; 60 | jump=[]; 61 | SegyHeader=[]; 62 | 63 | segyid = fopen(filename,'r','b'); % ALL DISK FILES ARE IN BIG 64 | % ENDIAN FORMAT, ACCORDING TO SEG 65 | % Y rev 1 66 | 67 | fseek(segyid,0,'eof'); 68 | BytesInFile = ftell(segyid); 69 | fseek(segyid,0,'bof'); 70 | 71 | 72 | ninput=nargin; 73 | % NEXT TWO LINES TO ENUSRE THAT VARARGIN CAN BE PASSED TO FUNCTION 74 | if ninput==2 75 | % CALL USING VARARGIN 76 | ninput=1+length(varargin{1}); 77 | varargin=varargin{1}; 78 | else 79 | % DIRECT CALL 80 | ninput=length(varargin); 81 | end 82 | 83 | 84 | % TRANSFORM VARARGING INTO PARAMETERS 85 | cargin=1; 86 | while (cargin0, Revision=1; end 166 | FormatName=SegyHeader.Rev(Revision+1).DataSampleFormat(SegyHeader.DataSampleFormat).name; 167 | Format=SegyHeader.Rev(Revision+1).DataSampleFormat(SegyHeader.DataSampleFormat).format; 168 | BPS=SegyHeader.Rev(Revision+1).DataSampleFormat(SegyHeader.DataSampleFormat).bps; 169 | txt=['SegyRevision ',sprintf('%0.4g',Revision),', ',FormatName,'(',num2str(SegyHeader.DataSampleFormat),')']; 170 | 171 | 172 | ns=SegyHeader.ns; 173 | 174 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 175 | % READ TEXTURAL FILE HEADER EXTENSION IF NEEDED 176 | %if SegyHeader.NumberOfExtTextualHeaders~=0 177 | % SegymatVerbose(['---------------------------------------------------']) 178 | % SegymatVerbose(['extendeD textual file headers are not supported yet']) 179 | % SegymatVerbose(['They are simply skipped']) 180 | % SegymatVerbose(['---------------------------------------------------']) 181 | %end 182 | 183 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 184 | %% READ DATA 185 | %Segy=fread(segyid,4000,'float32'); 186 | fseek(segyid,0,'eof'); DataEnd=ftell(segyid); 187 | 188 | DataStart=3600+3200*SegyHeader.NumberOfExtTextualHeaders; 189 | fseek(segyid,DataStart,'bof'); % Go to the beginning of the file 190 | 191 | ntraces=(DataEnd-DataStart)./(240+(SegyHeader.ns)*(BPS/8)); 192 | 193 | SegymatVerbose(['Number of Samples Per Trace=',num2str(SegyHeader.ns)]) 194 | SegymatVerbose(['Number of Traces=',num2str(ntraces)]) 195 | 196 | % Set Format : 197 | Revision=SegyHeader.SegyFormatRevisionNumber; 198 | if Revision>0, Revision=1; end 199 | Format=SegyHeader.Rev(Revision+1).DataSampleFormat(SegyHeader.DataSampleFormat).format; 200 | bitpersample=SegyHeader.Rev(Revision+1).DataSampleFormat(SegyHeader.DataSampleFormat).bps; 201 | bytepersample=bitpersample/8; 202 | ntraceheader=240/bytepersample; 203 | 204 | 205 | Data=fread(segyid,[ns+ntraceheader ntraces],Format); 206 | Data=Data([ntraceheader+1:1:ns+ntraceheader],:); 207 | %SegymatVerbose(['Now=',num2str(ftell(segyid)),' END=',num2str(DataEnd)]) 208 | 209 | % THE FOLLOWING DOES NOT WORK FOR OCTAVE (uint32) 210 | if (strcmp(Format,'uint32')==1), % IBM FLOATING POINT 211 | % CONVERT FROM FLOATING POINT 212 | verbose=1; 213 | if verbose>1, SegymatVerbose([mfilename,'Converting from IBM, DataFormat :',SegyHeader.DataFormat]); end 214 | Data=ibm2num(uint32(Data)); 215 | end; 216 | 217 | existJump=1-isempty(jump); 218 | existHeader=1-isempty(header); 219 | existTmin=1-isempty(tmin); 220 | existTmax=1-isempty(tmax); 221 | 222 | if existJump 223 | usetraces=[jump:jump:ntraces]; 224 | ntraces=length(usetraces); 225 | Data=Data(:,usetraces); 226 | end 227 | 228 | 229 | 230 | if (existTmin==1)&(existTmax==1) 231 | SegymatVerbose('TRANGE') 232 | % NEXT LINE SHOULD CONSIDER THAT ns in Trace and Segy Header could vary !!! 233 | origtrange=[1:1:SegyHeader.ns].*SegyHeader.dt.*1e-6; 234 | gooddata=find(origtrange>tmin & origtrange0, Revision=1; end 133 | 134 | if (SegyHeader.DataSampleFormat>length(SegyHeader.Rev(Revision+1).DataSampleFormat)); 135 | SegymatVerbose([mfilename,' : WARNING : YOU HAVE SELECTED (OR THE FILE IS FORMATTED SUCH THAT) A DATASAMPLE FORMAT THAT IS NOT DEFINED. \nREMEBER IEEE IS NOT SPECIFIED IN THE SEGY REV0 STANDARD !']) 136 | 137 | if (Revision==0) 138 | SegymatVerbose([mfilename,' : TRYING TO USE REVISION 1 AS OPPOSED TO REVISION 0']) 139 | Revision=1; 140 | 141 | if (SegyHeader.DataSampleFormat>length(SegyHeader.Rev(Revision+1).DataSampleFormat)); 142 | SegymatVerbose([mfilename,' : FATAL ERROR : STILL THE DATASAMPLE FORMAT IS NOT SUPPRTED - EXITING (Report error to tmh@gfy.ku.dk)']) 143 | else 144 | SegymatVerbose([mfilename,' : APPARENT SUCCES CHANING FROM Revision 0 to 1 - Continuing']) 145 | SegyHeader.SegyFormatRevisionNumber=1; % FORCING REVISION TO BE 1 !!! 146 | end 147 | 148 | end 149 | 150 | end 151 | 152 | 153 | FormatName=SegyHeader.Rev(Revision+1).DataSampleFormat(SegyHeader.DataSampleFormat).name; 154 | Format=SegyHeader.Rev(Revision+1).DataSampleFormat(SegyHeader.DataSampleFormat).format; 155 | BPS=SegyHeader.Rev(Revision+1).DataSampleFormat(SegyHeader.DataSampleFormat).bps; 156 | txt=['SegyRevision ',sprintf('%0.4g',Revision),', ',FormatName,'(',num2str(SegyHeader.DataSampleFormat),')']; 157 | 158 | 159 | fseek(segyid,0,'eof'); DataEnd=ftell(segyid); 160 | 161 | DataStart=3600+3200*SegyHeader.NumberOfExtTextualHeaders; 162 | fseek(segyid,DataStart,'bof'); % Go to the beginning of the file 163 | fseek(segyid,DataStart,'bof'); % Go to the beginning of the file 164 | 165 | 166 | SegyHeader.ntraces=(DataEnd-DataStart)./(240+(SegyHeader.ns)*(BPS/8)); 167 | catch 168 | % could not estimate ntraces 169 | end 170 | 171 | fclose(segyid); 172 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/ReadSegyTrace.m: -------------------------------------------------------------------------------- 1 | % ReadSegyTrace 2 | function [Data,STH,SegyHeader]=ReadSegyTrace(filename,traces,SegyHeader); 3 | 4 | Data=[]; 5 | if nargin<3 6 | SegyHeader=GetSegyHeader(filename); 7 | end 8 | 9 | if nargin<2 10 | [Data,STH,SegyHeader]=ReadSegyTrace(filename); 11 | end 12 | 13 | if (length(traces)>1) 14 | try 15 | Data=zeros(SegyHeader.ns,length(traces)); 16 | catch 17 | keyboard 18 | end 19 | for i=1:length(traces) 20 | [Data(:,i),STH(i)]=ReadSegyTrace(filename,traces(i),SegyHeader); 21 | end 22 | return 23 | end 24 | 25 | 26 | endian='ieee-be'; % Big Endian is default 27 | 28 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 29 | % OPEN FILE HANDLE 30 | if exist('endian')==1, 31 | SegymatVerbose([mfilename,' : ENDIAN : ',endian],1) 32 | segyid = fopen(filename,'r',endian); 33 | else 34 | endian='ieee-be'; 35 | SegymatVerbose([mfilename,' : ENDIAN SET TO ',endian],0) 36 | segyid = fopen(filename,'r','ieee-be'); % ALL DISK FILES ARE IN BIG 37 | end % ENDIAN FORMAT, ACCORDING TO 38 | 39 | Revision=SegyHeader.SegyFormatRevisionNumber; 40 | if Revision>0, Revision=1; end 41 | 42 | FormatName=SegyHeader.Rev(Revision+1).DataSampleFormat(SegyHeader.DataSampleFormat).name; 43 | Format=SegyHeader.Rev(Revision+1).DataSampleFormat(SegyHeader.DataSampleFormat).format; 44 | BPS=SegyHeader.Rev(Revision+1).DataSampleFormat(SegyHeader.DataSampleFormat).bps; 45 | txt=['SegyRevision ',sprintf('%0.4g',Revision),', ',FormatName,'(',num2str(SegyHeader.DataSampleFormat),')']; 46 | 47 | 48 | % move to proper location in segyfile 49 | DataStart=3600+3200*SegyHeader.NumberOfExtTextualHeaders; 50 | fseek(segyid,DataStart,'bof'); % Go to the beginning of the file 51 | 52 | 53 | skip=240+(BPS/8)*SegyHeader.ns; 54 | fseek(segyid,(traces-1)*skip,'cof'); 55 | %SegymatVerbose([num2str(traceinfile),' - SKIPPING TRACE ... ',num2str(outtrace)],2) 56 | 57 | TraceStart=ftell(segyid); 58 | 59 | STH=GetSegyTraceHeader(segyid,TraceStart,Format,SegyHeader.ns,[]); 60 | Data=GetSegyTraceData(segyid,STH.ns,SegyHeader); 61 | 62 | 63 | fclose(segyid); -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/ReadSegyTraceHeaderValue.m: -------------------------------------------------------------------------------- 1 | % ReadSegyTraceHeaderValue : Read a spedicifc trace header value 2 | % 3 | % Call: 4 | % % By Name 5 | % cdp=ReadSegyTraceHeaderValue(filename,'key','cdp'); 6 | % SourceX=ReadSegyTraceHeaderValue(filename,'key','SourceX'); 7 | % SourceY=ReadSegyTraceHeaderValue(filename,'key','SourceY'); 8 | % 9 | % % By location in Trace Header 10 | % SourceX=ReadSegyTraceHeaderValue(filename,'pos',72,'precision','int32'); 11 | % 12 | % % Call 'TraceHeaderDef(1)' to see a list of TraceHeader 'key' names 13 | % 14 | % See also WriteSegyTraceHeaderValue, TraceHeaderDef 15 | % 16 | 17 | % 18 | 19 | function hval=ReadSegyTraceHeaderValue(filename,varargin);%pos,type) 20 | 21 | pos=0; 22 | precision='int32'; 23 | 24 | ninput=nargin; 25 | % TRANSFORM VARARGING INTO PARAMETERS 26 | cargin=1; 27 | while (cargin0, Revision=1; end 97 | if (SegyHeader.DataSampleFormat>length(SegyHeader.Rev(Revision+1).DataSampleFormat)); 98 | SegymatVerbose([mfilename,' : WARNING : YOU HAVE SELECTED (OR THE FILE IS FORMATTED SUCH THAT) A DATASAMPLE FORMAT THAT IS NOT DEFINED. \nREMEBER IEEE IS NOT SPECIFIED IN THE SEGY REV0 STANDARD !']) 99 | if (Revision==0) 100 | SegymatVerbose([mfilename,' : TRYING TO USE REVISION 1 AS OPPOSED TO REVISION 0']) 101 | Revision=1; 102 | if (SegyHeader.DataSampleFormat>length(SegyHeader.Rev(Revision+1).DataSampleFormat)); 103 | SegymatVerbose([mfilename,' : FATAL ERROR : STILL THE DATASAMPLE FORMAT IS NOT SUPPRTED - EXITING (Report error to tmh@gfy.ku.dk)']) 104 | else 105 | SegymatVerbose([mfilename,' : APPARENT SUCCES CHANING FROM Revision 0 to 1 - Continuing']) 106 | SegyHeader.SegyFormatRevisionNumber=1; % FORCING REVISION TO BE 1 !!! 107 | end 108 | end 109 | end 110 | 111 | FormatName=SegyHeader.Rev(Revision+1).DataSampleFormat(SegyHeader.DataSampleFormat).name; 112 | Format=SegyHeader.Rev(Revision+1).DataSampleFormat(SegyHeader.DataSampleFormat).format; 113 | BPS=SegyHeader.Rev(Revision+1).DataSampleFormat(SegyHeader.DataSampleFormat).bps; 114 | txt=['SegyRevision ',sprintf('%0.4g',Revision),', ',FormatName,'(',num2str(SegyHeader.DataSampleFormat),')']; 115 | 116 | 117 | %Revision=SegyHeader.SegyFormatRevisionNumber; 118 | %if Revision>0, Revision=1; end 119 | %FormatName=SegyHeader.Rev(Revision+1).DataSampleFormat(SegyHeader.DataSampleFormat).name; 120 | %Format=SegyHeader.Rev(Revision+1).DataSampleFormat(SegyHeader.DataSampleFormat).format; 121 | %BPS=SegyHeader.Rev(Revision+1).DataSampleFormat(SegyHeader.DataSampleFormat).bps; 122 | %txt=['SegyRevision ',sprintf('%0.4g',Revision),', 123 | %',FormatName,'(',num2str(SegyHeader.DataSampleFormat),')'];% 124 | 125 | 126 | fseek(segyid,0,'eof'); DataEnd=ftell(segyid); 127 | 128 | DataStart=3600+3200*SegyHeader.NumberOfExtTextualHeaders; 129 | fseek(segyid,DataStart,'bof'); % Go to the beginning of the file 130 | 131 | ntraces=(DataEnd-DataStart)./(240+(SegyHeader.ns)*(BPS/8)); 132 | 133 | hval=zeros(1,ntraces); 134 | for itrace=1:ntraces 135 | if ((itrace/10000)==round(itrace/10000)) 136 | progress_txt(itrace,ntraces,'Trace #') 137 | end 138 | 139 | %GOTO START OF TRACE HEADER 140 | skip=DataStart+(itrace-1)*(240+(BPS/8)*SegyHeader.ns); 141 | fseek(segyid,skip,'bof'); 142 | fseek(segyid,pos,'cof'); 143 | hval(itrace)=fread(segyid,1,precision); 144 | 145 | end 146 | fclose(segyid); -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/ReadSuFast.m: -------------------------------------------------------------------------------- 1 | % ReadSuFast 2 | % 3 | % PURPOSE : reads a SEISMIC section i SU format in big endian format, 4 | % strips the headers and returns the field in the matrix seis. 5 | % If nx==0 and nt<>0, nx will be computed 6 | % If nt==0 and nx<>0, nt will be computed 7 | % 8 | % Call : function seis=ReadSuFast(fileid,nt,nx,'byteorder'); 9 | % byteorder : 'l' for little or 'b' for big endian (Default : Native ) 10 | % 11 | % BY : TMH 1/8 1997 12 | % Updated by Thomas Mejer Hansen : 22-03-1999 13 | % 14 | function [seis,nt,nx]=ReadSuFast(fileid,nt,nx,byte); 15 | 16 | if nargin==4 | nargin==2, 17 | if nargin==2, byte=nt; nt=0; end 18 | if byte=='b' 19 | b_order='ieee-be'; 20 | else 21 | b_order='ieee-le'; 22 | end 23 | SegymatVerbose(['SU2MAT : Byteorder : ',b_order],2) 24 | else 25 | % USE DEFAULT BYTEORDER 26 | SegymatVerbose(['SU2MAT : Byteorder : DEFAULT'],2) 27 | end 28 | 29 | 30 | if nargin==1 | nargin==2, 31 | if exist('b_order')==1, fid=fopen(fileid,'r',b_order); 32 | else, fid=fopen(fileid,'r'); end 33 | 34 | S0=fread(fid,60,'int16');nt=S0(58); 35 | if nt<0, 36 | % THIS CANNOT BE, MAYBE WRONG BYTE ORDER 37 | SegymatVerbose([mfilename,' : Wrong NT, maybe wrong byte order']) 38 | seis=[];nt=nt;nx=[]; 39 | return 40 | end 41 | SegymatVerbose(['nt=',num2str(nt)],2) 42 | nx=0; 43 | fclose(fid); 44 | end 45 | 46 | if exist('b_order')==1, fid=fopen(fileid,'r',b_order); 47 | else, fid=fopen(fileid,'r'); end 48 | S=fread(fid,inf,'float'); 49 | 50 | l=length(S); 51 | 52 | 53 | if nt==0, nt=l/nx-60; SegymatVerbose(['nt=',num2str(nt)],2);end 54 | if nx==0, nx=l/(nt+60); SegymatVerbose(['nx=',num2str(nx)],2); end, 55 | 56 | S=reshape(S,nt+60,nx); 57 | 58 | seis=S(61:nt+60,:); 59 | 60 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/Sac2Segy.m: -------------------------------------------------------------------------------- 1 | % Sac2Segy : Reads SAC formatted data into a SegyMAT (SGY) structure 2 | % 3 | % CALL : 4 | % [Data,SegyTraceHeader,SegyHeader]=Sac2Segy(files_in,segyfile_out,varargin) 5 | % 6 | % files_in : Either a single filename or a strcture of filenames 7 | % files_in='d1.SAC'; 8 | % or 9 | % files_in{1}='d1.SAC'; 10 | % files_in{2}='d2.SAC'; 11 | % 12 | % Examples : 13 | % [D,STH,SH]=Sac2Segy('','test.segy','FixedLengthTraceFlag',1); 14 | % converts all SAC files into one SEGY file (test.segy), using 15 | % a FixedLengthTraceFlag of 1. This is compatible with mosty 16 | % any SEGY reader. 17 | % 18 | % [D,STH,SH]=Sac2Segy('','test.segy','FixedLengthTraceFlag',0); 19 | % converts all SAC files into one SEGY file (test.segy), using 20 | % a FixedLengthTraceFlag of 0, allowing varying trace length of SEGY files 21 | % This is only compatible with revision 1 of the SEGY format. 22 | % 23 | % [D,STH,SH]=Sac2Segy('file.sac'); 24 | % convert file.sac to file.segy 25 | % 26 | % [D,STH,SH]=Sac2Segy('file.sac','another_file.segy'); 27 | % convert file.sac to another_file.segy 28 | % 29 | % 30 | % Force little endian byte format for SAC file: 31 | % Sac2Segy('file.sac','test.sgy','endian','l'); 32 | % 33 | % Relies on sac2mat.m 34 | % 35 | % Download SAC files from : http://www.iris.edu/hq/ssn/events 36 | % 37 | function [Data,STH,SegyHeader]=Sac2Segy(files_in,segyfile_out,varargin) 38 | 39 | endian='b'; % Default big endian SAC files 40 | 41 | if nargin==0 42 | d=dir('*.sac'); 43 | if (length(d)==0) 44 | SegymatVerbose(sprintf('No SAC files found.',mfilename)); 45 | Data=[];STH=[];SegyHeader=[]; 46 | return 47 | end 48 | for i=1:length(d); files_in{i}=d(i).name;end 49 | end 50 | 51 | 52 | if nargin>0 53 | if isempty(files_in) 54 | d=dir('*.sac'); 55 | for i=1:length(d); files_in{i}=d(i).name;end 56 | end 57 | if (ischar(files_in)&(nargin==1)) 58 | [p,f,e]=fileparts(files_in); 59 | segyfile_out=[f,'.segy']; 60 | end 61 | end 62 | 63 | ninput=nargin; 64 | % NEXT TWO LINES TO ENUSRE THAT VARARGIN CAN BE PASSED TO FUNCTION 65 | if ninput==3 66 | % CALL USING VARARGIN 67 | ninput=2+length(varargin{1}); 68 | varargin=varargin{1}; 69 | else 70 | % DIRECT CALL 71 | ninput=length(varargin); 72 | end 73 | 74 | 75 | % TRANSFORM VARARGING INTO PARAMETERS 76 | cargin=1; 77 | while (cargin1)|(exist('segyfile_out','var'))) 248 | SegyHeader=WriteSegyStructure(segyfile_out,SegyHeader,STH,Data); 249 | end -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/Segy2Su.m: -------------------------------------------------------------------------------- 1 | % Segy2Su : Converts SEGY file to SU format 2 | % 3 | % Call : Segy2Su(filename,ReadSegyOption) 4 | % Replaces the filename suffix to '.su'; 5 | % 'ReadSegyOptions' are the same as to 'ReadSegy' 6 | % 7 | % See also : ReadSegy 8 | % 9 | 10 | % 11 | % 12 | % (C) 2001,2002 Thomas Mejer Hansen, thomas@cultpenguin.com 13 | % 14 | % This program is free software; you can redistribute it and/or modify 15 | % it under the terms of the GNU General Public License as published by 16 | % the Free Software Foundation; either version 2 of the License, or 17 | % (at your option) any later version. 18 | % 19 | % This program is distributed in the hope that it will be useful, 20 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | % GNU General Public License for more details. 23 | % 24 | % You should have received a copy of the GNU General Public License 25 | % along with this program; if not, write to the Free Software 26 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 27 | % 28 | % 29 | function Segy2Su(filename,varargin); 30 | [Data,SegyTraceHeaders,SegyHeader]=ReadSegy(filename,varargin); 31 | SegyHeader.DataSampleFormat=5; % IEEE 32 | SegyHeader.SegyFormatRevisionNumber=100; % SEGY REVISION 1 33 | WriteSuStructure([filename,'.su'],SegyHeader,SegyTraceHeaders,Data); 34 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/SegyMAT_GAIN.m: -------------------------------------------------------------------------------- 1 | % SegyMAT_GAIN : Gain plugin for SegyMAT 2 | % 3 | % [Data,SegyTraceHeaders,SegyHeader]=SegyMAT_GAIN(Data,SegyTraceHeaders,SegyHeader,varargin); 4 | % 5 | % ex. AGC using AGC window of 100 ms : 6 | % [Data]=SegyMAT_GAIN(Data,SegyTraceHeaders,SegyHeader,'agc',.1); 7 | % ex. apply t^(pow), pow=2 8 | % [Data]=SegyMAT_GAIN(Data,SegyTraceHeaders,SegyHeader,'pow',2); 9 | % 10 | % 11 | % (C) Thomas Mejer Hansen (thomas@cultpenguin.com), 2002 12 | % 13 | 14 | % 15 | % This program is free software; you can redistribute it and/or modify 16 | % it under the terms of the GNU General Public License as published by 17 | % the Free Software Foundation; either version 2 of the License, or 18 | % (at your option) any later version. 19 | % 20 | % This program is distributed in the hope that it will be useful, 21 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | % GNU General Public License for more details. 24 | % 25 | % You should have received a copy of the GNU General Public License 26 | % along with this program; if not, write to the Free Software 27 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 28 | % 29 | function [Data,SegyTraceHeaders,SegyHeader]=SegyMAT_GAIN(Data,SegyTraceHeaders,SegyHeader,varargin); 30 | 31 | nv=0; 32 | for i=1:length(varargin) 33 | if strcmp(varargin{i},'agc') 34 | type=1; 35 | window=varargin{i+1}; 36 | end 37 | if strcmp(varargin{i},'pow') 38 | type=2; 39 | pow=varargin{i+1}; 40 | end 41 | end 42 | 43 | 44 | if type==1 45 | disp([mfilename,' AGC']) 46 | for it=1:size(Data,2) 47 | disp([mfilename,' AGC trace : ',num2str(it)]) 48 | 49 | % Trace Data 50 | TraceData=Data(:,it); 51 | 52 | % Window Length 53 | nsw=round(window./(SegyTraceHeaders(it).dt./1e+6)); 54 | nshalf=floor(nsw/2); 55 | startsample=ceil(nsw/2); 56 | endsample=length(TraceData)-floor(nsw); 57 | for is=startsample:1:endsample; 58 | 59 | range=[is-nshalf+1:1:is+nshalf]; 60 | 61 | gain=mean(abs(TraceData(range))); 62 | if gain~=0 63 | 64 | TraceData(is)=TraceData(is)./mean(abs(TraceData(range))); 65 | 66 | % APPLY TO TOP 67 | if is==startsample 68 | for i=[1:startsample-1]; 69 | TraceData(i)=TraceData(i)./mean(abs(TraceData(range))); 70 | end 71 | end 72 | 73 | if is==endsample 74 | for i=[endsample+1:1:length(TraceData)]; 75 | TraceData(i)=TraceData(i)./gain; 76 | end 77 | end 78 | 79 | 80 | end 81 | 82 | end 83 | 84 | Data(:,it)=TraceData; 85 | 86 | end % END LOOP OVER TRACES 87 | end % END TYPE 88 | 89 | 90 | if type==2 91 | disp([mfilename,' POW']) 92 | for it=1:size(Data,2) 93 | % disp([mfilename,' POW trace : ',num2str(it)]) 94 | t=[1:1:SegyTraceHeaders(it).ns]*SegyTraceHeaders(it).dt./1e+6+SegyTraceHeaders(it).DelayRecordingTime./1e+3; 95 | tp=t.^(pow)'; 96 | Data(:,it)=Data(:,it).*tp; 97 | end 98 | end -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/SegyMATdemo1.m: -------------------------------------------------------------------------------- 1 | % SegyMATdemo1 : Creates, Reads and plots a Segy File; 2 | 3 | % load test data set 4 | load Clown; 5 | 6 | % choose a file name; 7 | file='segy_test.sgy'; 8 | 9 | % Write segy file, using default setting 10 | WriteSegy(file,X); 11 | 12 | % Read the segy file with Segy Header and Segy Trace Header 13 | [Data,STH,SH]=ReadSegy(file); 14 | 15 | 16 | x=[STH.TraceNumber]; 17 | t=SH.time; 18 | 19 | 20 | subplot(2,2,1) 21 | wiggle(x,t,Data) % variable Area 22 | title('Wiggle') 23 | subplot(2,2,2) 24 | title('Wiggle') 25 | wiggle(x,t,Data,'VA') % variable Area 26 | title('Variable Area') 27 | 28 | subplot(2,1,2) 29 | scale=1; % MAX Data Value 30 | showmax=300; % Max number of traces to display using wiggle 31 | plimage=1; % plot image plot 32 | wiggle(x,t,Data,'wiggle',[],showmax,plimage); 33 | title('Wiggle + image') -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/SegymatHelp.m: -------------------------------------------------------------------------------- 1 | function SegymatHelp(file); 2 | if nargin==0 3 | file='index'; 4 | end 5 | 6 | [SegyMAT_root]=fileparts(which('ReadSegy')); 7 | 8 | docpath=[SegyMAT_root, filesep , 'html']; 9 | 10 | if isdir(docpath) 11 | helpfile=[docpath, filesep, file, '.html']; 12 | if exist(helpfile) 13 | web(['file://',helpfile]) 14 | else 15 | SegymatVerbose(sprintf('Could not open help file : "%s"',helpfile)) 16 | end 17 | else 18 | SegymatVerbose(sprintf('"%s" does not exist',docpath)) 19 | SegymatVerbose('Cannot show local help') 20 | SegymatVerbose(sprintf('Trying to open the online help',docpath)) 21 | web('http://segymat.sourceforge.net/doc/') 22 | end -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/SegymatRevision.m: -------------------------------------------------------------------------------- 1 | % SegymatRevision - Returns the revision history 2 | % 3 | % Call : [Revision]=SegymatRevision 4 | % 5 | 6 | % 7 | % (C) 2001-2011, Thomas Mejer Hansen, thomas.mejer.hansen@gmail.com 8 | % 9 | % This program is free software; you can redistribute it and/or modify 10 | % it under the terms of the GNU General Public License as published by 11 | % the Free Software Foundation; either version 2 of the License, or 12 | % (at your option) any later version. 13 | % 14 | % This program is distributed in the hope that it will be useful, 15 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | % GNU General Public License for more details. 18 | % 19 | % You should have received a copy of the GNU General Public License 20 | % along with this program; if not, write to the Free Software 21 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | % 23 | 24 | function [Rev]=SegymatRevision; 25 | 26 | revisionfile=[fileparts(which('ReadSegy')),'/REVISION']; 27 | 28 | fid=fopen(revisionfile,'r'); 29 | cl=0; 30 | while 1 31 | cl=cl+1; 32 | currentline=fgetl(fid); 33 | if ~ischar(currentline), break, end 34 | st{cl} = currentline; 35 | end 36 | fclose(fid); 37 | 38 | if nargout==0, 39 | SegymatVerbose(['SegyMAT Revision History']) 40 | for i=1:length(st); 41 | SegymatVerbose(st{i}) 42 | end 43 | else 44 | Rev=st; 45 | end 46 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/SegymatVerbose.m: -------------------------------------------------------------------------------- 1 | % SegymatVerbose : Writes out verbose information to the screen 2 | % 3 | % 4 | % Call : 5 | % SegymatVerbose(text,verboselevel) 6 | % prints out 'text' to screen if verboselevel is higher than threshold 7 | % set in m-file. 8 | % 9 | 10 | % 11 | % (C) 2001-2004, Thomas Mejer Hansen, tmh@gfy.ku.dk/thomas@cultpenguin.com 12 | % 13 | % This program is free software; you can redistribute it and/or modify 14 | % it under the terms of the GNU General Public License as published by 15 | % the Free Software Foundation; either version 2 of the License, or 16 | % (at your option) any later version. 17 | % 18 | % This program is distributed in the hope that it will be useful, 19 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | % GNU General Public License for more details. 22 | % 23 | % You should have received a copy of the GNU General Public License 24 | % along with this program; if not, write to the Free Software 25 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 26 | 27 | 28 | function SegymatVerbose(txt,level) 29 | 30 | if nargin==0, return, end 31 | if nargin==1, 32 | level=1; 33 | end 34 | 35 | VerboseLevel=0; 36 | 37 | % Only print information if at or above VerboseLevel 38 | if level<=VerboseLevel 39 | disp(sprintf('%s : %s','SegyMAT',txt)) 40 | end 41 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/SegymatVersion.m: -------------------------------------------------------------------------------- 1 | % SegymatVersion - Returns the version and release date 2 | % 3 | % [ver,d]=SegymatVersion; 4 | % 5 | 6 | % 7 | % (C) 2001-2011, Thomas Mejer Hansen, thomas.mejer.hansen@gmail.com 8 | % 9 | % This program is free software; you can redistribute it and/or modify 10 | % it under the terms of the GNU General Public License as published by 11 | % the Free Software Foundation; either version 2 of the License, or 12 | % (at your option) any later version. 13 | % 14 | % This program is distributed in the hope that it will be useful, 15 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | % GNU General Public License for more details. 18 | % 19 | % You should have received a copy of the GNU General Public License 20 | % along with this program; if not, write to the Free Software 21 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | function [ver,d]=SegymatVersion; 24 | version='1.5.1'; 25 | releasedate='October 28, 2011'; 26 | 27 | SegymatVerbose(['This is SegyMAT version ',version,' - released ',releasedate],-1) 28 | ver=version; 29 | d=releasedate; 30 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/Su2Segy.m: -------------------------------------------------------------------------------- 1 | % SU2Segy : Converts SEGY file to SU format 2 | 3 | % 4 | % (C) 2001-2004, Thomas Mejer Hansen, tmh@gfy.ku.dk/thomas@cultpenguin.com 5 | % 6 | % This program is free software; you can redistribute it and/or modify 7 | % it under the terms of the GNU General Public License as published by 8 | % the Free Software Foundation; either version 2 of the License, or 9 | % (at your option) any later version. 10 | % 11 | % This program is distributed in the hope that it will be useful, 12 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | % GNU General Public License for more details. 15 | % 16 | % You should have received a copy of the GNU General Public License 17 | % along with this program; if not, write to the Free Software 18 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | % 20 | % 21 | % 22 | function SU2Segy(filename,varargin); 23 | [Data,SegyTraceHeaders,SegyHeader,HeaderInfo]=ReadSu(filename,varargin); 24 | WriteSegyStructure([filename,'.segy'],SegyHeader,SegyTraceHeaders,Data);% 25 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/TraceHeaderDef.m: -------------------------------------------------------------------------------- 1 | % TraceHeaderDef : Defines names, position, and precision for Trace Headers 2 | % 3 | % % To get a Matlab structure with trace header definitions call: 4 | % STH==TraceHeaderDef; 5 | % % To get a list fo trace header definision listed on the screen call: 6 | % STH==TraceHeaderDef(1) 7 | % 8 | % See also: ReadSegyTraceHeaderValue, WriteSegyTraceHeaderValue 9 | % 10 | function STH=TraceHeaderDef(print); 11 | 12 | if nargin>0 13 | STH=TraceHeaderDef; 14 | fn=fieldnames(STH); 15 | disp(sprintf('%4s %6s %s','POS','PREC','Traece Header Name')) 16 | for i=1:length(fn) 17 | disp(sprintf('%4d %6s %s',STH.(fn{i}).pos,STH.(fn{i}).precision,fn{i})) 18 | end 19 | return 20 | end 21 | 22 | %NEW 23 | STH.TraceSequenceLine.pos=0; STH.TraceSequenceLine.precision='int32'; 24 | STH.TraceSequenceFile.pos=4; STH.TraceSequenceFile.precision='int32'; 25 | STH.FieldRecord.pos=8; STH.FieldRecord.precision='int32'; 26 | STH.TraceNumber.pos=12; STH.TraceNumber.precision='int32'; 27 | STH.EnergySourcePoint.pos=16;STH.EnergySourcePoint.precision='int32'; 28 | STH.cdp.pos=20; STH.cdp.precision='int32'; 29 | STH.cdpTrace.pos=24; STH.cdpTrace.precision='int32'; 30 | 31 | STH.TraceIdenitifactionCode.pos=28;STH.TraceIdenitifactionCode.precision='int16'; 32 | STH.NSummedTraces.pos=30; STH.NSummedTraces.precision='int16'; 33 | STH.NStackedTraces.pos=32; STH.NStackedTraces.precision='int16'; 34 | STH.DataUse.pos=34; STH.DataUse.precision='int16'; 35 | 36 | STH.offset.pos=36;STH.offset.precision='int32'; 37 | STH.ReceiverGroupElevation.pos=40;STH.ReceiverGroupElevation.precision='int32'; 38 | STH.SourceSurfaceElevation.pos=44;STH.SourceSurfaceElevation.precision='int32'; 39 | STH.SourceDepth.pos=48;STH.SourceDepth.precision='int32'; 40 | STH.ReceiverDatumElevation.pos=52;STH.ReceiverDatumElevation.precision='int32'; 41 | STH.SourceDatumElevation.pos=56;STH.SourceDatumElevation.precision='int32'; 42 | STH.SourceWaterDepth.pos=60;STH.SourceWaterDepth.precision='int32'; 43 | STH.GroupWaterDepth.pos=64;STH.GroupWaterDepth.precision='int32'; 44 | 45 | STH.ElevationScalar.pos=68;STH.ElevationScalar.precision='int16'; 46 | STH.SourceGroupScalar.pos=70;STH.SourceGroupScalar.precision='int16'; 47 | 48 | STH.SourceX.pos=72;STH.SourceX.precision='int32'; 49 | STH.SourceY.pos=76;STH.SourceY.precision='int32'; 50 | STH.GroupX.pos=80;STH.GroupX.precision='int32'; 51 | STH.GroupY.pos=84;STH.GroupY.precision='int32'; 52 | 53 | STH.CoordinateUnits.pos=88;STH.CoordinateUnits.precision='int16'; 54 | STH.WeatheringVelocity.pos=90;STH.WeatheringVelocity.precision='int16'; 55 | STH.SubWeatheringVelocity.pos=92;STH.SubWeatheringVelocity.precision='int16'; 56 | STH.SourceUpholeTime.pos=94;STH.SourceUpholeTime.precision='int16'; 57 | STH.GroupUpholeTime.pos=96;STH.GroupUpholeTime.precision='int16'; 58 | STH.SourceStaticCorrection.pos=98;STH.SourceStaticCorrection.precision='int16'; 59 | STH.GroupStaticCorrection.pos=100;STH.GroupStaticCorrection.precision='int16'; 60 | STH.TotalStaticApplied.pos=102;STH.TotalStaticApplied.precision='int16'; 61 | STH.LagTimeA.pos=104;STH.LagTimeA.precision='int16'; 62 | STH.LagTimeB.pos=106;STH.LagTimeB.precision='int16'; 63 | STH.DelayRecordingTime.pos=108;STH.DelayRecordingTime.precision='int16'; 64 | STH.MuteTimeStart.pos=110;STH.MuteTimeStart.precision='int16'; 65 | STH.MuteTimeEND.pos=112;STH.MuteTimeEND.precision='int16'; 66 | 67 | STH.ns.pos=114;STH.ns.precision='uint16'; 68 | STH.dt.pos=116;STH.dt.precision='uint16'; 69 | 70 | STH.GainType.pos=118;STH.GainType.precision='int16'; 71 | STH.InstrumentGainConstant.pos=120;STH.InstrumentGainConstant.precision='int16'; 72 | STH.InstrumentInitialGain.pos=122;STH.InstrumentInitialGain.precision='int16'; 73 | STH.Correlated.pos=124;STH.Correlated.precision='int16'; 74 | STH.SweepFrequenceStart.pos=126;STH.SweepFrequenceStart.precision='int16'; 75 | STH.SweepFrequenceEnd.pos=128;STH.SweepFrequenceEnd.precision='int16'; 76 | STH.SweepLength.pos=130;STH.SweepLength.precision='int16'; 77 | STH.SweepType.pos=132;STH.SweepType.precision='int16'; 78 | STH.SweepTraceTaperLengthStart.pos=134;STH.SweepTraceTaperLengthStart.precision='int16'; 79 | STH.SweepTraceTaperLengthEnd.pos=136;STH.SweepTraceTaperLengthEnd.precision='int16'; 80 | STH.TaperType.pos=138;STH.TaperType.precision='int16'; 81 | STH.AliasFilterFrequency.pos=140;STH.AliasFilterFrequency.precision='int16'; 82 | STH.AliasFilterSlope.pos=142;STH.AliasFilterSlope.precision='int16'; 83 | STH.NotchFilterFrequency.pos=144;STH.NotchFilterFrequency.precision='int16'; 84 | STH.NotchFilterSlope.pos=146;STH.NotchFilterSlope.precision='int16'; 85 | STH.LowCutFrequency.pos=148;STH.LowCutFrequency.precision='int16'; 86 | STH.HighCutFrequency.pos=150;STH.HighCutFrequency.precision='int16'; 87 | STH.LowCutSlope.pos=152;STH.LowCutSlope.precision='int16'; 88 | STH.HighCutSlope.pos=154;STH.HighCutSlope.precision='int16'; 89 | STH.YearDataRecorded.pos=156;STH.YearDataRecorded.precision='int16'; 90 | STH.DayOfYear.pos=158;STH.DayOfYear.precision='int16'; 91 | STH.HourOfDay.pos=160;STH.HourOfDay.precision='int16'; 92 | STH.MinuteOfHour.pos=162;STH.MinuteOfHour.precision='int16'; 93 | STH.SecondOfMinute.pos=164;STH.SecondOfMinute.precision='int16'; 94 | STH.TimeBaseCode.pos=166;STH.TimeBaseCode.precision='int16'; 95 | %STH.TimeBaseCodeText.pos=168;STH.TimeBaseCodeText.precision='int16'; 96 | STH.TraceWeightningFactor.pos=168;STH.TraceWeightningFactor.precision='int16'; 97 | STH.GeophoneGroupNumberRoll1.pos=170;STH.GeophoneGroupNumberRoll1.precision='int16'; 98 | STH.GeophoneGroupNumberFirstTraceOrigField.pos=172;STH.GeophoneGroupNumberFirstTraceOrigField.precision='int16'; 99 | STH.GeophoneGroupNumberLastTraceOrigField.pos=174;STH.GeophoneGroupNumberLastTraceOrigField.precision='int16'; 100 | STH.GapSize.pos=176;STH.GapSize.precision='int16'; 101 | STH.OverTravel.pos=178;STH.OverTravel.precision='int16'; 102 | 103 | STH.cdpX.pos=180;STH.cdpX.precision='int32'; 104 | STH.cdpY.pos=184;STH.cdpY.precision='int32'; 105 | STH.Inline3D.pos=188;STH.Inline3D.precision='int32'; 106 | STH.Crossline3D.pos=192;STH.Crossline3D.precision='int32'; 107 | STH.ShotPoint.pos=196;STH.ShotPoint.precision='int32'; 108 | 109 | STH.ShotPointScalar.pos=200;STH.ShotPointScalar.precision='int16'; 110 | 111 | STH.TraceValueMeasurementUnit.pos=202;STH.TraceValueMeasurementUnit.precision='int16'; 112 | 113 | STH.TransductionConstantMantissa.pos=204;STH.TransductionConstantMantissa.precision='int32'; 114 | 115 | STH.TransductionConstantPower.pos=208;STH.TransductionConstantPower.precision='int16'; 116 | STH.TransductionUnit.pos=210;STH.TransductionUnit.precision='int16'; 117 | STH.TraceIdentifier.pos=212;STH.TraceIdentifier.precision='int16'; 118 | STH.ScalarTraceHeader.pos=214;STH.ScalarTraceHeader.precision='int16'; 119 | STH.SourceType.pos=216;STH.SourceType.precision='int16'; 120 | 121 | STH.SourceEnergyDirectionMantissa.pos=218;STH.SourceEnergyDirectionMantissa.precision='int32'; 122 | 123 | STH.SourceEnergyDirectionExponent.pos=222;STH.SourceEnergyDirectionExponent.precision='int16'; 124 | 125 | STH.SourceMeasurementMantissa.pos=224;STH.SourceMeasurementMantissa.precision='in32'; 126 | 127 | STH.SourceMeasurementExponent.pos=228;STH.SourceMeasurementExponent.precision='int16'; 128 | STH.SourceMeasurementUnit.pos=230;STH.SourceMeasurementUnit.precision='int16'; 129 | 130 | STH.UnassignedInt1.pos=232;STH.UnassignedInt1.precision='int32'; 131 | STH.UnassignedInt2.pos=236;STH.UnassignedInt2.precision='int32'; 132 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/WriteSegy.m: -------------------------------------------------------------------------------- 1 | % WriteSegy : writes data to disk using SEGY REV 1 standard. 2 | % 3 | % EX 4 | % WriteSegy('datacube.segy',data,'dt',.004,'Inline3D',Inline,'Crossline3D',Crossline,'cdpX',X,'cdpY',Y); 5 | % 6 | % to use a specific SEG revision use : 7 | % WriteSegy('test.segy',seisdata,'revision',0); % SEG-Y Revision 0 8 | % WriteSegy('test.segy',seisdata,'revision',1); % SEG-Y Revision 1 9 | % 10 | % to use a specific Data Sampling Format use : 11 | % WriteSegy('test.segy',seisdata,'dsf',1); % IBM FLAOTING POINT 12 | % 13 | % Forice Revision 1 and IEEE Floating point : 14 | % WriteSegy('test.segy',seisdata,'dsf',5,'revision',1); 15 | % 16 | % See also : WriteSegyStructure, WriteSu, WriteSuStructure 17 | % 18 | 19 | % 20 | % (C) 2001-2007, Thomas Mejer Hansen, tmh@gfy.ku.dk/thomas.mejer.hansen@gmail.com 21 | % 22 | % This program is free software; you can redistribute it and/or modify 23 | % it under the terms of the GNU General Public License as published by 24 | % the Free Software Foundation; either version 2 of the License, or 25 | % (at your option) any later version. 26 | % 27 | % This program is distributed in the hope that it will be useful, 28 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 29 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 30 | % GNU General Public License for more details. 31 | % 32 | % You should have received a copy of the GNU General Public License 33 | % along with this program; if not, write to the Free Software 34 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 35 | % 36 | function WriteSegy(filename,data,varargin); 37 | 38 | [ns,ntraces]=size(data); 39 | 40 | 41 | for i=1:2:length(varargin) 42 | var=varargin{i}; 43 | val=varargin{i+1}; 44 | eval([var,'=[',num2str(val),'];']); 45 | end 46 | 47 | if exist('dt')~=1 48 | dt=0.004; 49 | SegymatVerbose([mfilename,' - No dt set. Using dt=',num2str(dt)],0) 50 | end 51 | 52 | %%%%%%%%%% 53 | % SET UP SegyHeader structure. 54 | if exist('TextualFileHeader'), SegyHeader.TextualFileHeader=TextualFileHeader; end 55 | if exist('Job')==1, SegyHeader.Job=Job; end; 56 | if exist('Line')==1, SegyHeader.Line=Line; end 57 | if exist('Reel')==1, SegyHeader.Reel=Reel; end 58 | if exist('DataTracePerEnsemble')==1, SegyHeader.DataTracePerEnsemble=DataTracePerEnsemble; end 59 | if exist('AuxiliaryTracePerEnsemble')==1, SegyHeader.AuxiliaryTracePerEnsemble=AuxiliaryTracePerEnsemble; end 60 | if exist('dt')==1, SegyHeader.dt=dt.*1e+6; end 61 | if exist('dtOrig')==1, SegyHeader.dtOrig=dtOrig; end 62 | if exist('ns')==1, SegyHeader.ns=ns; end 63 | if exist('nsOrig')==1, SegyHeader.nsOrig=nsOrig; end 64 | if exist('EnsembleFold')==1, SegyHeader.EnsembleFold=EnsembleFold; end 65 | if exist('TraceSorting')==1, SegyHeader.TraceSorting=TraceSorting; end 66 | if exist('VerticalSumCode')==1, SegyHeader.VerticalSumCode=VerticalSumCode; end 67 | 68 | 69 | %%%%%%%%%% 70 | %% CHOOSE WHICH SEGY REVISION AND DATATYPE TO USE 71 | %% DEFAULT IS REVISION 1, 4-byte IEEE 72 | 73 | % IF A SPECFIC REVISION HAS BEEN CHOSEN, USE THAT 74 | if exist('revision')==1, 75 | if revision==1, 76 | SegyHeader.SegyFormatRevisionNumber=100; 77 | else 78 | SegyHeader.SegyFormatRevisionNumber=0; 79 | end 80 | SegymatVerbose([mfilename,' : Using user specified SEG Y revision : ',num2str(revision)],1) 81 | end 82 | 83 | 84 | % IF A SPECFIC DATA SAMPLING FORMAT HAS BEEN SELECTED USE THAT 85 | if exist('dsf')==1, 86 | SegyHeader.DataSampleFormat=dsf; 87 | SegymatVerbose([mfilename,' : Using user specified Data Sample Format : ',num2str(revision)],1) 88 | end 89 | 90 | 91 | 92 | % UNCOMMENT THE FOLLOWING TWO LINES TO USE REVISION 1 (2002) 93 | %SegyHeader.SegyFormatRevisionNumber=100; % 2002 SEG Y STYLE 94 | %SegyHeader.DataSampleFormat=2; % '1'->4-byte IBM floating point 95 | % '2'->4-byte two's complement integer 96 | % '3'->2-byte two's complement integer 97 | % '5'->4-byte IEEE floating point (default) 98 | % '8'->1-byte two's complement integer 99 | 100 | % UNCOMMENT THE FOLLOWING TWO LINES TO USE REVISION 0 (1975) 101 | %SegyHeader.SegyFormatRevisionNumber=0; % 1975 SEoG Y STYLE 102 | %SegyHeader.DataSampleFormat=1; % '1'->4-byte IBM Floating Point 103 | 104 | % OPEN SEGY FILE HANDLE 105 | segyid = fopen(filename,'w','b'); % ALL DISK FILES ARE IN BIG 106 | % ENDIAN FORMAT, ACCORDING SEG 107 | % Y rev 1 108 | 109 | % Write SEGY HEADER 110 | SegyHeader=PutSegyHeader(segyid,SegyHeader); 111 | 112 | for i=1:ntraces; 113 | if (i/100)==round(i/100), 114 | SegymatVerbose(['writing trace ',num2str(i),' of ',num2str(ntraces)],0); 115 | end 116 | % Basic TraceHeader information 117 | 118 | % INITALIZE SEGY TRACE HEADER 119 | if exist('SegyTraceHeader')==0; 120 | SegyTraceHeader=InitSegyTraceHeader(ns,dt*1e+6); 121 | end 122 | 123 | if exist('TraceNumber')==0 124 | SegyTraceHeader.TraceNumber=i; 125 | SegyTraceHeader.TraceSequenceFile=i; 126 | end 127 | 128 | % Update TraceHeader information if available 129 | if exist('cdpX')==1,SegyTraceHeader.cdpX = cdpX(i);end 130 | if exist('offset')==1,SegyTraceHeader.offset = offset(i);end 131 | if exist('cdpY')==1,SegyTraceHeader.cdpY = cdpY(i);end 132 | if exist('Inline3D')==1,SegyTraceHeader.Inline3D = Inline3D(i);end 133 | if exist('Crossline3D')==1,SegyTraceHeader.Crossline3D=Crossline3D(i);end 134 | 135 | if exist('YearDataRecorded')==1,SegyTraceHeader.YearDataRecorded=YearDataRecorded(i);end 136 | if exist('DayOfYear')==1,SegyTraceHeader.DayOfYear=DayOfYear(i);end 137 | if exist('HourOfDay')==1,SegyTraceHeader.HourOfDay=HourOfDay(i);end 138 | if exist('MinuteOfOur')==1,SegyTraceHeader.MinuteOfOur=MinuteOfOur(i);end 139 | if exist('SecondOfMinute')==1,SegyTraceHeader.SecondOfMinute=SecondOfMinute(i);end 140 | if exist('TimeBaseCode')==1,SegyTraceHeader.TimeBaseCode=TimeBaseCode(i);end 141 | 142 | 143 | 144 | 145 | % Write the Trace 146 | PutSegyTrace(segyid,data(:,i),SegyTraceHeader,SegyHeader); 147 | end 148 | 149 | % CLOSE SEGY FILE HANDLE 150 | 151 | fclose(segyid); 152 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/WriteSegyStructure.m: -------------------------------------------------------------------------------- 1 | % WriteSegyStructure : writes data to disk using SEGY REV 0 and 1 standards. 2 | % 3 | % EX 4 | % WriteSegyStructure('datacube.segy',SegyHeader,SegyTraceHeaders,Data); 5 | % 6 | % To force the use of SEG Y revision 0 7 | % WriteSegyStructure('datacube.segy',SegyHeader,SegyTraceHeaders,Data,'revision',0); 8 | % To force the use of SEG Y revision 1 9 | % WriteSegyStructure('datacube.segy',SegyHeader,SegyTraceHeaders,Data,'revision',1); 10 | % To force the data sampling format to be IBM Floating Point 11 | % WriteSegyStructure('datacube.segy',SegyHeader,SegyTraceHeaders,Data,'dsf',1); 12 | % 13 | % To force the use of SEG Y revision 0 and data sampling format IEEE : 14 | % WriteSegyStructure('datacube.segy',SegyHeader,SegyTraceHeaders,Data,'revision',1,'dsf',5); 15 | % 16 | % See the dokumentation for for proper values of 'dsf' 17 | % 18 | % 19 | 20 | % 21 | % (C) 2001-2004, Thomas Mejer Hansen, tmh@gfy.ku.dk/thomas@cultpenguin.com 22 | % 23 | % This program is free software; you can redistribute it and/or modify 24 | % it under the terms of the GNU General Public License as published by 25 | % the Free Software Foundation; either version 2 of the License, or 26 | % (at your option) any later version. 27 | % 28 | % This program is distributed in the hope that it will be useful, 29 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 30 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 31 | % GNU General Public License for more details. 32 | % 33 | % You should have received a copy of the GNU General Public License 34 | % along with this program; if not, write to the Free Software 35 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 36 | % 37 | % 38 | function SegyHeader=WriteSegyStructure(filename,SegyHeader,SegyTraceHeaders,Data,varargin) 39 | 40 | for i=1:2:length(varargin) 41 | var=varargin{i}; 42 | val=varargin{i+1}; 43 | eval([var,'=[',num2str(val),'];']); 44 | end 45 | 46 | 47 | if exist('revision')==1, 48 | if revision==0, 49 | SegyHeader.SegyFormatRevisionNumber=0; 50 | else 51 | SegyHeader.SegyFormatRevisionNumber=100; 52 | end 53 | SegymatVerbose([mfilename,' : Using SEG Y revision ',num2str(revision)]) 54 | end 55 | 56 | if exist('dsf'), 57 | SegyHeader.DataSampleFormat=dsf; 58 | SegymatVerbose([mfilename,' : Using Data Sample Format ',num2str(dsf)]) 59 | end 60 | 61 | 62 | 63 | 64 | segyid = fopen(filename,'w','b'); % ALL DISK FILES ARE IN BIG 65 | % ENDIAN FORMAT, ACCORDING SEG 66 | % Y rev 1 67 | 68 | % JUST SOME INFORMATION TO WRITE TO SCREEN : 69 | Revision=SegyHeader.SegyFormatRevisionNumber; 70 | if Revision>0, Revision=1; end 71 | %Format=SegyHeader.Rev(Revision+1).DataSampleFormat(SegyHeader.DataSampleFormat).name; 72 | %txt=['SegyRevision ',sprintf('%0.4g',Revision),', ',Format,'(',num2str(SegyHeader.DataSampleFormat),')']; 73 | txt=''; 74 | 75 | SegyHeader=PutSegyHeader(segyid,SegyHeader); 76 | 77 | ntraces=size(Data,2); 78 | hw=waitbar(0,['Writing to SEGY-file : ',filename,' - ',txt]); 79 | 80 | 81 | for i=1:ntraces; 82 | if (i/100)==round(i/100), 83 | SegymatVerbose(['writing trace ',num2str(i),' of ',num2str(ntraces),', filepos=',num2str(ftell(segyid))]) 84 | waitbar(i/ntraces,hw) 85 | end 86 | PutSegyTrace(segyid,Data(:,i),SegyTraceHeaders(i),SegyHeader); 87 | 88 | end 89 | close(hw) 90 | fclose(segyid); 91 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/WriteSegyTraceHeaderValue.m: -------------------------------------------------------------------------------- 1 | % WriteSegyTraceHeaderValue : Write trace header valaue at specific location 2 | % 3 | % Call: 4 | % 5 | % % Update all trace header values starting at position 72, in integer32 6 | % % format, to the value 30 7 | % data=30; 8 | % WriteSegyTraceHeaderValue(filename,data,'pos',72,'precision','int32',); 9 | % 10 | % % Update all trace header values starting at position 72, in integer32 11 | % % format, to the values in array 'data' 12 | % ntraces=311; 13 | % data=[1:1:311]*10; 14 | % WriteSegyTraceHeaderValue(filename,data,'pos',72,'precision','int32'); 15 | % d_header=ReadSegyTraceHeaderValue(filename,'pos',72,'precision','int32'); 16 | % 17 | % % Update the 'cdp' TraceHeader value: 18 | % cdp=ReadSegyTraceHeaderValue(file,'key','cdp'); % READ CDP 19 | % cdp=cdp+10; % change CDP 20 | % WriteSegyTraceHeaderValue(file,cdp,'key','cdp'); % UPDATE CDP 21 | % 22 | % Call 'TraceHeaderDef(1)' to see a list of TraceHeader 'key' names 23 | % 24 | % See also ReadSegyTraceHeaderValue, PutSegyTraceHeader, TraceHeaderDef 25 | % 26 | 27 | function dread=WriteSegyTraceHeaderValue(filename,data,varargin);%pos,type) 28 | 29 | pos=0; 30 | precision='int32'; 31 | 32 | ninput=length(varargin); 33 | % TRANSFORM VARARGING INTO PARAMETERS 34 | cargin=1; 35 | while (cargin0, Revision=1; end 96 | if (SegyHeader.DataSampleFormat>length(SegyHeader.Rev(Revision+1).DataSampleFormat)); 97 | SegymatVerbose([mfilename,' : WARNING : YOU HAVE SELECTED (OR THE FILE IS FORMATTED SUCH THAT) A DATASAMPLE FORMAT THAT IS NOT DEFINED. \nREMEBER IEEE IS NOT SPECIFIED IN THE SEGY REV0 STANDARD !']) 98 | if (Revision==0) 99 | SegymatVerbose([mfilename,' : TRYING TO USE REVISION 1 AS OPPOSED TO REVISION 0']) 100 | Revision=1; 101 | if (SegyHeader.DataSampleFormat>length(SegyHeader.Rev(Revision+1).DataSampleFormat)); 102 | SegymatVerbose([mfilename,' : FATAL ERROR : STILL THE DATASAMPLE FORMAT IS NOT SUPPRTED - EXITING (Report error to tmh@gfy.ku.dk)']) 103 | else 104 | SegymatVerbose([mfilename,' : APPARENT SUCCES CHANING FROM Revision 0 to 1 - Continuing']) 105 | SegyHeader.SegyFormatRevisionNumber=1; % FORCING REVISION TO BE 1 !!! 106 | end 107 | end 108 | end 109 | 110 | FormatName=SegyHeader.Rev(Revision+1).DataSampleFormat(SegyHeader.DataSampleFormat).name; 111 | Format=SegyHeader.Rev(Revision+1).DataSampleFormat(SegyHeader.DataSampleFormat).format; 112 | BPS=SegyHeader.Rev(Revision+1).DataSampleFormat(SegyHeader.DataSampleFormat).bps; 113 | txt=['SegyRevision ',sprintf('%0.4g',Revision),', ',FormatName,'(',num2str(SegyHeader.DataSampleFormat),')']; 114 | 115 | 116 | fseek(segyid,0,'eof'); DataEnd=ftell(segyid); 117 | 118 | DataStart=3600+3200*SegyHeader.NumberOfExtTextualHeaders; 119 | fseek(segyid,DataStart,'bof'); % Go to the beginning of the file 120 | 121 | ntraces=(DataEnd-DataStart)./(240+(SegyHeader.ns)*(BPS/8)); 122 | 123 | hval=zeros(1,SegyHeader.ntraces); 124 | for itrace=1:SegyHeader.ntraces 125 | if ((itrace/1000)==round(itrace/1000)) 126 | progress_txt(itrace,ntraces,'Trace #') 127 | end 128 | 129 | %GOTO START OF TRACE HEADER 130 | skip=DataStart+(itrace-1)*(240+(BPS/8)*SegyHeader.ns); 131 | fseek(segyid,skip,'bof'); 132 | fseek(segyid,pos,'cof'); 133 | if length(data)==1; 134 | d_trace=data; 135 | else 136 | d_trace=data(itrace); 137 | end 138 | fwrite(segyid,d_trace,precision); 139 | 140 | end 141 | 142 | if nargout>0 143 | dread=ReadSegyTraceHeaderValue(filename,varargin); 144 | end 145 | 146 | fclose(segyid); -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/WriteSu.m: -------------------------------------------------------------------------------- 1 | % WriteSu : writes data to disk using SEGY REV 2 standard. 2 | % 3 | % EX 4 | % WriteSu('datacube.su',data,'dt',.004,'Inline3D',Inline,'Crossline3D',Crossline,'cdpX',X,'cdpY',Y); 5 | % 6 | % to use a specific SEG revision use : 7 | % WriteSu('test.su',seisdata,'revision',0); % SEG-Y Revision 0 8 | % WriteSu('test.su',seisdata,'revision',1); % SEG-Y Revision 1 9 | % 10 | % to use a specific Data Sampling Format use : 11 | % WriteSu('test.su',seisdata,'dsf',1); % IBM FLAOTING POINT 12 | % 13 | % Forice Revision 1 and IEEE Floating point : 14 | % WriteSu('test.su',seisdata,'dsf',5,'revision',1); 15 | % 16 | 17 | % 18 | % (C) 2001-2004, Thomas Mejer Hansen, thomas@cultpenguin.com 19 | % 20 | % This program is free software; you can redistribute it and/or modify 21 | % it under the terms of the GNU General Public License as published by 22 | % the Free Software Foundation; either version 2 of the License, or 23 | % (at your option) any later version. 24 | % 25 | % This program is distributed in the hope that it will be useful, 26 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 27 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 28 | % GNU General Public License for more details. 29 | % 30 | % You should have received a copy of the GNU General Public License 31 | % along with this program; if not, write to the Free Software 32 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 33 | % 34 | function WriteSu(filename,data,varargin); 35 | 36 | [ns,ntraces]=size(data); 37 | 38 | if exist('dt')~=1 39 | dt=0.004; 40 | SegymatVerbose([mfilename,' - No dt set. Using dt=',num2str(dt)]) 41 | end 42 | 43 | for i=1:2:length(varargin) 44 | var=varargin{i}; 45 | val=varargin{i+1}; 46 | eval([var,'=[',num2str(val),'];']); 47 | end 48 | 49 | 50 | SegyHeader.SegyFormatRevisionNumber=100; 51 | SegyHeader.DataSampleFormat=5; 52 | 53 | SegyHeader.Rev=GetSegyHeaderBasics; 54 | 55 | % UNCOMMENT THE FOLLOWING TWO LINES TO USE REVISION 1 (2002) 56 | %SegyHeader.SegyFormatRevisionNumber=100; % 2002 SEG Y STYLE 57 | %SegyHeader.DataSampleFormat=2; % '1'->4-byte IBM floating point 58 | % '2'->4-byte two's complement integer 59 | % '3'->2-byte two's complement integer 60 | % '5'->4-byte IEEE floating point (default) 61 | % '8'->1-byte two's complement integer 62 | 63 | % UNCOMMENT THE FOLLOWING TWO LINES TO USE REVISION 0 (1975) 64 | %SegyHeader.SegyFormatRevisionNumber=0; % 1975 SEoG Y STYLE 65 | %SegyHeader.DataSampleFormat=1; % '1'->4-byte IBM Floating Point 66 | 67 | 68 | 69 | % OPEN SEGY FILE HANDLE 70 | segyid = fopen(filename,'w'); 71 | % segyid = fopen(filename,'w','b'); % BIG ENDIAN 72 | 73 | SegyTraceHeader=InitSegyTraceHeader(ns,dt*1e+6); 74 | for i=1:ntraces; 75 | if (i/100)==round(i/100),SegymatVerbose(['writing trace ',num2str(i),' of ',num2str(ntraces)],1),end 76 | % Basic TraceHeader information 77 | %SegyTraceHeader.ns=ns; 78 | %SegyTraceHeader.dt=dt.*1e+6; 79 | % Update TraceHeader information if available 80 | if exist('cdpX')==1,SegyTraceHeader.cdpX = cdpX(i);end 81 | if exist('offset')==1,SegyTraceHeader.offset = offset(i);end 82 | if exist('cdpY')==1,SegyTraceHeader.cdpY = cdpY(i);end 83 | if exist('Inline3D')==1,SegyTraceHeader.Inline3D = Inline3D(i);end 84 | if exist('Crossline3D')==1,SegyTraceHeader.Crossline3D=Crossline3D(i);end 85 | % Write the Trace 86 | PutSegyTrace(segyid,data(:,i),SegyTraceHeader,SegyHeader); 87 | end 88 | 89 | % CLOSE SEGY FILE HANDLE 90 | 91 | fclose(segyid); 92 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/WriteSuStructure.m: -------------------------------------------------------------------------------- 1 | % WriteSuStructure : writes data to disk using SU-CWP format 2 | % 3 | % EX 4 | % WriteSuStructure('datacube.segy',SegyHeader,SegyTraceHeaders,Data); 5 | 6 | % 7 | % (C) 2001-2004 Thomas Mejer Hansen, tmh@gfy.ku.dk/thomas@cultpenguin.com 8 | % 9 | % This program is free software; you can redistribute it and/or modify 10 | % it under the terms of the GNU General Public License as published by 11 | % the Free Software Foundation; either version 2 of the License, or 12 | % (at your option) any later version. 13 | % 14 | % This program is distributed in the hope that it will be useful, 15 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | % GNU General Public License for more details. 18 | % 19 | % You should have received a copy of the GNU General Public License 20 | % along with this program; if not, write to the Free Software 21 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | % 23 | % 24 | function WriteSuStructure(filename,SegyHeader,SegyTraceHeaders,Data) 25 | 26 | 27 | segyid = fopen(filename,'w'); % USE LOCAL ENDIAN FLAG, 28 | % I.E. ENDIAN FORMAT NOT SPECIFIED 29 | % segyid = fopen(filename,'w','b'); % BIG ENDIAN 30 | 31 | 32 | 33 | % FORCE THE USE OF IEEE 34 | SegyHeader.SegyFormatRevisionNumber=100; 35 | SegyHeader.DataSampleFormat=5; % IEEE 36 | 37 | 38 | ntraces=size(Data,2); 39 | hw=waitbar(0,['Writing to SU-file : ',filename]); 40 | for i=1:ntraces; 41 | if (i/200)==round(i/200), 42 | SegymatVerbose(['writing trace ',num2str(i),' of ',num2str(ntraces),', filepos=',num2str(ftell(segyid))],1) 43 | SegymatVerbose(SegyTraceHeaders(i).ns,1) 44 | end 45 | PutSegyTrace(segyid,Data(:,i),SegyTraceHeaders(i),SegyHeader); 46 | waitbar(i/ntraces,hw); 47 | end 48 | close(hw) 49 | fclose(segyid); 50 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/ascii2ebcdic.m: -------------------------------------------------------------------------------- 1 | % ascii2ebcdic : Converts ASCII formatted text to EBCDIC formatted text 2 | % 3 | % CALL : ebcdic=ascii2ebcdic(ascii); 4 | % 5 | % ascii : Array on unsigned integers 6 | % ebcdic : Array on unsigned integers 7 | % 8 | % (C) 2002-2009, Thomas Mejer Hansen, tmh@gfy.ku.dk/thomas.mejer.hansen@gmail.com 9 | % 10 | 11 | % 12 | % This program is free software; you can redistribute it and/or modify 13 | % it under the terms of the GNU General Public License as published by 14 | % the Free Software Foundation; either version 2 of the License, or 15 | % (at your option) any later version. 16 | % 17 | % This program is distributed in the hope that it will be useful, 18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | % GNU General Public License for more details. 21 | % 22 | % You should have received a copy of the GNU General Public License 23 | % along with this program; if not, write to the Free Software 24 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 25 | % 26 | function ebcdic=ascii2ebcdic(ascii) 27 | 28 | ebcdic_arr=[ 29 | '00';'01';'02';'03';'04';'05';'06';'07';'08';'09'; 30 | '0A';'0B';'0C';'0D';'0E';'0F';'10';'11';'12';'13'; 31 | '14';'15';'16';'17';'18';'19';'1A';'1B';'1C';'1D'; 32 | '1E';'1F';'20';'21';'22';'23';'24';'25';'26';'27'; 33 | '28';'29';'2A';'2B';'2C';'2D';'2E';'2F';'30';'31'; 34 | '32';'33';'34';'35';'36';'37';'38';'39';'3A';'3B'; 35 | '3C';'3D';'3E';'3F';'40';'4A';'4B';'4C';'4D';'4E'; 36 | '4F';'50';'5A';'5B';'5C';'5D';'5E';'5F';'60';'61'; 37 | '6A';'6B';'6C';'6D';'6E';'6F';'79';'7A';'7B';'7C'; 38 | '7D';'7E';'7F';'81';'82';'83';'84';'85';'86';'87'; 39 | '88';'89';'91';'92';'93';'94';'95';'96';'97';'98'; 40 | '99';'A1';'A2';'A3';'A4';'A5';'A6';'A7';'A8';'A9'; 41 | 'C0';'C1';'C2';'C3';'C4';'C5';'C6';'C7';'C8';'C9'; 42 | 'D0';'D1';'D2';'D3';'D4';'D5';'D6';'D7';'D8';'D9'; 43 | 'E0';'E2';'E3';'E4';'E5';'E6';'E7';'E8';'E9';'F0'; 44 | 'F1';'F2';'F3';'F4';'F5';'F6';'F7';'F8';'F9';'FF'; 45 | '00';'01';'02';'03';'37';'2D';'2E';'2F';'2F';'16'; 46 | '05';'25';'0B';'0C';'0D';'10';'11';'12';'13';'3C'; 47 | '3D';'32';'26';'18';'3F';'27';'1C';'1D';'1D';'1E'; 48 | '1F';'07';'40';'5A';'7F';'7B';'5B';'6C';'50';'7D'; 49 | '4D';'5D';'5C';'4E';'6B';'60';'4B';'61';'F0';'F1'; 50 | 'F2';'F3';'F4';'F5';'F6';'F7';'F8';'F9';'7A';'5E'; 51 | '4C';'7E';'6E';'6F';'7C';'00';'E0';'00';'00';'6D'; 52 | '79';'C0';'4F';'D0';'A1']; 53 | 54 | ascii_arr=[ 55 | '00';'01';'02';'03';'9C';'09';'86';'7F';'97';'8D'; 56 | '8E';'0B';'0C';'0D';'0E';'0F';'10';'11';'12';'13'; 57 | '9D';'85';'08';'87';'18';'19';'92';'8F';'1C';'1D'; 58 | '1E';'1F';'80';'81';'82';'83';'84';'0A';'17';'1B'; 59 | '88';'89';'8A';'8B';'8C';'05';'06';'07';'90';'91'; 60 | '16';'93';'94';'95';'96';'04';'98';'99';'9A';'9B'; 61 | '14';'15';'9E';'1A';'20';'A2';'2E';'3C';'28';'2B'; 62 | '7C';'26';'21';'24';'2A';'29';'3B';'AC';'2D';'2F'; 63 | 'A6';'2C';'25';'5F';'3E';'3F';'60';'3A';'23';'40'; 64 | '27';'3D';'22';'61';'62';'63';'64';'65';'66';'67'; 65 | '68';'69';'6A';'6B';'6C';'6D';'6E';'6F';'70';'71'; 66 | '72';'7E';'73';'74';'75';'76';'77';'78';'79';'7A'; 67 | '7B';'41';'42';'43';'44';'45';'46';'47';'48';'49'; 68 | '7D';'4A';'4B';'4C';'4D';'4E';'4F';'50';'51';'52'; 69 | '5C';'53';'54';'55';'56';'57';'58';'59';'5A';'30'; 70 | '31';'32';'33';'34';'35';'36';'37';'38';'39';'9F'; 71 | '00';'01';'02';'03';'04';'05';'06';'07';'07';'08'; 72 | '09';'0A';'0B';'0C';'0D';'10';'11';'12';'13';'14'; 73 | '15';'16';'17';'18';'1A';'1B';'1C';'1D';'1D';'1E'; 74 | '1F';'7F';'20';'21';'22';'23';'24';'25';'26';'27'; 75 | '28';'29';'2A';'2B';'2C';'2D';'2E';'2F';'30';'31'; 76 | '32';'33';'34';'35';'36';'37';'38';'39';'3A';'3B'; 77 | '3C';'3D';'3E';'3F';'40';'5B';'5C';'5D';'5E';'5F'; 78 | '60';'7B';'7C';'7D';'7E' 79 | ]; 80 | 81 | ascii_dec_array=hex2dec(ascii_arr); 82 | 83 | ebcdic_dec_array=hex2dec(ebcdic_arr); 84 | 85 | 86 | for i=1:length(ascii) 87 | m=find(ascii_dec_array==ascii(i)); 88 | if length(m)>1, 89 | m=m(1); 90 | end 91 | if length(m)==0, 92 | ebcdic(i)=0; 93 | else 94 | ebcdic(i)=(ebcdic_dec_array(m)); 95 | end 96 | end 97 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/cmap_rwb.m: -------------------------------------------------------------------------------- 1 | function cmap=cmap_rwb 2 | col(1,:)=[1 0 0]; 3 | col(2,:)=[1 1 1]; 4 | col(3,:)=[0 0 0]; 5 | 6 | N=20; 7 | for i=1:3; 8 | cmap1(1:N,i)=linspace(col(1,i),col(2,i),N); 9 | cmap2(1:N,i)=linspace(col(2,i),col(3,i),N); 10 | end 11 | cmap=[cmap1;cmap2(2:N,:)]; 12 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/ebcdic2ascii.m: -------------------------------------------------------------------------------- 1 | % ebcdic2ascii : Converts EBCDIC formatted text to ASCII formatted text 2 | % 3 | % CALL : ascii=ebcdic2ascii(ebcdic); 4 | % 5 | % ebcdic : Array on unsigned integers 6 | % ascii : Array on unsigned integers 7 | % 8 | % (C) 2002-2004, Thomas Mejer Hansen, tmh@gfy.ku.dk/thomas@cultpenguin.com 9 | % 10 | 11 | % 12 | % This program is free software; you can redistribute it and/or modify 13 | % it under the terms of the GNU General Public License as published by 14 | % the Free Software Foundation; either version 2 of the License, or 15 | % (at your option) any later version. 16 | % 17 | % This program is distributed in the hope that it will be useful, 18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | % GNU General Public License for more details. 21 | % 22 | % You should have received a copy of the GNU General Public License 23 | % along with this program; if not, write to the Free Software 24 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 25 | % 26 | function ascii=ebcdic2ascii(ebcdic) 27 | 28 | ebcdic_arr=[ 29 | '00';'01';'02';'03';'04';'05';'06';'07';'08';'09'; 30 | '0A';'0B';'0C';'0D';'0E';'0F';'10';'11';'12';'13'; 31 | '14';'15';'16';'17';'18';'19';'1A';'1B';'1C';'1D'; 32 | '1E';'1F';'20';'21';'22';'23';'24';'25';'26';'27'; 33 | '28';'29';'2A';'2B';'2C';'2D';'2E';'2F';'30';'31'; 34 | '32';'33';'34';'35';'36';'37';'38';'39';'3A';'3B'; 35 | '3C';'3D';'3E';'3F';'40';'4A';'4B';'4C';'4D';'4E'; 36 | '4F';'50';'5A';'5B';'5C';'5D';'5E';'5F';'60';'61'; 37 | '6A';'6B';'6C';'6D';'6E';'6F';'79';'7A';'7B';'7C'; 38 | '7D';'7E';'7F';'81';'82';'83';'84';'85';'86';'87'; 39 | '88';'89';'91';'92';'93';'94';'95';'96';'97';'98'; 40 | '99';'A1';'A2';'A3';'A4';'A5';'A6';'A7';'A8';'A9'; 41 | 'C0';'C1';'C2';'C3';'C4';'C5';'C6';'C7';'C8';'C9'; 42 | 'D0';'D1';'D2';'D3';'D4';'D5';'D6';'D7';'D8';'D9'; 43 | 'E0';'E2';'E3';'E4';'E5';'E6';'E7';'E8';'E9';'F0'; 44 | 'F1';'F2';'F3';'F4';'F5';'F6';'F7';'F8';'F9';'FF'; 45 | '00';'01';'02';'03';'37';'2D';'2E';'2F';'2F';'16'; 46 | '05';'25';'0B';'0C';'0D';'10';'11';'12';'13';'3C'; 47 | '3D';'32';'26';'18';'3F';'27';'1C';'1D';'1D';'1E'; 48 | '1F';'07';'40';'5A';'7F';'7B';'5B';'6C';'50';'7D'; 49 | '4D';'5D';'5C';'4E';'6B';'60';'4B';'61';'F0';'F1'; 50 | 'F2';'F3';'F4';'F5';'F6';'F7';'F8';'F9';'7A';'5E'; 51 | '4C';'7E';'6E';'6F';'7C';'00';'E0';'00';'00';'6D'; 52 | '79';'C0';'4F';'D0';'A1']; 53 | 54 | ascii_arr=[ 55 | '00';'01';'02';'03';'9C';'09';'86';'7F';'97';'8D'; 56 | '8E';'0B';'0C';'0D';'0E';'0F';'10';'11';'12';'13'; 57 | '9D';'85';'08';'87';'18';'19';'92';'8F';'1C';'1D'; 58 | '1E';'1F';'80';'81';'82';'83';'84';'0A';'17';'1B'; 59 | '88';'89';'8A';'8B';'8C';'05';'06';'07';'90';'91'; 60 | '16';'93';'94';'95';'96';'04';'98';'99';'9A';'9B'; 61 | '14';'15';'9E';'1A';'20';'A2';'2E';'3C';'28';'2B'; 62 | '7C';'26';'21';'24';'2A';'29';'3B';'AC';'2D';'2F'; 63 | 'A6';'2C';'25';'5F';'3E';'3F';'60';'3A';'23';'40'; 64 | '27';'3D';'22';'61';'62';'63';'64';'65';'66';'67'; 65 | '68';'69';'6A';'6B';'6C';'6D';'6E';'6F';'70';'71'; 66 | '72';'7E';'73';'74';'75';'76';'77';'78';'79';'7A'; 67 | '7B';'41';'42';'43';'44';'45';'46';'47';'48';'49'; 68 | '7D';'4A';'4B';'4C';'4D';'4E';'4F';'50';'51';'52'; 69 | '5C';'53';'54';'55';'56';'57';'58';'59';'5A';'30'; 70 | '31';'32';'33';'34';'35';'36';'37';'38';'39';'9F'; 71 | '00';'01';'02';'03';'04';'05';'06';'07';'07';'08'; 72 | '09';'0A';'0B';'0C';'0D';'10';'11';'12';'13';'14'; 73 | '15';'16';'17';'18';'1A';'1B';'1C';'1D';'1D';'1E'; 74 | '1F';'7F';'20';'21';'22';'23';'24';'25';'26';'27'; 75 | '28';'29';'2A';'2B';'2C';'2D';'2E';'2F';'30';'31'; 76 | '32';'33';'34';'35';'36';'37';'38';'39';'3A';'3B'; 77 | '3C';'3D';'3E';'3F';'40';'5B';'5C';'5D';'5E';'5F'; 78 | '60';'7B';'7C';'7D';'7E' 79 | ]; 80 | 81 | ascii_dec_array=hex2dec(ascii_arr); 82 | 83 | ebcdic_dec_array=hex2dec(ebcdic_arr); 84 | 85 | 86 | for i=1:length(ebcdic) 87 | m=find(ebcdic_dec_array==ebcdic(i)); 88 | if length(m)>1, 89 | m=m(1); 90 | end 91 | if length(m)==0, 92 | ascii(i)=0; 93 | else 94 | ascii(i)=(ascii_dec_array(m)); 95 | end 96 | end 97 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/f11_02673_45Hz.segy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seg/tutorials-2014/aab1cf917bc4b223e1061d2984aa1bce4bc41a1c/1410_Phase/SegyMAT/f11_02673_45Hz.segy -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/gse2segy.m: -------------------------------------------------------------------------------- 1 | function file_out=gse2segy(file_in,file_out); 2 | 3 | if nargin<2 4 | [p,f]=fileparts(file_in); 5 | file_out=[f,'.sgy']; 6 | end 7 | 8 | GSE = read_gse_int(file_in); 9 | 10 | for i=1:length(GSE) 11 | YearDataRecorded(i)=GSE{i}.year; 12 | DayOfYear(i)=GSE{i}.day; 13 | HourOfDay(i)=GSE{i}.hour; 14 | MinuteOfOur(i)=GSE{i}.minute; 15 | SecondOfMinute(i)=GSE{i}.second; 16 | TimeBaseCode(i) = 1; %Local(1), GMT(2); other(3), UTC(4) 17 | data(:,i)=GSE{i}.data(:); 18 | end 19 | dt=GSE{1}.dt; 20 | WriteSegy(file_out,data, 'dt',dt,'YearDataRecorded',YearDataRecorded,... 21 | 'DayOfYear',DayOfYear,... 22 | 'HourOfDay',HourOfDay,... 23 | 'MinuteOfOur',MinuteOfOur,... 24 | 'SecondOfMinute',SecondOfMinute,... 25 | 'TimeBaseCode',TimeBaseCode); 26 | 27 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/ibm2num.m: -------------------------------------------------------------------------------- 1 | function x=ibm2num(b) 2 | % ibm2num : convert IBM 32 bit floating point format to doubles 3 | % x=num2ibm(b) 4 | % b is a matrix of uint32 5 | % x is a corresponding matrix of doubles 6 | % 7 | % 8 | % See also num2ibm 9 | 10 | % 11 | % This program is free software; you can redistribute it and/or modify 12 | % it under the terms of the GNU General Public License as published by 13 | % the Free Software Foundation; either version 2 of the License, or 14 | % (at your option) any later version. 15 | % 16 | % This program is distributed in the hope that it will be useful, 17 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | % GNU General Public License for more details. 20 | % 21 | % You should have received a copy of the GNU General Public License 22 | % along with this program; if not, write to the Free Software 23 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | % 25 | % 26 | % (C) Brian Farrelly, 22 October 2001 27 | % mailto:Brian.Farrelly@nho.hydro.com Norsk Hydro Research Centre 28 | % phone +47 55 99 68 74 ((( Postboks 7190 29 | % fax +47 55 99 69 70 2oooS N-5020 Bergen 30 | % home +47 55 13 78 49 HYDRO Norway 31 | % 32 | 33 | 34 | 35 | x=repmat(NaN,size(b)); 36 | 37 | sign=bitget(b,32); % get sign from first bit 38 | sign=double(sign); 39 | 40 | % format hex 41 | exp=bitand(b,uint32(hex2dec('7f000000'))); % get exponent from first byte, last 7 bits 42 | exp=bitshift(exp,-24); 43 | %format long 44 | 45 | exp=double(exp)- 64; % remove bias from exponent 46 | 47 | %format hex 48 | frac=bitand(b,uint32(hex2dec('00ffffff'))); % get mantissa from last 3 bytes 49 | %format long 50 | frac=double(frac); 51 | frac=frac/2^24; 52 | 53 | 54 | x=(1-2*sign).*16.^exp .* frac; 55 | 56 | err = frac==0 & (exp~=-64 | sign~=0); % bias removal is incorrect for zero 57 | if any(err) 58 | % TMH 19/06/2003 59 | disp(['WARNING : ',mfilename,' Invalid zero input --> Sure data are IBM FLOAT formatted ?']) 60 | return; 61 | %warning('Invalid zero input in ibm2num for the following:') 62 | % format hex; disp(b(err)); format 63 | end 64 | 65 | err = frac~=0 & (frac<1/16 | frac>=1); 66 | if any(err) 67 | % TMH 19/06/2003 68 | disp(['WARNING : ',mfilename,' Invalid mantissa input --> Sure data are IBM FLOAT formatted ?']) 69 | return; 70 | % warning('Invalid mantissa input in ibm2num for the following:') 71 | % format hex; disp(b(err)); format 72 | end 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/isoctave.m: -------------------------------------------------------------------------------- 1 | % isoctave : checks of octave 2 | function r=isoctave 3 | v=version; 4 | if (str2num(v(1)))>4 5 | r=0; 6 | else 7 | r=1; 8 | end 9 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/num2ibm.m: -------------------------------------------------------------------------------- 1 | function b=num2ibm(x) 2 | % num2ibm : convert IEEE 754 doubles to IBM 32 bit floating point format 3 | % b=num2ibm(x) 4 | % x is a matrix of doubles 5 | % b is a corresponding matrix of uint32 6 | % 7 | % The representations for NaN and inf are arbitrary 8 | % 9 | % See also ibm2num 10 | 11 | % 12 | % This program is free software; you can redistribute it and/or modify 13 | % it under the terms of the GNU General Public License as published by 14 | % the Free Software Foundation; either version 2 of the License, or 15 | % (at your option) any later version. 16 | % 17 | % This program is distributed in the hope that it will be useful, 18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | % GNU General Public License for more details. 21 | % 22 | % You should have received a copy of the GNU General Public License 23 | % along with this program; if not, write to the Free Software 24 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 25 | % 26 | % 27 | % (C) Brian Farrelly, 22 October 2001 28 | % mailto:Brian.Farrelly@nho.hydro.com Norsk Hydro Research Centre 29 | % phone +47 55 99 68 74 ((( Postboks 7190 30 | % fax +47 55 99 69 70 2oooS N-5020 Bergen 31 | % home +47 55 13 78 49 HYDRO Norway 32 | % 33 | 34 | b=repmat(uint32(0),size(x)); 35 | err=zeros(size(x)); 36 | 37 | %format long 38 | 39 | x(x> 7.236998675585915e+75)= inf; % change big numbers to infinity 40 | x(x<-7.236998675585915e+75)=-inf; % 7.236998675585915e+75 is 41 | % ibm2num(uint32(hex2dec('7fffffff')) or 42 | % ibm2num(num2ibm(inf)) 43 | 44 | [F E]=log2(abs(x)); 45 | 46 | e=E/4; % exponent of base 16 47 | ec=ceil(e); % adjust upwards to integer 48 | p=ec+64; % offset exponent 49 | 50 | f=F.*2.^(-4*(ec-e)); % correct mantissa for fractional part of exponent 51 | f=round(f*2^24); % convert to integer. Roundoff here can be as large as 52 | % 0.5/2^20 when mantissa is close to 1/16 so that 53 | % 3 bits of signifance are lost. 54 | 55 | p(f==2^24)=p(f==2^24)+1; % Roundoff can cause f to be 2^24 for numbers just under a 56 | f(f==2^24)=2^20; % power of 16, so correct for this 57 | 58 | %format hex 59 | psi=uint32(p*2^24); % put exponent in first byte of psi. 60 | phi=uint32(f); % put mantissa into last 3 bytes of phi 61 | 62 | % make bit representation 63 | 64 | b=bitor(psi,phi); % exponent and mantissa 65 | b(x<0)=bitset(b(x<0),32); % sign bit 66 | %format long 67 | 68 | % special cases 69 | 70 | b(x==0) =uint32(0) ; % bias is incorrect for zero 71 | b(isnan(x)) =uint32(hex2dec('7fffffff')); % 7.237005145973116e+75 in IBM format 72 | b(isinf(x) & x>0)=uint32(hex2dec('7ffffff0')); % 7.236998675585915e+75 ,, 73 | b(isinf(x) & x<0)=uint32(hex2dec('fffffff0')); % -7.236998675585915e+75 ,, 74 | % Note that NaN > inf in IBM format 75 | 76 | % check bit representation for normal cases 77 | 78 | checkx=ibm2num(b); % note that use of base 16 in IBM format 79 | z=x==0; % can lead to a loss of 3 bits of precision 80 | err(z)=0; % compared with an IEEE single. 81 | q=(checkx(~z)-x(~z))./x(~z); 82 | err(~z) = abs(q) > 5e-7; % this is almost reached with numbers 83 | % of the form 16^n + 0.5*16^(n-5) where 84 | % the mantissa is 100001 hex. Roundoff 85 | % error is then 0.5/16^5=0.5/2^20=4.7684e-7 86 | 87 | 88 | if any(err) 89 | warning('Conversion error in num2ibm for the following:') 90 | disp(x(logical(err))) 91 | end 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/pick_line.m: -------------------------------------------------------------------------------- 1 | % pick_line : pick a line from a figure; 2 | % 3 | % 4 | % Based on doc(ginput); 5 | 6 | function [xy,xys]=pick_line(name,LineWidth,LineColor); 7 | 8 | 9 | if nargin<1, name='line';end 10 | if nargin<2, LineWidth=3;end 11 | if nargin<3, LineColor=[1 1 0];end 12 | 13 | hold on 14 | % Initially, the list of points is empty. 15 | xy = []; 16 | n = 0; 17 | % Loop, picking up the points. 18 | disp('Left mouse button picks points.') 19 | disp('Right mouse button picks last point.') 20 | but = 1; 21 | while but == 1 22 | [xi,yi,but] = ginput(1); 23 | n = n+1; 24 | xy(:,n) = [xi;yi]; 25 | if n ==1; 26 | p=plot(xy(1),xy(2),'-','LineWidth',LineWidth,'Color',LineColor); 27 | p_point=plot(xy(1),xy(2),'*','LineWidth',LineWidth,'Color',LineColor); 28 | else 29 | set(p_point,'Xdata',xy(1,:)); 30 | set(p_point,'Ydata',xy(2,:)); 31 | 32 | try 33 | %SPLINE INTERPOLATION 34 | t = 1:n; 35 | ts = 1: 0.1: n; 36 | xys = spline(t,xy,ts); 37 | set(p,'Xdata',xys(1,:)); 38 | set(p,'Ydata',xys(2,:)); 39 | % p=plot(xy(1,:),xy(2,:),'w-'); 40 | end 41 | end 42 | drawnow; 43 | %plot(xi,yi,'ro') 44 | end 45 | 46 | hold off 47 | 48 | eval(sprintf('save %s.mat xy xys',name)); 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/progress_txt.m: -------------------------------------------------------------------------------- 1 | % progress_txt : console based progress bar 2 | % 3 | % Ex1 : 4 | % for i=1:10000; 5 | % progress_txt(i,10000,'Ciao'); 6 | % end 7 | % 8 | % Ex1 : 9 | % 10 | % for i=1:10; 11 | % for j=1:10; 12 | % for k=1:10; 13 | % progress_txt([i j k],[10 100 1000],'i','j','k'); 14 | % end 15 | % end 16 | % end 17 | % 18 | % TMH/2005, thomas@cultpenguin.com 19 | % 20 | function progress_txt(i,max,varargin); 21 | 22 | if nargin==0 23 | help progress_txt 24 | return; 25 | end 26 | 27 | ncols=length(i); 28 | 29 | % 30 | nchar=45; 31 | 32 | % 33 | pc=i./max; 34 | 35 | % clear command window 36 | clc; 37 | 38 | for m=1:ncols 39 | 40 | try 41 | txt=varargin{m}; 42 | catch 43 | txt=''; 44 | end 45 | 46 | char_prog=''; 47 | for j=1:nchar 48 | if j<=(pc(m)*nchar); 49 | char_prog=[char_prog,'#']; 50 | else 51 | char_prog=[char_prog,'_']; 52 | end 53 | end 54 | disp(sprintf('%10s %s %3.1f%% %d/%d',txt,char_prog,100*pc(m),i(m),max(m))) 55 | 56 | end -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/read_gse_int.m: -------------------------------------------------------------------------------- 1 | function GSE=read_gse_int(filename); 2 | 3 | fid=fopen(filename,'r'); 4 | 5 | i=0; 6 | while ~feof(fid); 7 | i=i+1; 8 | SegymatVerbose(sprintf('Reading trace #%02d',i)) 9 | 10 | line1=fgetl(fid); 11 | 12 | try,GSE{i}.type=line1(45:47);end 13 | 14 | try,GSE{i}.year=str2num(line1(6:9));,end 15 | try,GSE{i}.month=str2num(line1(11:12));,end 16 | try,GSE{i}.day=str2num(line1(14:15));,end 17 | 18 | try,GSE{i}.hour=str2num(line1(17:18));,end 19 | try,GSE{i}.minute=str2num(line1(20:21));,end 20 | try,GSE{i}.second=str2num(line1(23:24));,end 21 | try,GSE{i}.mills=str2num(line1(26:28));,end 22 | try,GSE{i}.nspersec=str2num(line1(57:68));end 23 | try,GSE{i}.dt=1./GSE{i}.nspersec;end 24 | try;GSE{i}.ns=str2num(line1(52:56));end 25 | 26 | line2=fgetl(fid); 27 | line3=fgetl(fid); 28 | 29 | for j=1:GSE{i}.ns 30 | l=fgetl(fid); 31 | GSE{i}.data(j)=sscanf(l,'%f'); 32 | end 33 | 34 | %GSE{i}.data=fscanf(fid,'%f',GSE{i}.ns) 35 | 36 | line4=fgetl(fid); 37 | GSE{i}.CHK2=str2num(line4(6:length(line4))); 38 | 39 | end 40 | fclose(fid); -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/testWriteSegy.m: -------------------------------------------------------------------------------- 1 | % testWriteSegy : Script to test WriteSegy and WriteSegyStructure 2 | % 3 | n=200; 4 | seisdata=peaks(n); 5 | imagesc(seisdata);colorbar; 6 | xlabel('Traces'); 7 | ylabel('Time') 8 | title('The data that should be written to disk') 9 | 10 | % use WriteSegy to write an IEEE Revision 1 formatted file 11 | % 12 | WriteSegy('test.segy',seisdata); 13 | 14 | % Read the file we just created with all of its header values 15 | % 16 | [Data,SegyTraceHeaders,SegyHeader,HeaderInfo]=ReadSegy('test.segy'); 17 | 18 | % NOW WE CAN WRITE ALL THE FORMATS SUPPORTED BY SegyMAT : 19 | 20 | 21 | % WRITE IBM FLOATING POINT REV 0 22 | % THIS IS THE ONLY IMPLEMENTED FORMAT FOR REV 0 23 | SegyHeader.SegyFormatRevisionNumber=0; 24 | SegyHeader.DataSampleFormat=1; 25 | WriteSegyStructure('data_IBM_REV0.segy',SegyHeader,SegyTraceHeaders,Data); 26 | 27 | % WRITE IBM FLOATING POINT REV 1 28 | SegyHeader.SegyFormatRevisionNumber=100; 29 | SegyHeader.DataSampleFormat=1; 30 | WriteSegyStructure('data_IBM_REV1.segy',SegyHeader,SegyTraceHeaders,Data); 31 | 32 | 33 | % WRITE 4BYTE INT POINT REV 1 34 | SegyHeader.SegyFormatRevisionNumber=100; 35 | SegyHeader.DataSampleFormat=2; 36 | WriteSegyStructure('data_4byteINT.segy',SegyHeader,SegyTraceHeaders,Data); 37 | 38 | % WRITE 2BYTE INT POINT REV 1 39 | SegyHeader.SegyFormatRevisionNumber=100; 40 | SegyHeader.DataSampleFormat=3; 41 | WriteSegyStructure('data_2byteINT.segy',SegyHeader,SegyTraceHeaders,Data); 42 | 43 | % WRITE 1BYTE INT POINT REV 1 44 | SegyHeader.SegyFormatRevisionNumber=100; 45 | SegyHeader.DataSampleFormat=8; 46 | WriteSegyStructure('data_1byteINT.segy',SegyHeader,SegyTraceHeaders,Data); 47 | 48 | 49 | % WRITE IEEE POINT REV 1 50 | SegyHeader.SegyFormatRevisionNumber=100; 51 | SegyHeader.DataSampleFormat=5; 52 | WriteSegyStructure('data_IEEE.segy',SegyHeader,SegyTraceHeaders,Data); 53 | 54 | -------------------------------------------------------------------------------- /1410_Phase/SegyMAT/wiggle.m: -------------------------------------------------------------------------------- 1 | % wiggle : plot wiggle/VA/image plot 2 | % 3 | % Call 4 | % wiggle(Data); % wiggle plot 5 | % wiggle(Data,scale); % scaled wiggle plot 6 | % wiggle(x,t,Data); % wiggle plt 7 | % wiggle(x,t,Data,'VA') % variable Area (pos->black;neg->transp) 8 | % wiggle(x,t,Data,'VA2') % variable Area (pos->black;neg->red) 9 | % wiggle(x,t,Data,'wiggle',scale); % Scaled wiggle 10 | % wiggle(x,t,Data,'wiggle',scale,showmax); % Scaled wiggle and max 11 | % showmax traces. 12 | % wiggle(x,t,Data,'wiggle',scale,showmax,plimage); % wiggle + image 13 | % wiggle(x,t,Data,'wiggle',scale,showmax,plimage,caxis); % wiggle + 14 | % scaled image 15 | % 16 | % Data : [nt,ntraces] 17 | % x : [1:ntraces] X axis (ex [SegyTraceheaders.offset]) 18 | % t : [1:nt] Y axis 19 | % style : ['VA'] : Variable Area 20 | % ['wiggle'] : Wiggle plot 21 | % scale : scaling factor, can be left empty as [] 22 | % showmax [scalar] : max number of traces to show on display [def=100] 23 | % plimage [0/1] : Show image beneath wiggles [def=0]; 24 | % caxis [min max]/[scalar] : amplitude range for colorscale 25 | % 26 | % 27 | % MAKE IT WORK FOR ANY X-AXIS !!! 28 | % 29 | % 30 | 31 | % 32 | % (C) 2001-2004, Thomas Mejer Hansen, tmh@gfy.ku.dk/thomas@cultpenguin.com 33 | % 34 | % This program is free software; you can redistribute it and/or modify 35 | % it under the terms of the GNU General Public License as published by 36 | % the Free Software Foundation; either version 2 of the License, or 37 | % (at your option) any later version. 38 | % 39 | % This program is distributed in the hope that it will be useful, 40 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 41 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 42 | % GNU General Public License for more details. 43 | % 44 | % You should have received a copy of the GNU General Public License 45 | % along with this program; if not, write to the Free Software 46 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 47 | % 48 | % 49 | 50 | function wiggle(x,t,Data,style,dmax,showmax,plImage,imageax,ax_order,lineColor,example_plot); 51 | 52 | is_hold_on = ishold; 53 | 54 | 55 | if (nargin==11); 56 | np=3; 57 | subplot(np,np,1); wiggle(Data); 58 | subplot(np,np,2); wiggle(Data,dmax); 59 | subplot(np,np,3); wiggle(x,t,Data); 60 | subplot(np,np,4); wiggle(x,t,Data,style,dmax); 61 | subplot(np,np,5); wiggle(x,t,Data,style,dmax,showmax); 62 | subplot(np,np,6); wiggle(x,t,Data,style,dmax,showmax,plImage); 63 | if isempty(dmax), 64 | dmax=max(abs(Data(:))); 65 | end 66 | subplot(np,np,7); wiggle(x,t,Data,style,dmax,showmax,plImage,dmax./10); 67 | return 68 | end 69 | 70 | showmax_def=100; 71 | style_def='wiggle'; 72 | 73 | if nargin==1, 74 | Data=x; 75 | t=[1:1:size(Data,1)]; 76 | x=[1:1:size(Data,2)]; 77 | dmax=max(Data(:)); 78 | style=style_def; 79 | showmax=showmax_def; 80 | end 81 | 82 | 83 | if nargin==2, 84 | Data=x; 85 | dmax=t; 86 | t=[1:1:size(Data,1)]; 87 | x=[1:1:size(Data,2)]; 88 | style=style_def; 89 | showmax=showmax_def; 90 | end 91 | 92 | if nargin==3, 93 | style=style_def; 94 | dmax=max(abs(Data(:))); 95 | showmax=showmax_def; 96 | end 97 | 98 | if nargin==4, 99 | dmax=max(abs(Data(:))); 100 | showmax=showmax_def; 101 | end 102 | 103 | if nargin==5, 104 | showmax=showmax_def; 105 | end 106 | 107 | if nargin<7 108 | plImage=0; 109 | end 110 | 111 | if nargin<9 112 | ax_order=1; 113 | end 114 | 115 | if nargin<10 116 | lineColor=[0 0 0]; 117 | end 118 | 119 | 120 | if isempty(dmax), 121 | % Set scaling factor dmax if empty 122 | dmax=max(abs(Data(:))); 123 | end 124 | 125 | if isempty(showmax), 126 | showmax=100; 127 | end 128 | 129 | if nargin==7, 130 | imageax=[-1 1].*dmax; 131 | end 132 | 133 | 134 | 135 | if plImage==1, 136 | if ax_order==1; 137 | imagesc(x,t,Data); 138 | else 139 | imagesc(t,x,Data'); 140 | end 141 | if (length(imageax)==1) 142 | imageax=[-1 1].*abs(imageax); 143 | end 144 | caxis(imageax); 145 | hold on 146 | end 147 | 148 | if (showmax>0) 149 | if length(x)>1, 150 | dx=x(2)-x(1); 151 | else 152 | dx=1; 153 | end 154 | ntraces=length(x); 155 | ntraces=size(Data,2); 156 | d=ntraces/showmax; 157 | if d<=1; d=1; end 158 | d=round(d); 159 | 160 | dmax=dmax/d; 161 | 162 | LineWidth=0.0001; 163 | EdgeColor=lineColor; 164 | for i=1:d:ntraces 165 | xt=dx*Data(:,i)'./dmax; 166 | if (strmatch('VA',style)==1) 167 | xt1=xt;xt1(find(xt1>0))=0; 168 | 169 | xx=[xt,fliplr(xt1)]; 170 | tt=[t,fliplr(t)]; 171 | ii=find(~isnan(xx)); 172 | if ax_order==1; 173 | f1=fill(x(i)+xx(ii),tt(ii),lineColor); 174 | %f1=fill(x(i)+xx,tt,lineColor); 175 | else 176 | f1=fill(tt(ii),x(i)+xx(i),[lineColor]); 177 | %f1=fill(tt,x(i)+xx,[lineColor]); 178 | %f1=fill([t,fliplr(t)],x(i)+[xt,fliplr(xt1)],[lineColor]); 179 | end 180 | set(f1,'LineWidth',LineWidth) 181 | set(f1,'EdgeColor',EdgeColor) 182 | %set(f1,'EdgeAlpha',[0]); % GIVES ROCKY IMAGES 183 | hold on 184 | if (strmatch('VA2',style,'exact')==1) 185 | xt2=xt;xt2(find(xt2<0))=0; 186 | if ax_order==1; 187 | f2=fill(x(i)+[xt,fliplr(xt2)],[t,fliplr(t)],[1 0 0]); 188 | else 189 | f2=fill([t,fliplr(t)],x(i)+[xt,fliplr(xt2)],[1 0 0]); 190 | end 191 | set(f2,'LineWidth',LineWidth) 192 | set(f2,'EdgeColor',EdgeColor) 193 | %set(f2,'EdgeAlpha',[0]) 194 | end 195 | 196 | else 197 | 198 | % MATLAB PLOT 199 | if ax_order==1; 200 | 201 | plot(xt+x(i),t,'-','linewidth',.05,'color',lineColor); 202 | else 203 | plot(t,xt+x(i),'-','linewidth',.05,'color',lineColor); 204 | end 205 | %OCTAVE PLOT 206 | %plot(xt+x(i),t,'k-') 207 | end 208 | if i==1, hold on;end 209 | 210 | end 211 | 212 | 213 | end 214 | hold off; 215 | set(gca,'Ydir','reverse') 216 | 217 | if is_hold_on==1 218 | return; 219 | end 220 | 221 | try 222 | if ax_order==1; 223 | axis([min(x(1:ntraces))-(x(2)-x(1)) max(x(1:ntraces))+(x(2)-x(1)) min(t) max(t)]) 224 | else 225 | axis([min(t) max(t) min(x)-(x(2)-x(1)) max(x)+(x(2)-x(1)) ]) 226 | end 227 | catch 228 | try 229 | if ax_order==1; 230 | axis([min(x) max(x) min(t) max(t)]) 231 | else 232 | axis([min(t) max(t) min(x) max(x) ]) 233 | end 234 | end 235 | end 236 | -------------------------------------------------------------------------------- /1410_Phase/complex_attributes_on_section.m: -------------------------------------------------------------------------------- 1 | function [z, envelope, phase] = complex_attributes_on_section(section) 2 | % function [z, envelope, phase] = complex_attributes_on_section(section) 3 | 4 | sz = size(section) 5 | hilbert = zeros(sz); % initialise an empty slice 6 | for n = 1:sz(2) % for every trace 7 | % phase shift by 90 degrees so that the hilbert signal lags 8 | % the original trace. Hence -90, and resulting in generally 9 | % increasing phase values down the trace 10 | hilbert(:,n) = fftshifter(section(:,n), -90); 11 | end 12 | z = section + 1i*hilbert; % form a complex version of the section 13 | envelope = sqrt(real(z).^2 + imag(z).^2); 14 | phase = -1*angle(z); 15 | 16 | 17 | -------------------------------------------------------------------------------- /1410_Phase/configure_tutorial.m: -------------------------------------------------------------------------------- 1 | current_dir = pwd; 2 | addpath(current_dir); 3 | addpath([current_dir '/SegyMAT']); 4 | addpath([current_dir '/SegyMAT/GUI']); 5 | disp('PATH updated'); 6 | 7 | % other config 8 | pkg rebuild -noauto oct2mat 9 | if (~isunix() && ~ismac()) 10 | graphics_toolkit('fltk'); 11 | end 12 | warning('off', 'Octave:possible-matlab-short-circuit-operator'); 13 | 14 | screensize = get(0,'screensize'); 15 | big_plot(1) = 0.1*screensize(3); 16 | big_plot(2) = 0.1*screensize(4); 17 | big_plot(3) = 0.9*screensize(3); 18 | big_plot(4) = 0.9*screensize(4); 19 | 20 | axes_font_size = 12; 21 | title_font_size = 20; 22 | -------------------------------------------------------------------------------- /1410_Phase/data/penobscot_xl1155.sgy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seg/tutorials-2014/aab1cf917bc4b223e1061d2984aa1bce4bc41a1c/1410_Phase/data/penobscot_xl1155.sgy -------------------------------------------------------------------------------- /1410_Phase/data/trace_il1190_xl1155.trace: -------------------------------------------------------------------------------- 1 | 1190 1155 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -128 -231 212 1638 3162 1785 -2553 -7283 -9185 -6320 694 9332 15583 16540 9773 -2562 -11688 -13510 -9715 -4038 720 3015 2580 845 -598 -1338 -1789 -1875 -1400 -355 1077 2227 2324 1528 510 -4 372 1118 1389 1039 389 -311 -650 -257 626 1764 2856 2064 -1533 -5016 -4671 -1152 1398 1382 737 1164 1881 1366 -63 -998 -1065 -738 -262 363 1003 1214 511 -678 -1326 -1247 -999 -786 -361 87 11 -442 -566 -169 401 753 699 656 1061 1345 558 -1290 -2957 -2797 -418 2332 3161 1775 -207 -1209 -1011 -653 -946 -1206 -520 493 566 34 341 1342 1451 309 -718 -1012 -1195 -1204 -300 1013 1287 816 1011 1199 -327 -2680 -3171 -1254 1188 2507 2358 1174 82 56 576 320 -879 -1941 -1997 -1239 -436 131 934 2097 2612 1566 -346 -1652 -1817 -1319 -596 73 452 428 -142 -1140 -1590 -395 2229 4185 3029 -867 -3769 -2927 -161 948 12 -605 177 1143 1027 134 -471 -241 383 838 1126 1276 970 171 -629 -1060 -1275 -1422 -1169 -295 736 1094 493 -482 -1010 -849 -280 305 410 74 415 2063 3412 2443 -237 -2333 -2806 -2125 -887 112 -128 -1291 -1363 686 2871 2467 -273 -2497 -2390 -596 1634 3396 3402 941 -2238 -3450 -2020 436 1974 1883 887 65 -236 -173 -56 -233 -500 -264 407 677 -23 -1475 -2361 -874 2896 5522 3505 -2084 -6070 -5064 -1320 988 1111 749 362 -391 -722 213 1737 2365 1636 651 474 639 113 -1044 -1747 -1303 -265 464 737 985 986 -17 -2061 -3832 -3515 -564 3248 4959 3271 -55 -2160 -1975 -600 571 991 750 129 -840 -2077 -2665 -1466 1127 3138 2950 899 -1043 -1378 -521 163 168 -113 -320 -458 -592 -450 226 1104 1502 1206 522 -173 -683 -1060 -1353 -1184 -312 687 1019 664 142 -224 -337 -140 212 334 42 -528 -1341 -2277 -2322 -404 2634 4164 2782 235 -731 154 675 -446 -1944 -2173 -1217 -79 762 1142 834 157 -22 552 1068 846 258 -55 -278 -993 -2099 -2769 -2332 -747 1575 3758 4496 2909 -355 -3094 -3150 -749 1496 1640 380 -666 -1050 -1133 -1017 -619 -162 161 444 513 40 -509 -290 359 289 -467 -598 379 1273 1008 145 -253 -201 -115 261 1128 1548 486 -1463 -2471 -1653 -9 952 725 -121 -659 -188 1153 2242 1960 442 -1191 -2144 -2276 -1464 151 1450 1144 -554 -1879 -1266 1011 3044 3115 1378 -475 -1229 -1235 -1339 -1562 -1358 -700 -191 -183 -282 99 872 1241 657 -373 -817 -341 546 1295 1680 1476 648 -308 -850 -937 -758 -349 116 149 -414 -865 -285 1187 2101 1108 -1277 -2846 -2132 -232 555 -235 -618 885 2809 2434 -555 -3626 -4447 -3181 -1335 491 2634 4523 4614 2567 69 -1165 -866 250 1265 1416 461 -1029 -1912 -1518 -491 -183 -989 -1705 -975 941 2477 2529 1184 -887 -2873 -3846 -3249 -1541 132 1152 1985 3128 4024 3692 2072 92 -1436 -2473 -3188 -3290 -2450 -1045 9 217 -51 -169 29 353 715 1178 1716 2020 1636 590 -357 -520 -30 515 724 591 349 171 -15 -372 -904 -1448 -1752 -1506 -599 519 981 302 -1123 -2359 -2558 -1427 506 2127 2526 1622 138 -794 -340 1116 2130 1765 626 -152 -239 -53 -25 -274 -681 -1077 -1330 -1322 -1042 -549 52 520 601 384 262 355 325 9 -298 -399 -485 -526 139 2006 4180 4667 2277 -1971 -5613 -6794 -5283 -2033 1534 4010 4636 3728 2173 502 -1337 -3220 -4285 -3607 -1467 682 1616 1375 818 549 547 540 360 -56 -643 -1037 -758 191 1238 1888 2122 2119 1968 1662 1154 382 -650 -1698 -2416 -2657 -2494 -2038 -1346 -497 243 474 130 -344 -490 -263 173 656 1014 1147 1036 615 -57 -640 -883 -901 -832 -579 -39 649 1036 691 -99 -396 171 937 1202 924 454 125 28 31 100 351 768 1041 841 237 -345 -599 -587 -551 -697 -990 -1167 -1098 -972 -1000 -1080 -894 -405 -112 -389 -875 -1019 -714 -104 624 1167 1351 1387 1562 1853 2001 1761 1010 -109 -1121 -1483 -1067 -350 20 -178 -585 -678 -321 147 344 270 307 796 1583 2095 1890 1003 -112 -932 -1323 -1606 -2063 -2505 -2474 -1833 -898 -109 229 51 -385 -678 -593 -151 428 899 1214 1384 1298 930 506 300 478 945 1305 1312 1217 1291 1374 1201 783 265 -270 -838 -1492 -2233 -2871 -3018 -2446 -1476 -652 -102 400 876 1006 570 -206 -654 -307 421 696 326 -184 -325 15 470 486 141 190 861 1402 1231 638 164 -2 10 74 226 440 560 509 257 -193 -705 -1163 -1449 -1209 -235 972 1587 1347 595 -411 -1622 -2672 -2992 -2479 -1497 -397 489 821 604 277 386 1032 1567 1346 584 -162 -652 -552 417 1700 2313 1939 1110 521 287 25 -285 -326 -188 -101 -35 -126 -467 -811 -1266 -2056 -2506 -1880 -679 119 181 -220 -557 -494 -159 287 836 1296 1386 1091 637 258 -5 -256 -366 -76 406 577 256 -307 -675 -585 -84 804 1952 2593 2068 809 -315 -983 -1315 -1480 -1501 -1136 -338 321 245 -464 -1188 -1422 -1137 -744 -581 -506 -291 97 757 1580 1883 1259 260 -400 -545 -223 346 613 407 364 851 1337 1306 771 -101 -894 -1040 -533 116 421 72 -777 -1485 -1608 -1216 -596 -41 304 472 387 -78 -701 -963 -630 4 435 440 330 577 1140 1448 1172 569 78 31 373 413 -310 -1288 -1824 -1706 -846 569 1752 2007 1354 300 -489 -694 -651 -609 -424 -232 -300 -463 -550 -596 -442 77 706 988 801 489 230 -150 -449 -241 165 209 60 -18 -257 -557 -432 16 327 485 595 500 142 -388 -1027 -1395 -1062 -356 38 112 340 810 1117 870 95 -738 -1051 -603 322 1106 1377 1213 815 363 46 -201 -533 -735 -478 220 983 1152 283 -1046 -1772 -1664 -1212 -702 -191 149 95 -270 -444 -127 184 -51 -439 -310 258 930 1543 1565 627 -556 -1248 -1651 -1720 -834 800 2203 2836 2559 1530 493 -18 -242 -435 -417 -115 166 234 291 344 -125 -1233 -2255 -2711 -2601 -1712 -273 565 324 -282 -754 -957 -618 62 550 937 1445 1871 2071 1918 1230 281 -441 -719 -429 348 1152 1450 968 -59 -991 -1500 -1527 -931 -14 454 334 145 126 147 -47 -615 -1245 -1502 -1341 -869 -329 -88 19 509 1156 1301 1065 942 715 122 -313 -308 -383 -534 -111 680 1024 734 -97 -1386 -2470 -2622 -1895 -595 1019 2340 2834 2667 2228 1569 692 -130 -584 -640 -551 -550 -595 -692 -971 -1241 -1248 -1201 -1227 -980 -418 44 256 313 79 -528 -1000 -689 274 1243 1837 1923 1537 1155 1214 1433 1324 877 232 -520 -1035 -1131 -1125 -1182 -1131 -918 -605 -342 -327 -378 -305 -383 -632 -619 -331 -37 286 634 859 831 350 -417 -716 -203 518 882 1013 1215 1593 2072 2240 1672 561 -702 -2034 -3113 -3322 -2731 -1975 -1145 -76 744 830 636 660 645 427 295 185 -190 -528 -376 112 550 740 620 517 917 1547 1649 1191 630 -44 -995 -1883 -2226 -1964 -1375 -675 -72 70 -223 -327 137 850 1413 1736 1791 1532 976 118 -872 -1540 -1697 -1557 -1116 -350 305 594 671 429 -322 -1252 -1866 -1851 -973 622 2182 2884 2374 921 -579 -1194 -840 -88 594 893 652 218 77 203 388 630 791 638 291 -154 -950 -2029 -2762 -2714 -2035 -1100 -182 612 1175 1298 971 656 822 1326 1566 1279 827 412 -336 -1448 -2271 -2383 -1877 -851 497 1637 2142 2032 1457 503 -471 -980 -1143 -1300 -1055 -109 754 950 1017 1282 1334 938 63 -1166 -2120 -2375 -2206 -1793 -1025 22 1100 1837 1986 1768 1359 560 -453 -1085 -1165 -917 -509 -10 513 860 692 31 -550 -520 20 657 1081 954 275 -222 -133 -19 -214 -388 -305 97 589 518 -89 -495 -718 -1136 -1340 -986 -513 -350 -472 -540 -149 550 882 636 287 98 -58 -38 429 1082 1468 1615 1666 1523 1146 510 -435 -1455 -2212 -2663 -2604 -1638 -113 938 1154 1143 1124 612 -280 -852 -1064 -1152 -934 -549 -336 -101 260 471 563 714 866 1054 1191 712 -499 -1400 -1044 132 1027 1198 996 675 96 -592 -914 -747 -364 -127 -263 -531 -600 -635 -697 -355 398 1029 1211 857 147 -383 -432 -176 205 540 526 195 -58 -141 -299 -426 -237 35 47 -54 -68 -69 -86 -91 -118 -85 63 155 103 51 37 17 1 -1 0 2 | -------------------------------------------------------------------------------- /1410_Phase/environment.yml: -------------------------------------------------------------------------------- 1 | name: seg-tutorial-phase 2 | channels: 3 | - conda-forge 4 | - defaults 5 | dependencies: 6 | - pip 7 | - numpy 8 | - scipy 9 | - matplotlib 10 | - ipywidgets 11 | - jupyter 12 | - jupyterlab 13 | - pip: 14 | - segyio 15 | - tqdm 16 | -------------------------------------------------------------------------------- /1410_Phase/ffthilbert.m: -------------------------------------------------------------------------------- 1 | function y = ffthilbert(x) 2 | y = fftshifter(x, -pi/2); -------------------------------------------------------------------------------- /1410_Phase/fftshifter.m: -------------------------------------------------------------------------------- 1 | function y = fftshifter(x, phase_shift_in_radians) 2 | % Create an array to apply the coefficient to 3 | % positive and negative frequencies appropriately 4 | N = length(x); 5 | M = ceil((N+1)/2); 6 | R0 = exp(i*phase_shift_in_radians); 7 | R = ones(size(x)); 8 | R(1:M) = R0; 9 | R(M+1:N) = conj(R0); 10 | 11 | % Apply the phase shift in the frequency domain 12 | Xshifted = R.*fft(x); 13 | 14 | % Recover the shifted time domain signal 15 | y = real(ifft(Xshifted)); -------------------------------------------------------------------------------- /1410_Phase/find_peaks.m: -------------------------------------------------------------------------------- 1 | function [y, ya] = find_peaks(x, a) 2 | % Detect peaks in envelope using non-maximal supression 3 | window_length = 3; 4 | trace_length = numel(x); 5 | halflength = ceil((window_length - 1) / 2); 6 | y = zeros(size(x)); 7 | ya = NaN*ones(size(x)); 8 | for n = int32(halflength+1:trace_length-halflength) 9 | range = n-halflength:n+halflength; 10 | local_max = max(x(range)); 11 | if (x(n) >= local_max) 12 | y(n) = x(n); 13 | ya(n) = a(n); 14 | end 15 | end -------------------------------------------------------------------------------- /1410_Phase/get_idealised_phase.m: -------------------------------------------------------------------------------- 1 | function ideal_phase = get_idealised_phase(peaks, phase) 2 | % flip to nearest 'zero' phase point 3 | ideal_phase = zeros(size(phase)); 4 | ideal_phase(abs(phase) < pi/2) = 0; 5 | ideal_phase(abs(phase - pi) < pi/2) = pi; 6 | ideal_phase(abs(phase + pi) < pi/2) = -pi; 7 | 8 | phase(peaks == 0) = NaN; 9 | ideal_phase(peaks == 0) = NaN; -------------------------------------------------------------------------------- /1410_Phase/load_abenaki.m: -------------------------------------------------------------------------------- 1 | function [H, min_range, max_range] = load_abenaki() 2 | data = load('-ascii','data/abenaki_horizon.ascii'); 3 | min_range = min(data); 4 | max_range = max(data); 5 | 6 | %H = NaN*ones(max_range(1) - min_range(1), max_range(2) - min_range(2)); 7 | H = NaN*ones(601, 481); 8 | 9 | sz = size(data); 10 | for i = 1:sz(1) 11 | a = data(i,1) - min_range(1) + 1; 12 | b = data(i,2) - min_range(2) + 1; 13 | H(a, b) = data(i,3); 14 | end -------------------------------------------------------------------------------- /1410_Phase/load_simple_trace.m: -------------------------------------------------------------------------------- 1 | function [s, t, trace_header] = load_simple_trace(filename) 2 | % This function will oad a trace that was exported from 3 | % OpenDTect as a Simple File with header info 4 | s = load(filename); 5 | s = s(3:end); % extract data part and reverse to correct order 6 | t = 0:4:6000; 7 | trace_header = s(1:2); -------------------------------------------------------------------------------- /1410_Phase/plot_complex_attributes_on_a_slice.m: -------------------------------------------------------------------------------- 1 | % Load Slice of SEGY 2 | [data, segyHeader] = ReadSegy('data/penobscot_xl1155.sgy'); 3 | 4 | [z, envelope, phase] = complex_attributes_on_section(data); 5 | 6 | plot_range = 500:750; % select 1s window for plotting 7 | 8 | figure(3) 9 | colormap(gray(256)) 10 | z(:,190) = 6500 + 1i*8000; 11 | imagesc(fliplr(real(z(plot_range,:)))) % the original seismic section 12 | set(gca, 'ytick', [1 50 100 150 200 250]); 13 | set(gca, 'yticklabel', {'2000','2200','2400','2600','2800','3000'}); 14 | set(gca,'FontSize', axes_font_size) 15 | title('Original', 'FontSize', title_font_size); 16 | colorbar 17 | 18 | figure(4) 19 | imagesc(fliplr(imag(z(plot_range,:)))) % the (trace-wise) Hilbert transform section 20 | set(gca, 'ytick', [1 50 100 150 200 250]); 21 | set(gca, 'yticklabel', {'2000','2200','2400','2600','2800','3000'}); 22 | set(gca,'FontSize',axes_font_size) 23 | title('Hilbert', 'FontSize', title_font_size) 24 | colorbar 25 | 26 | figure(5) 27 | envelope(:,190) = 10000; 28 | imagesc(fliplr(envelope(plot_range,:))) % the Envelope (Instantaneous Amplitude) = abs(z) 29 | set(gca, 'ytick', [1 50 100 150 200 250]); 30 | set(gca, 'yticklabel', {'2000','2200','2400','2600','2800','3000'}); 31 | set(gca,'FontSize',axes_font_size) 32 | title('Envelope', 'FontSize', title_font_size) 33 | colorbar 34 | 35 | figure(6) 36 | phase(:,190) = 0; 37 | imagesc(fliplr(phase(plot_range,:))) % the Instantaneous Phase = angle(z) 38 | set(gca, 'ytick', [1 50 100 150 200 250]); 39 | set(gca, 'yticklabel', {'2000','2200','2400','2600','2800','3000'}); 40 | set(gca,'FontSize',axes_font_size) 41 | title('Phase', 'FontSize', title_font_size) 42 | colorbar -------------------------------------------------------------------------------- /1410_Phase/plot_complex_attributes_on_a_trace.m: -------------------------------------------------------------------------------- 1 | % Load a seismic trace 2 | % This is trace was exported from OpenDTect as a Simple File 3 | [s, t] = load_simple_trace('data/trace_il1190_xl1155.trace'); 4 | 5 | % Compute the Analytic (Complex) Trace 6 | z = s + i*ffthilbert(s); 7 | envelope = abs(z); 8 | phase = angle(z); 9 | 10 | % plot the complex trace 11 | plot_range = 500:750; % select 1s window for plotting 12 | tshort = t(plot_range); 13 | h = figure(1) 14 | clf 15 | plot(tshort, real(z(plot_range)),'k'); 16 | hold on; 17 | plot(tshort, imag(z(plot_range)),'k-.'); 18 | plot(tshort, envelope(plot_range),'r'); 19 | plot(tshort, -envelope(plot_range),'r'); 20 | axis tight 21 | set(gca,'FontSize', axes_font_size) 22 | title('Trace Amplitudes', 'FontSize', title_font_size) 23 | xlabel('Time, t(ms)', 'FontSize', axes_font_size) 24 | set(legend('Original','Hilbert','Envelope','location','northeast'),'FontSize', axes_font_size) 25 | 26 | h = figure(2) 27 | plot(tshort, phase(plot_range),'k'); 28 | axis tight 29 | set(gca,'FontSize',axes_font_size) 30 | title('Instaneous Phase') 31 | xlabel('Time, t(ms)', 'FontSize', axes_font_size) 32 | ylabel('Angle (radians)', 'FontSize', axes_font_size) 33 | title('Original', 'FontSize', title_font_size); -------------------------------------------------------------------------------- /1410_Phase/plot_phase_at_envelope_peaks_on_a_slice.m: -------------------------------------------------------------------------------- 1 | % Load Slice of SEGY 2 | [data, segyHeader] = ReadSegy('data/penobscot_xl1155.sgy'); 3 | 4 | % Compute the complex attributes 5 | [z, envelope, phase] = complex_attributes_on_section(data); 6 | 7 | sz = size(data); 8 | envelope_peaks = zeros(sz); 9 | phase_at_envelope_peaks = zeros(sz); 10 | idealised_phase = zeros(sz); 11 | for n = 1:sz(2) 12 | % Detect peaks in envelope using non-maximal supression 13 | [envelope_peaks(:,n), phase_at_envelope_peaks(:,n)] = find_peaks(envelope(:,n), phase(:,n)); 14 | idealised_phase(:,n) = get_idealised_phase(envelope_peaks(:,n), phase(:,n)); 15 | end 16 | 17 | figure(9) 18 | imagesc(fliplr(phase_at_envelope_peaks(500:750,:))) 19 | colormap(hsv(256)) 20 | colorbar 21 | set(gca, 'ytick', [1 50 100 150 200 250]); 22 | set(gca, 'yticklabel', {'2000','2200','2400','2600','2800','3000'}); 23 | set(gca,'FontSize',axes_font_size) 24 | title('Phase at Envelope Peaks', 'FontSize', title_font_size) 25 | 26 | 27 | figure(10) 28 | phase_error = abs(idealised_phase - phase_at_envelope_peaks); 29 | phase_error(:,190) = 1.5; 30 | imagesc(fliplr(phase_error(500:750, :))) 31 | colormap(jet(256)) 32 | colorbar 33 | set(gca, 'ytick', [1 50 100 150 200 250]); 34 | set(gca, 'yticklabel', {'2000','2200','2400','2600','2800','3000'}); 35 | set(gca,'FontSize',axes_font_size) 36 | title('Absolute Phase Error at Envelope Peaks', 'FontSize', title_font_size) 37 | -------------------------------------------------------------------------------- /1410_Phase/plot_phase_at_envelope_peaks_on_a_trace.m: -------------------------------------------------------------------------------- 1 | % Load a seismic trace 2 | % This is trace was exported from OpenDTect as a Simple File 3 | [s, t] = load_simple_trace('data/trace_il1190_xl1155.trace'); 4 | trace_length = numel(t); 5 | 6 | % Compute the Analytic (Complex) Trace 7 | z = s + i*ffthilbert(s); 8 | envelope = abs(z); 9 | phase = -1*angle(z); 10 | 11 | % Detect peaks in envelope using non-maximal supression 12 | [envelope_peaks, phase_at_envelope_peaks] = find_peaks(envelope, phase); 13 | idealised_phase = get_idealised_phase(envelope_peaks, phase); 14 | phase_differences = abs(idealised_phase - phase_at_envelope_peaks); 15 | 16 | % plot 17 | plot_range = 500:750; 18 | tshort = t(plot_range); 19 | h = figure(7); 20 | clf 21 | plot(tshort, real(z(plot_range)),'k') 22 | hold on 23 | grid on 24 | plot(tshort, envelope(plot_range),'r') 25 | envelope_peaks(envelope_peaks == 0) = NaN; 26 | stem(tshort, envelope_peaks(plot_range),'r'); 27 | title('Envelope', 'FontSize', title_font_size); 28 | xlabel('Time, t(ms)', 'FontSize', axes_font_size); 29 | set(legend('Original','Envelope','Envelope Peaks','location','northeast'),'FontSize', axes_font_size); 30 | plot(tshort, -envelope(plot_range),'r') 31 | stem(tshort, -envelope_peaks(plot_range),'r'); 32 | axis tight 33 | 34 | figure(8) 35 | phase_at_envelope_peaks(envelope_peaks == NaN) = NaN; 36 | stem(tshort, idealised_phase(plot_range), 'k'); 37 | hold on 38 | grid on 39 | stem(tshort, phase_at_envelope_peaks(plot_range),'r'); 40 | set(gca,'XLim',[tshort(1) tshort(end)]); 41 | 42 | ax = findall(h,'type','axes'); 43 | 44 | title('Phase', 'FontSize', title_font_size) 45 | xlabel('Time, t(ms)', 'FontSize', axes_font_size) 46 | ylabel('Phase (Radians)', 'FontSize', axes_font_size) 47 | set(legend('Actual Phase', 'Idealised Phase'),'FontSize', axes_font_size); -------------------------------------------------------------------------------- /1410_Phase/purves_tutorial_long.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seg/tutorials-2014/aab1cf917bc4b223e1061d2984aa1bce4bc41a1c/1410_Phase/purves_tutorial_long.pdf -------------------------------------------------------------------------------- /1410_Phase/readme.md: -------------------------------------------------------------------------------- 1 | How to run through the tutorial 2 | =============================== 3 | The code for this tutorial has been developed in GNU Octave a high level programming environment for linear algebra, signal processing and more. Octave is matlab compatible so this tutorial should also work in matlab should you have that available. 4 | 5 | 6 | 2020 Refresh 7 | ------------ 8 | 9 | The tutorial code hase been ported to Python! and the repo now includes an ipython notebook [here](./phase_and_hilbert_transform.ipynb)|[here](https://iooxa.com/@stevejpurves/geoscience/phaseandhilbert) with all calculation and plotting code included. 10 | A remix of the article using the new plots is posted [here](https://iooxa.com/@stevejpurves/geoscience/phase-and-the-hilbert-transform). 11 | 12 | 13 | ### Getting Started with the python version 14 | 15 | - `conda env create -f environment.yml` 16 | - `conda activate seg-tutorial-phase` 17 | - `jupyter lab` 18 | 19 | 20 | 2014 Original Version 21 | --------------------- 22 | 23 | 24 | Expanded Tutorial Paper 25 | ----------------------- 26 | A pdf of the expanded tutorial paper is [here](purves_tutorial_long.pdf) this includes plots of seismic attributes on sections are well as the trace plots included in the TLE tutorial. 27 | 28 | Installation 29 | ------------ 30 | To install GNU octave, 31 | - on Linux or MAC follow the instructions for your operating system on the [Octave website](http://www.gnu.org/software/octave/download.html) to get the appropriate packages. NOTE: some Linux distributions come with octave pre-installed. 32 | - on Windows download the latest binary installers distribution from [Octave Forge](http://sourceforge.net/projects/octave/files/Octave%20Windows%20binaries/) 33 | - on MacOS_X follow this [guide](http://wiki.octave.org/Octave_for_MacOS_X) 34 | 35 | Octave Basics 36 | ------------- 37 | If you are familar with Matlab, you already know (mostly) how to use Octave. Otherwise get started with this [cheatsheet](http://ais.informatik.uni-freiburg.de/teaching/ss13/robotics/exercises/cheatsheet.pdf) or dive in with [this one](http://folk.ntnu.no/joern/itgk/refcard-a4.pdf). 38 | 39 | Generating nice plots 40 | --------------------- 41 | I have recently updated the code to plot each graph / image in its own figure window. Octave will open a new figure at its default size, often not great for the graph in question. However, you can now resize the figure window to a better size and aspect ratio and then hit 'e' to replot the graph. 42 | 43 | If you want to save the plots to image files, don't take screenshots instead use [print](http://wiki.octave.org/Octave_for_MacOS_X) 44 | 45 | Running the Tutorial Code 46 | ------------------------- 47 | Open octave from the command line or start menu shortcut then carry out the following steps on the octave command prompt. 48 | 1. cd into the tutorials directory e.g. cd home\seg\tutorials\1410_Phase 49 | 1. then run the following scripts inside Octave (tip: use 'tab' to autocomplete long names) 50 | 1. configure_tutorial 51 | 1. [plot_complex_attributes_on_a_trace](plot_complex_attributes_on_a_trace.m) - to produce figure 1 from the tutorial. This uses fftshifter.m to compute the hilbert transform, and subsequently envelope and phase. 52 | 1. [plot_complex_attributes_on_a_slice](plot_complex_attributes_on_a_slice.m) - will repeat the trace based computation for each trace within a the section of data. SegyMAT is used to load the seismic section from the .sgy file included in the data folder, and we simply loop over the traces in the resulting 2d array. 53 | 1. [plot_phase_at_envelope_peaks_on_a_trace](plot_phase_at_envelope_peaks_on_a_trace.m) - will produce figure 2 from the tutorial. This repeats the envelope and phase computation and then detects peaks in the envelope function. Envelope and phase are extracted at those locations. Phase values are then plotted against an computed "idealised phase". 54 | 1. [plot_phase_at_envelope_peaks_on_a_section](plot_phase_at_envelope_peaks_on_a_slice.m) - applies the same algorithm from the last step to each trace in a section, creating new sparse envelope and phase sections. Note these could also be computed over all traces in a cube, however soem limiations of octave prevent us from doing so here. 55 | 56 | Conclusions from working with Octave 57 | ------------------------------------ 58 | Octave provides an alternative environment to the commercial Matlab package. The degree of similarity and compatibility is good, certainly for ore functions. However, there are limitations in Octave that make working with it challenging, the most significant being the lack of precompiled 64 bit builds, which limits the amount of data that we can load and process to 2GB. In this tutorial, we've worked with traces and seismic sections that in this case easily fit within that limit. 59 | 60 | However, if you want to work with 3D data or generate maps over hilbert transformed data, then you'll need to put significant effort into managing memory and its likely your processing will be unnecessarily slow as a result, makign withing with 3D in Octave prohibitive. 61 | 62 | Note on Plotting: Octave doesn't always autoscale the contents of its figure windows. Sometimes to get nice large/clear plots, you'll need to plot, resize the window and then plot again. 63 | 64 | References 65 | ---------- 66 | 1. For convenience this repositoty includes the source code for [SegyMAT](http://segymat.sourceforge.net/) 67 | 1. Data used in the tutorial has been taken from the Pensobscot survey available in the [OpenDTect Open Seismic Repository](https://opendtect.org/osr/pmwiki.php/Main/PENOBSCOT3DSABLEISLAND) 68 | -------------------------------------------------------------------------------- /1412_Tuning_and_AVO/Thin_beds_and_AVO__Draft.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seg/tutorials-2014/aab1cf917bc4b223e1061d2984aa1bce4bc41a1c/1412_Tuning_and_AVO/Thin_beds_and_AVO__Draft.pdf -------------------------------------------------------------------------------- /1412_Tuning_and_AVO/figure_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seg/tutorials-2014/aab1cf917bc4b223e1061d2984aa1bce4bc41a1c/1412_Tuning_and_AVO/figure_1.png -------------------------------------------------------------------------------- /1412_Tuning_and_AVO/figure_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seg/tutorials-2014/aab1cf917bc4b223e1061d2984aa1bce4bc41a1c/1412_Tuning_and_AVO/figure_2.png -------------------------------------------------------------------------------- /1412_Tuning_and_AVO/tuning_wedge.py: -------------------------------------------------------------------------------- 1 | """ 2 | Python script to generate a zero-offset synthetic from a 3-layer wedge model. 3 | 4 | Created by: Wes Hamlyn 5 | Create Date: 19-Aug-2014 6 | Last Mod: 1-Nov-2014 7 | 8 | This script is provided without warranty of any kind. 9 | 10 | """ 11 | 12 | 13 | import numpy as np 14 | import matplotlib.pyplot as plt 15 | from matplotlib import gridspec 16 | 17 | 18 | 19 | ########################################################### 20 | # 21 | # DEFINE MODELING PARAMETERS HERE 22 | # 23 | 24 | 25 | # 3-Layer Model Parameters [Layer1, Layer2, Layer 3] 26 | vp_mod = [2500.0, 2600.0, 2550.0] # P-wave velocity (m/s) 27 | vs_mod = [1200.0, 1300.0, 1200.0] # S-wave velocity (m/s) 28 | rho_mod= [1.95, 2.0, 1.98] # Density (g/cc) 29 | 30 | dz_min = 0.0 # Minimum thickness of Layer 2 (m) 31 | dz_max = 60.0 # Maximum thickness of Layer 2 (m) 32 | dz_step= 1.0 # Thickness step from trace-to-trace (normally 1.0 m) 33 | 34 | 35 | # Ricker Wavelet Parameters 36 | wvlt_length= 0.128 37 | wvlt_cfreq = 30.0 38 | wvlt_phase = 0.0 39 | 40 | 41 | # Trace Parameters 42 | tmin = 0.0 43 | tmax = 0.5 44 | dt = 0.0001 # changing this from 0.0001 can affect the display quality 45 | 46 | # Plot Parameters 47 | min_plot_time = 0.15 48 | max_plot_time = 0.3 49 | excursion = 2 50 | 51 | 52 | 53 | 54 | ########################################################### 55 | # 56 | # FUNCTIONS DEFINITIONS 57 | # 58 | 59 | def plot_vawig(axhdl, data, t, excursion, highlight=None): 60 | 61 | import numpy as np 62 | import matplotlib.pyplot as plt 63 | 64 | [ntrc, nsamp] = data.shape 65 | 66 | 67 | 68 | 69 | t = np.hstack([0, t, t.max()]) 70 | 71 | for i in range(0, ntrc): 72 | tbuf = excursion * data[i] / np.max(np.abs(data)) + i 73 | 74 | tbuf = np.hstack([i, tbuf, i]) 75 | 76 | if i==highlight: 77 | lw = 2 78 | else: 79 | lw = 0.5 80 | 81 | axhdl.plot(tbuf, t, color='black', linewidth=lw) 82 | 83 | plt.fill_betweenx(t, tbuf, i, where=tbuf>i, facecolor=[0.6,0.6,1.0], linewidth=0) 84 | plt.fill_betweenx(t, tbuf, i, where=tbuf= t_int[lyr]: 191 | rc[i] = rc_int[lyr] 192 | lyr = lyr + 1 193 | 194 | if lyr > nint: 195 | break 196 | 197 | return rc 198 | 199 | 200 | 201 | 202 | ########################################################## 203 | # 204 | # COMPUTATIONS BELOW HERE... 205 | # 206 | 207 | 208 | 209 | # Some handy constants 210 | nlayers = len(vp_mod) 211 | nint = nlayers - 1 212 | nmodel = int((dz_max-dz_min)/dz_step+1) 213 | 214 | # Generate ricker wavelet 215 | wvlt_t, wvlt_amp = ricker(wvlt_cfreq, wvlt_phase, dt, wvlt_length) 216 | 217 | # Calculate reflectivities from model parameters 218 | rc_int = calc_rc(vp_mod, rho_mod) 219 | 220 | 221 | syn_zo = [] 222 | rc_zo = [] 223 | lyr_times = [] 224 | for model in range(0, nmodel): 225 | 226 | # Calculate interface depths 227 | z_int = [500.0] 228 | z_int.append(z_int[0]+dz_min+dz_step*model) 229 | 230 | # Calculate interface times 231 | t_int = calc_times(z_int, vp_mod) 232 | lyr_times.append(t_int) 233 | 234 | # Digitize 3-layer model 235 | nsamp = int((tmax-tmin)/dt) + 1 236 | t = [] 237 | for i in range(0,nsamp): 238 | t.append(i*dt) 239 | 240 | rc = digitize_model(rc_int, t_int, t) 241 | rc_zo.append(rc) 242 | 243 | # Convolve wavelet with reflectivities 244 | syn_buf = np.convolve(rc, wvlt_amp, mode='same') 245 | syn_buf = list(syn_buf) 246 | syn_zo.append(syn_buf) 247 | print "finished step %i" % (model) 248 | 249 | syn_zo = np.array(syn_zo) 250 | t = np.array(t) 251 | lyr_times = np.array(lyr_times) 252 | lyr_indx = np.array(np.round(lyr_times/dt), dtype='int16') 253 | 254 | # Use the transpose because rows are traces; 255 | # columns are time samples. 256 | tuning_trace = np.argmax(np.abs(syn_zo.T)) % syn_zo.T.shape[1] 257 | tuning_thickness = tuning_trace * dz_step 258 | 259 | # Plotting Code 260 | [ntrc, nsamp] = syn_zo.shape 261 | 262 | fig = plt.figure(figsize=(12, 14)) 263 | fig.set_facecolor('white') 264 | 265 | gs = gridspec.GridSpec(3, 1, height_ratios=[1, 1, 1]) 266 | 267 | ax0 = fig.add_subplot(gs[0]) 268 | ax0.plot(lyr_times[:,0], color='blue', lw=1.5) 269 | ax0.plot(lyr_times[:,1], color='red', lw=1.5) 270 | ax0.set_ylim((min_plot_time,max_plot_time)) 271 | ax0.invert_yaxis() 272 | ax0.set_xlabel('Thickness (m)') 273 | ax0.set_ylabel('Time (s)') 274 | plt.text(2, 275 | min_plot_time + (lyr_times[0,0] - min_plot_time)/2., 276 | 'Layer 1', 277 | fontsize=16) 278 | plt.text(dz_max/dz_step - 2, 279 | lyr_times[-1,0] + (lyr_times[-1,1] - lyr_times[-1,0])/2., 280 | 'Layer 2', 281 | fontsize=16, 282 | horizontalalignment='right') 283 | plt.text(2, 284 | lyr_times[0,0] + (max_plot_time - lyr_times[0,0])/2., 285 | 'Layer 3', 286 | fontsize=16) 287 | plt.gca().xaxis.tick_top() 288 | plt.gca().xaxis.set_label_position('top') 289 | ax0.set_xlim((-excursion, ntrc+excursion)) 290 | 291 | ax1 = fig.add_subplot(gs[1]) 292 | plot_vawig(ax1, syn_zo, t, excursion, highlight=tuning_trace) 293 | ax1.plot(lyr_times[:,0], color='blue', lw=1.5) 294 | ax1.plot(lyr_times[:,1], color='red', lw=1.5) 295 | ax1.set_ylim((min_plot_time,max_plot_time)) 296 | ax1.invert_yaxis() 297 | ax1.set_xlabel('Thickness (m)') 298 | ax1.set_ylabel('Time (s)') 299 | 300 | ax2 = fig.add_subplot(gs[2]) 301 | ax2.plot(syn_zo[:,lyr_indx[:,0]], color='blue') 302 | ax2.set_xlim((-excursion, ntrc+excursion)) 303 | ax2.axvline(tuning_trace, color='k', lw=2) 304 | ax2.grid() 305 | ax2.set_title('Upper interface amplitude') 306 | ax2.set_xlabel('Thickness (m)') 307 | ax2.set_ylabel('Amplitude') 308 | plt.text(tuning_trace + 2, 309 | plt.ylim()[0] * 1.1, 310 | 'tuning thickness = {0} m'.format(str(tuning_thickness)), 311 | fontsize=16) 312 | 313 | plt.savefig('figure_1.png') 314 | plt.show() 315 | 316 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # tutorials-2014 2 | 3 | Tutorials from [The Leading Edge](http://library.seg.org/journal/leedff) column, which started in February 2014. 4 | 5 | These are [Jupyter Notebooks](https://jupyter.org/). They can be opened and read (but not actually run) right here in GitHub, or you can install the Notebook software (e.g. with **`conda install jupyter`**), then clone this repo, and start a notebook server in the *tutorials-2014* directory. 6 | 7 | For more in-depth hints on getting started, see Hall, M (2016). A user guide to the geophysical tutorials. _The Leading Edge_ **35** (2), 190–191, doi: [10.1190/tle35020190.1](http://library.seg.org/doi/abs/10.1190/tle35020190.1). 8 | 9 | Questions? [Get in touch!](mailto:matt@agilegeoscience.com) 10 | 11 | ## February 2014 12 | - [Filtering horizons and attributes](http://dx.doi.org/10.1190/tle33020128.1), by Matt Hall 13 | - [Smoothing surfaces and attributes](http://wiki.seg.org/wiki/Smoothing_surfaces_and_attributes_%28tutorial%29) — SEG Wiki article 14 | - [Jupyter Notebook](https://github.com/seg/tutorials-2014/blob/master/1402_Smoothing_surfaces/1402_Smoothing_surfaces.ipynb) 15 | 16 | ## April 2014 17 | - [Euler deconvolution of potential field data](http://library.seg.org/doi/abs/10.1190/tle33040448.1), by Leonardo Uieda, Vanderlei C. Oliveira Jr, and Valéria C. F. Barbosa 18 | - [Euler deconvolution of potential field data](http://wiki.seg.org/wiki/Euler_deconvolution_of_potential_field_data_%28tutorial%29) — article in SEG Wiki 19 | - [Jupyter notebook to generate synthetic data](https://github.com/seg/tutorials-2014/blob/master/1404_Euler_deconvolution/create_synthetic_data.ipynb) 20 | - [Jupyter notebook to run the Euler deconvolution](https://github.com/seg/tutorials/blob/master/1404_Euler_deconvolution/euler-deconvolution-examples.ipynb) 21 | 22 | ## June 2014 23 | - [Well-tie calculus](http://library.seg.org/doi/abs/10.1190/tle33060674.1), by Evan Bianco 24 | - [Well-tie calculus](http://wiki.seg.org/wiki/Well_tie_calculus_%28tutorial%29) — article in SEG Wiki 25 | - [Jupyter Notebook](https://github.com/seg/tutorials-2014/blob/master/1406_Make_a_synthetic/how_to_make_synthetic.ipynb) 26 | 27 | ## August 2014 28 | - [Evaluate and compare colormaps](http://library.seg.org/doi/abs/10.1190/tle33080910.1), by Matteo Niccoli — article in *TLE*, with low-res figures (resulting in incorrect colours for Figure 3a). 29 | - [How to evaluate and compare colormaps](http://wiki.seg.org/wiki/How_to_evaluate_and_compare_color_maps) — article in SEG Wiki, with high-res figures 30 | - [Jupyter Notebook](https://github.com/seg/tutorials-2014/blob/master/1408_Evaluate_and_compare_colormaps/How_to_evaluate_and_compare_colormaps.ipynb) 31 | 32 | ## October 2014 33 | - [Phase and the Hilbert transform](http://library.seg.org/doi/abs/10.1190/tle33101164.1), by Steve Purves — article in *TLE* 34 | - [A guide to running the tutorial with GNU Octave](1410_Phase/readme.md) 35 | - [A longer version of the tutorial paper](https://github.com/seg/tutorials-2014/raw/master/1410_Phase/purves_tutorial_long.pdf) 36 | 37 | ## December 2014 38 | - [Thin beds, tuning, and AVO](http://library.seg.org/doi/abs/10.1190/tle33121394.1), by Wes Hamlyn 39 | - [The scripts](https://github.com/seg/tutorials-2014/raw/master/1412_Tuning_and_AVO) 40 | 41 |
42 | 43 | The content of the articles and of the notebooks is © the author(s) and openly licensed [CC-BY-SA](https://creativecommons.org/licenses/by-sa/3.0/). The code is © the author(s) and openly licensed under the terms of the Apache License 2, or under the terms specified by the author, if any. 44 | --------------------------------------------------------------------------------