[2615] | 1 | #include "sopnamsp.h"
|
---|
[722] | 2 | #include "machdefs.h"
|
---|
| 3 | #include <stdio.h>
|
---|
| 4 | #include <stdlib.h>
|
---|
[2322] | 5 | #include <iostream>
|
---|
[722] | 6 | #include <math.h>
|
---|
| 7 |
|
---|
| 8 | #include <typeinfo>
|
---|
| 9 |
|
---|
| 10 | #include <vector>
|
---|
| 11 | #include <string>
|
---|
| 12 |
|
---|
| 13 | #include "piacmd.h"
|
---|
| 14 | #include "nobjmgr.h"
|
---|
| 15 | #include "pistdimgapp.h"
|
---|
| 16 | #include "servnobjm.h"
|
---|
| 17 | #include "tvector.h"
|
---|
| 18 | #include "pitvmaad.h"
|
---|
| 19 | #include "fftpserver.h"
|
---|
| 20 | #include "bruit.h"
|
---|
| 21 | #include "piscdrawwdg.h"
|
---|
| 22 | #include "ctimer.h"
|
---|
| 23 |
|
---|
[1540] | 24 | #include "pidrawer.h"
|
---|
| 25 | #include "nomgadapter.h"
|
---|
[2595] | 26 | #include "nomskymapadapter.h"
|
---|
[1540] | 27 |
|
---|
[722] | 28 | extern "C" {
|
---|
| 29 | void sopiamodule_init();
|
---|
| 30 | void sopiamodule_end();
|
---|
| 31 | }
|
---|
| 32 |
|
---|
[2920] | 33 | void SophyaFFT_forw(string& nom, string& nomout, string dopt);
|
---|
| 34 | void SophyaFFT_back(string& nom, string& nomout, string dopt);
|
---|
| 35 | void SophyaFFT_crefilter(string& nomvec, string& nomfilter, string func, string dopt);
|
---|
| 36 | void SophyaFFT_filter(string& nom, string& nomfilter, string dopt);
|
---|
[722] | 37 |
|
---|
| 38 | class sopiamoduleExecutor : public CmdExecutor {
|
---|
| 39 | public:
|
---|
| 40 | sopiamoduleExecutor();
|
---|
| 41 | virtual ~sopiamoduleExecutor();
|
---|
[1267] | 42 | virtual int Execute(string& keyw, vector<string>& args, string& toks);
|
---|
[722] | 43 | };
|
---|
| 44 |
|
---|
[1540] | 45 | // Classe pour trace de grille en projection spherique Mollweide
|
---|
| 46 | class MollweideGridDrawer : public PIDrawer {
|
---|
| 47 | public:
|
---|
| 48 | MollweideGridDrawer(int np, int nm, int nx, int ny);
|
---|
| 49 | MollweideGridDrawer(int np, int nm, double x_larg=0., double x_0=0.,
|
---|
| 50 | double y_larg=0., double y_0=0.);
|
---|
| 51 | virtual ~MollweideGridDrawer();
|
---|
| 52 | virtual void Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax);
|
---|
| 53 | virtual void UpdateLimits();
|
---|
| 54 |
|
---|
| 55 | protected:
|
---|
| 56 | double xlarg, x0;
|
---|
| 57 | double ylarg, y0;
|
---|
| 58 | int nbparall, nbmerid;
|
---|
| 59 | int nbpt;
|
---|
| 60 | bool fgrevtheta;
|
---|
| 61 | };
|
---|
| 62 |
|
---|
[722] | 63 | /* --Methode-- */
|
---|
[1540] | 64 | MollweideGridDrawer::MollweideGridDrawer(int np, int nm, int nx, int ny)
|
---|
| 65 | {
|
---|
| 66 | x0 = (double)nx/2.;
|
---|
| 67 | y0 = (double)ny/2.;
|
---|
| 68 | xlarg = nx;
|
---|
| 69 | ylarg = ny;
|
---|
| 70 | nbparall = np;
|
---|
| 71 | nbmerid = nm;
|
---|
| 72 | nbpt = ny/5;
|
---|
| 73 | if ((nbpt % 20) == 0) nbpt++;
|
---|
| 74 | fgrevtheta = true;
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | /* --Methode-- */
|
---|
| 78 | MollweideGridDrawer::MollweideGridDrawer(int np, int nm, double x_larg, double x_0,
|
---|
| 79 | double y_larg, double y_0)
|
---|
| 80 | {
|
---|
| 81 | if (x_larg > 0.) {
|
---|
| 82 | xlarg = x_larg; x0 = x_0;
|
---|
| 83 | }
|
---|
| 84 | else {
|
---|
| 85 | xlarg = M_PI*2.; x0 = M_PI;
|
---|
| 86 | }
|
---|
| 87 | if (y_larg > 0.) {
|
---|
| 88 | ylarg = y_larg; y0 = y_0;
|
---|
| 89 | }
|
---|
| 90 | else {
|
---|
| 91 | ylarg = M_PI; y0 = 0.;
|
---|
| 92 | }
|
---|
| 93 | nbparall = np;
|
---|
| 94 | nbmerid = nm;
|
---|
| 95 | nbpt = 101;
|
---|
| 96 | fgrevtheta = false;
|
---|
| 97 | }
|
---|
| 98 |
|
---|
| 99 | /* --Methode-- */
|
---|
| 100 | MollweideGridDrawer::~MollweideGridDrawer()
|
---|
| 101 | {
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | /* --Methode-- */
|
---|
| 105 | void MollweideGridDrawer::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax)
|
---|
| 106 | {
|
---|
| 107 | PIGrCoord * xxl = new PIGrCoord[nbpt];
|
---|
| 108 | PIGrCoord * xxr = new PIGrCoord[nbpt];
|
---|
| 109 | PIGrCoord * yy = new PIGrCoord[nbpt];
|
---|
| 110 |
|
---|
| 111 | char buff[64];
|
---|
| 112 |
|
---|
| 113 | // Trace des paralleles
|
---|
| 114 | g->DrawLine(xmin, y0, xmax, y0);
|
---|
| 115 | g->DrawString(x0+xlarg/100, y0+ylarg/100, "0");
|
---|
| 116 |
|
---|
| 117 | // PIGrCoord asc, PIGrCoord desc;
|
---|
| 118 | int i,k;
|
---|
| 119 |
|
---|
| 120 | int nkp = (nbparall-1)/2;
|
---|
| 121 | if (nkp > 0) {
|
---|
| 122 | double dy = 0.5*ylarg/(double)(nkp+1);
|
---|
| 123 | double dtd = 90./(double)(nkp+1);
|
---|
| 124 | for(k=1; k<=nkp; k++) {
|
---|
| 125 | double fx = sin(acos(2.*(double)k*dy/ylarg))*0.5;
|
---|
| 126 | double yc = k*dy+y0;
|
---|
| 127 | g->DrawLine(x0-fx*xlarg, yc, x0+fx*xlarg, yc);
|
---|
| 128 | double ctd = (fgrevtheta) ? -dtd*k : dtd*k;
|
---|
| 129 | sprintf(buff, "%5.1f", ctd);
|
---|
| 130 | g->DrawString(x0, yc, buff);
|
---|
| 131 | g->DrawString(x0-0.3*xlarg, yc, buff);
|
---|
| 132 | g->DrawString(x0+0.25*xlarg, yc, buff);
|
---|
| 133 | yc = -k*dy+y0;
|
---|
| 134 | g->DrawLine(x0-fx*xlarg, yc, x0+fx*xlarg, yc);
|
---|
| 135 | sprintf(buff, "%5.1f", -ctd);
|
---|
| 136 | g->DrawString(x0, yc, buff);
|
---|
| 137 | g->DrawString(x0-0.3*xlarg, yc, buff);
|
---|
| 138 | g->DrawString(x0+0.25*xlarg, yc, buff);
|
---|
| 139 | }
|
---|
| 140 | }
|
---|
| 141 |
|
---|
| 142 | // Trace des meridiennes
|
---|
| 143 | g->DrawLine(x0, ymin, x0, ymax);
|
---|
| 144 |
|
---|
| 145 | int nkm = (nbmerid-1)/2;
|
---|
| 146 | if (nkm < 1) nkm = 1;
|
---|
| 147 | double dphi = M_PI/nkm;
|
---|
| 148 | double dpd = 180./(double)(nkm);
|
---|
| 149 | double dy = ylarg/(nbpt-1);
|
---|
| 150 | for(k=0; k<nkm; k++) {
|
---|
| 151 | double phi0 = k*dphi;
|
---|
| 152 | double dphimil = fabs(phi0-M_PI);
|
---|
| 153 | if (dphimil < 1.e-6) continue;
|
---|
| 154 | for(i=0; i<nbpt; i++) {
|
---|
| 155 | double yc = (double)i*dy+y0-0.5*ylarg;
|
---|
| 156 | double fx = (2.*fabs(yc-y0)/ylarg <= 1.) ?
|
---|
| 157 | sin(acos(2.*fabs(yc-y0)/ylarg)) * dphimil/M_PI * 0.5 : 0.;
|
---|
| 158 | yy[i] = yc;
|
---|
| 159 | xxl[i] = x0-fx*xlarg;
|
---|
| 160 | xxr[i] = x0+fx*xlarg;
|
---|
| 161 | }
|
---|
| 162 |
|
---|
| 163 | g->DrawPolygon(xxl, yy, nbpt, false);
|
---|
| 164 | g->DrawPolygon(xxr, yy, nbpt, false);
|
---|
| 165 |
|
---|
| 166 | if (k == 0) continue;
|
---|
| 167 | for(i=-1; i<=1; i++) {
|
---|
| 168 | double yc = 0.20*i*ylarg+y0;
|
---|
| 169 | double fx = sin(acos(2.*fabs(yc-y0)/ylarg)) * dphimil/M_PI * 0.5;
|
---|
| 170 | double xc = x0-fx*xlarg;
|
---|
| 171 | sprintf(buff, "%4.1f", dpd*k);
|
---|
| 172 | g->DrawString(xc, yc, buff);
|
---|
| 173 | xc = x0+fx*xlarg;
|
---|
| 174 | sprintf(buff, "%4.1f", 360.-dpd*k);
|
---|
| 175 | g->DrawString(xc, yc, buff);
|
---|
| 176 | }
|
---|
| 177 | }
|
---|
| 178 |
|
---|
| 179 | delete [] xxl;
|
---|
| 180 | delete [] xxr;
|
---|
| 181 | delete [] yy;
|
---|
| 182 | }
|
---|
| 183 |
|
---|
| 184 | /* --Methode-- */
|
---|
| 185 | void MollweideGridDrawer::UpdateLimits()
|
---|
| 186 | {
|
---|
| 187 | SetLimits(x0-xlarg/2., x0+xlarg/2., y0-ylarg/2., y0+ylarg/2.);
|
---|
| 188 | }
|
---|
| 189 |
|
---|
| 190 | /* --Methode-- */
|
---|
[722] | 191 | sopiamoduleExecutor::sopiamoduleExecutor()
|
---|
| 192 | {
|
---|
| 193 |
|
---|
| 194 | PIACmd * mpiac;
|
---|
| 195 | NamedObjMgr omg;
|
---|
| 196 | mpiac = omg.GetImgApp()->CmdInterpreter();
|
---|
| 197 |
|
---|
| 198 | string hgrp = "SophyaCmd";
|
---|
[2920] | 199 | string kw,usage;
|
---|
| 200 |
|
---|
| 201 | kw = "powerspec";
|
---|
| 202 | usage = "FFT on a vector -> Plots power spectrum ";
|
---|
| 203 | usage += "\n Usage: powerspec vecName vecFFT [graphic_att] ";
|
---|
[722] | 204 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
[2920] | 205 |
|
---|
| 206 | kw = "fftforw";
|
---|
| 207 | usage = "FFT on a vector -> Plots power spectrum (same as powerspec)";
|
---|
| 208 | usage += "\n Usage: fftforw vecName vecFFT [graphic_att] ";
|
---|
| 209 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
| 210 |
|
---|
| 211 | kw = "fftback";
|
---|
| 212 | usage = "FFT on a vector -> Plots power spectrum";
|
---|
| 213 | usage += "\n Usage: fftback vecFFT vecName [graphic_att] ";
|
---|
| 214 | usage += "\n vecFFT is complex<r_8>";
|
---|
| 215 | usage += "\n If vecName already exist, it gives the type(r_8 or complex<r_8>)";
|
---|
| 216 | usage += "\n If vecName does not exist, return type is complex<r_8>";
|
---|
| 217 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
| 218 |
|
---|
| 219 | kw = "crefilter";
|
---|
| 220 | usage = "Create a filter for vecFFT (vector complex<r_8>)";
|
---|
| 221 | usage += "\n Usage: crefilter vecFFT filter f(x) [graphic_att] ";
|
---|
| 222 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
| 223 |
|
---|
| 224 | kw = "fftfilter";
|
---|
| 225 | usage = "Filter (multiply) vecFFT (vector complex<r_8>) by filter (vector<r_8>)";
|
---|
| 226 | usage += "\n Usage: fftfilter vecFFT filter [graphic_att] ";
|
---|
| 227 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
| 228 |
|
---|
[1540] | 229 | kw = "mollgridsph";
|
---|
| 230 | usage = "Creates a spherical coordinate grid in Molleweide projection ";
|
---|
| 231 | usage += "\n Usage: mollgridsph NameSphericalMap [Nb_Parallel Nb_Meridien graphic_att] ";
|
---|
| 232 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
[2920] | 233 |
|
---|
[1540] | 234 | kw = "mollgrid";
|
---|
| 235 | usage = "Creates a spherical coordinate grid in Molleweide projection ";
|
---|
| 236 | usage += "\n Usage: mollgrid [Nb_Parallel Nb_Meridien graphic_att] ";
|
---|
| 237 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
[2920] | 238 |
|
---|
[2595] | 239 | kw = "setprjmoldefval";
|
---|
| 240 | usage = "Set default value for Molleweide projection of spherical maps (outside maps)";
|
---|
| 241 | usage += "\n Usage: setprjmoldefval OutOfMapValue ";
|
---|
| 242 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
[722] | 243 |
|
---|
| 244 | }
|
---|
| 245 |
|
---|
| 246 | /* --Methode-- */
|
---|
| 247 | sopiamoduleExecutor::~sopiamoduleExecutor()
|
---|
| 248 | {
|
---|
| 249 | }
|
---|
| 250 |
|
---|
| 251 | /* --Methode-- */
|
---|
[1267] | 252 | int sopiamoduleExecutor::Execute(string& kw, vector<string>& tokens, string& toks)
|
---|
[722] | 253 | {
|
---|
| 254 |
|
---|
[2920] | 255 | if (kw == "powerspec" || kw == "fftforw") {
|
---|
[722] | 256 | if (tokens.size() < 2) {
|
---|
| 257 | cout << "Usage: powerspec nameVec vecFFT [graphic_att]" << endl;
|
---|
| 258 | return(0);
|
---|
| 259 | }
|
---|
[2920] | 260 | if (tokens.size() < 3) tokens.push_back((string)"");
|
---|
| 261 | SophyaFFT_forw(tokens[0], tokens[1], tokens[2]);
|
---|
[722] | 262 | }
|
---|
[2920] | 263 | else if (kw == "fftback") {
|
---|
| 264 | if (tokens.size() < 2) {
|
---|
| 265 | cout << "Usage: fftback vecFFT nameVec [graphic_att]" << endl;
|
---|
| 266 | return(0);
|
---|
| 267 | }
|
---|
| 268 | if (tokens.size() < 3) tokens.push_back((string)"");
|
---|
| 269 | SophyaFFT_back(tokens[0], tokens[1], tokens[2]);
|
---|
| 270 | }
|
---|
| 271 | else if (kw == "crefilter") {
|
---|
| 272 | if (tokens.size() < 3) {
|
---|
| 273 | cout << "Usage: crefilter vecFFT filter f(x) [graphic_att]" << endl;
|
---|
| 274 | return(0);
|
---|
| 275 | }
|
---|
| 276 | if (tokens.size() < 4) tokens.push_back((string)"");
|
---|
| 277 | SophyaFFT_crefilter(tokens[0], tokens[1], tokens[2], tokens[3]);
|
---|
| 278 | }
|
---|
| 279 | else if (kw == "fftfilter") {
|
---|
| 280 | if (tokens.size() < 2) {
|
---|
| 281 | cout << "Usage: fftfilter vecFFT filter [graphic_att]" << endl;
|
---|
| 282 | return(0);
|
---|
| 283 | }
|
---|
| 284 | if (tokens.size() < 3) tokens.push_back((string)"");
|
---|
| 285 | SophyaFFT_filter(tokens[0], tokens[1], tokens[2]);
|
---|
| 286 | }
|
---|
| 287 |
|
---|
[2595] | 288 | else if (kw == "prjmoldefval") {
|
---|
| 289 | if (tokens.size() < 1) {
|
---|
| 290 | cout << "Usage: prjmoldefval OutOfMapValue" << endl;
|
---|
| 291 | return(0);
|
---|
| 292 | }
|
---|
| 293 | Set_Project_Mol_DefVal(atof(tokens[0].c_str()) );
|
---|
| 294 | }
|
---|
| 295 | else if ( (kw == "mollgridsph") || (kw == "mollgrid") ) {
|
---|
[1540] | 296 | NamedObjMgr omg;
|
---|
| 297 | MollweideGridDrawer * mollgrid = NULL;
|
---|
| 298 | string dopt="";
|
---|
| 299 | if (kw == "mollgridsph") {
|
---|
| 300 | if (tokens.size() < 1) {
|
---|
| 301 | cout << "Usage: mollgridsph NameSphericalMap [Nb_Parallel Nb_Meridien graphic_att]"
|
---|
| 302 | << endl;
|
---|
| 303 | return(0);
|
---|
| 304 | }
|
---|
| 305 | int np = 5;
|
---|
| 306 | int nm = 5;
|
---|
| 307 | dopt = "same,thinline";
|
---|
| 308 | if (tokens.size() > 1) np = atoi(tokens[1].c_str());
|
---|
| 309 | if (tokens.size() > 2) nm = atoi(tokens[2].c_str());
|
---|
| 310 | if (tokens.size() > 3) dopt = tokens[3];
|
---|
| 311 | NObjMgrAdapter* obja = omg.GetObjAdapter(tokens[0]);
|
---|
| 312 | if (obja == NULL) {
|
---|
| 313 | cout << "mollgridsph Error , No object with name " << tokens[0] << endl;
|
---|
| 314 | return(0);
|
---|
| 315 | }
|
---|
| 316 | P2DArrayAdapter* arr = obja->Get2DArray(dopt);
|
---|
| 317 | if (arr == NULL) {
|
---|
| 318 | cout << "mollgridsph Error , object has non 2DArrayAdapter - Not a spherical map "
|
---|
| 319 | << endl;
|
---|
| 320 | return(0);
|
---|
| 321 | }
|
---|
| 322 | int nx = arr->XSize();
|
---|
| 323 | int ny = arr->YSize();
|
---|
| 324 | delete arr;
|
---|
| 325 | mollgrid = new MollweideGridDrawer(np, nm, nx, ny);
|
---|
| 326 | cout << " mollgridsph: Creating MollweideGridDrawer() for object" << tokens[0] << endl;
|
---|
| 327 | }
|
---|
| 328 | else if (kw == "mollgrid") {
|
---|
| 329 | int np = 5;
|
---|
| 330 | int nm = 5;
|
---|
| 331 | if (tokens.size() > 0) np = atoi(tokens[0].c_str());
|
---|
| 332 | if (tokens.size() > 1) nm = atoi(tokens[1].c_str());
|
---|
| 333 | if (tokens.size() > 2) dopt = tokens[2];
|
---|
| 334 | mollgrid = new MollweideGridDrawer(np, nm);
|
---|
| 335 | cout << " mollgrid: Creating MollweideGridDrawer(" << np << "," << nm << ")" << endl;
|
---|
| 336 | }
|
---|
[722] | 337 |
|
---|
[1540] | 338 | if (mollgrid == NULL) {
|
---|
| 339 | cout << "mollgridsph Error/BUG !!! mollgrid = NULL " << endl;
|
---|
| 340 | return(0);
|
---|
| 341 | }
|
---|
| 342 |
|
---|
| 343 | int wrsid = 0;
|
---|
[2179] | 344 | //bool fgsr = true;
|
---|
[1540] | 345 |
|
---|
| 346 | string name = "mollgrid";
|
---|
[1972] | 347 | wrsid = omg.GetImgApp()->DispScDrawer(mollgrid, name, dopt);
|
---|
[1540] | 348 | }
|
---|
| 349 |
|
---|
[722] | 350 | return(0);
|
---|
| 351 |
|
---|
| 352 | }
|
---|
| 353 |
|
---|
| 354 | static sopiamoduleExecutor * piaerex = NULL;
|
---|
| 355 | /* Nouvelle-Fonction */
|
---|
| 356 | void sopiamodule_init()
|
---|
| 357 | {
|
---|
| 358 | // Fonction d'initialisation du module
|
---|
| 359 | // Appele par le gestionnaire de modules de piapp (PIACmd::LoadModule())
|
---|
| 360 | if (piaerex) delete piaerex;
|
---|
| 361 | piaerex = new sopiamoduleExecutor;
|
---|
| 362 | }
|
---|
| 363 |
|
---|
| 364 | /* Nouvelle-Fonction */
|
---|
| 365 | void sopiamodule_end()
|
---|
| 366 | {
|
---|
| 367 | // Desactivation du module
|
---|
| 368 | if (piaerex) delete piaerex;
|
---|
| 369 | piaerex = NULL;
|
---|
| 370 | }
|
---|
| 371 |
|
---|
| 372 |
|
---|
[2920] | 373 | /* Nouvelle-Fonction */
|
---|
| 374 | void SophyaFFT_forw(string& nom, string& nomout, string dopt)
|
---|
[722] | 375 | {
|
---|
[2920] | 376 | //Timer tm("powerspec");
|
---|
[722] | 377 | NamedObjMgr omg;
|
---|
| 378 | AnyDataObj* obj=omg.GetObj(nom);
|
---|
| 379 | if (obj == NULL) {
|
---|
[2920] | 380 | cout<<"SophyaFFT_forw() Error , Pas d'objet de nom "<<nom<<endl;
|
---|
[722] | 381 | return;
|
---|
| 382 | }
|
---|
| 383 |
|
---|
[2920] | 384 | TVector<r_8>* vin = dynamic_cast<TVector<r_8> *>(obj);
|
---|
| 385 | TVector< complex<r_8> >* vinc = dynamic_cast<TVector< complex<r_8> >*>(obj);
|
---|
| 386 | if (vin == NULL && vinc == NULL) {
|
---|
| 387 | cout<<"SophyaFFT_forw() Error , Objet n'est pas un vecteur r_8 ou complex<r_8>"<<endl;
|
---|
[722] | 388 | return;
|
---|
[2920] | 389 | }
|
---|
| 390 | TVector< complex<r_8> > * vout = new TVector< complex<r_8> > ;
|
---|
[722] | 391 | FFTPackServer ffts;
|
---|
[2920] | 392 | if(vin!=NULL) {
|
---|
| 393 | cout<<"SophyaFFT_forw() - Computing FFT of TVector<r_8> of size "<<vin->NElts()<< endl;
|
---|
| 394 | ffts.FFTForward(*vin, *vout);
|
---|
| 395 | cout<<"...Output TVector<complex<r_8>> of size: "<<vout->NElts()<<endl;
|
---|
| 396 | } else {
|
---|
| 397 | cout<<"SophyaFFT_forw() - Computing FFT of vector TVector<complex<r_8>> of size "<<vinc->NElts()<< endl;
|
---|
| 398 | ffts.FFTForward(*vinc, *vout);
|
---|
| 399 | cout<<"...Output TVector<complex<r_8>> of size: "<<vout->NElts()<<endl;
|
---|
| 400 | }
|
---|
[1481] | 401 | // cout << " SophyaFFT - FFT done " << endl;
|
---|
| 402 | // tm.Split(" FFT done ");
|
---|
[722] | 403 |
|
---|
| 404 | omg.AddObj(vout, nomout);
|
---|
[2920] | 405 | if(dopt.size()>0) omg.DisplayObj(nomout, dopt);
|
---|
[722] | 406 | return;
|
---|
| 407 |
|
---|
| 408 | }
|
---|
[2920] | 409 |
|
---|
| 410 |
|
---|
| 411 | /* Nouvelle-Fonction */
|
---|
| 412 | void SophyaFFT_back(string& nom, string& nomout, string dopt)
|
---|
| 413 | {
|
---|
| 414 | //Timer tm("powerspec");
|
---|
| 415 | NamedObjMgr omg;
|
---|
| 416 | AnyDataObj* obj=omg.GetObj(nom);
|
---|
| 417 | if (obj == NULL) {
|
---|
| 418 | cout << "SophyaFFT_back() Error , Pas d'objet de nom " << nom << endl;
|
---|
| 419 | return;
|
---|
| 420 | }
|
---|
| 421 |
|
---|
| 422 | TVector< complex<r_8> >* vinc = dynamic_cast<TVector< complex<r_8> >*>(obj);
|
---|
| 423 | if (vinc == NULL) {
|
---|
| 424 | cout << "SophyaFFT_back() Error , Objet n'est pas un vecteur complex<r_8>" << endl;
|
---|
| 425 | return;
|
---|
| 426 | }
|
---|
| 427 |
|
---|
| 428 | TVector< r_8 > * vout = NULL;
|
---|
| 429 | TVector< complex<r_8> > * voutc = NULL;
|
---|
| 430 | obj=omg.GetObj(nomout);
|
---|
| 431 | if(obj == NULL) {
|
---|
| 432 | voutc = new TVector< complex<r_8> >;
|
---|
| 433 | } else {
|
---|
| 434 | vout = dynamic_cast<TVector<r_8>*>(obj);
|
---|
| 435 | if(vout==NULL) voutc = dynamic_cast<TVector< complex<r_8> >*>(obj);
|
---|
| 436 | }
|
---|
| 437 | if(vout==NULL && voutc==NULL) {
|
---|
| 438 | cout << "SophyaFFT_back() Error , Output objet n'est pas un vecteur r_8 ou complex<r_8>" << endl;
|
---|
| 439 | return;
|
---|
| 440 | }
|
---|
| 441 |
|
---|
| 442 | FFTPackServer ffts;
|
---|
| 443 | cout << "SophyaFFT_back() - Computing Backward FFT of vector size " << vinc->NElts() << endl;
|
---|
| 444 | if(vout!=NULL) {
|
---|
| 445 | ffts.FFTBackward(*vinc, *vout);
|
---|
| 446 | cout<<"...Output TVector<r_8> of size: "<<vout->NElts()<<endl;
|
---|
| 447 | omg.AddObj(vout, nomout);
|
---|
| 448 | } else {
|
---|
| 449 | ffts.FFTBackward(*vinc, *voutc);
|
---|
| 450 | cout<<"...Output TVector<complex<r_8>> of size: "<<voutc->NElts()<<endl;
|
---|
| 451 | omg.AddObj(voutc, nomout);
|
---|
| 452 | }
|
---|
| 453 |
|
---|
| 454 | if(dopt.size()>0) omg.DisplayObj(nomout, dopt);
|
---|
| 455 | return;
|
---|
| 456 | }
|
---|
| 457 |
|
---|
| 458 | /* Nouvelle-Fonction */
|
---|
| 459 | void SophyaFFT_crefilter(string& nomvec, string& nomfilter, string func, string dopt)
|
---|
| 460 | {
|
---|
| 461 | NamedObjMgr omg;
|
---|
| 462 | AnyDataObj* obj=omg.GetObj(nomvec);
|
---|
| 463 | if(obj == NULL) {
|
---|
| 464 | cout<<"SophyaFFT_crefilter() Error , Pas d'objet de nom "<<nomvec<<endl;
|
---|
| 465 | return;
|
---|
| 466 | }
|
---|
| 467 |
|
---|
| 468 | TVector< complex<r_8> >* vfft = dynamic_cast<TVector< complex<r_8> >*>(obj);
|
---|
| 469 | if(vfft == NULL) {
|
---|
| 470 | cout<<"SophyaFFT_crefilter() Error , Objet "<<nomvec<<" n'est pas un Tvector<complex<r_8>>"<< endl;
|
---|
| 471 | return;
|
---|
| 472 | }
|
---|
| 473 | int n = vfft->Size();
|
---|
| 474 | if(n<=0) return;
|
---|
| 475 |
|
---|
| 476 | cout<<"Creating filter "<<nomfilter<<"("<<n<<") from vec "<<nomvec<<" with fun "<<func<<endl;
|
---|
| 477 | omg.GetServiceObj()->PlotFunc(func,nomfilter,0.,(double)n,n,dopt);
|
---|
| 478 | }
|
---|
| 479 |
|
---|
| 480 | /* Nouvelle-Fonction */
|
---|
| 481 | void SophyaFFT_filter(string& nom, string& nomfilter, string dopt)
|
---|
| 482 | {
|
---|
| 483 | NamedObjMgr omg;
|
---|
| 484 | AnyDataObj* obj=omg.GetObj(nom);
|
---|
| 485 | if(obj == NULL) {
|
---|
| 486 | cout<<"SophyaFFT_filter() Error , Pas d'objet de nom "<<nom<<endl;
|
---|
| 487 | return;
|
---|
| 488 | }
|
---|
| 489 |
|
---|
| 490 | AnyDataObj* objfilter=omg.GetObj(nomfilter);
|
---|
| 491 | if(objfilter == NULL) {
|
---|
| 492 | cout<<"SophyaFFT_filter() Error , Pas d'objet de nom "<<nomfilter<<endl;
|
---|
| 493 | return;
|
---|
| 494 | }
|
---|
| 495 |
|
---|
| 496 | TVector< complex<r_8> >* vfft = dynamic_cast<TVector< complex<r_8> >*>(obj);
|
---|
| 497 | if(vfft == NULL) {
|
---|
| 498 | cout<<"SophyaFFT_filter() Error , Objet "<<nom<<" n'est pas un Tvector<complex<r_8>>"<< endl;
|
---|
| 499 | return;
|
---|
| 500 | }
|
---|
| 501 |
|
---|
| 502 | TVector<r_8>* vfilter = dynamic_cast<TVector<r_8>*>(objfilter);
|
---|
| 503 | if(vfft == NULL) {
|
---|
| 504 | cout<<"SophyaFFT_filter() Error , Objet "<<nomfilter<<" n'est pas un Tvector<r_8>"<<endl;
|
---|
| 505 | return;
|
---|
| 506 | }
|
---|
| 507 |
|
---|
| 508 | int n = (vfilter->Size()<vfft->Size()) ? vfilter->Size(): vfft->Size();
|
---|
| 509 | cout<<"...filtering from 0 to "<<n<<endl;
|
---|
| 510 | for(int i=0;i<n;i++) (*vfft)(i) *= (*vfilter)(i);
|
---|
| 511 |
|
---|
| 512 | if(dopt.size()>0) omg.DisplayObj(nom,dopt);
|
---|
| 513 | return;
|
---|
| 514 | }
|
---|