示例#1
0
def create_acquisition_operator_REC(pointing,
                                    d,
                                    nf_sub_rec,
                                    verbose=False,
                                    instrument=None):
    # scene
    s = qubic.QubicScene(d)
    if d['nf_sub'] == 1:
        if verbose:
            print('Making a QubicInstrument.')
        q = qubic.QubicInstrument(d)
        # one subfreq for recons
        _, nus_edge, _, _, _, _ = qubic.compute_freq(
            d['filter_nu'] / 1e9, nf_sub_rec, d['filter_relative_bandwidth'])
        arec = qubic.QubicAcquisition(q, pointing, s, d)

        return arec
    else:
        if instrument is None:
            if verbose:
                print('Making a QubicMultibandInstrument.')
            q = qubic.QubicMultibandInstrument(d)
        else:
            q = instrument
        # number of sub frequencies for reconstruction
        _, nus_edge, _, _, _, _ = qubic.compute_freq(
            d['filter_nu'] / 1e9, nf_sub_rec, d['filter_relative_bandwidth'])
        # Operator for Maps Reconstruction
        arec = qubic.QubicMultibandAcquisition(q, pointing, s, d, nus_edge)
        return arec
示例#2
0
def create_acquisition_operator_REC(pointing, d, nf_sub_rec):
    # Polychromatic instrument model
    q = qubic.QubicMultibandInstrument(d)
    # scene
    s = qubic.QubicScene(d)
    # number of sub frequencies for reconstruction
    _, nus_edge, _, _, _, _ = qubic.compute_freq(
        d['filter_nu'] / 1e9, nf_sub_rec, d['filter_relative_bandwidth'])
    # Operator for Maps Reconstruction
    arec = qubic.QubicMultibandAcquisition(q, pointing, s, d, nus_edge)
    return arec
示例#3
0
def create_acquisition_operator_TOD(pointing, d):
    # Polychromatic instrument model
    q = qubic.QubicMultibandInstrument(d)
    # scene
    s = qubic.QubicScene(d)
    # number of sub frequencies to build the TOD
    _, nus_edge_in, _, _, _, _ = qubic.compute_freq(
        d['filter_nu'] / 1e9, d['filter_relative_bandwidth'],
        d['nf_sub'])  # Multiband instrument model
    # Multi-band acquisition model for TOD fabrication
    atod = qubic.QubicMultibandAcquisition(q, pointing, s, d, nus_edge_in)
    return atod
示例#4
0
def get_tod(d, p, x0):
    # Polychromatic instrument model
    q = qubic.QubicMultibandInstrument(d)

    # Scene
    s = qubic.QubicScene(d)

    # Number of sub frequencies to build the TOD
    _, nus_edge_in, _, _, _, _ = qubic.compute_freq(
        d['filter_nu'] / 1e9, d['filter_relative_bandwidth'], d['nf_sub'])

    # Multi-band acquisition operator
    a = qubic.QubicMultibandAcquisition(q, p, s, d, nus_edge_in)

    tod, _ = a.get_observation(x0, noiseless=True)

    return q, tod
示例#5
0
def make_covTD(d):
	"""
	Usually coverage map is provided in a separate file. But if not the case, this method can compute a coverage map
	Parameters:
	d: Qubic dictionary
	Return:
	cov: coverage map in a.QubicMultibandAcquisition shape (nfreq, npix).
	"""

	pointing = qubic.get_pointing(d)
	q= qubic.QubicMultibandInstrument(d)
	s= qubic.QubicScene(d)
	nf_sub_rec = d['nf_recon']
	_, nus_edge, nus, _, _, _ = qubic.compute_freq(d['filter_nu'] / 1e9, 
												   nf_sub_rec, d['filter_relative_bandwidth'])
	arec = qubic.QubicMultibandAcquisition(q, pointing, s, d, nus_edge)
	cov = arec.get_coverage()
	return cov
示例#6
0
def create_acquisition_operator_TOD(pointing, d, verbose=False):
    # scene
    s = qubic.QubicScene(d)
    if d['nf_sub'] == 1:
        if verbose:
            print('Making a QubicInstrument.')
        q = qubic.QubicInstrument(d)
        return qubic.QubicAcquisition(q, pointing, s, d)
    else:
        # Polychromatic instrument model
        if verbose:
            print('Making a QubicMultibandInstrument.')
        q = qubic.QubicMultibandInstrument(d)
        # number of sub frequencies to build the TOD
        _, nus_edge_in, _, _, _, _ = qubic.compute_freq(
            d['filter_nu'] / 1e9,
            d['nf_sub'],  # Multiband instrument model
            d['filter_relative_bandwidth'])
        # Multi-band acquisition model for TOD fabrication
        return qubic.QubicMultibandAcquisition(q, pointing, s, d, nus_edge_in)
示例#7
0
def get_tod(d, p, x0, closed_horns=None):
    """

    Parameters
    ----------
    d : dictionnary
    p : pointing
    x0 : sky
    closed_horns : array
        index of closed horns

    Returns
    -------
    Returns an instrument with closed horns and TOD
    """
    # Polychromatic instrument model
    q = qubic.QubicMultibandInstrument(d)
    # q = qubic.QubicInstrument(d)
    if closed_horns is not None:
        for i in range(d['nf_sub']):
            for h in closed_horns:
                q[i].horn.open[h] = False

    # Scene
    s = qubic.QubicScene(d)

    # Number of sub frequencies to build the TOD
    _, nus_edge_in, _, _, _, _ = qubic.compute_freq(
        d['filter_nu'] / 1e9, d['nf_sub'], d['filter_relative_bandwidth'])

    # Multi-band acquisition operator
    a = qubic.QubicMultibandAcquisition(q, p, s, d, nus_edge_in)
    # a = qubic.QubicPolyAcquisition(q, p, s, d)

    tod = a.get_observation(x0, convolution=False, noiseless=True)

    return q, tod
示例#8
0
alaImager = False  # if True, the beam will be a simple gaussian
component = 0  # Choose the component number to plot (IQU)
oneComponent = False  # True if you want to study only I component, otherwise False if you study IQU
sel_det = True  # True if you want to use one detector, False if you want to use all detectors in focal plane
dets_FPindex = [594] # if sel_det == True, choose detector number

# Dictionnary
d = qubic.qubicdict.qubicDict()
d.read_from_file('global_source_oneDet.dict')

# Scene
s = qubic.QubicScene(d)

# Instrument
q = qubic.QubicMultibandInstrument(d)

if sel_det:
    make_detector_subset_instrument(q, dets_FPindex, multiband=True)

# Pointing
p = qubic.get_pointing(d)

fix_azimuth = d['fix_azimuth']
print('fix_azimuth', fix_azimuth)

plt.figure(figsize=(12, 8))
plt.subplot(411)
plt.plot(p.time, p.azimuth, 'bo')
plt.ylabel('Azimuth')
plt.subplot(412)
def MainProg(filename):
    start = timeit.default_timer()

    print filename, "passing filename test"
    #scene = QubicScene(256)
    #inst = instrument.QubicInstrument(filter_nu=150e9)
    #    inst = instrument.QubicInstrument()
    #    centers = inst.horn.center[:,0:2]
    #    detcenters = inst.detector.center[..., :2]
    d = qubic.qubicdict.qubicDict()
    d.read_from_file('/home/james/qubic/qubic/scripts/global_default_FI.dict')

    q = qubic.QubicMultibandInstrument(d)

    rep = "/home/james/CF-Source-Focal-Place-Analysis/UItest"

    files = glob.glob(rep + filename)
    files.sort()

    #vtxs = vertexes of TD detectors
    #    vtxs = inst.detector.vertex[496:744]
    #    #full detector setup
    #    vtxsF = inst.detector.vertex

    #SET DETECTOR VERTEXES TO FULL INSTRUMENT
    #q[0].calibration.detarray = '/usr/local/lib/python2.7/dist-packages/qubic/calfiles/CalQubic_DetArray_FI.fits'
    vtxs = q[0].detector.vertex

    #should be 992 for FI
    #vtxcounter = np.zeros(248)
    vtxcounter = np.zeros(992)
    #DEBUG
    print "vtxs = ", vtxs.shape
    print "vtxcounter = ", vtxcounter.shape

    MagXarr, PhaXarr, ReXarr, ImXarr, MagYarr, PhaYarr, ReYarr, ImYarr, vtxcntarr, PixCenX, PixCenY = getXYcoords(
        filename, vtxs)

    vtxcounter = np.vstack((vtxcounter, vtxcntarr))

    IntX = (ReXarr * ReXarr) + (ImXarr * ImXarr)
    IntY = (ReYarr * ReYarr) + (ImYarr * ImYarr)
    IntT = IntX[:] + IntY[:]

    vtxcounter = vtxcounter.T
    vtxcounter = vtxcounter[:, 1:3]

    #use this order for a header
    #dat = np.hstack((MagXmat,vtxcounter,ReXmat,ImXmat,ReYmat,ImYmat))
    dat = np.vstack(
        (MagXarr, PhaXarr, ReXarr, ImXarr, MagYarr, PhaYarr, ReYarr, ImYarr,
         vtxcntarr, PixCenX, PixCenY, IntX, IntY, IntT))
    dat = dat.T
    #SAVE DATA TO MAKE LOADING EASY
    #create strings for saving to file IO
    datstring = "dat"
    dataIO(dat, datstring)

    datmodstring = "datmod"
    datmod = dataAnalysis(dat)  # THIS DIVIDES BY NUMBER OF POINTS PER PIXEL
    dataIO(datmod, datmodstring)

    #load data for plotting raw modal data
    dataCF1 = np.loadtxt(filename, skiprows=1)
    xycoords = np.array(dataCF1[:, 2:4])

    #plotting RAW INTENSITY
    Ix = (dataCF1[:, 4] * np.cos(dataCF1[:, 5]))**2 + (
        dataCF1[:, 4] * np.sin(dataCF1[:, 5]))**2
    Iy = (dataCF1[:, 6] * np.cos(dataCF1[:, 7]))**2 + (
        dataCF1[:, 6] * np.sin(dataCF1[:, 7]))**2
    IT = Ix + Iy
    #testing setting zeros to NANs
    ITnans = [np.nan if x == 0 else x for x in IT]
    ITnans = np.asarray(ITnans)

    #save vars as local
    SaveVars(MagXarr, PhaXarr, ReXarr, ImXarr, MagYarr, PhaYarr, ReYarr,
             ImYarr, vtxcntarr, PixCenX, PixCenY, IntX, IntY, IntT, Ix, Iy, IT,
             xycoords, filename)

    os.system('spd-say "Main program has finished"')
    stop = timeit.default_timer()
    print stop - start

    return
示例#10
0
def do_some_dets(detnums,
                 d,
                 p,
                 directory,
                 fittedpeakfile,
                 az,
                 el,
                 proj_name,
                 custom=False,
                 q=None,
                 nside=None,
                 tol=5e-3,
                 refit=False,
                 resample=False,
                 newsize=70,
                 doplot=True,
                 verbose=True,
                 sbfitmodel=None,
                 angs=None,
                 usepeaks=None,
                 azmin=None,
                 azmax=None,
                 remove=None,
                 fitted_directory=None,
                 weighted=False,
                 nf_sub_rec=1,
                 lowcut=1e-3,
                 highcut=0.3):

    if nside is not None:
        d['nside'] = nside
    s = qubic.QubicScene(d)

    if q == None:
        q = qubic.QubicMultibandInstrument(d)

    if len(q) == 1:
        xgrf, ygrf, FP_index, index_q = sc.get_TES_Instru_coords(q,
                                                                 frame='GRF',
                                                                 verbose=False)
    else:
        xgrf, ygrf, FP_index, index_q = sc.get_TES_Instru_coords(q[0],
                                                                 frame='GRF',
                                                                 verbose=False)

    # Create TES, index and ASIC numbers assuming detnums is continuos TES number (1-248).
    tes, asic = np.zeros((len(detnums), ), dtype=int), np.zeros(
        (len(detnums), ), dtype=int)
    qpix = np.zeros((len(detnums), ), dtype=int)

    for j, npix in enumerate(detnums):
        tes[j], asic[j] = (npix, 1) if (npix < 128) else (npix - 128, 2)
        qpix[j] = tes2pix(tes[j], asic[j]) - 1
        if verbose:
            print("DETNUM{} TES{} ASIC{} QPIX{}".format(
                npix, tes[j], asic[j], qpix[j]))

    #Center of FOV
    azcen_fov = np.mean(az)
    elcen_fov = np.mean(el)

    #Directory where the maps are:
    mapsdir = directory
    #File where the fitted peaks are:
    peaksdir = fittedpeakfile

    if not custom:
        if verbose:
            print('')
            print('Normal Reconstruction')
        qcut = select_det(qubic.QubicMultibandInstrument(d), detnums)
        #qcut = select_det(qubic.QubicMultibandInstrument(d),[145])
    else:
        if verbose:
            print('')
            print('Custom Reconstruction')
        ### Refit or not the locations of the peaks
        ### from the synthesized beam images
        ### First instantiate a jchinstrument (modified from instrument
        ### to be able to read peaks from a file)

        print("Generating jchinstrument")
        qcut = select_det(
            jcinst.QubicMultibandInstrument(d,
                                            peakfile=fittedpeakfile,
                                            tes=tes,
                                            asic=asic), qpix)
        print("LEN(qcut) and detector", len(qcut),
              np.shape(qcut[0].detector.center))
        print("Generating jchinstrument"[::-1])

        ### In the present case, we use the peak measurements at 150 GHz
        ### So we assume its index is len(qcut)//2
        id150 = len(qcut) // 2
        nu = qcut[id150].filter.nu
        synthbeam = qcut[id150].synthbeam
        horn = getattr(qcut[id150], 'horn', None)
        primary_beam = getattr(qcut[id150], 'primary_beam', None)
        # Cosine projection with elevation center of the FOV considering symetric scan in azimuth for each elevation step
        thecos = np.cos(np.radians(elcen_fov))

        #Read map (flat or healpy) for each detector
        print("TES ASIC", tes, asic)
        filemaps = readmaps(directory,
                            tes,
                            asic,
                            az,
                            el,
                            p,
                            proj_name=proj_name,
                            nside=d['nside'],
                            verbose=verbose)

        # Compute measured coordenates
        allphis_M, allthetas_M, allvals_M = get_data_Mrefsyst(
            detnums,
            filemaps,
            az,
            el,
            fitted_directory,
            fittedpeakfile,
            proj_name,
            resample=resample,
            newsize=newsize,
            azmin=azmin,
            azmax=azmax,
            remove=remove,
            sbfitmodel=sbfitmodel,
            refit=refit,
            verbose=verbose)
        if doplot:
            _plot_onemap(filemaps,
                         az,
                         el, [allphis_M, allthetas_M],
                         proj_name,
                         makerotation=False)

        ### Now we want to perform the rotation to go to boresight
        ### reference frame (used internally by QubicSoft)
        if verbose:
            print("Solid angles synthbeam = {:.3e}, QubicScene {:.3e}".format(
                synthbeam.peak150.solid_angle, s.solid_angle))

        allphis_Q, allthetas_Q, allvals_Q, numpeak = convert_M2Q(
            detnums,
            allphis_M,
            allthetas_M,
            allvals_M,
            elcen_fov,
            solid_angle=synthbeam.peak150.solid_angle,
            nu=nu,
            horn=horn,
            solid_angle_s=s.solid_angle,
            angs=angs,
            verbose=verbose)
        print("allphis_Q , allvals_Q shapes", np.shape(allphis_Q),
              np.shape(allvals_Q))

        if doplot:
            plt.title("xy coord. of peaks in M and Q ref system")
            plt.plot(np.cos(allphis_M[0]) * np.sin(allthetas_M[0]),
                     np.sin(allphis_M[0]) * np.sin(allthetas_M[0]),
                     'r+',
                     ms=10,
                     label="M ref syst")
            plt.plot(np.cos(allphis_Q[0]) * np.sin(allthetas_Q[0]),
                     np.sin(allphis_Q[0]) * np.sin(allthetas_Q[0]),
                     'b+',
                     ms=10,
                     label="Q ref syst")
            plt.legend()
            plt.show()

        if doplot:
            # Plot peaks in measured reference frame.
            _plot_grfRF(detnums, xgrf, ygrf, qcut, numpeak)

        for idet in range(len(detnums)):
            position = np.ravel(qcut[0].detector[idet].center)
            position = -position / np.sqrt(np.sum(position**2))
            theta_center = np.arcsin(np.sqrt(position[0]**2 + position[1]**2))
            phi_center = np.arctan2(position[1], position[0])
            rav_thQ = np.ravel(allthetas_Q[idet, :])
            rav_phQ = np.ravel(allphis_Q[idet, :])
            ## Now we identify the nearest peak to the theoretical Line Of Sight
            angdist = np.zeros(len(rav_phQ))
            for k in range(len(rav_phQ)):
                angdist[k] = sbfit.ang_dist([theta_center, phi_center],
                                            [rav_thQ[k], rav_phQ[k]])
                print(k, np.degrees(angdist[k]))
            idxmin = np.argmin(angdist)
            numpeak[idet] = idxmin

        ### We nowwrite the temporary file that contains the peaks locations to be used
        if usepeaks is None:
            peaknums = np.arange(9)
        else:
            peaknums = usepeaks
        data = [
            allthetas_Q[:, peaknums], allphis_Q[:, peaknums] - np.pi,
            allvals_Q[:, peaknums], numpeak
        ]
        file = open(os.environ['QUBIC_PEAKS'] + 'peaks.pk', 'wb')
        pickle.dump(data, file)
        file.close()

    ### Make the TODs from the measured synthesized beams
    realTOD = np.zeros((len(detnums), len(p)))
    sigmaTOD = np.zeros(len(detnums))
    if weighted:
        sumweight = 0.

    allimg = []

    for i in range(len(detnums)):
        if proj_name == "flat":
            filename = directory + 'flat_ASIC{}TES{}.fits'.format(
                asic[i], tes[i])
            img = FitsArray(filename)
        elif proj_name == "healpix":
            filename = directory + '../../Flat/synth_beam/flat_ASIC{}TES{}.fits'.format(
                asic[i], tes[i])
            img = FitsArray(filename)
        allimg.append(img)
        fact = 1  #5e-28
        realTOD[i, :] = np.ravel(img) * fact

        if weighted:  ## Not to be used - old test...
            realTOD[i, :] *= 1. / ss**2
            sumweight += 1. / ss**2
    print("All img", np.shape(allimg))
    ### new code multiband
    plt.figure()
    for i in range(len(detnums)):
        plt.plot(realTOD[i, :], label='TES#{0:}'.format(detnums[i]))
    plt.legend()
    plt.xlabel('Samples')
    plt.ylabel('TOD')
    plt.show()

    plt.figure()
    for i in range(len(detnums)):
        spectrum_f, freq_f = ft.power_spectrum(np.arange(len(realTOD[i, :])),
                                               realTOD[i, :])
        pl = plt.plot(freq_f,
                      spectrum_f,
                      label='TES#{0:}'.format(detnums[i]),
                      alpha=0.5)
        plt.xscale('log')
        plt.yscale('log')
    plt.legend()
    plt.xlabel('Fourier mode')
    plt.ylabel('Power Spectrum')
    plt.title('Before Filtering')
    plt.show()

    for i in range(len(detnums)):
        realTOD[i, :] = ft.filter_data(np.arange(len(realTOD[i, :])),
                                       realTOD[i, :], lowcut, highcut)
        mm, ss = ft.meancut(realTOD[i, :], 3)
        sigmaTOD[i] = ss
    if doplot:
        for i in range(len(detnums)):
            plt.figure()
            plt.subplot(1, 2, 1)
            plt.imshow(allimg[i] * fact,
                       vmin=mm - 3 * ss,
                       vmax=mm + 3 * ss,
                       extent=[
                           np.max(az) * thecos,
                           np.min(az) * thecos,
                           np.min(el),
                           np.max(el)
                       ],
                       aspect='equal')
            plt.colorbar()
            plt.title('Init - TOD {0:} RMS={1:5.2g}'.format(
                detnums[i], sigmaTOD[i]))
            plt.subplot(1, 2, 2)
            plt.imshow(np.reshape(realTOD[i, :], np.shape(img)),
                       vmin=mm - 3 * ss,
                       vmax=mm + 3 * ss,
                       extent=[
                           np.max(az) * thecos,
                           np.min(az) * thecos,
                           np.min(el),
                           np.max(el)
                       ],
                       aspect='equal')
            plt.colorbar()
            plt.title('Filtered - TOD {0:} RMS={1:5.2g}'.format(
                detnums[i], sigmaTOD[i]))

    plt.figure()
    for i in range(len(detnums)):
        spectrum_f, freq_f = ft.power_spectrum(np.arange(len(realTOD[i, :])),
                                               realTOD[i, :])
        pl = plt.plot(freq_f,
                      spectrum_f,
                      label='TES#{0:} Var*2pi={1:5.2g}'.format(
                          detnums[i], sigmaTOD[i]**2 * 2 * np.pi),
                      alpha=0.5)
        plt.plot(freq_f,
                 freq_f * 0 + sigmaTOD[i]**2 * 2 * np.pi,
                 color=pl[0].get_color())
        plt.xscale('log')
        plt.yscale('log')
    plt.ylim(np.min(sigmaTOD**2 * 2 * np.pi),
             np.max(sigmaTOD**2 * 2 * np.pi) * 1e9)
    plt.legend()
    plt.xlabel('Fourier mode')
    plt.ylabel('Power Spectrum')
    plt.title('After Filtering')
    if lowcut:
        plt.axvline(x=lowcut, color='k')
    if highcut:
        plt.axvline(x=highcut, color='k')
    plt.show()

    plt.figure()
    plt.clf()
    print('%%%%%%%%%%%%%%%%%%%%%%')
    ax = plt.subplot(111, projection='polar')
    print("len qcut", len(qcut[0].detector.center))
    print("=?===============================")
    print(np.shape(realTOD), np.shape(p), nf_sub_rec, np.shape(qcut))
    print("=?===============================")

    maps_recon, cov, nus, nus_edge = si.reconstruct_maps(
        realTOD,
        d,
        p,
        nf_sub_rec,
        x0=None,
        instrument=qcut,  #verbose=True,
        forced_tes_sigma=sigmaTOD)
    ax.set_rmax(0.5)
    #legend(fontsize=8)
    if weighted:
        maps_recon /= sumweight / len(detnums)
    return maps_recon, qcut, np.mean(cov, axis=0), nus, nus_edge
示例#11
0
def MainProg(filepath, pklrep, tesdatrep):

    start = timeit.default_timer()
    repfile = filepath
    #strip Modal qb filename from filepath
    qbfilename = os.path.splitext(os.path.basename(repfile))[0]

    # Use a tool from qubicpack to get a path
    basedir = Qubic_DataDir(datafile='instrument.py', )
    print('basedir : ', basedir)
    dictfilename = basedir + '/dicts/global_source_oneDet.dict'
    d = qubic.qubicdict.qubicDict()
    #d.read_from_file('../qubic/qubic/dicts/global_source_oneDet.dict')
    #change to moddded dictionary
    d.read_from_file(
        '/home/james/libraries/qubic/qubic/dicts/global_source_oneDetFI.dict')
    q = qubic.QubicMultibandInstrument(d)

    vtxs = q[0].detector.vertex
    vtxcounter = np.zeros(992)
    print("vertexes shape: ", vtxs.shape)

    MagXarr, PhaXarr, ReXarr, ImXarr, MagYarr, PhaYarr, ReYarr, ImYarr, vtxcntarr, PixCenX, PixCenY = getXYcoords(
        filepath, vtxs)
    print('getxycoordfunctest', max(MagXarr), MagXarr.shape)

    vtxcounter = np.vstack((vtxcounter, vtxcntarr))
    vtxcounter = vtxcounter.T
    vtxcounter = vtxcounter[:, 1:3]

    #caluclate and return instensity values for given mag & phase PIXELS
    IntX, IntY, IntT = IntensityCalc(MagXarr, PhaXarr, MagYarr, PhaYarr)
    print('intensity tests shape max', IntX.shape, max(IntX))

    dat = np.vstack(
        (MagXarr, PhaXarr, ReXarr, ImXarr, MagYarr, PhaYarr, ReYarr, ImYarr,
         vtxcntarr, PixCenX, PixCenY, IntX, IntY, IntT))
    dat = dat.T

    #save the mag&pha data with the calculated intensity values PIXELS
    #chose whether to bother even saving the un-normed data if it just gets overwitten
    #dataIO(dat, tesdatrep, qbfilename)
    datmodstring = 'datmod'
    #dataAnalysis function normalises the data PIXELS
    datmod = dataAnalysis(dat)
    dataIO(datmod, tesdatrep, qbfilename)

    #load MODAL style data point data
    dataCF1 = np.loadtxt(repfile, skiprows=1)
    xycoords = np.array(dataCF1[:, 2:4])
    freq = dataCF1[0, 10]
    print('frequency', freq)

    #return intensity values for data points in the MODAL style
    Ix, Iy, IT = IntensityCalcRAW(repfile)
    ITnans = [(np.nan if x == 0 else x) for x in IT]
    ITnans = np.asarray(ITnans)

    #save in a folder as pickle files with all data accesible.
    SaveVars(MagXarr, PhaXarr, ReXarr, ImXarr, MagYarr, PhaYarr, ReYarr,
             ImYarr, vtxcntarr, PixCenX, PixCenY, IntX, IntY, IntT, Ix, Iy, IT,
             xycoords, qbfilename, freq, pklrep)

    os.system('spd-say "Main program has finished"')
    stop = timeit.default_timer()
    time = stop - start
    seconds = (time - int(time)) * 60
    print(time / 60, 'm', seconds, 's')