Looping with a range of integers for 'numeric' inputs in QGIS Python Console
I think the problem is dys/dayss
is datatype np.int64
when it should be int
:
import numpy as np
dayss = np.arange(1, 367, 1)
print(type(dayss[0]))
<class 'numpy.int64'>
Try int(dys)
in your paramms dictionary:
paramms = {'elevation': r'C:\***\dem_wg32_500m.tif', 'aspect':r'C:\***\asp_wg32_500m.tif', 'aspect_value': 270, 'slope': r'C:\***\slp_wg32_500m.tif', 'slope_value':0.0, 'linke': None, 'albedo': None, 'albedo_value': 0.2, 'lat': None, 'long': None, 'coeff_bh': None, 'coeff_dh': None, 'horizon_basemap': None, 'horizon_step': 1, 'day': int(dys), 'step': 1.0, 'declination': None, 'distance_step': 0.5, 'civil_time': None, 'time': 12.00, 'beam_rad': outfile, 'GRASS_REGION_PARAMETER': r'C:\***\dem_wg32_500m.tif', 'GRASS_REGION_CELLSIZE_PARAMETER': 0 }
Since you populate dayss
list using NumPy arange
method, type of items in the list is not int
, instead, it is <class 'numpy.int32'>
.
Just add dys = int(dys)
to for
loop.
for dys in dayss:
dys = int(dys)
Or generate the list using Python range
method.
dayss = range(1, 367, 1)