Ignore:
Timestamp:
Jun 14, 2001, 5:16:20 PM (24 years ago)
Author:
cmv
Message:

optimisation cmv 14/6/01

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaProg/PrgMap/extrap2sph.cc

    r1526 r1528  
    11// Pour boucher les trous d'une sphere HEALPIX utilisant une autre sphere
    22//             cmv 13/6/01
     3// extrap2sph -w sph143k05_e.fits sph143k05.fits sphred.fits sphout_2.fits
     4// extrap2sph -m -1.e-30 -M +1.e-30 sph143k05.fits sphred.fits sphout_22.fits
    35#include "machdefs.h"
    46#include <unistd.h>
     
    1416void usage()
    1517{
    16 cout<<"extrap2sph [-w sphinw.fits -0 nulval]"<<endl
     18cout<<"extrap2sph [-w sphinw.fits -m valmin -M valmax]"<<endl
    1719    <<"           sphin.fits sphred.fits sphout.fits"<<endl
    1820    <<" -w sphinw.fits : input sphere  weight (def=NULL)"<<endl
    19     <<" -0 nulval : value to identify empty pixel in sphin (def=0.)"<<endl
    20     <<"             (used if sphinw.fits==NULL)"<<endl
    21     <<" sphin.fits : input sphere"<<endl
     21    <<" -m minval : value to identify EMPTY pixel (def=-1.e30.)"<<endl
     22    <<" -M maxval : value to identify EMPTY pixel (def=+1.e30)"<<endl
     23    <<"    condition for EMPTY pixel is (minval<val<maxval)"<<endl
     24    <<"    (bounds are excluded, used only if sphinw.fits==NULL)"<<endl
     25    <<" sphin.fits   : input sphere"<<endl
    2226    <<" sphred.fits  : input reducted sphere"<<endl
    2327    <<" sphout.fits  : output sphere"<<endl;
     
    2630int main(int narg, char* arg[])
    2731{
    28 double nulval=0.;
     32bool tstmin=false, tstmax=false;
     33double valmin=-1.e30, valmax=+1.e30;
    2934char * fsphinw = NULL;
    3035int c;
    31 while((c = getopt(narg,arg,"h0:w:")) != -1) {
     36while((c = getopt(narg,arg,"hm:M:w:")) != -1) {
    3237  switch (c) {
    33   case '0' :
    34     sscanf(optarg,"%lf",&nulval);
     38  case 'm' :
     39    sscanf(optarg,"%lf",&valmin);
     40    tstmin=true;
     41    break;
     42  case 'M' :
     43    sscanf(optarg,"%lf",&valmax);
     44    tstmax=true;
    3545    break;
    3646  case 'w' :
     
    4858char * fsphout  = arg[optind+2];
    4959
    50 cout<<"Sphere Input : "<<fsphin<<endl
    51     <<"Weight Sphere Input : "<<fsphinw<<endl
    52     <<"Reducted Sphere Input : "<<fsphred<<endl
    53     <<"Sphere Output : "<<fsphout<<endl
    54     <<"nulval : "<<nulval<<endl;
     60cout<<"Input Sphere          : "<<fsphin<<endl
     61    <<"Input Weight Sphere   : "<<fsphinw<<endl
     62    <<"Input Reducted Sphere : "<<fsphred<<endl
     63    <<"Output Sphere         : "<<fsphout<<endl;
     64if(!fsphinw)
     65  cout<<"- test min("<<tstmin<<") : "<<valmin<<endl
     66      <<"  test max("<<tstmax<<") : "<<valmax<<endl
     67      <<"Condition for EMPTY pixel is :\n    ("<<valmin
     68      <<" < sphere value < "<<valmax<<") bounds are excluded!"<<endl;
    5569
    5670// Lecture des spheres
     
    5872{FitsInFile sfits(fsphin); sfits >> sphin;}
    5973int nlat = sphin.SizeIndex();
    60 cout<<"Opening Sphere Input :"<<endl
     74cout<<"Opening Input Sphere :"<<endl
    6175    <<"          Type of map : "<<sphin.TypeOfMap()<<endl
    6276    <<"     Number of pixels : "<<sphin.NbPixels()<<endl
     
    6781  FitsInFile sfits(fsphinw);
    6882  sfits >> sphinw;
    69   cout<<"Opening Weight Sphere Input :"<<endl
     83  cout<<"Opening Input Weight Sphere :"<<endl
    7084      <<"          Type of map : "<<sphinw.TypeOfMap()<<endl
    7185      <<"     Number of pixels : "<<sphinw.NbPixels()<<endl
     
    7993SphereHEALPix<r_8> sphred;
    8094{FitsInFile sfits(fsphred); sfits >> sphred;}
    81 cout<<"Opening Reducted Sphere Input :"<<endl
     95cout<<"Opening Input Reducted Sphere :"<<endl
    8296    <<"          Type of map : "<<sphred.TypeOfMap()<<endl
    8397    <<"     Number of pixels : "<<sphred.NbPixels()<<endl
    8498    <<"                 Nlat : "<<sphred.SizeIndex()<<endl;
    8599
    86 // Creation de la sphere output
    87 cout<<"Creating Sphere for output"<<endl;
    88 SphereHEALPix<r_8> sphout(sphin,false);
    89 
    90100// Filling hole for Output Sphere
    91101cout<<"...Filling hole for Output Sphere"<<endl;
    92 uint_4 n=0;
    93 for(int_4 i=0;i<sphout.NbPixels();i++) {
    94   if(fsphinw) {if(sphinw(i)>0.) continue;}
    95      else     {if(sphout(i)!=nulval) continue;}
     102uint_4 n=0, n0=0;
     103for(int_4 i=0;i<sphin.NbPixels();i++) {
     104  if(fsphinw) {
     105    if(sphinw(i)>0.) continue;
     106  } else {
     107    // Not Filled pixels ]valmin,valmax[
     108    // Filled pixels ]-Infinity,valmin] or [valmax,+Infinity[
     109    if(tstmin && sphin(i)<=valmin) continue;
     110    if(tstmax && sphin(i)>=valmax) continue;
     111  }
    96112  double theta,phi;
    97   sphout.PixThetaPhi(i,theta,phi);
     113  sphin.PixThetaPhi(i,theta,phi);
    98114  int_4 ir = sphred.PixIndexSph(theta,phi);
    99   sphout(i) = sphred(ir);
    100   n++;
     115  sphin(i) = sphred(ir);
     116  n++; if(sphred(ir)!=0.) n0++;
    101117}
    102 cout<<"      Number of filled pixels "<<n<<endl;
     118cout<<"      Number of pixels filled "
     119    <<n<<" (not null values "<<n0<<")"<<endl;
    103120
    104121// Ecriture de la sphere
     
    107124FitsOutFile sfits(fsphout);
    108125cout<<"Writing Output Sphere Fits file"<<endl;
    109 sfits<<sphout;
     126sfits<<sphin;
    110127}
    111128
Note: See TracChangeset for help on using the changeset viewer.