KMarkert / servir-vic-training

Training materials for the VIC hydrologic model setup developed for the @SERVIR program
GNU General Public License v3.0
36 stars 32 forks source link

Zero-size array to reduction operation maximum which has no identity #32

Closed giaMSU closed 2 years ago

giaMSU commented 2 years ago

Hi everyone, I ran the VIC Model using Dr. Markert code. I am creating forcing files. However, I met an issues " _Traceback (most recent call last): File "gia_format_meteo_forcing.py", line 172, in main() File "gia_format_meteo_forcing.py", line 164, in main format_meteo_forcing(sys.argv[1],sys.argv[2],sys.argv[3],sys.argv[4],sys.argv[5]) File "gia_format_meteo_forcing.py", line 122, in format_meteo_forcing tmaxval = np.max(tmax[cnt1:cnt2+1,idx[0],idx[1]]-273.15) File "<__array_function__ internals>", line 5, in amax File "/home/giamsu/anaconda3/lib/python3.8/site-packages/numpy/core/fromnumeric.py", line 2733, in amax return _wrapreduction(a, np.maximum, 'max', axis, None, out, File "/home/giamsu/anaconda3/lib/python3.8/site-packages/numpy/core/fromnumeric.py", line 85, in _wrapreduction return reduction(axis=axis, out=out, **passkwargs) File "/home/giamsu/anaconda3/lib/python3.8/site-packages/numpy/ma/core.py", line 5830, in max result = self.filled(fill_value).max( File "/home/giamsu/anaconda3/lib/python3.8/site-packages/numpy/core/_methods.py", line 39, in _amax return umrmaximum(a, axis, None, out, keepdims, initial, where) ValueError: zero-size array to reduction operation maximum which has no identity"

Could anyone know how to fix the issue? Thank you so much. GN

giaMSU commented 2 years ago

To solve the issue, I replaced

"tmaxval = np.max(tmax[cnt1:cnt2+1,idx[0],idx[1]]-273.15)" by "try: tmaxval = np.max(tmax[cnt1:cnt2+1,idx[0],idx[1]]-273.15) except: tmaxval = 0"