Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error when running 3_detect_ARs.ipynb #24

Open
everson-ufsm opened this issue Jun 28, 2024 · 2 comments
Open

error when running 3_detect_ARs.ipynb #24

everson-ufsm opened this issue Jun 28, 2024 · 2 comments

Comments

@everson-ufsm
Copy link

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
Copy link
Author

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.

@Xunius
Copy link
Collaborator

Xunius commented Jul 8, 2024

@everson-ufsm Glad to hear that you solved the problem. Sorry for not having responded earlier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants