In order to define a contextual action for map windows, you need to put your Python script in your Python directory under a directory called Contextual_Spectrum_Plot_Spectrum_Plot_Layer.
Go to Tools->Options->Environment->Python Scripts (or Tools->Options->Python->Scripts in INTViewer 5.2) and click "Refresh from Disk". Your script should be listed automatically.
You will now be able to execute this script from the contextual menu of the spectrum plot layer:
This script will create a new spectrum layer in a new spectrum window, the spectrum type of which will vary based on the spectrum type of the original layer's window
This script is attached to the bottom of this article.
The window created after the script executes should look something like the following.