First, the Imtbl montage routine looks in the workdir for fits images to obtain the metadata. It automatically skips "*_area.fits" files, as it understand these are montage-generated. But, in successive executions, if tmpfiles are not deleted, there's a _mosaic64.fits file in the dir, which is (wrongly) included in the .tbl file, causing the program to crash.
Second, montage methods mAdd and mConvert sometimes fail silently and the program keeps going, crashing in a later stage (as the mosaic intermediate files are obviously missing).
With these fixes, the tmpdir is deleted in successive executions to avoid the first problem, and exceptions are handled when calling the montage routines, returning a -1 and taking the "best" image by default.
Spotted a couple of issues when mosaicking:
First, the Imtbl montage routine looks in the workdir for fits images to obtain the metadata. It automatically skips "*_area.fits" files, as it understand these are montage-generated. But, in successive executions, if tmpfiles are not deleted, there's a _mosaic64.fits file in the dir, which is (wrongly) included in the .tbl file, causing the program to crash.
Second, montage methods mAdd and mConvert sometimes fail silently and the program keeps going, crashing in a later stage (as the mosaic intermediate files are obviously missing).
With these fixes, the tmpdir is deleted in successive executions to avoid the first problem, and exceptions are handled when calling the montage routines, returning a -1 and taking the "best" image by default.