  The shapes of Stokes profiles contain much information about the atmospheric
conditions that produced them. However, a variety of different atmospheric
structures can produce very similar profiles. Thus, it is important for proper
interpretation of observations to have a good understanding of how the shapes
of Stokes profiles depend on the underlying atmosphere. An excellent tool in
this regard is forward modeling, i.e. computing and studying synthetic spectra
from realistic simulations of the solar atmosphere. Modern simulations
routinely produce several hundred thousand spectral profiles per snapshot. With
such numbers, it becomes necessary to use automated procedures in order to
organize the profiles according to their shape. Here we illustrate the use of
two complementary methods, k-means and k-Shape, to cluster similarly shaped
profiles, and demonstrate how the resulting clusters can be combined with
knowledge of the simulation's atmosphere to interpret spectral shapes. We
generate synthetic Stokes profiles for the Ca II 854.2 nm line using the
Multi3D code from a Bifrost simulation snapshot. We then apply the k-means and
k-Shape clustering techniques to group the profiles together according to their
shape. We show and compare the classes of profile shapes we retrieve from
applying both k-means and k-Shape to our synthetic intensity spectra. We then
show the structure of the underlying atmosphere for two particular classes of
profile shapes retrieved by the clustering, and demonstrate how this leads to
an interpretation for the formation of those profile shapes. Furthermore, we
apply both methods to the subset of our profiles containing the strongest
Stokes V signals, and demonstrate how k-Shape can be qualitatively better than
k-means at retrieving complex profile shapes when using a small number of
clusters.
