Commit 0fc44146 authored by Reza  ANSARI's avatar Reza ANSARI
Browse files

Ajout programme de lecture track-files (fichiers traces de satellite/soleil)...

Ajout programme de lecture track-files (fichiers traces de satellite/soleil) conversion en DataTable, Reza 26/11/2018
parent 8a0e551e
......@@ -12,7 +12,7 @@ SGP4LIB = ${EXTLIBDIR}/Satellites/sgp4/libsgp4/
SGP4CCFLG = ''
# Define our target list
all : predictsatsgp4
all : predictsatsgp4 trk2dt
clean :
rm -f $(EXE)/predictsatsgp4
......@@ -22,6 +22,10 @@ clean :
$(OBJ)/predictsatsgp4.o : predictsatsgp4.cc $(SGP4INC)/Tle.h
$(CXXCOMPILE) $(SGP4CCFLG) -o $(OBJ)/predictsatsgp4.o -I$(SGP4INC) predictsatsgp4.cc
$(OBJ)/trk2dt.o : trk2dt.cc
$(CXXCOMPILE) -o $(OBJ)/trk2dt.o trk2dt.cc
###### Compilation et link des executables
predictsatsgp4 : $(EXE)/predictsatsgp4
echo 'predictsatsgp4 --- made'
......@@ -29,3 +33,10 @@ predictsatsgp4 : $(EXE)/predictsatsgp4
$(EXE)/predictsatsgp4 : $(OBJ)/predictsatsgp4.o
$(CXXLINK) -o $(EXE)/predictsatsgp4 $(OBJ)/predictsatsgp4.o -L$(SGP4LIB) -lsgp4 -lstdc++ -lc -lm
###### Compilation et link des executables
trk2dt : $(EXE)/trk2dt
echo 'trk2dt --- made'
$(EXE)/trk2dt : $(OBJ)/trk2dt.o
$(CXXLINK) -o $(EXE)/trk2dt $(OBJ)/trk2dt.o $(SOPHYAEXTSLBLIST)
......@@ -95,7 +95,13 @@ J'ai donc modifie le Makefile en ajoutant un flag optionnel de compilation - pou
..../AnaPAON4/Satellites/Objs/predictsatsgp4 -T "2018/10/20 15:16:00" -H 0.,81. -K 41859 -p 2 galileo.txt
-----
5-/ Remarques
5-/ Fichiers trace
-----
.le programme predictsatsgp4 peut crer des fichiers de trace (track) pour satellite slectionn et pour le solei.
On peut utiliser le programme trk2dt.cc pour lire le fichier trace et le convertir en DataTable (fichier PPF, voir FITS eventuellement)
-----
6-/ Remarques
-----
.Est aussi fourni un petit job de test (testpredsatsgp4.py) python (2.7) utilisant le module "sgp4"
https://pypi.python.org/pypi/sgp4/
......
#include "machdefs.h"
/* ----------------------------------------------------------
Projet BAORadio/PAON4 - (C) LAL/IRFU 2008-2015
Programme de conversion fichiers ascii track (satellites, soleil)
en DataTable, sauve en PPF (ou fits) Reza, Mai 2018
---------------------------------------------------------- */
// include standard c/c++
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <string>
// include SOPHYA
#include "pexceptions.h"
#include "timestamp.h"
#include "histats.h"
#include "datatable.h"
#include "histinit.h"
using namespace std;
using namespace SOPHYA;
int Usage(void)
{
cout<<"--- trk2dt.cc : Converting track file to DataTable \n"<<endl;
cout<<"Usage: trk2dt [-options] track_file.txt outFile (.ppf or .fits) \n";
cout<<endl;
return 1;
}
//----------------------------------------------------
int main(int narg, const char* arg[])
{
int rc=0;
// --- Decoding parameters
if ((narg<3)||((narg>1)&&(strcmp(arg[1],"-h")==0))) return Usage();
string infile = arg[1];
string outfile = arg[2];
cout << " ==== trk2dt reading input track file "<<infile<<" to create DataTable"<<endl
<< " ... saved to output file"<<outfile<<endl;
try {
DataTable dt(128);
dt.AddDateTimeColumn("datetime");
dt.AddDoubleColumn("timesec");
dt.AddDoubleColumn("azimuth");
dt.AddDoubleColumn("elevation");
dt.AddDoubleColumn("latitude");
dt.AddDoubleColumn("longitude");
dt.AddDoubleColumn("deltalatitude");
dt.AddDoubleColumn("deltalongitude");
dt.Info().Comment()="Satellite track DataTable from predictsatsgp4.cc";
dt.Info()["datetime"] = "Date/Time";
dt.Info()["timesec"] = "time of day, in seconds";
dt.Info()["azimuth"] = "Azimuth angle , in degree";
dt.Info()["elevation"] = "Elevation angle , in degree";
dt.Info()["latitude"] = "Latitude , in degree";
dt.Info()["longitude"] = "Longitude , in degree";
int nlines = 0;
int nok = 0;
DataTableRow row = dt.EmptyRow();
ifstream is(infile);
string sline;
while (!is.eof()) {
sline = "";
getline(is, sline); nlines++;
if (!is.good() && !is.eof()) continue;
if ((sline.length()<69) || (sline[0] == '#')) continue;
int yy=2018 , mm=1, dd=1;
sscanf(sline.c_str(), "%d-%d-%d",&yy,&mm,&dd);
int hh=0 , mn=0;
double ss=0.;
sscanf(sline.c_str()+11, "%d:%d:%lg",&hh,&mn,&ss);
TimeStamp datetm(yy, mm, dd, hh, mn, ss);
TimeStamp date0(yy, mm, dd, 0, 0, 0.);
double azim, elev, latitude, longitude, deltlat, deltalong;
sscanf(sline.c_str()+30, "%lg %lg %lg %lg %lg %lg", &azim, &elev, &latitude, &longitude, &deltlat, &deltalong);
double tmsec = TimeStamp::TimeDifferenceSeconds(datetm, date0);
row[0] = datetm;
row[1] = tmsec;
row[2] = azim;
row[3] = elev;
row[4] = latitude;
row[5] = longitude;
row[6] = deltlat;
row[7] = deltalong;
dt.AddRow(row); nok++;
}
cout << " --- Read track file nPointOk= " << nok << " / NLines=" << nlines << endl;
dt.SetShowMinMaxFlag(true);
cout << dt ;
POutPersist pof(outfile);
pof << dt;
}
catch (PException& exc) {
cerr << " rdvisip4.cc catched PException " << exc.Msg() << endl;
rc = 77;
}
catch (std::exception& sex) {
cerr << "\n trk2dt.cc std::exception :"
<< (string)typeid(sex).name() << "\n msg= " << sex.what() << endl;
rc = 78;
}
catch (...) {
cerr << " trk2dt.cc catched unknown (...) exception " << endl;
rc = 79;
}
cout << ">>>> trk2dt.cc ------- END ----------- RC=" << rc << endl;
return rc;
}
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