guillochon/MOSFiT

tde model fails

LydiaMak opened this issue · 6 comments

Hi,

I am trying to run mosfit (I had to reinstall) so it's the latest version and I get this error

Basic model file:
  /Users/lydiamakrygianni/miniconda3/lib/python3.10/site-packages/mosfit/models/model.json
Model file:
  /Users/lydiamakrygianni/miniconda3/lib/python3.10/site-packages/mosfit/models/tde/tde.json
Parameter file:
  models/tde/parameters.json
Traceback (most recent call last):
  File "/Users/lydiamakrygianni/miniconda3/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/lydiamakrygianni/miniconda3/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/lydiamakrygianni/miniconda3/lib/python3.10/site-packages/mosfit/__main__.py", line 5, in <module>
    main.main()
  File "/Users/lydiamakrygianni/miniconda3/lib/python3.10/site-packages/mosfit/main.py", line 977, in main
    Fitter(**fitargs).fit_events(**fitargs)
  File "/Users/lydiamakrygianni/miniconda3/lib/python3.10/site-packages/mosfit/fitter.py", line 352, in fit_events
    self._model = Model(
  File "/Users/lydiamakrygianni/miniconda3/lib/python3.10/site-packages/mosfit/model.py", line 290, in __init__
    self._modules[task] = self._load_task_module(task)
  File "/Users/lydiamakrygianni/miniconda3/lib/python3.10/site-packages/mosfit/model.py", line 336, in _load_task_module
    return mod_class(
  File "/Users/lydiamakrygianni/miniconda3/lib/python3.10/site-packages/mosfit/modules/engines/fallback.py", line 91, in __init__
    time['lo'] = np.array([
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part.

I also tried another model e.g. ia and it moved on to the next step so probably the issue is the TDE model.

Any ideas?

Thanks,
Lydia

Hi Lydia,

Thanks for bringing this up! This is a recent issue with changes in the latest numpy models that requires some rewriting of interpolation functions in the code. We are currently working on getting it fixed, but it should be backwards compatible with early versions of numpy. For now, if you'd like you can download the source code from github and run it with earlier numpy versions and it should work. Sorry about this!

Best,
Brenna

Hi Brenna,

No worries, thanks for letting me know! A question about using the source code. Should I make the steps described for development install and it should work?

I tried the setup.py from github but still doesn't work. Should I add something specific for it to use an older version of numpy?

Hmm I'm not sure what your exact python setup is. I normally have a separate conda environment for MOSFiT, and I checked my numpy in it and it's currently using v1.21.5. From a quick google search of this issue, switching to 1.21 should fix it for now (e.g. numpy/numpy#23231). If you'd like more help, feel free to email me at bmockler@carnegiescience.edu! Also, I should get the issue fixed in the next couple weeks, I have just been traveling for the past month and haven't been able to get to it yet.

Recent NumPy versions silently creates an object array. The solution is to use dtype = 'object' to make sure numpy doesn't silently creates an object array.

e.g.
instead of x = np.array(blah) it shloud be x = np.array(blah, dtype='object').

also, another change you need to make in few of the codes is to use 'float64' instead of just 'float' while specifying data type.

Hi Lydia, I think this is now fixed -- I just had to implement Brenna and Harsh's solution in one extra line. Try the latest version and see if it works!