If two or more spectra have been taken under the same conditions, a very efficient way of removing particle hits from the raw data is to replace pixel values with large deviations from other observations with a local estimator, as done in the command COMBINE/LONG.
If multiple images are not available, cosmic ray hits have to be filtered out by a different method. The main requirement is that the image is not changed where there are no hits, especially on the area covered by the object under study. This can for instance be done with the command:
FILTER/MEDIAN inframe outframe 0,3,0.3 NR subframe
where subframe defines the region to filter. But you may wish to try other parameters and parameter values. This step is done twice to remove the hits on the sky on each side of the object.
Those cosmic ray hits in the area surrounding the object spectrum, which are particularly disturbing, were removed one by one using MODIFY/AREA ? ? 1, and working with the cursor on a zoomed display. Particular care must be exercised here, in order to modify only the few pixels affected by cosmic rays. For point sources and extended sources with very smoothly varying spatial profiles, FILTER/MEDIAN may also be tried. However, in order to preserve the instrumental profile the filter width along the dispersion axis must be set to 0.
Another possibility is to use the command FILTER/COSMIC. The algorithm detects hot pixels from a comparison of the pixel value with the ones of the neighbouring pixels. It rejects every `feature' that is more strongly peaked than the point spread function.
Regardless of the method used, it is necessary to check the performance of the filter by careful inspection of the difference between raw and filtered image which can be computed as COMPUTE/IMA TEST = RAW-FILTERED.