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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.