The usual explanation for discrete spectra is that electrons can absorb particular wavelengths of the electromagnetic spectrum, move up to a higher energy level, and then electromagnetic waves are released when the electron moves back down to its original energy level. I read that an electron in a particular subshell must have a particular amount of energy which can't vary, and I've also read that this electron jumping explanation is not what happens when atoms and molecules emit infrared radiation.
I've read that anything above 0 kelvin emits infrared. Apparently infrared absorption doesn't excite the electrons, but changes rotation, vibration, etc. What I don't understand is the mechanics behind what causes the infrared to be emitted in the first place (is it somehow related to electrons like the explanation in the first paragraph?), and why specific wavelengths of infrared lead to emission which can be used to identify substances