<commit_before>#!/usr/env python

import pprocess  # parallel computing module
import os  # os utilitites
import time  # 

import astropy.io.fits as fits  # FITS manipulating library
import matplotlib.pyplot as plt
import numpy as np  # numeric python for array manipulation

import myscitools # my personal tools


#input file informations and variables atributions----------------------
inptname = str(raw_input('Input file (with extension): '))
outptname = os.path.splitext(inptname)[0]+'_z2n_output_t.fits'
inpt = fits.open(inptname)
times = inpt[1].data.field('TIME')
inpt.close()

startf = float(raw_input('Enter the start frequency: '))
endf = float(raw_input('Enter the last frequency: '))
deltaf = float(raw_input('Enter the frequency interval: '))
freqs = np.arange(startf, endf, deltaf)

harm = int(raw_input('The Harmonic to be considered:'))

#----------------- The parallelism starts here ------------------------
nproc = int(raw_input('Enter the number of processor to use: '))
if nproc < 1:
    nproc = 1  # default number of cpus = 1

freqlist = np.array_split(freqs, nproc)


results = pprocess.Map(limit=nproc, reuse=1)
parallel_z2n = results.manage(pprocess.MakeReusable(myscitools.z2n))

print "\n Calculating with ", nproc, " processor(s)\n"

tic = time.time()
[parallel_z2n(somefreqs, times, harm) for somefreqs in freqlist]

print 'time = {0}'.format(time.time() - tic)
z2n = []
for result in results:
    for value in result:
        z2n.append(value)

print z2n

plt.plot(freqs, z2n)
plt.show()
plt.plot(freqs, z2n)
plt.savefig('teste.png')

#create and write the output.fits file
col1 = [freqs, 'Frequency', 'E', 'Hz']
col2 = [z2n, 'Z2nPower', 'E', 'arbitrary']
myscitools.makefits(outptname, col1, col2)<commit_msg>delete bugtracker move time marker<commit_after>#!/usr/env python

import pprocess  # parallel computing module
import os  # os utilitites
import time  # keep track of time

import astropy.io.fits as fits  # FITS manipulating library
import matplotlib.pyplot as plt
import numpy as np  # numeric python for array manipulation

import myscitools # my personal tools


#input file informations and variables atributions----------------------
inptname = str(raw_input('Input file (with extension): '))
outptname = os.path.splitext(inptname)[0]+'_z2n_output_t.fits'
inpt = fits.open(inptname)
times = inpt[1].data.field('TIME')
inpt.close()

startf = float(raw_input('Enter the start frequency: '))
endf = float(raw_input('Enter the last frequency: '))
deltaf = float(raw_input('Enter the frequency interval: '))
freqs = np.arange(startf, endf, deltaf)

harm = int(raw_input('The Harmonic to be considered:'))

#----------------- The parallelism starts here ------------------------
nproc = int(raw_input('Enter the number of processor to use: '))
if nproc < 1:
    nproc = 1  # default number of cpus = 1

freqlist = np.array_split(freqs, nproc)


results = pprocess.Map(limit=nproc, reuse=1)
parallel_z2n = results.manage(pprocess.MakeReusable(myscitools.z2n))

print "\n Calculating with ", nproc, " processor(s)\n"

tic = time.time()
[parallel_z2n(somefreqs, times, harm) for somefreqs in freqlist]

z2n = []
for result in results:
    for value in result:
        z2n.append(value)

print 'time = {0}'.format(time.time() - tic)

plt.plot(freqs, z2n)
plt.show()
plt.plot(freqs, z2n)
plt.savefig('z2n.png')

#create and write the output.fits file
col1 = [freqs, 'Frequency', 'E', 'Hz']
col2 = [z2n, 'Z2nPower', 'E', 'arbitrary']
myscitools.makefits(outptname, col1, col2)
{'fraction_non_alphanumeric': 0.15769997153430115, 'fraction_numerical': 0.012524907486478793, 'mean_word_length': 4.122448979591836, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '1822157', 'n_tokens_mistral': 1260, 'n_tokens_neox': 1205, 'n_words': 339}