{ "cells": [ { "cell_type": "markdown", "id": "e02df895-ba9a-4d70-843a-a0a76c80b8dd", "metadata": {}, "source": [ "# Convert ModEM files to VTK\n", "\n", "For this you should clone MTpy `metadata` branch: https://github.com/MTgeophysics/mtpy/tree/metadata\n", "\n", "If you `cd` into the folder containing the cloned branch you can use `pip install -e .` or just link your `PYTHONPATH` to the folder." ] }, { "cell_type": "code", "execution_count": 1, "id": "0de8223d-6786-4628-9f9b-79cf40eae9b0", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "GDAL_DATA environment variable is not set Please see https://trac.osgeo.org/gdal/wiki/FAQInstallationAndBuilding#HowtosetGDAL_DATAvariable \n", "2022-03-31 14:27:15,759 [line 133] error.get_mtpy_logger - INFO: Logging file can be found C:\\Users\\jpeacock\\Documents\\GitHub\\mtpy\\logs\\mtpy_error.log\n", "2022-03-31 14:27:15,759 [line 133] matplotlib.get_mtpy_logger - INFO: Logging file can be found C:\\Users\\jpeacock\\Documents\\GitHub\\mtpy\\logs\\matplotlib_warn.log\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Ignore GDAL as it is not working. Will use pyproj\n", "2022-03-31T14:27:15 [line 157] numexpr.utils._init_num_threads - INFO: NumExpr defaulting to 8 threads.\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "C:\\Users\\jpeacock\\Anaconda3\\envs\\mt\\lib\\_collections_abc.py:720: MatplotlibDeprecationWarning: The global colormaps dictionary is no longer considered public API.\n", " yield from self._mapping\n", "C:\\Users\\jpeacock\\Documents\\GitHub\\mtpy\\mtpy\\imaging\\mtcolors.py:283: MatplotlibDeprecationWarning: The global colormaps dictionary is no longer considered public API.\n", " cmapdict.update(cm.cmap_d)\n" ] } ], "source": [ "from mtpy.modeling.modem import Model, Data" ] }, { "cell_type": "code", "execution_count": 2, "id": "02bc3a7b-5f86-4311-8f01-6c68c24fc93e", "metadata": {}, "outputs": [], "source": [ "d = Data()\n", "d.read_data_file(r\"c:\\Users\\jpeacock\\OneDrive - DOI\\Geysers\\modem_inv\\inv03\\gz_data_err03_tec_edit.dat\")" ] }, { "cell_type": "markdown", "id": "940057c4-d4fa-4aa1-a8a7-6788fb741f7e", "metadata": {}, "source": [ "## This is for UTM coordinates\n", "\n", "This will convert to UTM coordinates in a coordinate systems with x=North, y=East, z +downward. If you want geographic coordinates you can set the keyword `geographic=True`. If you want relative coordinates you can leave the shift keywords set to 0. Be careful with the `shift_elev` and `shift_z` because the model center is relative to an elevation ceiling, which I think is set to 1100m. Might need to play around with this value to make the elevations relative to sea level." ] }, { "cell_type": "code", "execution_count": 4, "id": "35a8a778-77fa-4eb8-a6b5-270dc10a4104", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2022-03-31 14:30:30,033 [line 2012] mtpy.modeling.modem.data.Data.write_vtk_station_file - INFO: Wrote station VTK file to c:\\Users\\jpeacock\\OneDrive - DOI\\Geysers\\modem_inv\\inv03\\geysers_stations_utm\n" ] }, { "data": { "text/plain": [ "WindowsPath('c:/Users/jpeacock/OneDrive - DOI/Geysers/modem_inv/inv03/geysers_stations_utm')" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "d.write_vtk_station_file(\n", " vtk_fn_basename=\"geysers_stations_utm\",\n", " shift_north=d.center_point.north[0], \n", " shift_east=d.center_point.east[0], \n", " shift_elev=d.center_point.elev[0]\n", ")" ] }, { "cell_type": "code", "execution_count": 5, "id": "8993d767-62df-48ea-8216-fd211cb93815", "metadata": {}, "outputs": [], "source": [ "m = Model()\n", "m.read_model_file(r\"c:\\Users\\jpeacock\\OneDrive - DOI\\Geysers\\modem_inv\\inv03\\gz_err03_cov02_NLCG_057.rho\")" ] }, { "cell_type": "code", "execution_count": 8, "id": "81d1d7c0-8799-4ba0-bb5c-625fd10f391f", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "2022-03-31T14:35:51 [line 1517] Model.write_vtk_file - INFO: Wrote model file to c:\\Users\\jpeacock\\OneDrive - DOI\\Geysers\\modem_inv\\inv03\\geysers_model_utm\n", "==========================\n", " model dimensions = (70, 81, 70)\n", " * north 70\n", " * east 81\n", " * depth 70\n", "==========================\n" ] } ], "source": [ "m.write_vtk_file(\n", " vtk_fn_basename=\"geysers_model_utm\",\n", " shift_north=d.center_point.north[0], \n", " shift_east=d.center_point.east[0], \n", " shift_z=d.center_point.elev[0]\n", ")" ] }, { "cell_type": "code", "execution_count": 10, "id": "0ae6df9d-4557-4e13-a47c-44a2c5e882fe", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Wrote ModEM control file to control.fwd\n", "Wrote ModEM control file to control.inv\n" ] } ], "source": [ "from mtpy.modeling.modem import ControlFwd, ControlInv\n", "\n", "cfwd = ControlFwd()\n", "cfwd.write_control_file(\"control.fwd\")\n", "\n", "cfwd = ControlInv()\n", "cfwd.write_control_file(\"control.inv\")\n" ] }, { "cell_type": "code", "execution_count": null, "id": "58962cdb-4a82-4329-b94a-c6395a844be4", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.11" } }, "nbformat": 4, "nbformat_minor": 5 }