Comments (2)
@CedricPatzer Could you provide an example of the header where it fails?
Also, are you using MTData.from_modem()
? If not try that.
from mtpy import MTData
md = MTData()
md.from_modem(modem_data_filename)
from mtpy-v2.
Hello
I am having a similar issue as @CedricPatzer. I have tested with two ModEM files, one file of my own and one that I downloaded from the old repo of mtpy (https://github.com/MTgeophysics/mtpy/blob/develop/examples/data/ModEM_files/ModEM_Data.dat).
My version of MTpy is 2.0.6
import mtpy
from mtpy import MTData
datafile = 'datos3.dat'
#datafile = 'ModEM_Data.dat'
md = MTData()
md.from_modem(datafile)
With my modem file (datos3.dat) I get the following error
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
Cell In[9], line 8
5 datafile = 'datos3.dat'
7 md = MTData()
----> 8 md.from_modem(datafile)
File [~/projects/test_pymt/envs/lib/python3.12/site-packages/mtpy/core/mt_data.py:917](http://localhost:8888/lab/tree/envs/lib/python3.12/site-packages/mtpy/core/mt_data.py#line=916), in MTData.from_modem(self, data_filename, file_type, **kwargs)
905 """
906 read in a modem data file
907
(...)
914
915 """
916 modem_data = Data(**kwargs)
--> 917 mdf = modem_data.read_data_file(data_filename)
918 if file_type in ["data"]:
919 mdf.dataframe["survey"] = "data"
File [~/projects/test_pymt/envs/lib/python3.12/site-packages/mtpy/modeling/modem/data.py:1141](http://localhost:8888/lab/tree/envs/lib/python3.12/site-packages/mtpy/modeling/modem/data.py#line=1140), in Data.read_data_file(self, data_fn)
1138 dlines = dfid.readlines()
1140 # read header information
-> 1141 n_periods, n_stations = self._read_header(
1142 [line for line in dlines if ">" in line or "#" in line]
1143 )
1145 # create a list of dictionaries to make into a pandas dataframe
1146 entries = []
File [~/projects/test_pymt/envs/lib/python3.12/site-packages/mtpy/modeling/modem/data.py:939](http://localhost:8888/lab/tree/envs/lib/python3.12/site-packages/mtpy/modeling/modem/data.py#line=938), in Data._read_header(self, header_lines)
936 n_stations = int(hline[1:].strip().split()[1])
938 for head_line, inv_mode in zip(header_list, inv_list):
--> 939 self._parse_header_line(head_line, inv_mode)
941 self._get_inv_mode(inv_list)
943 return n_periods, n_stations
File [~/projects/test_pymt/envs/lib/python3.12/site-packages/mtpy/modeling/modem/data.py:978](http://localhost:8888/lab/tree/envs/lib/python3.12/site-packages/mtpy/modeling/modem/data.py#line=977), in Data._parse_header_line(self, header_line, mode)
976 if len(item_list) == 2:
977 key = item_list[0]
--> 978 value = item_list[1].replace("%", "").split()[0]
979 if key in ["error_value", "data_rotation"]:
980 try:
IndexError: list index out of range
and with ModEM_Data.dat I get
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[8], line 8
5 #datafile = 'datos3.dat'
7 md = MTData()
----> 8 md.from_modem(datafile)
File [~/projects/test_pymt/envs/lib/python3.12/site-packages/mtpy/core/mt_data.py:917](http://localhost:8888/lab/tree/envs/lib/python3.12/site-packages/mtpy/core/mt_data.py#line=916), in MTData.from_modem(self, data_filename, file_type, **kwargs)
905 """
906 read in a modem data file
907
(...)
914
915 """
916 modem_data = Data(**kwargs)
--> 917 mdf = modem_data.read_data_file(data_filename)
918 if file_type in ["data"]:
919 mdf.dataframe["survey"] = "data"
File [~/projects/test_pymt/envs/lib/python3.12/site-packages/mtpy/modeling/modem/data.py:1141](http://localhost:8888/lab/tree/envs/lib/python3.12/site-packages/mtpy/modeling/modem/data.py#line=1140), in Data.read_data_file(self, data_fn)
1138 dlines = dfid.readlines()
1140 # read header information
-> 1141 n_periods, n_stations = self._read_header(
1142 [line for line in dlines if ">" in line or "#" in line]
1143 )
1145 # create a list of dictionaries to make into a pandas dataframe
1146 entries = []
File [~/projects/test_pymt/envs/lib/python3.12/site-packages/mtpy/modeling/modem/data.py:939](http://localhost:8888/lab/tree/envs/lib/python3.12/site-packages/mtpy/modeling/modem/data.py#line=938), in Data._read_header(self, header_lines)
936 n_stations = int(hline[1:].strip().split()[1])
938 for head_line, inv_mode in zip(header_list, inv_list):
--> 939 self._parse_header_line(head_line, inv_mode)
941 self._get_inv_mode(inv_list)
943 return n_periods, n_stations
File [~/projects/test_pymt/envs/lib/python3.12/site-packages/mtpy/modeling/modem/data.py:1016](http://localhost:8888/lab/tree/envs/lib/python3.12/site-packages/mtpy/modeling/modem/data.py#line=1015), in Data._parse_header_line(self, header_line, mode)
1010 setattr(obj, item_dict["error_value"], value)
1012 if "deg" in item:
1013 setattr(
1014 self,
1015 item_dict["data_rotation"],
-> 1016 float(item.split("_")[0]),
1017 )
ValueError: could not convert string to float: ' data rotated 0.0'
from mtpy-v2.
Related Issues (20)
- GMT outputs
- plot pseudo-section of phasetensor with tipper HOT 3
- Downsampling frequencies HOT 2
- add_tf does not read elevation from EDIs HOT 3
- Exporting shapefiles of PT & IV HOT 1
- mtpy-data link not working HOT 2
- Add Phase Tensor output to modeling files
- Can't open Occam2D model file (.iter) with mtpy-v2 HOT 1
- Update Documentation
- Can't make ModEM file due to not knowing epsg. HOT 2
- error when outputing convariace_topo.cov HOT 2
- attribute calculate_rel_locations HOT 1
- EDI files with only tippers are present do not plot
- add ability to read geotiff to add topography to model
- Tippers are not plotted in parkinson convention
- Model conversion to other formats needs more options
- Slow addition of TFs HOT 1
- VTK to geographic coordinates
- Add client for downloading tfs
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mtpy-v2.