How to solve math domain error using Spatio-temporal weighted regression(STWR)?

41 Views Asked by At

i'm trying to use STWR statistics model.

I'm following quexiang github examples(https://github.com/quexiang/Fast-STWR).

And i have some issue.

I make STWR input data(coord, X, y, delt_intervel).

However, when i run Sel_Spt_BW functions, it stops soon with ValueError : math domain error

I saw the problem, it seems like a coord(lon, lat) problem.

I think this problem is calculating sqrt(I assumed that calculated values are negative value or None)

How do i solve this problem?

stwr_selector_ = Sel_Spt_BW(cal_coord_list, y, cal_X_list,delt_stwr_intervel,spherical = True)

Output

ValueError                                Traceback (most recent call last)
Untitled-2.ipynb Cell 110 in ()
----> 1 stwr_selector_ = Sel_Spt_BW(cal_coord_list, y, cal_X_list,delt_stwr_intervel,spherical = True)
      2 #optalpha,optsita,opt_btticks,opt_gwr_bw0 = stwr_selector_.search() 
      3 optalpha,optsita,opt_btticks,opt_gwr_bw0 = stwr_selector_.search()

File c:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\stwr-2.1.0-py3.10.egg\stwr\sel_bw.py:464, in Sel_Spt_BW.__init__(self, coordslist, y_list, X_list, tick_times_intervel, dspal_mat_list, sorted_dspal_list, d_tmp_list, dspmat, dtmat, family, offset, kernel, fixed, multi, eps, constant, spherical)
    462 self.constant = constant
    463 self.spherical = spherical
--> 464 self._build_dMatlist()
    465 self.search_params = {}

File c:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\stwr-2.1.0-py3.10.egg\stwr\sel_bw.py:492, in Sel_Spt_BW._build_dMatlist(self)
    490     self.sorted_dspal_list = None
    491 else:
--> 492     self.dspal_mat_list,self.d_tmp_list,self.dspmat,self.dtmat=cspatiltemporaldist(
    493                                 self.coordslist,self.coordslist,
    494                                 self.y_list,self.n_tick_nums,
    495                                 self.tick_timesIntls,self.spherical)
    496     if self.sorted_dspal_list is None:
    497             self.sorted_dspal_list = []

File c:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\stwr-2.1.0-py3.10.egg\stwr\kernels.py:293, in cspatiltemporaldist(cal_data_list1, cal_data_list2, y_valuelist, bt_size, deta_t_list, spherical, pred)
    291     for i in range(nsize) :
...
    270 a = sin(dLat/2)**2 + cos(lat1)*cos(lat2)*sin(dLon/2)**2
--> 271 c = 2*asin(sqrt(a))
    272 return R * c

ValueError: math domain error
Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...

Expectec

<stwr.sel_bw.Sel_Spt_BW at 0x2890632e170>

I'm trying to solve this problem change input data or using np.asarray

0

There are 0 best solutions below