Running SOLN_LAB_3_3 with a Husky doesn't yield correct results

I ran my own code with the simulated data instead and the key was guess as expected. I also found this link (Blinking together ADC and Glitch (CW Husky) - #20 by jpthibault) that gave good information on how to find and correct scope errors on the Husky.

The issue is that Husky was clipping all the time. The Husky still has errors even after putting it on scope.gain.mode = 'low' (gain too low). Setting scope.gain.db=9 (I tried 15 as well) worked really well to clear those errors.

So now my Husky does not blink anymore. However, I still don’t have any clear outliers for the key recovery. For instance the following code:

# ###################
# Add your code here

byte_to_check = 0
    
for hypothetical_bit in range (8):
    print("Guessing bit {}".format(hypothetical_bit))
    max_diff_list = [0]*256
    for guess in range(256):

        one_list = []
        zero_list = []

        for trace_index in range(numtraces):

            input_byte = textin_array[trace_index][byte_to_check]
            hypothetical_leakage_bit = get_bit(aes_internal(guess, input_byte), hypothetical_bit)
            #Get a hypothetical leakage list - use aes_internal(guess, input_byte)          

            if hypothetical_leakage_bit == 1:
                one_list.append(trace_array[trace_index])
            else:
                zero_list.append(trace_array[trace_index])

        avg_one_list = np.asarray(one_list).mean(axis=0)
        avg_zero_list = np.asarray(zero_list).mean(axis=0)
        diff = avg_one_list - avg_zero_list
        max_diff_list[guess] = np.max(np.abs(diff))
       
    sorted_list = np.argsort(max_diff_list)[::-1]
    for guess in sorted_list[0:5]:
        print("Guessing {:02X} = {} max difference".format(guess, max_diff_list[guess]))

# ###################
#raise NotImplementedError("Add Your Code Here")

Output:

Guessing bit 0
Guessing 99 = 0.005902638194051749 max difference
Guessing 7A = 0.005651018018613788 max difference
Guessing 03 = 0.005514248138483439 max difference
Guessing F0 = 0.0045560546346249675 max difference
Guessing A2 = 0.004528716593514479 max difference
Guessing bit 1
Guessing 33 = 0.004505359428481234 max difference
Guessing 54 = 0.0044835073738925535 max difference
Guessing EF = 0.004276400725818183 max difference
Guessing 0E = 0.004237268944205896 max difference
Guessing A9 = 0.004094750817250428 max difference
Guessing bit 2
Guessing 44 = 0.004499186393307323 max difference
Guessing D1 = 0.004198045386538934 max difference
Guessing D6 = 0.004053841480777816 max difference
Guessing 83 = 0.0040455373638026045 max difference
Guessing 9C = 0.003885179901513696 max difference
Guessing bit 3
Guessing 83 = 0.005833940307519856 max difference
Guessing 37 = 0.0046457416430466004 max difference
Guessing B0 = 0.004334934195035417 max difference
Guessing 16 = 0.0041111867860526875 max difference
Guessing 84 = 0.003990534049397788 max difference
Guessing bit 4
Guessing ED = 0.0058740444125536945 max difference
Guessing 5A = 0.005001952192327491 max difference
Guessing 2F = 0.004694605105501987 max difference
Guessing A0 = 0.0042323282288084345 max difference
Guessing 80 = 0.0039705824675472096 max difference
Guessing bit 5
Guessing 62 = 0.0053920840119666205 max difference
Guessing EC = 0.005068692860458104 max difference
Guessing 1B = 0.004922486227210338 max difference
Guessing 96 = 0.004566689473281572 max difference
Guessing BB = 0.0041205128408917935 max difference
Guessing bit 6
Guessing CD = 0.005902739682644095 max difference
Guessing 7B = 0.0055705732562989045 max difference
Guessing 31 = 0.005075793975103635 max difference
Guessing 08 = 0.004965798668758303 max difference
Guessing BA = 0.004730152508342213 max difference
Guessing bit 7
Guessing 0B = 0.006503706862239184 max difference
Guessing 27 = 0.005723674687116199 max difference
Guessing AF = 0.005167010000418467 max difference
Guessing 9C = 0.005066483919737769 max difference
Guessing 3B = 0.005016875155058068 max difference

Note how close the differences are and how much they change given the bit of the SBox I study.
I use SAM4S as a target.

Using the simulated data consistently gives me 2B as an answer for byte 0 and all 8 bits so I don’t think my code has an issue but if it does feel free to tell me.

Using the solution code at the end with the ghost peaks correction and windowing does not work either. The key does not even show in the top 5 guesses. What am I doing wrong ?

Edit: tried augmenting samples to 37000 to see all AES rounds, tried windowing, the key is barely in the top 5 and never has dominant peaks compared to other key guesses. I can provide all traces captured with the CWHusky if it is of any help.