Changeset 1520 in Sophya


Ignore:
Timestamp:
Jun 12, 2001, 7:40:20 PM (24 years ago)
Author:
cmv
Message:

Re-shape de map2toi cmv 12/6/01

Location:
trunk/ArchTOIPipe
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/ArchTOIPipe/ProcWSophya/map2toi.cc

    r1514 r1520  
    88: mSph(sph)
    99{
     10 SetEquinox();
     11 SetCoorIn();
     12 SetCoorMap();
    1013}
    1114
     
    1720void Map2TOI::init() {
    1821  cout << "Map2TOI::init" << endl;
    19   declareInput("AlphaIn");     // input  index 0
    20   declareInput("DeltaIn");     // input  index 1
    21   declareOutput("AlphaOut");   // output index 0
    22   declareOutput("DeltaOut");   // output index 1
    23   declareOutput("BoloOut");    // output index 2
     22  declareInput("Coord1In");     // input  index 0
     23  declareInput("Coord2In");     // input  index 1
     24  declareOutput("Coord1Out");   // output index 0
     25  declareOutput("Coord2Out");   // output index 1
     26  declareOutput("BoloOut");     // output index 2
    2427}
    2528
     
    3942}
    4043if(!checkInputTOIIndex(0) || !checkInputTOIIndex(1)) {
    41   cout<<"Map2TOI::run() - Input TOI (AlphaIn or DeltaIn) not connected! "<<endl;
    42   throw ParmError("Map2TOI::run() Output TOI (AlphaIn or DeltaIn) not connected!");
     44  cout<<"Map2TOI::run() - Input TOI (Coord1In or Coord2In) not connected! "<<endl;
     45  throw ParmError("Map2TOI::run() Output TOI (Coord1In or Coord2In) not connected!");
    4346}
    44 bool connected_AlphaOut = checkOutputTOIIndex(0);
    45 bool connected_DeltaOut = checkOutputTOIIndex(1);
     47bool connected_Coord1Out = checkOutputTOIIndex(0);
     48bool connected_Coord2Out = checkOutputTOIIndex(1);
    4649if(!checkOutputTOIIndex(2)) {
    4750  cout<<"Map2TOI::run() - Output TOI (BoloOut) not connected! "<<endl;
    4851  throw ParmError("Map2TOI::run() Output TOI (BoloOut) not connected!");
     52}
     53if( !(mTypCoorIn&TypCoordEq || mTypCoorIn&TypCoordGal) ) {
     54  cout<<"Map2TOI::run() - CoordIn Coordinates not Eq or Gal! "<<endl;
     55  throw ParmError("Map2TOI::run() - CoordIn Coordinates not Eq or Gal!");
     56}
     57if( !(mTypCoorMap&TypCoordEq || mTypCoorMap&TypCoordGal) ) {
     58  cout<<"Map2TOI::run() - Sphere Coordinates not Eq or Gal! "<<endl;
     59  throw ParmError("Map2TOI::run() - Sphere Coordinates not Eq or Gal!");
    4960}
    5061
     
    5263try {
    5364
     65uint_4 mSnRead=0, mSnFilled=0;
     66double mjd = MJDfrYear(mActualYear);
     67
    5468for(int k=snb;k<=sne;k++) {
    5569
    5670  int_8 flg = 0;
    57   //  double alpha = getData(0,k); // alpha entre [0,24[ en heures
    58   //  if(alpha<0. || alpha>=24.) flg=1;
    59   // On passe l'angle en longitude en degres - de [0,360[ deg
    60   double alpha = getData(0,k); // alpha entre [0,360[ en heures
    61   if(alpha<0. || alpha>=360.) flg=1;
    62   double delta = getData(1,k); // delta entre [-90,90] en degres
    63   if(delta<-90. || delta>90.) flg=1;
    64   double bolo = -99999.;
     71  double coord1 = getData(0,k);
     72  double coord2 = getData(1,k);
     73  double c1 = coord1, c2=coord2, bolo = -99999.;
     74  mSnRead++;
     75
     76  // Convert CoordIn to Standard
     77  double phi=-1.,theta;
     78  CoordConvertToStd(mTypCoorIn,c1,c2);
     79  if(mTypCoorIn&TypCoordEq && mTypCoorMap&TypCoordGal) { // CIn=Eq  CMap=Gal
     80    EqtoGal(mjd,c1,c2,&c1,&c2);
     81    phi   = c1 * M_PI/180.;
     82  } else if(mTypCoorIn&TypCoordGal && mTypCoorMap&TypCoordEq) { // CIn=Gal CMap=Eq
     83    GaltoEq(mjd,c1,c2,&c1,&c2);
     84    phi   = c1 * M_PI/12.;
     85  } else if(mTypCoorMap&TypCoordGal) { // CIn=Gal CMap=Gal
     86    phi   = c1 * M_PI/180.;
     87  } else if(mTypCoorMap&TypCoordEq) { // CIn=Eq CMap=Eq
     88    phi   = c1 * M_PI/12.;
     89  }
     90  theta = (90.-c2) * M_PI/180.;
     91  if(phi<0.   || phi>=2*M_PI) flg=FlgToiOut;
     92  if(theta<0. || theta>=M_PI) flg=FlgToiOut;
    6593
    6694  if(!flg) {
    67     //    double phi   = alpha *M_PI/12.; // sphere phi entre [0,2*Pi] en radian
    68     double phi   = alpha *M_PI/180.; // sphere phi entre [0,2*Pi] en radian
    69     double teta  = (90.-delta) *M_PI/180.; // sphere teta entre [0,Pi] en radian
    70     bolo = mSph(teta,phi);
     95    bolo = mSph(theta,phi);
     96    mSnFilled++;
    7197  }
    7298
    73   if(connected_AlphaOut) putData(0,k,alpha,0);
    74   if(connected_DeltaOut) putData(1,k,delta,0);
     99  if(connected_Coord1Out) putData(0,k,coord1,flg);
     100  if(connected_Coord2Out) putData(1,k,coord2,flg);
    75101  putData(2,k,bolo,flg);
    76102}
     103
     104cout<<"TOI2Map::run: Samples Read "<<mSnRead<<" Filled "<<mSnFilled<<endl;
    77105
    78106//---------------------------------------------------------
  • trunk/ArchTOIPipe/ProcWSophya/map2toi.h

    r1463 r1520  
    55#include "toiprocessor.h"
    66#include "spherehealpix.h"
     7#include "flagtoidef.h"
     8#include "xastropack.h"
    79
    8 //-- Un generateur de TOI a partir d'une sphere et de 2 TOIs alpha,delta
    9 // Lecture de 2 TOI alpha,delta et d'une Sphere Healpix
    10 // Sortie de 3 TOI alpha,delta,boloMuV
     10//-- Un generateur de TOI a partir d'une sphere et de 2 TOIs coordin1,coordin2
     11// Lecture de 2 TOI coord1,coord2 et d'une Sphere Healpix
     12// Sortie de 3 TOI coord1,coord2,boloMuV
    1113//
    1214// Structure generale :
    13 // (les alpha[0,360[,delta[-90,90] sont en degres decimaux)
    1415//             Sphere ---- |
    1516//                         |
    16 //                    -----------
    17 //   toi AlphaIn ---> |         | ---> toi AlphaOut
    18 //                    | Map2TOI | ---> toi DeltaOut
    19 //   toi DeltaIn ---> |         | ---> toi BoloOut
    20 //                    -----------
     17//                     -----------
     18//   toi CoordIn1 ---> |         | ---> toi CoordOut1
     19//                     | Map2TOI | ---> toi CoordOut2
     20//   toi CoordIn2 ---> |         | ---> toi BoloOut
     21//                     -----------
     22// Gestion du type de coordonnees :
     23// Coord1In,Coord2In : soit Equatoriales (Alpha,Delta)
     24//                     soit Galactiques  (GLong,GLat)
     25// La sphere peut avoir des coordonnees differentes des CoordIn
     26// Si les CoordIn et les CoordSphere sont equatoriales -> meme equinoxe!
     27// La sortie CoordOut aura les MEMES coordonnees que les CoordIn
    2128
    2229class Map2TOI : public TOIProcessor {
     
    2532  virtual       ~Map2TOI();
    2633
    27   virtual void  init(void); 
     34  virtual void  init(void);
    2835  virtual void  run(void);
    29  
     36
     37  // Pour savoir si on a de HourDeg,DegDeg,RadRad
     38  inline void SetEquinox(double actualyear=2000.)
     39              {mActualYear = actualyear;}
     40  inline void SetCoorIn(TypAstroCoord mfg=TypCoordGalStd)
     41              {mTypCoorIn = mfg;}
     42  inline void SetCoorMap(TypAstroCoord mfg=TypCoordGalStd)
     43              {mTypCoorMap = mfg;}
     44
    3045protected:
    3146  SphereHEALPix<r_8>& mSph;
     47  TypAstroCoord mTypCoorIn,mTypCoorMap;
     48  double mActualYear;
    3249};
    3350
  • trunk/ArchTOIPipe/ProcWSophya/toi2map.cc

    r1516 r1520  
    9696  // sphere phi   entre [0,2*Pi] en radians
    9797  // sphere theta entre [0,Pi]   en radians
    98   double phi,theta;
     98  double phi=-1.,theta;
    9999  CoordConvertToStd(mTypCoorIn,coord1,coord2);
    100100  if(mTypCoorIn&TypCoordEq && mTypCoorOut&TypCoordGal) { // Eq -> Gal
  • trunk/ArchTOIPipe/ProcWSophya/toi2map.h

    r1516 r1520  
    2424//                     soit Galactiques  (GLong,GLat)
    2525// Sortie sur une sphere en coordonnees Equatoriales ou Galactiques
     26// Si les CoordIn et les CoordOut sont equatoriales -> meme equinoxe!
    2627
    2728class TOI2Map : public TOIProcessor {
  • trunk/ArchTOIPipe/TestPipes/tstmap2toi.cc

    r1476 r1520  
    1717void usage(void) {
    1818 cout<<"tstmap2toi [-h] [-p lp] [-s samplemin,samplemax] [-w data_window_size]"<<endl
    19      <<"           [-a label_alpha] [-d label_delta] [-b label_bolomuv]"<<endl
    20      <<"           fitsin fitsphere fitsout"<<endl;
     19     <<"           [-a label_coord1In] [-d label_coord2In] [-b label_bolomuv]"<<endl
     20     <<"           [-i c,h] [-m c,h]"<<endl
     21     <<"           fitsin_point fitsphere fitsout"<<endl
     22     <<" -p lp : print level (def=0)"<<endl
     23     <<" -s samplemin,samplemax : sample range to be treated (def=all)"<<endl
     24     <<" -w data_window_size : window size for pipe (def=8192)"<<endl
     25     <<" -a label_coord1 : label fits for alpha/gLong (def=coord1)"<<endl
     26     <<" -d label_coord2 : label fits for delta/gLat (def=coord2)"<<endl
     27     <<"          coord1 = alpha or gLong ; coord2 = delta or gLat"<<endl
     28     <<" -b label_bolomuv : label fits for bolo value (def=boloMuV)"<<endl
     29     <<" -i c,h : coordIn caracteristics (c=G/E h=H/D) (def=G,D)"<<endl
     30     <<" -m c,h : idem -i for Sphere"<<endl
     31     <<" fitsin_point : fits file for pointing"<<endl
     32     <<" fitsphere : fits file for input Healpix sphere"<<endl
     33     <<" fitsout : fits file for output"<<endl;
    2134 return;
     35}
     36
     37unsigned long typecoord(char typc=' ',char hd=' ');
     38unsigned long typecoord(char typc,char hd)
     39// typc : G=galactiques, E=equatoriales, autres=galactiques
     40// hd : H=heure, D=degre, autres=(heure si typc==E, degre si typc==G)
     41{
     42  if(typc!='G' && typc!='E') typc='G';
     43  if(hd!='H' && hd!='D') {if(typc=='E') hd='H'; else hd='D';}
     44 unsigned long rc=TypCoordUndef;
     45  if(typc=='G') rc |= TypCoordGal;
     46    else        rc |= TypCoordEq;
     47  if(hd=='D')   rc |= TypCoordDD;
     48    else        rc |= TypCoordHD;
     49  return rc;
    2250}
    2351
     
    2957//-- Decodage arguments
    3058int lp = 0, width = 8192;
    31 char *label_alpha = "alpha", *label_delta = "delta", *label_bolomuv = "boloMuV";
     59char *label_coord1 = "coord1", *label_coord2 = "coord2", *label_bolomuv = "boloMuV";
    3260long sdeb,sfin;
    33 int c;
    34 while((c = getopt(narg,arg,"hp:s:w:a:d:b:")) != -1) {
     61unsigned long tcoorin=typecoord(), tcoormap=typecoord();
     62int c; char t=' ',h=' ';
     63while((c = getopt(narg,arg,"hp:s:w:a:d:b:i:m:")) != -1) {
    3564  switch (c) {
    3665  case 's' :
     
    3867    cout<<"Requested Samples from "<<sdeb<<" , "<<sfin<<endl;
    3968    if(sfin>=sdeb) mgr->setRequestedSample(sdeb,sfin);
    40     else {cout<<"Bad sample interval "<<endl; exit(-2);}
     69    else {cout<<"Bad sample interval "<<endl; exit(1);}
    4170    break;
    4271  case 'w' :
     
    5079    break;
    5180  case 'a' :
    52     label_alpha = optarg;
     81    label_coord1 = optarg;
    5382    break;
    5483  case 'd' :
    55     label_delta = optarg;
     84    label_coord2 = optarg;
    5685    break;
    5786  case 'b' :
    5887    label_bolomuv = optarg;
    5988    break;
     89  case 'i' :
     90    sscanf(optarg,"%c,%c",&t,&h);
     91    tcoorin=typecoord(t,h);
     92    break;
     93  case 'm' :
     94    sscanf(optarg,"%c,%c",&t,&h);
     95    tcoormap=typecoord(t,h);
     96    break;
    6097  case 'h' :
    61     usage(); exit(-1);
    62     break;
    6398  default:
    64     usage(); exit(-1);
     99    usage(); exit(1);
    65100  }
    66101}
    67 if(optind+2>=narg) {usage(); exit(-2);}
    68 char * fitsin          = arg[optind];
     102if(optind+2>=narg) {usage(); exit(2);}
     103char * fitsin_point    = arg[optind];
    69104string const fitsphere = arg[optind+1];
    70105char * fitsout         = arg[optind+2];
    71106
     107{
     108unsigned long tg,te,hd,dd;
    72109cout<<">>>> tstmap2toi:"<<endl
    73     <<"Fits Infile(snum,alpha,delta)= "<<fitsin<<endl
    74     <<"  ...label_alpha "<<label_alpha<<"  ,  label_delta "<<label_delta<<endl
    75     <<"Fits Sphere Healpix"<<fitsphere<<endl
    76     <<"Fits Outfile(snum,[alpha,delta],boloMuV)"<<fitsout<<endl
     110    <<"Pipe Window Size "<<width<<endl
     111    <<"Fits OutFile "<<fitsout<<endl
    77112    <<"  ...label_bolomuv "<<label_bolomuv<<endl;
     113tg = tcoorin&TypCoordGal; te = tcoorin&TypCoordEq;
     114hd = tcoorin&TypCoordHD;  dd = tcoorin&TypCoordDD;
     115cout<<"Fits Infile Pointing "<<fitsin_point<<endl
     116    <<"  ...label_coord1 "<<label_coord1<<endl
     117    <<"  ...label_coord2 "<<label_coord2<<endl
     118    <<"  ...... Gal="<<tg<<" Eq="<<te<<"   hour="<<hd<<" deg="<<dd<<endl;
     119tg = tcoormap&TypCoordGal; te = tcoormap&TypCoordEq;
     120hd = tcoormap&TypCoordHD;  dd = tcoormap&TypCoordDD;
     121cout<<"Fits Healpix Sphere "<<fitsphere<<endl
     122    <<"  ...... Gal="<<tg<<" Eq="<<te<<"   hour="<<hd<<" deg="<<dd<<endl;
     123}
    78124
    79125SophyaInit();
     
    85131
    86132 // FITS reader et writer
    87  FITSTOIReader rfits(fitsin);
     133 FITSTOIReader rfits(fitsin_point);
    88134 int ncol = rfits.getNOut();
    89  cout<<"Number of columns in fits Infile : "<<ncol<<endl;
    90  if(ncol<2) exit(-3);
     135 cout<<"Number of columns in fits Infile Pointing : "<<ncol<<endl;
     136 if(ncol<2) exit(3);
    91137
    92138 FITSTOIWriter wfits(fitsout);
     
    104150 Map2TOI m2toi(sph);
    105151 cout<<"Map2TOI created"<<endl;
     152 m2toi.SetEquinox(2000.);
     153 m2toi.SetCoorIn((TypAstroCoord) tcoorin);
     154 m2toi.SetCoorMap((TypAstroCoord) tcoormap);
    106155
    107156 // Definition des tuyaux
    108  TOISeqBuffered * toialphain = new TOISeqBuffered("toi_alpha_in",width);
    109  if(lp) toialphain->setDebugLevel(1);
    110  rfits.addOutput(label_alpha,toialphain);
    111  m2toi.addInput("AlphaIn",toialphain);
    112 
    113  TOISeqBuffered * toialphaout = new TOISeqBuffered("toi_alpha_out",width);
    114  m2toi.addOutput("AlphaOut",toialphaout);
    115  wfits.addInput(label_alpha,toialphaout);
    116 
    117  TOISeqBuffered * toideltain = new TOISeqBuffered("toi_delta_in",width);
    118  if(lp) toideltain->setDebugLevel(1);
    119  rfits.addOutput(label_delta,toideltain);
    120  m2toi.addInput("DeltaIn",toideltain);
    121 
    122  TOISeqBuffered * toideltaout = new TOISeqBuffered("toi_delta_out",width);
    123  m2toi.addOutput("DeltaOut",toideltaout);
    124  wfits.addInput(label_delta,toideltaout);
     157 TOISeqBuffered * toicoord1in = new TOISeqBuffered("toi_coord1_in",width);
     158 // toicoord1in->setDebugLevel(1);
     159 rfits.addOutput(label_coord1,toicoord1in);
     160 m2toi.addInput("Coord1In",toicoord1in);
     161
     162 TOISeqBuffered * toicoord1out = new TOISeqBuffered("toi_coord1_out",width);
     163 m2toi.addOutput("Coord1Out",toicoord1out);
     164 wfits.addInput(label_coord1,toicoord1out);
     165
     166 TOISeqBuffered * toicoord2in = new TOISeqBuffered("toi_coord2_in",width);
     167 // toicoord2in->setDebugLevel(1);
     168 rfits.addOutput(label_coord2,toicoord2in);
     169 m2toi.addInput("Coord2In",toicoord2in);
     170
     171 TOISeqBuffered * toicoord2out = new TOISeqBuffered("toi_coord2_out",width);
     172 m2toi.addOutput("Coord2Out",toicoord2out);
     173 wfits.addInput(label_coord2,toicoord2out);
    125174
    126175 TOISeqBuffered * toibolout = new TOISeqBuffered("toi_bolo_out",width);
    127  if(lp) toibolout->setDebugLevel(1);
     176 // toibolout->setDebugLevel(1);
    128177 m2toi.addOutput("BoloOut",toibolout);
    129178 wfits.addInput(label_bolomuv,toibolout);
     
    142191 if(lp>1)
    143192   for(int jjjj=0;jjjj<5;jjjj++) {
    144      cout<<*toialphain;
     193     cout<<*toicoord1in;
    145194     cout<<*toibolout;
    146195     sleep(2);
  • trunk/ArchTOIPipe/TestPipes/tsttoi2map.cc

    r1516 r1520  
    2929     <<" -b label_bolomuv : label fits for bolo value (def=boloMuV)"<<endl
    3030     <<" -n nlat : nlat for Healpix sphere (def=128)"<<endl
    31      <<" -i c,h : coord1 caracteristics (c=G/E h=H/D) (def=G,D)"<<endl
    32      <<" -o c,h : idem -i for coord2"<<endl
     31     <<" -i c,h : coordIn caracteristics (c=G/E h=H/D) (def=G,D)"<<endl
     32     <<" -o c,h : idem -i for coordOut"<<endl
    3333     <<" fitsin_point : fits file for pointing"<<endl
    3434     <<" fitsin_bolo : fits file for bolo values"<<endl
     
    124124tg = tcoorin&TypCoordGal; te = tcoorin&TypCoordEq;
    125125hd = tcoorin&TypCoordHD;  dd = tcoorin&TypCoordDD;
    126 cout<<"  ...label_coord1 "<<label_coord1<<endl
     126cout<<"Fits Infile Pointing "<<fitsin_point<<endl
     127    <<"  ...label_coord1 "<<label_coord1<<endl
    127128    <<"  ...label_coord2 "<<label_coord2<<endl
    128129    <<"  ...... Gal="<<tg<<" Eq="<<te<<"   hour="<<hd<<" deg="<<dd<<endl;
Note: See TracChangeset for help on using the changeset viewer.