#NEWLINE# def sigma_clipping( date , mag , err , threshold = 3 , iteration = 1 ) : #NEWLINE# #INDENT# '\n    Remove any fluctuated data points by magnitudes.\n\n    Parameters\n    ----------\n    date : array_like\n        An array of dates.\n    mag : array_like\n        An array of magnitudes.\n    err : array_like\n        An array of magnitude errors.\n    threshold : float, optional\n        Threshold for sigma-clipping.\n    iteration : int, optional\n        The number of iteration.\n\n    Returns\n    -------\n    date : array_like\n        Sigma-clipped dates.\n    mag : array_like\n        Sigma-clipped magnitudes.\n    err : array_like\n        Sigma-clipped magnitude errors.\n    ' #NEWLINE# if ( ( len ( date ) != len ( mag ) ) or ( len ( date ) != len ( err ) ) or ( len ( mag ) != len ( err ) ) ) : #NEWLINE# #INDENT# raise RuntimeError ( 'The length of date, mag, and err must be same.' ) #NEWLINE# #UNINDENT# for i in range ( int ( iteration ) ) : #NEWLINE# #INDENT# mean = np . median ( mag ) #NEWLINE# std = np . std ( mag ) #NEWLINE# index = ( ( mag >= ( mean - ( threshold * std ) ) ) & ( mag <= ( mean + ( threshold * std ) ) ) ) #NEWLINE# date = date [ index ] #NEWLINE# mag = mag [ index ] #NEWLINE# err = err [ index ] #NEWLINE# #UNINDENT# return ( date , mag , err )