MTgeophysics / mtpy

Python toolbox for standard Magnetotelluric (MT) data analysis
GNU General Public License v3.0
147 stars 66 forks source link

error in modem.model.make_mesh_from_center #26

Closed alkirkby closed 6 years ago

alkirkby commented 6 years ago

make_mesh_from_center function appears to mostly duplicate functionality in make_mesh. Can we remove make_mesh_from center and bring across any new functionality? I'm getting errors in the make_mesh_from_center function.

Expected Behavior

create model file for modem inversion code

Current Behavior

Traceback (most recent call last): File "", line 1, in File "C:\Users\u64125\AppData\Local\Continuum\Miniconda2\envs\mtpy27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 714, in runfile execfile(filename, namespace) File "C:\Users\u64125\AppData\Local\Continuum\Miniconda2\envs\mtpy27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 74, in execfile exec(compile(scripttext, filename, 'exec'), glob, loc) File "C:/Users/u64125/OneDrive - Geoscience Australia/Reprocessing_2016/python/Modem_buildinputfiles.py", line 100, in mo.make_mesh_from_center() File "mtpy\modeling\modem\model.py", line 634, in make_mesh_from_center self.data_obj.center_position_utm[1] -= mean_egrid AttributeError: 'Data' object has no attribute 'center_position_utm'


from mtpy.modeling.modem import Model
from mtpy.modeling.modem import Data
from mtpy.modeling.modem import Covariance
#
#from mtpy.modeling.modem import Model
#from mtpy.modeling.modem import Data
#from mtpy.modeling.modem import Covariance

import mtpy.core.edi as mtedi
import os.path as op

import numpy as np

# path to save to
workdir = r'V:\2008\09GA_GA1_Georgina\Reprocessing_2016\ModEM\GBinv34r'
workdir = r'C:\Users\u64125\OneDrive - Geoscience Australia\Reprocessing_2016\ModEM\GBinvTST_makemesh'
if not op.exists(workdir):
    os.mkdir(workdir)

# path where topography is located, if using
sdir= r'V:\Software\mtpy\template_scripts\example_topo'

# epsg to project to. Google epsg 'your projection'
epsg = 28353

edipath = r'V:\2008\09GA_GA1_Georgina\Reprocessing_2016\edi\merged_edi_ss_masked3_shifted_plus_tipper'
edipath = r'C:\Users\u64125\OneDrive - Geoscience Australia\Reprocessing_2016\edi\merged_edi_rotate_ss_masked3_plus_tipper_combined'

# list of edi files, search for all files ending with '.edi'
edi_list = [op.join(edipath,ff) for ff in os.listdir(edipath) if (ff.endswith('.edi'))]# and ('GL' in ff))]
edi_list.sort()
#edi_list = edi_list[1::2]

# period list - get from one of the edi files
eo = mtedi.Edi(op.join(edipath,'GB03_GL01.edi'))
#period_list = 1./eo.Z.freq

eo2 = mtedi.Edi(r'V:\2008\09GA_GA1_Georgina\Reprocessing_2016\edi\LP_edi_masked\GL01.edi')
period_list = np.hstack([1./eo.Z.freq[:26],1./eo2.Z.freq])
#period_list = period_list[30:]
#period_list = 1./eo2.Z.freq

do = Data(edi_list=edi_list,
               inv_mode = '1',
               period_list=period_list,
               period_buffer=0.6,
               error_type_z='floor_egbert',
               error_value_z=5,
               error_value_tipper =.03,
               model_epsg=epsg
               )
do.write_data_file(save_path=workdir)
do.data_array['elev'] = 0.
do.write_data_file(fill=False)
#np.savetxt(op.join(workdir,'center_position.dat'),do.center_position_EN)
np.savetxt(op.join(workdir,'center_position.txt'),np.array([do.center_point['east'], do.center_point['north']]))
np.savetxt(op.join(workdir,'epsg.txt'),[epsg])

# create model file
mo = Model(data_obj=do,
           station_locations=do.station_locations,
                cell_size_east=2500,
                cell_size_north=2500,
                pad_north=8, # number of padding cells in each of the north and south directions
                pad_east=8,# number of east and west padding cells
                pad_z=6, # number of vertical padding cells
                pad_num=5,
                pad_stretch_v=1.6, # factor to increase by in padding cells (vertical)
                pad_stretch_h=1.8, # factor to increase by in padding cells (horizontal)
                pad_method='stretch',
                z_mesh_method = 'new',
                n_airlayers = 0, #number of air layers
                res_model=200, # halfspace resistivity value for reference model
                n_layers=90, # total number of z layers, including air
                z1_layer=10, # first layer thickness
                z_target_depth=120000)

#mo.make_mesh()
mo.make_mesh_from_center()
# add topography to res model
mo.write_model_file(save_path=workdir)

Your Environment

Installed Python Packages: use pip freeze or conda list [-n ENVIRONMENT_NAME] to list all the installed libraries. alabaster==0.7.10 asn1crypto==0.22.0 astroid==1.5.3 Babel==2.4.0 backports-abc==0.5 backports.functools-lru-cache==1.4 backports.shutil-get-terminal-size==1.0.0 backports.ssl-match-hostname==3.5.0.1 basemap==1.1.0 bleach==2.0.0 certifi==2017.7.27.1 cffi==1.10.0 chardet==3.0.4 click==6.7 click-plugins==1.0.3 cligj==0.4.0 colorama==0.3.9 configparser==3.5.0 cryptography==2.0.3 cycler==0.10.0 decorator==4.1.2 descartes==1.1.0 docutils==0.14 entrypoints==0.2.3 enum34==1.1.6 Fiona==1.7.9 funcsigs==1.0.2 functools32==3.2.3.post2 future==0.16.0 GDAL==2.1.3 geopandas==0.3.0 html5lib==0.999999999 idna==2.5 imagesize==0.7.1 ipaddress==1.0.18 ipykernel==4.6.1 ipython==5.4.1 ipython-genutils==0.2.0 ipywidgets==7.0.5 isort==4.2.15 jedi==0.10.2 Jinja2==2.9.6 jsonschema==2.5.1 jupyter-client==5.1.0 jupyter-console==5.2.0 jupyter-core==4.3.0 lazy-object-proxy==1.3.1 lxml==3.8.0 MarkupSafe==1.0 matplotlib==2.0.0 mccabe==0.6.1 mistune==0.7.4 mock==2.0.0 -e git+git@github.com:MTgeophysics/mtpy.git@36f927d06e492aea2bf00d3a9b842cc9c2b4db73#egg=mtpy munch==2.2.0 nbconvert==5.2.1 nbformat==4.3.0 netCDF4==1.3.1 notebook==5.2.2 numpy==1.12.1 numpydoc==0.7.0 obspy==1.1.0 olefile==0.44 pandas==0.20.3 pandocfilters==1.4.1 pathlib2==2.3.0 pbr==3.1.1 pep8==1.7.0 pickleshare==0.7.4 Pillow==4.3.0 prompt-toolkit==1.0.15 psutil==5.2.2 psycopg2==2.7.3 pycodestyle==2.3.1 pycparser==2.18 pyflakes==1.6.0 Pygments==2.2.0 pylint==1.7.1 pyOpenSSL==17.2.0 pyparsing==2.2.0 pyproj==1.9.5.1 PySAL==1.13.0 pyshp==1.2.12 PySocks==1.6.7 python-dateutil==2.6.1 pytz==2017.2 PyYAML==3.12 pyzmq==16.0.2 QtAwesome==0.4.4 qtconsole==4.3.1 QtPy==1.3.1 requests==2.18.4 -e git+git@github.com:GeoscienceAustralia/resistor_network.git@c4ec068698a8df5309a91fc2707397b66680f4d6#egg=rnpy rope==0.10.7 Rtree==0.8.3 scandir==1.5 scipy==0.19.1 Shapely==1.6.3 simplegeneric==0.8.1 singledispatch==3.4.0.3 six==1.10.0 snowballstemmer==1.2.1 Sphinx==1.6.3 sphinxcontrib-websupport==1.0.1 spyder==2.3.9 SQLAlchemy==1.1.13 testpath==0.3.1 tornado==4.5.2 traitlets==4.3.2 typing==3.6.2 urllib3==1.22 wcwidth==0.1.7 webencodings==0.5 widgetsnbextension==3.0.8 win-inet-pton==1.0.1 win-unicode-console==0.5 wincertstore==0.2 wrapt==1.10.11

geojunky commented 6 years ago

Hi Alison,

I've just moved make_mesh_from_center to legacy as discussed.

alkirkby commented 6 years ago

Thanks Rakib.