  Context. The solar chromosphere and the lower transition region is believed
to play a crucial role in the heating of the solar corona. Models that describe
the chromosphere (and the lower transition region), accounting for its highly
dynamic and structured character are, so far, found to be lacking. This is
partly due to the breakdown of complete frequency redistribution in the
chromospheric layers and also because of the difficulty in obtaining complete
sets of observations that adequately constrain the solar atmosphere at all
relevant heights. Aims. We aim to obtain semi-empirical model atmospheres that
reproduce the features of the Mg II h&k line profiles that sample the middle
chromosphere with focus on a sunspot. Methods. We use spectropolarimetric
observations of the Ca II 8542 A spectra obtained with the Swedish 1-m Solar
Telescope (SST) and use NICOLE inversions to obtain semi-empirical model
atmospheres for different features in and around a sunspot. These are used to
synthesize Mg II h&k spectra using RH1.5D code, which we compare with
observations taken with the Interface Region Imaging Spectrograph (IRIS).
Results. Comparison of the synthetic profiles with IRIS observations reveals
that there are several areas, especially in the penumbra of the sunspot, where
most of the observed Mg II h&k profiles are very well reproduced. In addition,
we find that supersonic hot downflows, present in our collection of models in
the umbra, lead to synthetic profiles that agree well with the IRIS Mg II h&k
profiles, with the exception of the line core. Conclusions. We put forward and
make available four semi-empirical model atmospheres. Two for the penumbra,
reflecting the range of temperatures obtained for the chromosphere, one for
umbral flashes, and a model representative of the quiet surroundings of a
sunspot. These are available in electronic as well as in table formats.
