<commit_before>from subprocess import call
import matplotlib.pyplot as plt
import numpy as np
import healpy as hp
import sys
import time


spice_data='spice_data.fits'
spice_data_alm='spice_data_alm.fits'
spice_noise='spice_noise.fits'
spice_noise_alm='spice_noise_alm.fits'
spice_mask='spice_mask.fits'
spice_dl='spice_dl.dat'
spice_nl='spice_nl.dat'
spice_bl='spice_bl.dat'
spice_crr='spice_crr.dat'

def get_mask_file(inv_noise_map):
    mask=np.zeros(np.shape(inv_noise_map))
    mask[inv_noise_map>0]=1

    return mask

def compute_pcl_estimate(data_file,inv_noise_file,beam_file,num_samps):
    #write the data file
    d = hp.read_map(data_file)

    #create a mask file from inv_noise
    inv_n = hp.read_map(inv_noise_file)
    msk = get_mask_file(inv_n)

    #compute the useful area
    useful_pixels = len(msk[msk>0])

    fsky = useful_pixels/float(len(msk))

    print "fsky =",fsky

    total_objects = np.sum(inv_n[msk>0])

    print "total objects = ", total_objects

    shot_noise = 4*np.pi*fsky/total_objects

    print "shot noise = ", shot_noise

    if d.shape != inv_n.shape :
        raise RuntimeError("data and noise have different dimensions")

    nside=hp.npix2nside(np.shape(d)[0])


    #write the noise map
    n = np.zeros(np.shape(inv_n))
    n[inv_n>0]  = 1./np.sqrt(inv_n[inv_n>0])

    #load the beam file
    B_l_in = np.loadtxt(beam_file,delimiter=",")
    B_l = B_l_in[:,1]

    #compute the powe spectrum of the data
    D_l = hp.anafast(d,lmax=2*nside)
    #apply the fksy correction
    D_l /=fsky<commit_msg>a bug in the anafast solved<commit_after>from subprocess import call
import matplotlib.pyplot as plt
import numpy as np
import healpy as hp
import sys
import time


spice_data='spice_data.fits'
spice_data_alm='spice_data_alm.fits'
spice_noise='spice_noise.fits'
spice_noise_alm='spice_noise_alm.fits'
spice_mask='spice_mask.fits'
spice_dl='spice_dl.dat'
spice_nl='spice_nl.dat'
spice_bl='spice_bl.dat'
spice_crr='spice_crr.dat'

def get_mask_file(inv_noise_map):
    mask=np.zeros(np.shape(inv_noise_map))
    mask[inv_noise_map>0]=1

    return mask

def compute_pcl_estimate(data_file,inv_noise_file,beam_file,num_samps):
    #write the data file
    d = hp.read_map(data_file)

    msk = np.ones(np.shape(d))

    #create a mask file from inv_noise
    if inv_noise_file != None :
        #inv_n = hp.read_map(inv_noise_file)
        msk = get_mask_file(inv_n)

    #compute the useful area
    useful_pixels = np.shape(msk)[0]

    if inv_noise_file != None :
        useful_pixels = len(msk[msk>0])

    fsky = useful_pixels/float(np.shape(msk)[0])

    print "fsky =",fsky

    total_objects = np.sum(d[msk>0])

    print "total objects = ", total_objects

    shot_noise = 4*np.pi*fsky/total_objects

    print "shot noise = ", shot_noise

    if d.shape != d.shape :
        raise RuntimeError("data and noise have different dimensions")

    nside=hp.npix2nside(np.shape(d)[0])


    #write the noise map
    #n = np.zeros(np.shape(inv_n))
    #n[inv_n>0]  = 1./np.sqrt(inv_n[inv_n>0])

    #load the beam file
    B_l_in = np.loadtxt(beam_file,delimiter=",")
    B_l = B_l_in[:,1]

    #compute the powe spectrum of the data
    D_l = hp.anafast(d,lmax=2*nside)
    #apply the fksy correction
    D_l /=fsky
{'fraction_non_alphanumeric': 0.11403240599205136, 'fraction_numerical': 0.007948639559767655, 'mean_word_length': 3.9129129129129128, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '4476606', 'n_tokens_mistral': 1392, 'n_tokens_neox': 1312, 'n_words': 250}