<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def ThermalSpectrum(self):
 """Calculate thermal spectrum. Returns ------- sp : `~pysynphot.spectrum.CompositeSourceSpectrum` Thermal spectrum in ``photlam``. Raises ------ IndexError Calculation failed. """

        try:
            # delegate to subclass.
            thom = _ThermalObservationMode(self._obsmode)
            self.pixscale = thom.pixscale
            return thom._getSpectrum()
        except IndexError:   # graph table is broken.
            raise IndexError("Cannot calculate thermal spectrum; graphtable may be broken")