MTPy software requires a Python Interpreter with a dependency packages installed.
We recommend to use Anaconda Python distribution (https://www.anaconda.com/what-is-anaconda/), as it can be easily installed without administration or root privilege. In addition, Ananconda provides and maintains a comprehensive repository of python libraries and packages for scientific computing.
In this guide we provide instructions on how to install anaconda python into a Linux desktop. It is tested on Ubuntu Linux Version-18.04, and should be similar for other flavours of Linux systems.
You can get access to Linux Virtual Machines (VM) in many ways, including using public cloud service providers such as AWS and Google.
Perhaps the most convenient and no-cost way to get Linux systems is to use Oracle VirtualBox: https://www.oracle.com/technetwork/server-storage/virtualbox/downloads/index.html, which allows PC/Laptop users to create virtual guest OS such as Ubuntu.
from https://www.anaconda.com/download/#linux
OR using the wget command
mtpy@mtpy-VirtualBox$ wget https://repo.anaconda.com/archive/Anaconda2-5.2.0-Linux-x86_64.sh
Saving to: 'Anaconda2-5.2.0-Linux-x86_64.sh’
Anaconda2-5.2.0-Linux-x86_64.sh 100%[=============================================>] 603.38M 209KB/s in 53m 32s
mtpy@mtpy-VirtualBox$ chmod 755 Anaconda2-5.2.0-Linux-x86_64.sh
mtpy@mtpy-VirtualBox$ ./Anaconda2-5.2.0-Linux-x86_64.sh
Welcome to Anaconda2 5.2.0
In order to continue the installation process, please review the license agreement. Please, press ENTER to continue
Accept the license and let it install into default directory location (/home/mtpy/anaconda2). This process will take a couple of minutes to complete. In the end when prompted, enter yes to make the new ananconda python PATH available by appending automatically a line of configuration into your $HOME/.bashrc, with output shown below:
[no] > yes
Appending source /home/mtpy/anaconda2/bin/activate to /home/mtpy/.bashrc A backup will be made to: /home/mtpy/.bashrc-anaconda2.bak
For this change to become active, you have to open a new terminal.
Thank you for installing Anaconda2!
........ Skip Visual Studio Code
Do you wish to proceed with the installation of Microsoft VSCode? [yes|no]
no
After the successful installation of anaconda python, open a new terminal and test to make sure your default python interpreter is /home/mtpy/anaconda2/bin/python, instead of your OS-provided python (/user/bin/python):
mtpy@mtpy-VirtualBox:~$ which python
/home/mtpy/anaconda2/bin/python
mtpy@mtpy-VirtualBox:~$ python -V
Python 2.7.15 :: Anaconda, Inc.
install geopandas and netcdf4 for data handling:
conda install geopandas -y
conda install netcdf4 -y
The conda install will resolve all dependency packages such as gdal, pandas, etc
Configure GDAL_DATA properly by appending in $HOME/.bashrc
export GDAL_DATA=/home/mtpy/anaconda2/share/gdal
(one way to do this is: echo 'export GDAL_DATA=/home/mtpy/anaconda2/share/gdal' >> /home/mtpy/.bashrc)
conda install spyder
Obtain the mtpy source code:
git clone https://github.com/MTgeophysics/mtpy
sudo apt install git
In [1]:
# what python you are using?
!which python
In [2]:
# If you cannot impport mtpy modules below, you need to set PYTHONPATH:
# here is a quick fix
import sys
sys.path.insert(0,'/home/mtpy/mtpy')
In [3]:
PATH2_SYNTH_EDI='/home/mtpy/mtpy/examples/data/edi_files_2/Synth00.edi'
SAVE_PATH='/home/mtpy/output_dir/'
import os
if not os.path.exists(SAVE_PATH):
os.mkdir(SAVE_PATH)
In [4]:
# import required modules
from mtpy.core.mt import MT
# Define the path to your edi file
edi_file = PATH2_SYNTH_EDI
# Create an MT object
mt_obj = MT(edi_file)
In [5]:
# To see the latitude and longitude
print (mt_obj.lat, mt_obj.lon)
In [6]:
# for example, to see the frequency values represented in the impedance tensor:
print mt_obj.Z.freq
In [7]:
# import required modules
# Define the path to your edi file and save path
edi_file = PATH2_SYNTH_EDI
savepath = SAVE_PATH
# Create an MT() object
mt_obj = MT(edi_file)
# To plot the edi file we read in in Part 1 & save to file:
pt_obj = mt_obj.plot_mt_response(plot_num=2)
pt_obj.save_plot(os.path.join(savepath,"Synth002.png"), fig_dpi=400)
In [8]:
pt_obj.plot()
In [ ]:
In [ ]: