Closed nlwagner closed 6 months ago
After a clean conda environment install I'm receiving the same error.
After some testing, it seems this error is only within Spyder. Jupyter notebooks still work fine. Tested with the included demo notebooks within /Demos.
I will play around with spyder to see if I can run into the issue. I think my first question/concern is what led to that initial crash
Also, can you check what happens if you just run a script from the terminal in the conda environment where tidalpy is installed? So basically the same thing you'd do in Spyder but without being in spyder.
So running the script from the command line results in the same error:
$ python testing_AK_model_elastic.py
2024-02-22 11:52:32(+00:00:00::825509) - INFO : TidalPy initializing...
2024-02-22 11:52:32(+00:00:00::825607) - INFO : TidalPy initialization complete.
Traceback (most recent call last):
File "/Users/nlwagner25/Desktop/PYTHON/TidalPy/testing_AK_model_elastic.py", line 15, in <module>
from TidalPy.RadialSolver import radial_solver
File "/Users/nlwagner25/Desktop/PYTHON/TidalPy/TidalPy/RadialSolver/__init__.py", line 1, in <module>
from TidalPy.RadialSolver.solver import radial_solver
ModuleNotFoundError: No module named 'TidalPy.RadialSolver.solver'
(TidalPy)
The best I can remember is I was just testing radial_solver for a model I had. The file is testing_AK_model_elastic.py in my forked repository if you can access it. It hasn't been modified since the crash.
In testing a new conda env I run the following:
conda create -n tidalpy2 python="3.11" numpy spyder jupyter matplotlib scipy
conda activate tidalpy2
Pip install TidalPy
python testing_AK_model_elastic.py
The last line running the script results in the error posted before.
Hey @nlwagner!
Okay I think I have found a few issues.
is_static_by_layer
"layer_types" etc than you actually have layers. The is_static_by_layer
, is_incompressible_by_layer
, upper_radius_by_layer
should all be the same size. You only need layers for liquid-solid interfaces and large density jumps. So if you have 100 radius "slices" (radius_array.size == 100
) but only the lower half are liquid then you only have 2 "layers". So layer_types=('liquid', 'solid')
.
upper_radius_by_layer[>6]
which does not exist.radius_array[0]
is near the planet center rather than on the surface. np.copy
s around:
elastic_rheology.vectorize_modulus_viscosity(forcing_frequency, np.copy(shear_array), np.copy(viscosity_array), complex_shear)
Cheers,
Okay figured out the problem with the complex shear calculations. The arrays are not being passed as C-contiguous arrays. This is not documented but that is a requirement for all TidalPy functionality. The reason they are not is because of the reverse operation [::-1]. As I mentioned in the last post, you don't want to do that anyways, but if for some reason you did end up needing to do that make sure to convert the arrays to contiguous via:
shear_array = np.ascontiguousarray(shear_array)
viscosity_array = np.ascontiguousarray(viscosity_array)
elastic_rheology.vectorize_modulus_viscosity(forcing_frequency, shear_array, viscosity_array, complex_shear)
I will add some better warnings and documentation in the next patch to make this clear.
Let me know if these fixes helped!
Thanks so much Joe. Sorry for the late reply, been focusing on LPSC related things. I followed your advice and I now have it working! I'm glad it was a simple issue. I definitely misunderstood the layer types input, I thought that had to be the same size as my input array.
I'll let you know if I run into any other errors I can't overcome :)
I'll try to detail the conditions that led up to this crash as best I can.
I was testing radial_solver with much finer layers and more property variations than previously. I'm currently using Python 3.9 and Spyder version 5.5.1 through conda.
After rebooting Spyder, however, I'm met with this error:
I tried reinstalling TidalPy through Pip, but no luck. I'm completely deleting and recreating my conda environment and will update with a comment once that finishes.