Influence of pH on protein peptide mass
Your approach in general seems to be OK, but I have a few suggestions:


You are basing all your calculations on whether the pH is above or below 7. However the N and C termini have pKa values that determine whether these groups will be ionized (8 and 3, respectively). You should check whether the pH is above/below these values instead of 7.
Different amino acid side chains can also be ionized and should be accounted for when calculating the MW. Amino acid pKas can be found here
Code wise: you pass a variable unimod_location in your function but it's never used. If it's not being used then take it out.