<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _calcLocalEnergy(self, diff, es, which):
 r"""Calculate local deformation energy using a difference vector. It is called in :meth:`dnaEY.getLocalDeformationEnergy` for energy calculation of each frame. Parameters diff : numpy.ndarray Array of difference between minimum and current parameter values. es : numpy.ndarray Elastic matrix. See in :meth:`dnaEY.calculateLocalElasticity` about elastic matrix. which : str For which type of motions, energy will be calculated. see ``which`` parameter in :meth:`dnaEY.getLocalDeformationEnergy` for keywords. Return ------ energy : float Deformation free energy value """


        if which not in self.enLocalTypes:
            raise ValueError('{0} is not a supported energy keywords.\n Use any of the following: \n {1}'.format(
                which, self.enLocalTypes))

        energy = None

        if which == 'full':
            temp = np.matrix(diff)
            energy = 0.5 * ((temp * es) * temp.T)
            energy = energy[0,0]

        if which == 'diag':
            energy = 0.5 * ((diff[0] ** 2 * es[0][0])
                            + (diff[1] ** 2 * es[1][1])
                            + (diff[2] ** 2 * es[2][2])
                            + (diff[3] ** 2 * es[3][3])
                            + (diff[4] ** 2 * es[4][4])
                            + (diff[5] ** 2 * es[5][5]))

        if which == 'shift' or which == 'x-disp':
            energy = 0.5 * (diff[0] ** 2 * es[0][0])

        if which == 'slide' or which == 'y-disp':
            energy = 0.5 * (diff[1] ** 2 * es[1][1])

        if which == 'rise' or which == 'h-rise':
            energy = 0.5 * (diff[2] ** 2 * es[2][2])

        if which == 'tilt' or which == 'inclination':
            energy = 0.5 * (diff[3] ** 2 * es[3][3])

        if which == 'roll' or which == 'tip':
            energy = 0.5 * (diff[4] ** 2 * es[4][4])

        if which == 'twist' or which == 'h-twist':
            energy = 0.5 * (diff[5] ** 2 * es[5][5])

        return energy