Docker-in-Docker (DinD) capabilities of public runners deactivated. More info

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

initial set of files for PAON4 visibility reader program, Reza 9/02/2015

parents
-------------------------------------------------------------------
PAON-4 visibility analysis programs
R. Ansari, J.E. Campagne, C. Magneville - Feb 2015
-------------------------------------------------------------------
List of files:
- makefile
- visip4reader.h .cc a class to read sequentially the visibility files
produced by mfac, merge the different frequency bands and set of visibilities
and reorder frequencies
- rdvisip4 : a simple main program to read visibilitiy files and produce a single
mean visibility matrix
# Makefile for PAON4 visibility analysis code
# Feb. 2015
include $(SOPHYABASE)/include/sophyamake.inc
# Define our target list
all : Objs/rdvisip4
clean :
rm -f Objs/*
######
Objs/rdvisip4 : Objs/rdvisip4.o Objs/visip4reader.o
$(CXXLINK) -o Objs/tlegpol Objs/rdvisip4.o Objs/visip4reader.o $(SOPHYAEXTSLBLIST)
Objs/rdvisip4.o : rdvisip4.cc visip4reader.h
$(CXXCOMPILE) -o Objs/rdvisip4.o rdvisip4.cc
Objs/visip4reader.o : visip4reader.cc visip4reader.h
$(CXXCOMPILE) -o Objs/visip4reader.o visip4reader.cc
// Utilisation de SOPHYA pour faciliter les tests ...
#include "sopnamsp.h"
#include "machdefs.h"
/* ----------------------------------------------------------
Projet BAORadio/PAON4 - (C) LAL/IRFU 2008-2015
Programme de lecture des fichiers matrices de
visibilites de PAON4 produits mfacq
R. Ansari, J.E. Campagne, C. Magneville - LAL/Irfu
V0 : Fev 2015
---------------------------------------------------------- */
// include standard c/c++
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <string>
#include "pexceptions.h"
#include "tvector.h"
#include "fioarr.h"
// #include "tarrinit.h"
#include "ntuple.h"
#include "datatable.h"
#include "histinit.h"
#include "matharr.h"
#include "timestamp.h"
#include <utilarr.h>
// include sophya mesure ressource CPU/memoire ...
#include "resusage.h"
#include "ctimer.h"
#include "timing.h"
// include lecteur de fichiers visibilites
//--------------------------- Fonctions de ce fichier -------------------
int Usage(bool fgshort=true);
int DecodeArgs(int narg, char* arg[]);
int ProcSVFiles(string& inoutpath, int imin, int imax, int istep, int jf1, int jf2, int nfreq,
vector<sa_size_t> tfrlist);
int FillVisDTable(BaseDataTable& visdt_, TMatrix< complex<r_4> > vismtx_, TVector< uint_4> chanum_,
sa_size_t jf1_, sa_size_t jf2_, sa_size_t djf_) ;
/* --Fonction-- */
int Usage(bool fgshort)
{
cout << " --- rdvisip4.cc : Read PPF files produced by mfacq time-frequency\n" << endl;
cout << " Usage: rdvisip4 InPathBAO5 InPathBAO6 Imin,Imax,step \n" << endl;
if (fgshort) {
cout << " rdvisip4 -h for detailed instructions" << endl;
return 1;
}
return 1;
}
//----------------------------------------------------
//----------------------------------------------------
int main(int narg, char* arg[])
{
if ((narg>1)&&(strcmp(arg[1],"-h")==0)) return Usage(false);
if (narg<4) return Usage(true);
HiStatsInitiator _inia;
// TArrayInitiator _inia;
int rc = 0;
try {
ResourceUsage resu;
resu.Update();
cout << resu;
}
catch (PException& exc) {
cerr << " rdvisip4.cc catched PException " << exc.Msg() << endl;
rc = 77;
}
catch (std::exception& sex) {
cerr << "\n rdvisip4.cc std::exception :"
<< (string)typeid(sex).name() << "\n msg= "
<< sex.what() << endl;
rc = 78;
}
catch (...) {
cerr << " rdvisip4.cc catched unknown (...) exception " << endl;
rc = 79;
}
cout << ">>>> rdvisip4.cc ------- END ----------- RC=" << rc << endl;
return rc;
}
//--------------------------------------------------------------------
// Traitement fichiers produits par vismfib (V Nov09)
/* --Fonction-- */
int DecodeArgs(int narg, char* arg[])
{
// Decodage des arguments et traitement
string inoutpath = arg[0];
int imin=0;
int imax=0;
int istep=1;
sscanf(arg[1],"%d,%d,%d",&imin,&imax,&istep);
int jf1=0;
int jf2=0;
int nfreq=0;
sscanf(arg[2],"%d,%d,%d",&jf1,&jf2,&nfreq);
int card=1;
vector<sa_size_t> rowlist;
if (narg>3) {
EnumeratedSequence es;
int nbad;
es.Append(arg[3], nbad, ",");
for(int j=0; j<es.Size(); j++) rowlist.push_back((int)es.Value(j));
}
if (rowlist.size()<1) rowlist.push_back(0);
cout << " ----- rdvisip4/DecodeProc - Start - InOutPath= " << inoutpath << " IMin,Max,Step="
<< imin << "," << imax << "," << istep << " Card=" << card << endl;
cout << "Frequency num range JF=" << jf1 << "," << jf2 << "," << nfreq << " ------- " << endl;
cout << " RowList: " ;
for(int j=0; j<rowlist.size(); j++) cout << rowlist[j] << " , " ;
cout << endl;
int rc=ProcSVFiles(inoutpath, imin, imax, istep, jf1, jf2, nfreq, rowlist);
return rc;
}
// Pour traitement (calcul FFT et visibilites (ProcA) 1 fibre, 2 voies RAW)
/* --Fonction-- */
int ProcSVFiles(string& inoutpath, int imin, int imax, int istep, int jf1, int jf2, int nfreq,
vector<sa_size_t> rowlist)
{
Timer tm("ProcSVFiles");
DataTable visdt;
visdt.AddDoubleColumn("mfc");
visdt.AddDoubleColumn("mtt");
visdt.AddIntegerColumn("jfreq");
visdt.AddIntegerColumn("numch");
visdt.AddFloatColumn("vre");
visdt.AddFloatColumn("vim");
vector< TMatrix< complex<r_4> > > vmtf;
if (jf1<1) jf1=1;
if ((jf2<1)||(jf2<jf1)) jf2=jf1;
if (nfreq<1) nfreq=1;
int djf=(jf2-jf1)/nfreq;
if (djf<1) djf=1;
char fname[1024];
cout << " ---- ProcSVFiles()-Begin - Reading chanum vector" << endl;
/*
TVector< uint_4 > chanum(8*17);
int ku=0;
for(int iu=1; iu<=16; iu++)
for(int ju=iu; ju<=16; ju++) {
chanum(ku)=iu*1000+ju; ku++;
}
*/
TVector< uint_4 > chanum;
{
sprintf(fname, "%s/chanum_0.ppf",inoutpath.c_str());
PInPersist pic(fname);
pic >> PPFNameTag("chanpairnum") >> chanum;
}
cout << " ---- ProcSVFiles()-Read chanum done " << endl;
sa_size_t nrows = (imax-imin+1)/istep;
sa_size_t kr=0;
sa_size_t mtf_binfreq=25;
sa_size_t mtf_bintime=5;
sa_size_t ncols=1;
for(int ifile=imin; ifile<=imax; ifile+=istep) {
sprintf(fname, "%s/vismtx_0_%d.ppf",inoutpath.c_str(),ifile);
cout << " ProcSVFiles[" << ifile << "] opening file " << fname << endl;
PInPersist pin(fname);
TMatrix< complex<r_4> > vismtx;
pin >> vismtx;
if (ifile==imin) {
ncols = vismtx.NCols();
cout << " ProcSVFilesVJun09/Info: Output Time-Frequency matrices NRows=NFiles"
<< nrows << " NCols=NFreq=" << ncols << endl;
for(size_t j=0; j<rowlist.size(); j++)
vmtf.push_back(TMatrix< complex<r_4> >(ncols/mtf_binfreq+1, nrows/mtf_bintime+1));
}
/*
for(size_t j=0; j<rowlist.size(); j++)
vmtf[j].Row(kr) = vismtx.Row(rowlist[j]);
*/
for(size_t j=0; j<rowlist.size(); j++)
for(sa_size_t icf=0; icf<ncols; icf++) {
vmtf[j](icf/mtf_binfreq,kr/mtf_bintime)+=vismtx(rowlist[j],icf);
}
// cout << " DBG* kr=" << kr << " kr/mtf_bintime=" << kr/mtf_bintime
// << " ncols/2/mtf_binfreq=" << ncols/2/mtf_binfreq << endl;
kr++;
// Calcul moyenne dans des bandes en frequence
FillVisDTable(visdt, vismtx, chanum, jf1, jf2, djf);
}
sprintf(fname, "%s/vistfreqmtx.ppf",inoutpath.c_str());
cout << "ProcSVFiles: Opening file " << fname << " for writing Visi(Freq,Time) matrices" << endl;
POutPersist po(fname);
char tagb[64];
for(size_t j=0; j<rowlist.size(); j++) {
sprintf(tagb,"visft%d", chanum(rowlist[j]));
po << PPFNameTag(tagb) << vmtf[j];
}
cout << visdt;
sprintf(fname, "%s/svvdt.ppf",inoutpath.c_str());
cout << "ProcSVFile: writing visibility datatable to file " << fname << endl;
POutPersist pod(fname);
pod << visdt;
return 0;
}
/* --Fonction-- */
int FillVisDTable(BaseDataTable& visdt_, TMatrix< complex<r_4> > vismtx_, TVector< uint_4> chanum_,
sa_size_t jf1_, sa_size_t jf2_, sa_size_t djf_)
{
double xnt_[20];
xnt_[0]=(double)vismtx_.Info()["MeanFC"];
xnt_[1]=(double)vismtx_.Info()["MeanTT"]/1.25e8;
uint_4 nmean_=vismtx_.Info()["NPAQSUM"];
if (djf_<2) {
for(sa_size_t rv=0; rv<vismtx_.NRows(); rv++) {
for(sa_size_t jf=jf1_; jf<jf2_; jf++) {
xnt_[2]=jf;
xnt_[3]=chanum_(rv);
xnt_[4]=vismtx_(rv,jf).real()/(r_4)(nmean_);
xnt_[5]=vismtx_(rv,jf).imag()/(r_4)(nmean_);
visdt_.AddRow(xnt_);
}
}
}
else {
for(sa_size_t rv=0; rv<vismtx_.NRows(); rv++) {
for(sa_size_t jf=jf1_; jf<jf2_; jf+=djf_) {
r_4 moyreal=0.;
r_4 moyimag=0.;
sa_size_t jjfmx=jf+djf_;
if (jjfmx > vismtx_.NCols()) jjfmx=vismtx_.NCols();
for(sa_size_t jjf=jf; jjf<jjfmx; jjf++) {
moyreal+=vismtx_(rv,jjf).real();
moyimag+=vismtx_(rv,jjf).imag();
}
xnt_[2]=jf+djf_/2;
xnt_[3]=chanum_(rv);
xnt_[4]=moyreal/(r_4)(nmean_*djf_);
xnt_[5]=moyimag/(r_4)(nmean_*djf_);
visdt_.AddRow(xnt_);
}
}
}
return 0;
}
//----------------------------------------------------------------
// Projet BAORadio/PAON4 - (C) LAL/IRFU 2008-2015
// Classe(s) de lecture des fichiers de visibilites PAON4
//----------------------------------------------------------------
#include "visip4reader.h"
/* --Methode-- */
VisiP4Reader::VisiP4Reader(string const& path1, string const& path2, int ifirst, int ilast, int istep, bool reorderfreq)
: path_1(path1), path_2(path2), first(ifirst), last(ilast), step(istep), fgreorderfreq(reorderfreq),
curfilenum(ifirst)
{
}
/* --Methode-- */
bool VisiP4Reader::ReadNext(TMatrix< complex<r_4> > & vismtx)
{
}
/* --Methode-- */
void VisiP4Reader::ReorderFreqs(TMatrix< complex<r_4> > & vismtx)
{
}
#ifndef VISIP4READER_H_SEEN
#define VISIP4READERASEPROC_H_SEEN
//----------------------------------------------------------------
// Projet BAORadio/PAON4 - (C) LAL/IRFU 2008-2011
// Classe(s) de lecture des fichiers de visibilites PAON4
//----------------------------------------------------------------
#include <string>
#include <vector>
#include <iostream>
// Include utiles SOPHYA TArray , FitsIOServer
#include "array.h"
#include "fitsioserver.h"
using namespace std;
using namespace SOPHYA;
class VisiP4Reader {
public:
VisiP4Reader(string const& path1, string const& path2, int ifirst, int ilast, int istep=1, bool reorderfreq=true);
bool ReadNext(TMatrix< complex<r_4> > & vismtx);
void ReorderFreqs(TMatrix< complex<r_4> > & vismtx);
string path_1, path_2; // path for visibility files produced by BAO5,BAO6 (first,second frequency band)
int first, last, step; // visibility files with first<=I<=last are read , with step
bool fgreorderfreq;
int curfilenum; // current file number
};
#endif
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