A method of generating a library of simulated-differentiation signals (simulated signals of a periodic grating includes obtaining a measured-diffraction signal (measured signal). Hypothetical parameters are associated with a hypothetical profile. The hypothetical parameters are varied within a range to generate a set of hypothetical profiles. The range to vary the hypothetical parameters is adjusted based on the measured signal. A set of simulated signals is generated from the set of hypothetical profiles.