(a) When a judgment of imprisonment is imposed, or the execution of a judgment of imprisonment is ordered suspended, the sentencing judge must, in their sound discretion, order imposition of a sentence not to exceed the middle term, except as otherwise provided in paragraph (b). (b) The court may only choose an upper term when (1) there are circumstances in aggravation of the crime that justify the imposition of an upper term, and (2) the facts underlying those circumstances have been (i) stipulated