to make things faster (and maybe more consistent), it may just be better to have lat and long rasters as input to r.sun, instead of repeatingly calling for a function to convert them.