MTgeophysics / mtpy

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

v2-MT collection #187

Open kashkoulimohammad opened 10 months ago

kashkoulimohammad commented 10 months ago

Hi All,

I am trying to use V2 for my purposes but I am faced with below error when importing MTCollection: `--------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In[1], line 2 1 from pathlib import Path ----> 2 from mtpy import MTCollection 3 get_ipython().run_line_magic('matplotlib', 'inline')

File ~\anaconda3\envs\em\lib\site-packages\mtpy-2.0.0-py3.8.egg\mtpy__init__.py:21 16 matplotlib_logger = get_mtpy_logger("matplotlib", level="warning") 18 # ============================================================================= 19 # Commonly used objects 20 # ============================================================================= ---> 21 from mtpy.core.mt import MT 22 from mtpy.core.mt_data import MTData 23 from mtpy.core.mt_collection import MTCollection

File ~\anaconda3\envs\em\lib\site-packages\mtpy-2.0.0-py3.8.egg\mtpy\core__init__.py:1 ----> 1 from .transfer_function import Z 2 from .transfer_function import Tipper 3 from .transfer_function import PhaseTensor

File ~\anaconda3\envs\em\lib\site-packages\mtpy-2.0.0-py3.8.egg\mtpy\core\transfer_function__init__.py:1 ----> 1 from .z import Z 2 from .tipper import Tipper 3 from .pt import PhaseTensor

File ~\anaconda3\envs\em\lib\site-packages\mtpy-2.0.0-py3.8.egg\mtpy\core\transfer_function\z.py:21 18 import numpy as np 20 import mtpy.utils.calculator as MTcc ---> 21 from .base import TFBase 22 from .pt import PhaseTensor 23 from .z_analysis import ( 24 ZInvariants, 25 find_distortion, 26 remove_distortion_from_z_object, 27 calculate_depth_of_investigation, 28 )

File ~\anaconda3\envs\em\lib\site-packages\mtpy-2.0.0-py3.8.egg\mtpy\core\transfer_function\base.py:19 16 import copy 18 import numpy as np ---> 19 import xarray as xr 21 from mtpy.utils.calculator import ( 22 rotate_matrix_with_errors, 23 rotate_vector_with_errors, 24 ) 25 from mtpy.utils.mtpy_logger import get_mtpy_logger

File ~\anaconda3\envs\em\lib\site-packages\xarray-2023.8.0-py3.8.egg\xarray__init__.py:1 ----> 1 from xarray import testing, tutorial 2 from xarray.backends.api import ( 3 load_dataarray, 4 load_dataset, (...) 8 save_mfdataset, 9 ) 10 from xarray.backends.zarr import open_zarr

File ~\anaconda3\envs\em\lib\site-packages\xarray-2023.8.0-py3.8.egg\xarray\testing.py:10 7 import numpy as np 8 import pandas as pd ---> 10 from xarray.core import duck_array_ops, formatting, utils 11 from xarray.core.coordinates import Coordinates 12 from xarray.core.dataarray import DataArray

File ~\anaconda3\envs\em\lib\site-packages\xarray-2023.8.0-py3.8.egg\xarray\core\duck_array_ops.py:36 33 from numpy.core.multiarray import normalize_axis_index # type: ignore[attr-defined] 34 from numpy.lib.stride_tricks import sliding_window_view # noqa ---> 36 from xarray.core import dask_array_ops, dtypes, nputils 37 from xarray.core.parallelcompat import get_chunked_array_type, is_chunked_array 38 from xarray.core.pycompat import array_type, is_duck_dask_array

File ~\anaconda3\envs\em\lib\site-packages\xarray-2023.8.0-py3.8.egg\xarray\core\dask_array_ops.py:3 1 from future import annotations ----> 3 from xarray.core import dtypes, nputils 6 def dask_rolling_wrapper(moving_func, a, window, min_count=None, axis=-1): 7 """Wrapper to apply bottleneck moving window funcs on dask arrays"""

File ~\anaconda3\envs\em\lib\site-packages\xarray-2023.8.0-py3.8.egg\xarray\core\dtypes.py:7 3 import functools 5 import numpy as np ----> 7 from xarray.core import utils 9 # Use as a sentinel value to indicate a dtype appropriate NA value. 10 NA = utils.ReprObject("")

File ~\anaconda3\envs\em\lib\site-packages\xarray-2023.8.0-py3.8.egg\xarray\core\utils.py:443 439 new_dict.update(second_dict) 440 return new_dict --> 443 class Frozen(Mapping[K, V]): 444 """Wrapper around an object implementing the mapping interface to make it 445 immutable. If you really want to modify the mapping, the mutable version is 446 saved under the mapping attribute. 447 """ 449 slots = ("mapping",)

TypeError: 'ABCMeta' object is not subscriptable`

kujaku11 commented 10 months ago

@kashkoulimohammad this looks like an xarray error, something in their testing suite is failing. For reference I have version 2022.6.0 running on my machine. Perhaps try installing that version of xarray and see if that fixes the issue. In the meantime, I'll try upgrading my xarray to the newer version and see if I can track down the issue, but that might take some time.

It also looks like you might have an older version of v2, try either pulling or redownloading https://github.com/MTgeophysics/mtpy/tree/v2.