<commit_before>import numpy
import astropy.io.fits as fits


def z2n(freqs, time, harm=1):
    '''
    z2n(freqs,time[, harm])

    Description
    -----------
    A python implementation of the Rayleigh Z_n^2 method to calculate the power
    spectrum of a time series in a given range of frequencies

    Caculates a periodogram, using Fourrier-analysis trough
    a method using the statistical variable Z^2_n wich has a
    probability density funcion equal to that of a X^2 (chi-squared)
    with 2n degrees of freedom

    Input
    ----------
    freqs: an array with frequencies in units of 1/s

    time: an array with the time series where to find a period

    harm: [optional] harmonic of the Fourrier analysis use higher harmonics to
    low signals.

    Returns
    ----------
      Z2n: An array with the powerspectrum of the time series

    '''
    N = len(time)
    Z2n = []
    for ni in freqs:
        aux = 0
        for k in xrange(harm):
            Phi = (ni*time) % 1
            arg = (k+1)*Phi*2.0*numpy.pi
            phicos = numpy.cos(arg)
            phisin = numpy.sin(arg)
            aux = aux + (phicos.sum())**2 + (phisin.sum())**2
        Z2n.append(2.0*aux/N)
    return Z2n


def makefits(outptname='output.fits', *cols):
    '''
    makefits(outptname, col1[, col2, col3, ...])

    Description
    ----
    Creates a fits file with the giver columns and named <outptname>

    Input
    ----
    outptname : a string to name de output file

    cols : one or more lists in the format:
        col1 : [array, 'name-of-the-column', 'format', 'unit']

    Returns
    ----
    Boolean True<commit_msg>minor changes in myscitools.py<commit_after>import numpy
import astropy.io.fits as fits


def z2n(freqs, time, harm=1):
    '''
    z2n(freqs,time[, harm])

    Description
    -----------
    A python implementation of the Rayleigh Z_n^2 method to calculate the power
    spectrum of a time series in a given range of frequencies

    Caculates a periodogram, using Fourrier-analysis trough
    a method using the statistical variable Z^2_n wich has a
    probability density funcion equal to that of a X^2 (chi-squared)
    with 2n degrees of freedom

    Input
    ----------
    freqs: an array with frequencies in units of 1/s

    time: an array with the time series where to find a period

    harm: [optional] harmonic of the Fourrier analysis use higher harmonics to
    low signals.

    Returns
    ----------
      Z2n: An array with the powerspectrum of the time series

    '''
    N = len(time)
    Z2n = []
    for ni in freqs:
        aux = 0
        for k in xrange(harm):
            Phi = (ni*time) % 1
            arg = (k+1)*Phi*2.0*numpy.pi
            phicos = numpy.cos(arg)
            phisin = numpy.sin(arg)
            aux = aux + (phicos.sum())**2 + (phisin.sum())**2
        Z2n.append(2.0*aux/N)
    return Z2n


def makefits(outptname='output.fits', *cols):
    '''
    makefits(outptname, col1[, col2, col3, ...])

    Description
    ----
    Creates a fits file with the provided columns information

    Input
    ----
    outptname : a string to name de output file

    cols : one or more lists in the format:
        col1 : [array, 'name-of-the-column', 'format', 'unit']

    Returns
    ----
    Boolean True
{'fraction_non_alphanumeric': 0.10972644376899696, 'fraction_numerical': 0.015197568389057751, 'mean_word_length': 2.1076487252124645, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1621754', 'n_tokens_mistral': 1065, 'n_tokens_neox': 997, 'n_words': 372}