uafgeotools / rtm

A Python package for locating infrasound sources using reverse time migration
https://uaf-rtm.readthedocs.io/
MIT License
38 stars 13 forks source link

Grid_search optimization #27

Closed davidfee5 closed 4 years ago

davidfee5 commented 4 years ago

Move from stream- to numpy-based grid search that pre-computes samples to remove in the ravel-time correction.

liamtoney commented 4 years ago

I get the following error when I attempt example_regional.py:

  File "/Users/ldtoney/repos/rtm/rtm/grid.py", line 536, in grid_search
    S.loc[dict(x=x, y=y)] = stk[i, j, :]
  File "/opt/miniconda3/envs/rtm/lib/python3.7/site-packages/xarray/core/dataarray.py", line 205, in __setitem__
    self.data_array[pos_indexers] = value
  File "/opt/miniconda3/envs/rtm/lib/python3.7/site-packages/xarray/core/dataarray.py", line 658, in __setitem__
    self.variable[key] = value
  File "/opt/miniconda3/envs/rtm/lib/python3.7/site-packages/xarray/core/variable.py", line 768, in __setitem__
    indexable[index_tuple] = value
  File "/opt/miniconda3/envs/rtm/lib/python3.7/site-packages/xarray/core/indexing.py", line 1267, in __setitem__
    array[key] = value
ValueError: could not broadcast input array from shape (1321) into shape (241)

it arises from the fact that we're specifying a starttime and and endtime for the grid search for this example, which is why example_local.py is unaffected. The time dimension of S is smaller — timing_st[0].count() = 241 — than the number of samples in the time dimension of stkst_proc[0].count() = 1321.

davidfee5 commented 4 years ago

I get the following error when I attempt example_regional.py:

  File "/Users/ldtoney/repos/rtm/rtm/grid.py", line 536, in grid_search
    S.loc[dict(x=x, y=y)] = stk[i, j, :]
  File "/opt/miniconda3/envs/rtm/lib/python3.7/site-packages/xarray/core/dataarray.py", line 205, in __setitem__
    self.data_array[pos_indexers] = value
  File "/opt/miniconda3/envs/rtm/lib/python3.7/site-packages/xarray/core/dataarray.py", line 658, in __setitem__
    self.variable[key] = value
  File "/opt/miniconda3/envs/rtm/lib/python3.7/site-packages/xarray/core/variable.py", line 768, in __setitem__
    indexable[index_tuple] = value
  File "/opt/miniconda3/envs/rtm/lib/python3.7/site-packages/xarray/core/indexing.py", line 1267, in __setitem__
    array[key] = value
ValueError: could not broadcast input array from shape (1321) into shape (241)

it arises from the fact that we're specifying a starttime and and endtime for the grid search for this example, which is why example_local.py is unaffected. The time dimension of S is smaller — timing_st[0].count() = 241 — than the number of samples in the time dimension of stkst_proc[0].count() = 1321.

I've got an idea on how to address this but am about to hop on a plane for 13 hrs, so hold off on any major changes for a bit!

liamtoney commented 4 years ago

I just sped up celerity_travel_time() on master and merged across all branches. It shouldn't affect this PR though.