There are a number of tools out there that can create a raster from a LiDAR point cloud by interpolating elevation, intensity or class values, but these tools generally limit you to interpolating those particular fields.
In particular I use the Python bindings for Whitebox. Unfortunately if you want to interpolate e.g., the number of returns per pulse* you have to trick the program by somehow swapping the field name for number of returns and a compatible field (like elevation).
I've tried to do this in-memory with laspy, but the memory limit is rather low. In these cases I've had to use a tool like las2txt and subsequently txt2las to swap the headers which is quite slow.
Another option is to convert the LiDAR cloud to vector points which have more general support for interpolation, but I'd guess that's even slower.
Is there a straightforward way in Python to swap LAS field headings in memory, allowing me to create as raster that is the result of interpolating any arbitrary LiDAR field? Pure Python solutions are preferred.
*Interpolating the elevation would result in a raster that represents the elevation at a given cell (i.e., a digital elevation model). Interpolating the number of returns per pulse results in a raster that represents the average number of returns per pulse in a given cell.