Changeset 1809 in Sophya for trunk/ArchTOIPipe/ProcWSophya


Ignore:
Timestamp:
Dec 3, 2001, 9:38:03 PM (24 years ago)
Author:
cmv
Message:
  • map2toi et toi2map avec nouvelle interface sys coor et unites.
  • les modifs map2toi (LocalMap) de EA sont introduites + certains bugs corriges.

cmv 3/12/01

Location:
trunk/ArchTOIPipe/ProcWSophya
Files:
4 edited

Legend:

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

    r1762 r1809  
    33//                               Christophe Magneville
    44//                               Reza Ansari
    5 // $Id: map2toi.cc,v 1.9 2001-11-13 16:22:47 aubourg Exp $
     5// $Id: map2toi.cc,v 1.10 2001-12-03 20:38:02 cmv Exp $
    66
    77#include "toimanager.h"
     
    99#include "ctimer.h"
    1010#include "map2toi.h"
     11// La valeur "Pi" doit etre celle de smathconst.h a cause du test sur theta
     12#include "smathconst.h"
    1113
    1214////////////////////////////////////////////////////////////////////////
     
    1416: mSph(sph)
    1517{
     18 SetBad();
    1619 SetEquinox();
    1720 SetCoorIn();
     
    2629void Map2TOI::Print(::ostream & os)
    2730{
    28   os<<"Map2TOI::Print -- Sphere NLat = "<<mSph.SizeIndex()<<endl
    29 
    30     <<"   - Equinoxe="<<mActualYear<<endl
    31 
    32     <<"   - TypCoorIn: Gal("<<((mTypCoorIn&TypCoordGal)?1:0)
    33     <<") Eq("<<((mTypCoorIn&TypCoordEq)?1:0)
    34     <<") Deg("<<((mTypCoorIn&TypCoordDD)?1:0)
    35     <<") Hour("<<((mTypCoorIn&TypCoordHD)?1:0)
    36     <<") Rad("<<((mTypCoorIn&TypCoordRR)?1:0)<<")"<<endl
    37 
    38     <<"   - TypCoorMap: Gal("<<((mTypCoorMap&TypCoordGal)?1:0)
    39     <<") Eq("<<((mTypCoorMap&TypCoordEq)?1:0)
    40     <<") Deg("<<((mTypCoorMap&TypCoordDD)?1:0)
    41     <<") Hour("<<((mTypCoorMap&TypCoordHD)?1:0)
    42     <<") Rad("<<((mTypCoorMap&TypCoordRR)?1:0)<<")"<<endl;
     31 os<<"Map2TOI::Print -- Sphere NLat = "<<mSph.SizeIndex()<<endl
     32   <<"   - Equinoxe:   "<<mActualYear<<" y"<<endl
     33   <<"   - TypCoorIn:  "<<mTypCoorIn<<" = "<<DecodeTypAstro(mTypCoorIn)<<endl
     34   <<"   - TypCoorMap: "<<mTypCoorMap<<" = "<<DecodeTypAstro(mTypCoorMap)<<endl;
    4335}
    4436
     
    8981try {
    9082
    91 uint_4 mSnRead=0, mSnFilled=0;
    9283double mjd = MJDfrYear(mActualYear);
     84cout<<"Map2TOI::run() - modified Julian day "<<mjd<<endl;
     85
     86uint_4 mSnRead=0, mSnFilled=0, BadCoorRange=0;
    9387
    9488for(int k=snb;k<=sne;k++) {
     
    10094  mSnRead++;
    10195
    102   // Convert CoordIn to Standard
    103   double phi=-1.,theta;
    104   CoordConvertToStd(mTypCoorIn,c1,c2);
     96  // Conversion de CoordIn to Standard
     97  double phi=-1.;
     98  CoordConvertToStd(mTypCoorIn,&c1,&c2);
     99
     100  // Conversion dans le systeme astronomique approprie
    105101  if(mTypCoorIn&TypCoordEq && mTypCoorMap&TypCoordGal) { // CIn=Eq  CMap=Gal
    106102    EqtoGal(mjd,c1,c2,&c1,&c2);
    107     phi   = c1 * M_PI/180.;
     103    phi   = c1 * Pi/180.;
    108104  } else if(mTypCoorIn&TypCoordGal && mTypCoorMap&TypCoordEq) { // CIn=Gal CMap=Eq
    109105    GaltoEq(mjd,c1,c2,&c1,&c2);
    110     phi   = c1 * M_PI/12.;
     106    phi   = c1 * Pi/12.;
    111107  } else if(mTypCoorMap&TypCoordGal) { // CIn=Gal CMap=Gal
    112     phi   = c1 * M_PI/180.;
     108    phi   = c1 * Pi/180.;
    113109  } else if(mTypCoorMap&TypCoordEq) { // CIn=Eq CMap=Eq
    114     phi   = c1 * M_PI/12.;
     110    phi   = c1 * Pi/12.;
    115111  }
    116   theta = (90.-c2) * M_PI/180.;
    117   if(phi<0.   || phi>=2*M_PI) flg=FlgToiOut;
    118   if(theta<0. || theta>=M_PI) flg=FlgToiOut;
     112  ToCoLat(&c2,TypUniteD);
     113  double theta = c2 * Pi/180.;
     114  if(phi<0. || phi>=2*Pi || theta<0. || theta>Pi)
     115               {BadCoorRange++; flg = mBadFlag; }
    119116
    120117  if(!flg) {
     
    128125}
    129126
    130 cout<<"TOI2Map::run: Samples Read "<<mSnRead<<" Filled "<<mSnFilled<<endl;
     127cout<<"TOI2Map::run: Samples Read "<<mSnRead
     128    <<" Filled "<<mSnFilled
     129    <<" BadCoorRange="<<BadCoorRange<<endl;
    131130
    132131//---------------------------------------------------------
  • trunk/ArchTOIPipe/ProcWSophya/map2toi.h

    r1762 r1809  
    55//                               Christophe Magneville
    66//                               Reza Ansari
    7 // $Id: map2toi.h,v 1.6 2001-11-13 16:22:47 aubourg Exp $
     7// $Id: map2toi.h,v 1.7 2001-12-03 20:38:02 cmv Exp $
    88
    99#ifndef MAP2TOI_H
     
    4242  virtual void  run(void);
    4343
    44   // Pour savoir si on a de HourDeg,DegDeg,RadRad
     44  // Flag pour les mauvais samples
     45  inline void SetBad(unsigned long long flg=FlgToiOut)
     46                    {mBadFlag = flg;}
     47
     48  // Pour definir la partie astrometrie
    4549  inline void SetEquinox(double actualyear=2000.)
    4650              {mActualYear = actualyear;}
    47   inline void SetCoorIn(TypAstroCoord mfg=TypCoordGalStd)
     51
     52  inline void SetCoorIn(unsigned long mfg=TypCoordGalStd)
    4853              {mTypCoorIn = mfg;}
    49   inline void SetCoorMap(TypAstroCoord mfg=TypCoordGalStd)
     54  inline void SetCoorIn(char const *ctype)
     55              {mTypCoorIn = DecodeTypAstro(ctype);}
     56
     57  inline void SetCoorMap(unsigned long mfg=TypCoordGal)
    5058              {mTypCoorMap = mfg;}
     59  inline void SetCoorMap(char const *ctype)
     60              {mTypCoorMap = DecodeTypAstro(ctype);}
     61
    5162  // Print
    5263  void Print(::ostream & os);
     
    5465protected:
    5566  SphereHEALPix<r_8>& mSph;
    56   TypAstroCoord mTypCoorIn,mTypCoorMap;
     67  unsigned long mTypCoorIn,mTypCoorMap;
     68  unsigned long long mBadFlag;
    5769  double mActualYear;
    5870};
  • trunk/ArchTOIPipe/ProcWSophya/toi2map.cc

    r1807 r1809  
    33//                               Christophe Magneville
    44//                               Reza Ansari
    5 // $Id: toi2map.cc,v 1.23 2001-12-01 13:35:15 aubourg Exp $
     5// $Id: toi2map.cc,v 1.24 2001-12-03 20:38:02 cmv Exp $
    66
    77#include "machdefs.h"
     
    1010#include "ctimer.h"
    1111#include "toi2map.h"
     12// La valeur "Pi" doit etre celle de smathconst.h a cause du test sur theta
     13#include "smathconst.h"
    1214
    1315////////////////////////////////////////////////////////////////////////
    1416TOI2Map::TOI2Map(PixelMap<r_8>* map,PixelMap<r_8>* wmap)
    15   : mMap(map), mWMap(map), mWMapInternal(false)
     17  : mMap(map), mWMap(wmap), mWMapInternal(false)
    1618{
    1719 SetEquinox();
    1820 SetCoorIn();
    19  SetCoorOut();
     21 SetCoorMap();
    2022 SetTestFlag();
    2123 SetTestMin();
    2224 SetTestMax();
    23 
    24  mIsColat = false;
    2525
    2626 if(mMap->NbPixels()<1) {
     
    3131 mMap->SetPixels(0.);
    3232 int nlat = mMap->SizeIndex();
     33 string typmap = mMap->TypeOfMap();
    3334
    3435 if(mWMap==NULL) {
    3536   // We would need a cloning function in maps. $$TBD$$ $CHECK$
    36    string typmap = mMap->TypeOfMap();
    3737   if (typmap == "LOCAL") {
    3838     mWMap = new LocalMap<r_8>(*(LocalMap<r_8>*)mMap);
     
    4747   mWMapInternal = false;
    4848   if(nlat != mWMap->SizeIndex()) {
    49      cout << "TOI2Map::TOI2Map() Bad size for sphere mWMap, does not "
    50           << "correspond to mMap : " << mMap->SizeIndex() << ", " << mWMap->SizeIndex() << endl;
    51      throw ParmError("TOI2Map::TOI2Map() - Different sizes for map and wmap");
     49     cout<<"TOI2Map::TOI2Map() Bad size for sphere mWMap, does not "
     50         <<"correspond to mMap : "<<mMap->SizeIndex()<<", "<<mWMap->SizeIndex()<<endl;
     51     if (typmap == "LOCAL") {
     52       throw ParmError("TOI2Map::TOI2Map() - Different sizes for map and wmap");
     53     } else if(typmap == "RING") {
     54       ((SphereHEALPix<r_8> *)mWMap)->Resize(nlat);
     55       cout<<"Resize have been done..."<<endl;
     56     } else {
     57       cout << "TOI2Map::TOI2Map() cannot handle map of type " << typmap << endl;
     58       throw ParmError("TOI2Map::TOI2Map() - bad type of map");
     59     }
    5260   }
    5361 }
     
    6876void TOI2Map::Print(::ostream & os)
    6977{
    70   os<<"TOI2Map::Print -- Map type " << mMap->TypeOfMap() << " SizeIndex = "<<mMap->SizeIndex()<<endl
    71 
    72     <<"   - Equinoxe="<<mActualYear<<endl
    73 
    74     <<"   - TypCoorIn: Gal("<<((mTypCoorIn&TypCoordGal)?1:0)
    75     <<") Eq("<<((mTypCoorIn&TypCoordEq)?1:0)
    76     <<") Deg("<<((mTypCoorIn&TypCoordDD)?1:0)
    77     <<") Hour("<<((mTypCoorIn&TypCoordHD)?1:0)
    78     <<") Rad("<<((mTypCoorIn&TypCoordRR)?1:0)<<")"<<endl
    79 
    80     <<"   - TypCoorOut: Gal("<<((mTypCoorOut&TypCoordGal)?1:0)
    81     <<") Eq("<<((mTypCoorOut&TypCoordEq)?1:0)
    82     <<") Deg("<<((mTypCoorOut&TypCoordDD)?1:0)
    83     <<") Hour("<<((mTypCoorOut&TypCoordHD)?1:0)
    84     <<") Rad("<<((mTypCoorOut&TypCoordRR)?1:0)<<")"<<endl
    85 
    86     <<"   - Tests: Flag("<<mTFlag<<") bad="<<mBadFlag
    87     <<" / Value Min("<<mTMin<<")="<<mValMin
    88     <<" , Max("<<mTMax<<")="<<mValMax<<endl;
     78 os<<"TOI2Map::Print -- Map type " << mMap->TypeOfMap() << " SizeIndex = "<<mMap->SizeIndex()<<endl
     79   <<"   - Equinoxe="<<mActualYear<<endl
     80   <<"   - TypCoorIn:  "<<mTypCoorIn<<" = "<<DecodeTypAstro(mTypCoorIn)<<endl
     81   <<"   - TypCoorMap: "<<mTypCoorMap<<" = "<<DecodeTypAstro(mTypCoorMap)<<endl
     82   <<"  - Tests: Flag("<<mTFlag<<") bad="<<mBadFlag
     83   <<" / Value Min("<<mTMin<<")="<<mValMin
     84   <<" , Max("<<mTMax<<")="<<mValMax<<endl;
    8985}
    9086
     
    116112  throw ParmError("TOI2Map::run() - Input Coordinates not Eq or Gal!");
    117113}
    118 if( !(mTypCoorOut&TypCoordEq || mTypCoorOut&TypCoordGal) ) {
     114if( !(mTypCoorMap&TypCoordEq || mTypCoorMap&TypCoordGal) ) {
    119115  cout<<"TOI2Map::run() - Output Coordinates not Eq or Gal! "<<endl;
    120116  throw ParmError("TOI2Map::run() - Output Coordinates not Eq or Gal!");
     
    126122
    127123int ii;
    128 uint_4 mNSnFill=0, mNpixFill=0, NFill[NFILL];
     124uint_4 mNSnFill=0, mNpixFill=0, NFill[NFILL], BadCoorRange=0;
    129125for(ii=0;ii<NFILL;ii++) NFill[ii]=0;
    130126double mjd = MJDfrYear(mActualYear);
     
    175171  // sphere phi   entre [0,2*Pi] en radians
    176172  // sphere theta entre [0,Pi]   en radians
    177   double phi=-1.,theta;
    178   CoordConvertToStd(mTypCoorIn,coord1,coord2);
    179 
    180   if(mTypCoorIn&TypCoordEq && mTypCoorOut&TypCoordGal) { // Eq -> Gal
     173  double phi=-1.;
     174  CoordConvertToStd(mTypCoorIn,&coord1,&coord2);
     175
     176  if(mTypCoorIn&TypCoordEq && mTypCoorMap&TypCoordGal) { // Eq -> Gal
    181177    EqtoGal(mjd,coord1,coord2,&coord1,&coord2);
    182     phi   = coord1 * M_PI/180.;
    183   } else if(mTypCoorIn&TypCoordGal && mTypCoorOut&TypCoordEq) { // Gal -> Eq
     178    phi   = coord1 * Pi/180.;
     179  } else if(mTypCoorIn&TypCoordGal && mTypCoorMap&TypCoordEq) { // Gal -> Eq
    184180    GaltoEq(mjd,coord1,coord2,&coord1,&coord2);
    185     phi   = coord1 * M_PI/12.;
    186   } else if(mTypCoorOut&TypCoordGal) { // Gal -> Gal
    187     phi   = coord1 * M_PI/180.;
    188   } else if(mTypCoorOut&TypCoordEq) { // Eq -> Eq
    189     phi   = coord1 * M_PI/12.;
     181    phi   = coord1 * Pi/12.;
     182  } else if(mTypCoorMap&TypCoordGal) { // Gal -> Gal
     183    phi   = coord1 * Pi/180.;
     184  } else if(mTypCoorMap&TypCoordEq) { // Eq -> Eq
     185    phi   = coord1 * Pi/12.;
    190186  }
    191 
    192   if (phi<0) phi += 2*M_PI;
    193   if (phi>=2*M_PI) phi -= 2*M_PI;
    194   if (mIsColat) {
    195     theta = coord2 * M_PI/180;
    196   } else {
    197     theta = (90.-coord2) * M_PI/180.;     
    198   }
    199 
    200   if(phi<0.   || phi>=2*M_PI) continue;
    201   if(theta<0. || theta>=M_PI) continue;
     187  ToCoLat(&coord2,TypUniteD);
     188  double theta = coord2 * Pi/180.;
     189
     190  if(phi<0. | phi>=2*Pi || theta<0. || theta>Pi)
     191                     {BadCoorRange++; continue;}
    202192
    203193  int_4 ipix = mMap->PixIndexSph(theta,phi);
     
    212202 for(int_4 i=0;i<mMap->NbPixels();i++) {
    213203   r_8 wf = (*mWMap)(i);
    214    if( wf > 0. ) {
    215      mNpixFill++;
    216      (*mMap)(i) /= wf;
    217    }
     204   if(wf>0.) {mNpixFill++; (*mMap)(i) /= wf;}
    218205   int_4 nf = int_4(wf);
    219206   if(nf>=NFILL) nf=NFILL-1; NFill[nf]++;
     
    227214 for(ii=0;ii<NFILL;ii++) {cout<<NFill[ii]<<" "; if(ii%10==9) cout<<endl;}
    228215 cout<<endl;
     216 cout<<"  BadCoorRange="<<BadCoorRange<<endl;
    229217
    230218#ifndef SANS_BUFFER
  • trunk/ArchTOIPipe/ProcWSophya/toi2map.h

    r1807 r1809  
    55//                               Christophe Magneville
    66//                               Reza Ansari
    7 // $Id: toi2map.h,v 1.13 2001-12-01 13:34:09 aubourg Exp $
     7// $Id: toi2map.h,v 1.14 2001-12-03 20:38:03 cmv Exp $
    88
    9 #ifndef TOI2GMAP_H
    10 #define TOI2GMAP_H
     9#ifndef TOI2MAP_H
     10#define TOI2MAP_H
    1111
    1212#include "toiprocessor.h"
     
    3333//                     soit Galactiques  (GLong,GLat)
    3434// Sortie sur une sphere en coordonnees Equatoriales ou Galactiques
    35 // Si les CoordIn et les CoordOut sont equatoriales -> meme equinoxe!
     35// Si les CoordIn et les CoordMap sont equatoriales -> meme equinoxe!
    3636
    3737class TOI2Map : public TOIProcessor {
    3838public:
    3939                 TOI2Map(PixelMap<r_8>* map,PixelMap<r_8>* wmap=NULL);
     40                 //TOI2Map(SphereHEALPix<r_8>* map,SphereHEALPix<r_8>* wmap=NULL);
    4041  virtual       ~TOI2Map();
    4142
     
    4647  inline void SetEquinox(double actualyear=2000.)
    4748              {mActualYear = actualyear;}
    48   inline void SetCoorIn(TypAstroCoord mfg=TypCoordGalStd)
     49
     50  inline void SetCoorIn(unsigned long mfg=TypCoordGalStd)
    4951              {mTypCoorIn = mfg;}
    50   inline void SetCoorOut(TypAstroCoord mfg=TypCoordGalStd)
    51               {mTypCoorOut = mfg;}
     52  inline void SetCoorIn(const char *ctype)
     53              {mTypCoorIn = DecodeTypAstro(ctype);}
     54
     55  inline void SetCoorMap(unsigned long mfg=TypCoordGal)
     56              {mTypCoorMap = mfg;}
     57  inline void SetCoorMap(const char *ctype)
     58              {mTypCoorMap = DecodeTypAstro(ctype);}
     59
    5260  // Test on flag value ? if yes, BAD sample have flag matching mBadFlag
    5361  inline void SetTestFlag(bool tflg=false, uint_8 badflg=FlgToiAll)
     
    6472  void Print(::ostream & os);
    6573
    66   void SetIsColat(bool b=true) {mIsColat=b;} // latitude is a colatitude, 0-Pi
    6774protected:
    6875  PixelMap<r_8>* mMap;
     
    7077  bool mWMapInternal;
    7178
    72   TypAstroCoord mTypCoorIn, mTypCoorOut;
     79  unsigned long mTypCoorIn, mTypCoorMap;
    7380  double mActualYear;
    7481
    7582  bool mTFlag,mTMin,mTMax;
    76   bool mIsColat; // temporary fix
    7783  uint_8 mBadFlag;
    7884  r_8 mValMin,mValMax;
Note: See TracChangeset for help on using the changeset viewer.