ihesp / IPART

Image-Process based Atmospheric River Tracking (IPART) algorithms
https://ipart.readthedocs.io/en/latest/
GNU General Public License v3.0
20 stars 8 forks source link

error when running 3_detect_ARs.ipynb #24

Open everson-ufsm opened 1 week ago

everson-ufsm commented 1 week ago

Hi. I got an error when running 3_detect_ARs.ipynb. More specifically, when executing the line: time_idx, labels, angles, crossfluxes, result_df = findARs(ivt.data, ivtrec.data, ivtano.data, qu.data, qv.data, latax, lonax, times=timeax, **PARAM_DICT)

The error message we got was: ==== Start of error message====(Added by me!)

: Metadata created.

: Processing time: 2024-04-20 00:00


ValueError Traceback (most recent call last) Cell In[9], line 1 ----> 1 time_idx, labels, angles, crossfluxes, result_df = findARs(ivt.data, ivtrec.data, 2 ivtano.data, qu.data, qv.data, latax, lonax, times=timeax, **PARAM_DICT)

File ~/anaconda3/envs/py_jupyter/lib/python3.11/site-packages/ipart/AR_detector.py:1884, in findARs(ivt, ivtrec, ivtano, qu, qv, lats, lons, times, ref_time, thres_low, min_area, max_area, min_LW, min_lat, max_lat, min_length, min_length_hard, rdp_thres, fill_radius, single_dome, max_ph_ratio, edge_eps, zonal_cyclic, verbose) 1873 finder_gen = findARsGen(ivt, ivtrec, ivtano, qu, qv, lats, lons, 1874 times=times, ref_time=ref_time, thres_low=thres_low, 1875 min_area=min_area, max_area=max_area, (...) 1880 edge_eps=edge_eps, zonal_cyclic=zonal_cyclic, 1881 verbose=verbose) 1882 next(finder_gen) # prime the generator to prepare metadata -> 1884 for (tidx, timett, label, angle, cross, ardf) in finder_gen: 1886 time_idx.append(tidx) 1887 labels_all.append(label)

File ~/anaconda3/envs/py_jupyter/lib/python3.11/site-packages/ipart/AR_detector.py:2073, in findARsGen(ivt, ivtrec, ivtano, qu, qv, lats, lons, times, ref_time, thres_low, min_area, max_area, min_LW, min_lat, max_lat, min_length, min_length_hard, rdp_thres, fill_radius, single_dome, max_ph_ratio, edge_eps, zonal_cyclic, verbose) 2070 continue 2072 # find AR axis -> 2073 axis_list, axismask=findARAxis(quslab, qvslab, mask_list, costhetas, 2074 sinthetas, reso, param_dict) 2076 # decompose background-transient 2077 qurec,quano,qvrec,qvano=uvDecomp(quslab,qvslab,slabrec,slabano)

File ~/anaconda3/envs/py_jupyter/lib/python3.11/site-packages/ipart/AR_detector.py:1401, in findARAxis(quslab, qvslab, armask_list, costhetas, sinthetas, reso, param_dict, verbose) 1399 gii=maskToGraph(maskii,quii,qvii,cosii,sinii,edge_eps) 1400 #--------------Get AR axis from graph-------------- -> 1401 axisarrii,axismaskii=getARAxis(gii,quii,qvii,maskii,None) 1403 if rollii: 1404 # shift back 1405 #axismaskii=np.roll(axismaskii, -axismaskii.shape[1]//2, axis=1) 1406 #newx=(axisarrii[:,1] - axismaskii.shape[1]//2)%axismaskii.shape[1] 1407 axismaskii=np.roll(axismaskii, -shift_lon, axis=1)

File ~/anaconda3/envs/py_jupyter/lib/python3.11/site-packages/ipart/AR_detector.py:455, in getARAxis(g, quslab, qvslab, mask, edge) 452 distii=distdict[nodeii] 453 dists[ii,outedgecoor.index(nodeii)]=distii --> 455 if np.max(dists)==0: 456 # this may happen when a mask is touching the map edges, and inedgecoor 457 # outedgecoor can't be linked by a path. Very rarely happen, but damn 458 # annoying. A fallback solution is to use an undirected graph linking 459 # the most inward and most outward pixels. 460 mostin=np.unravel_index(np.argmax(inedge), mask.shape) 461 mostout=np.unravel_index(np.argmin(inedge), mask.shape)

File ~/anaconda3/envs/py_jupyter/lib/python3.11/site-packages/numpy/core/fromnumeric.py:2810, in max(a, axis, out, keepdims, initial, where) 2692 @array_function_dispatch(_max_dispatcher) 2693 @set_module('numpy') 2694 def max(a, axis=None, out=None, keepdims=np._NoValue, initial=np._NoValue, 2695 where=np._NoValue): 2696 """ 2697 Return the maximum of an array or maximum along an axis. 2698 (...) 2808 5 2809 """ -> 2810 return _wrapreduction(a, np.maximum, 'max', axis, None, out, 2811 keepdims=keepdims, initial=initial, where=where)

File ~/anaconda3/envs/py_jupyter/lib/python3.11/site-packages/numpy/core/fromnumeric.py:88, in _wrapreduction(obj, ufunc, method, axis, dtype, out, kwargs) 85 else: 86 return reduction(axis=axis, out=out, passkwargs) ---> 88 return ufunc.reduce(obj, axis, dtype, out, **passkwargs)

ValueError: zero-size array to reduction operation maximum which has no identity ==== End of error message====(Added by me!)

Could it be an error due to some AR being at the edge of the data domain? My domain is not zonally cyclic! Does anyone have any suggestions? Goodbye

everson-ufsm commented 3 days ago

Hi, I've solved the problem! The error was actually due to the AR area being on the edge of the domain. By using data for the entire hemisphere (cyclic-zonally), the error was solved. Goodbye.