The SparSpec algorithm and the application to the detection of spatial periodicities in tokamaks: error weighting the penalization criterion to improve the performance of the algorithm**[Note: this work is partially based on a 4th year bachelor project by one of the authors (LMP), performed while being a student at the SPC-EPFL under the supervision of the corresponding author (DTA)]. (28th April 2021)