Remote X-ray spectrometry for NEAR and future missions: Modeling and analyzing X-ray production from source to surface