Commit 9d293aa5 authored by Reza  ANSARI's avatar Reza ANSARI
Browse files

Ajout classe P4FreqSelectorFilterMgr de gestion de bandes de frequences, pour...

Ajout classe P4FreqSelectorFilterMgr de gestion de bandes de frequences, pour calcul de visibilites moyennes/filtrees par bande , Reza 15/08/2018
parent f166eb70
/* ----------------------------------------------------------
Projet BAORadio/PAON4 - (C) LAL/IRFU 2008-2018
Classes et fonctions utilitaires pour les programmes d'analyse PAON4
Classe P4FreqSelectorFilterMgr gestionnaire de bandes de frequences
pour moyennes / filtrage de visibilites
R. Ansari Aout 2018
---------------------------------------------------------- */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <string>
#include "pexceptions.h"
#include "array.h"
#include "fioarr.h"
#include "p4freqselmgr.h"
P4FreqSelectorFilterMgr::P4FreqSelectorFilterMgr()
{
}
P4FreqSelectorFilterMgr::P4FreqSelectorFilterMgr(string const & filename)
{
readFreqBandDefinitioFile(filename);
}
size_t P4FreqSelectorFilterMgr::readFreqBandDefinitioFile(string const & filename)
{
// Il faut coder cette methode
throw ForbiddenError("P4FreqSelectorFilterMgr::readFreqBandDefinitioFile() NOT YET IMPLEMENTED");
}
size_t P4FreqSelectorFilterMgr::addBand(P4FreqBand& fb)
{
v_bands_.push_back( pair<sa_size_t , sa_size_t>(fb.getFirstFreqChannel() , fb.getLastFreqChannel() ) );
weight_bands_.push_back(complex<float>((float)(1./(double)(fb.getLastFreqChannel()-fb.getFirstFreqChannel())), 1.));
return v_bands_.size();
}
P4FreqBand P4FreqSelectorFilterMgr::getBand(size_t i)
{
if (i >= v_bands_.size()) throw RangeCheckError("P4FreqSelectorFilterMgr::getBand() Out of Range band number");
return P4FreqBand(v_bands_[i].first, v_bands_[i].second);
}
vector< complex<float> > P4FreqSelectorFilterMgr::getAverage( TVector< complex<float> > & vis)
{
if (vis.Size() != P4FreqBand::getP4NbFreqChannels())
throw ParmError("P4FreqSelectorFilterMgr::getAverage() Bad input visibility vector size ");
vector< complex<float> > rvec(size());
for (size_t i=0; i<size(); i++) {
rvec[i] = vis(Range(v_bands_[i].first, v_bands_[i].second)).Sum()*weight_bands_[i];
}
return rvec;
}
/* ----------------------------------------------------------
Projet BAORadio/PAON4 - (C) LAL/IRFU 2008-2018
Classes et fonctions utilitaires pour les programmes d'analyse PAON4
Classe P4FreqSelectorFilterMgr gestionnaire de bandes de frequences
pour moyennes / filtrage de visibilites
R. Ansari Aout 2018
---------------------------------------------------------- */
#ifndef P4FREQSELMGR_SEEN
#define P4FREQSELMGR_SEEN
#include "array.h"
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <sstream>
#include "p4autils.h"
using namespace SOPHYA ;
using namespace std;
//---------------------------------------------------------------------------------
//! \brief class for managing multiple frequency bands for averaging / filtering
class P4FreqSelectorFilterMgr {
public:
//! Default constructor, No frequency band defined
P4FreqSelectorFilterMgr();
//! \brief Constructor with the specification of the name of file containing definition of frequency bands
P4FreqSelectorFilterMgr(string const & filename);
//! \brief read the file containing the definition of frequency bands
size_t readFreqBandDefinitioFile(string const & filename);
//! \brief return the number of bands defined
inline size_t getNbBands() const { return v_bands_.size(); }
//! \brief return the number of bands defined
inline size_t size() const { return v_bands_.size(); }
//! \brief return the band i
P4FreqBand getBand(size_t i);
//! \brief Add a simple, without masked frequency band
size_t addBand(P4FreqBand& fb);
//! \brief return averaged visibilities in the defined bands ...
vector< complex<float> > getAverage( TVector< complex<float> > & vis);
protected:
// Definition of simple bands, without masked frequencies
std::vector< std::pair<sa_size_t , sa_size_t> > v_bands_;
std::vector< complex<float> > weight_bands_;
};
#endif /* P4FREQSELMGR_SEEN */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment