def draw_multiplet(ax, fine_state, p, hmin, w, fside='right',
                   label_separation=1, label_fontsize=15, fsize=10,
                   deltanu_fontsize=6, proportional=False, text='',
                   text_pos='top', magnetic_lines=False, **kwds):
    r"""We draw a multiplet."""
    # We determine the vertical positions, calculated from p[1] up.
    hyperfine_states = make_list_of_states([fine_state], 'hyperfine')

    h_list = [ei.nu - hyperfine_states[0].nu for ei in hyperfine_states]
    h_list = [i/h_list[-1] for i in h_list]
    h_min = min([h_list[i+1]-h_list[i] for i in range(len(h_list)-1)])
    h_list = [hmin*i/h_min + p[1] for i in h_list]

    if proportional:
        h_list = [p[1]+i*hmin for i in range(len(hyperfine_states))]

    omegaij = [(hyperfine_states[i+1].nu-hyperfine_states[i].nu)/1e6
               for i in range(len(hyperfine_states)-1)]

    for i in range(len(h_list)):
        label = '$\mathrm{F}='+str(hyperfine_states[i].f)+'$'
        if magnetic_lines:
            maxf = max([eee.f for eee in hyperfine_states])
            f = hyperfine_states[i].f
            nm = 2*maxf+1
            for mf in range(-f, f+1):
                draw_state(ax, [p[0]+mf*w/nm, h_list[i]], "", w/nm*0.5,
                           alignment=fside, fontsize=fsize)

            if fside == 'right':
                ax.text(p[0]+w+label_separation, h_list[i], label,
                        fontsize=fsize, horizontalalignment="right",
                        verticalalignment="center")
            elif fside == 'left':
                ax.text(p[0]-w-label_separation, h_list[i], label,
                        fontsize=fsize, horizontalalignment="left",
                        verticalalignment="center")
        else:
            draw_state(ax, [p[0], h_list[i]], label, w,
                       alignment=fside, fontsize=fsize)

    for i in range(len(h_list)-1):
        hmid = (h_list[i+1]+h_list[i])/2.0-0.5
        nu = str(omegaij[i])[:5]
        if fside == 'left':
            ax.text(p[0]-w/2.0, hmid, r'$'+nu+' \ \mathrm{MHz}$',
                    fontsize=deltanu_fontsize,
                    horizontalalignment=fside, verticalalignment='bottom')
        else:
            ax.text(p[0]+w/2.0, hmid, r'$'+nu+' \ \mathrm{MHz}$',
                    fontsize=deltanu_fontsize,
                    horizontalalignment=fside, verticalalignment='bottom')

    a = label_separation

    if text != '':
        if text_pos == 'top':
            labelx = p[0]
            labely = h_list[-1]+a

            ax.text(labelx, labely, '$'+text+'$',
                    verticalalignment='bottom',
                    horizontalalignment='center', fontsize=label_fontsize)
        elif text_pos == 'right':
            labelx = p[0]+w/2+2.0*a
            if fside == 'right': labelx = labelx+a*5.0
            labely = (h_list[-1]+h_list[0])/2.0

            ax.text(labelx, labely, '$'+text+'$',
                    verticalalignment='center',
                    horizontalalignment='left', fontsize=label_fontsize)

        elif text_pos == 'left':
            labelx = p[0]-w/2-2.0*a
            if fside == 'left': labelx = labelx-a*5.0
            labely = (h_list[-1]+h_list[0])/2.0

            ax.text(labelx, labely, '$'+text+'$',
                    verticalalignment='center',
                    horizontalalignment='right', fontsize=label_fontsize)

    return [[p[0], i] for i in h_list]
def draw_multiplet ( ax , fine_state , p , hmin , w , fside = 'right' , label_separation = 1 , label_fontsize = 15 , fsize = 10 , deltanu_fontsize = 6 , proportional = False , text = '' , text_pos = 'top' , magnetic_lines = False , ** kwds ) : hyperfine_states = make_list_of_states ( [ fine_state ] , 'hyperfine' ) h_list = [ ei . nu - hyperfine_states [ 0 ] . nu for ei in hyperfine_states ] h_list = [ i / h_list [ - 1 ] for i in h_list ] h_min = min ( [ h_list [ i + 1 ] - h_list [ i ] for i in range ( len ( h_list ) - 1 ) ] ) h_list = [ hmin * i / h_min + p [ 1 ] for i in h_list ] if proportional : h_list = [ p [ 1 ] + i * hmin for i in range ( len ( hyperfine_states ) ) ] omegaij = [ ( hyperfine_states [ i + 1 ] . nu - hyperfine_states [ i ] . nu ) / 1e6 for i in range ( len ( hyperfine_states ) - 1 ) ] for i in range ( len ( h_list ) ) : label = '$\mathrm{F}=' + str ( hyperfine_states [ i ] . f ) + '$' if magnetic_lines : maxf = max ( [ eee . f for eee in hyperfine_states ] ) f = hyperfine_states [ i ] . f nm = 2 * maxf + 1 for mf in range ( - f , f + 1 ) : draw_state ( ax , [ p [ 0 ] + mf * w / nm , h_list [ i ] ] , "" , w / nm * 0.5 , alignment = fside , fontsize = fsize ) if fside == 'right' : ax . text ( p [ 0 ] + w + label_separation , h_list [ i ] , label , fontsize = fsize , horizontalalignment = "right" , verticalalignment = "center" ) elif fside == 'left' : ax . text ( p [ 0 ] - w - label_separation , h_list [ i ] , label , fontsize = fsize , horizontalalignment = "left" , verticalalignment = "center" ) else : draw_state ( ax , [ p [ 0 ] , h_list [ i ] ] , label , w , alignment = fside , fontsize = fsize ) for i in range ( len ( h_list ) - 1 ) : hmid = ( h_list [ i + 1 ] + h_list [ i ] ) / 2.0 - 0.5 nu = str ( omegaij [ i ] ) [ : 5 ] if fside == 'left' : ax . text ( p [ 0 ] - w / 2.0 , hmid , r'$' + nu + ' \ \mathrm{MHz}$' , fontsize = deltanu_fontsize , horizontalalignment = fside , verticalalignment = 'bottom' ) else : ax . text ( p [ 0 ] + w / 2.0 , hmid , r'$' + nu + ' \ \mathrm{MHz}$' , fontsize = deltanu_fontsize , horizontalalignment = fside , verticalalignment = 'bottom' ) a = label_separation if text != '' : if text_pos == 'top' : labelx = p [ 0 ] labely = h_list [ - 1 ] + a ax . text ( labelx , labely , '$' + text + '$' , verticalalignment = 'bottom' , horizontalalignment = 'center' , fontsize = label_fontsize ) elif text_pos == 'right' : labelx = p [ 0 ] + w / 2 + 2.0 * a if fside == 'right' : labelx = labelx + a * 5.0 labely = ( h_list [ - 1 ] + h_list [ 0 ] ) / 2.0 ax . text ( labelx , labely , '$' + text + '$' , verticalalignment = 'center' , horizontalalignment = 'left' , fontsize = label_fontsize ) elif text_pos == 'left' : labelx = p [ 0 ] - w / 2 - 2.0 * a if fside == 'left' : labelx = labelx - a * 5.0 labely = ( h_list [ - 1 ] + h_list [ 0 ] ) / 2.0 ax . text ( labelx , labely , '$' + text + '$' , verticalalignment = 'center' , horizontalalignment = 'right' , fontsize = label_fontsize ) return [ [ p [ 0 ] , i ] for i in h_list ]
r"""We draw a multiplet.