1. A method of identifying materials in a sample, comprising the steps of: collecting from multiple points on the sample measurement data providing information from which the composition of the sample at the multiple points can be determined; analyzing the measurement data to identify materials present in a pure phase at any of the multiple points in the sample; forming a sample-specific reference library containing materials identified as present in a pure phase at any of the multiple points in the sample; and analyzing the measurement data using the sample-specific library to determine the composition of the multiple points on the sample.