I could not find a solution with raw files, I know that the recent version of hugin is supposed to support raw files using dcraw but I cannot test it myself. The next good solution in my opinion is to convert all of your raw data to tif or other lossless image format and use it.
For my method I mainly hugin_tools on the terminal, but I also use the GUI, so keep in mind that you need to install both.
You can find the hugin costume here for download.
I also use Ubuntu on my machine, but the procedure on mac should be the same.
First thing you need to put all the photos in one folder, it is mainly for convenience, but will help you with later orders.
Generate a pto file
Next, you need to generate a pto file, i.e. the file where all the image transformation data is saved.
You can do this by typing:
in the terminal where all the photos are located.
Cropping in a still area
You now need to find matches between all of your images, before doing so there is an optional part which will greatly reduce errors if there are moving objects in your set.
Open the hugin project you generated and change the interface to advanced.
In the window that opens, go to the masks tab and choose the cropping tab and select your first image. Now make sure that "all images of the selected lens" are checked, then drag them from the edges of the image and crop to the area with the least or no movement. This will restrict the match finder to this area and reduce errors during the remapping step. You can now save and exit the program.
Now you can find the matches, type:
cpfind --linearmatch *.pto
in the terminal, this will find matches between pairs of images.
You can also find matches between all the images by simply omitting the ‘linearmatch’ option, but if you have hundreds of images, it will take a long time and will probably be useless.
You can read more about cpfind here.
Then you need to clean up the checkpoints you found, there are two commands for this:
celeste_standalone -i default.pto -o default.pto
will try to clear the control points on the clouds (More information here).
cpclean -o default.pto default.pto
will delete checkpoints with a high error value. (cpclean help page)
Now that we are done with the checkpoints, open the new generated project called by default and go back to the masks tab as before, select the cropping tab again and click on the reset button, this will turn off cropping of all images.
After that, you need to optimize the checkpoints. Type:
pto_var --opt="y, p, r, TrX, TrY, TrZ" -o default.pto default.pto
autooptimiser -n -o default.pto default.pto
This will optimize the position and distortion of your set of images, you can read more about this process here.
You're almost done, just type:
pano_modify -o default.pto --projection=0 --fov=AUTO --center --canvas=AUTO --crop=AUTOHDR --output-type=REMAPORIG default.pto
to modify the project configuration.
Finally, simply type:
nona -m TIFF_m -o remapped default.pto
to output the remapped images.
If you also want to stack the images together, you can also use:
hugin_stacker --output=median --mode=median remapped*.tif
You can find more information about the hugin command line tools here.
There you go, my take on your problem, there are some missing links because this is my first answer, so I was limited to 8. If there are any errors or if you have any problems, let me know, my English is not the best sorry if I have made grammatical or spelling mistakes. Cheers!