Changeset 1528 in Sophya for trunk/SophyaProg/PrgMap/extrapsph.cc


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/extrapsph.cc

    r1526 r1528  
    11// Pour boucher les trous d'une sphere HEALPIX en clusterisant dans une sphere
    22// plus petite             cmv 13/6/01
     3// extrapsph -r 2 sph143k05.fits sph143k05_e.fits
     4//                sphout.fits sphoutw.fits sphred.fits sphredw.fits
    35#include "machdefs.h"
    46#include <unistd.h>
     
    1719    <<"                     sphout.fits [sphout_w.fits"
    1820    <<" sphred.fits sphred_w.fits]"<<endl
    19     <<" -r reduc : reduction factor for nlat in clustering must be 2^n (def=2)"<<endl
    20     <<" sphin.fits : input sphere"<<endl
    21     <<" sphin_w.fits : input sphere filling weight"<<endl
    22     <<" sphout.fits  : output sphere"<<endl
    23     <<" sphout_w.fits  : output sphere filling weight"<<endl
    24     <<" sphred.fits  : output reducted sphere"<<endl
    25     <<" sphred_w.fits  : output reducted sphere filling weight"<<endl;
     21    <<" -r reduc : reduction factor for clustering (must be 2^n, def=2)"<<endl
     22    <<" sphin.fits    : input sphere"<<endl
     23    <<" sphin_w.fits  : input sphere filling weight"<<endl
     24    <<" sphout.fits   : output sphere"<<endl
     25    <<" sphout_w.fits : output sphere filling weight"<<endl
     26    <<" sphred.fits   : output reducted sphere"<<endl
     27    <<" sphred_w.fits : output reducted sphere filling weight"<<endl;
    2628}
    2729
     
    5254if(optind+5<narg) fsphredw = arg[optind+5];
    5355
    54 cout<<"Sphere Input : "<<fsphin<<endl
    55     <<"Weight Sphere Input : "<<fsphinw<<endl
    56     <<"Sphere Output : "<<fsphout<<endl
    57     <<"Weight Sphere Output : "<<fsphoutw<<endl
    58     <<"Reducted Sphere Output : "<<fsphred<<endl
    59     <<"Reducted Weight Sphere Output : "<<fsphredw<<endl
     56cout<<"Input Sphere : "<<fsphin<<endl
     57    <<"Input Weight Sphere : "<<fsphinw<<endl
     58    <<"Output Sphere : "<<fsphout<<endl
     59    <<"Output Weight Sphere : "<<fsphoutw<<endl
     60    <<"Output Reducted Sphere : "<<fsphred<<endl
     61    <<"Output Reducted Weight Sphere : "<<fsphredw<<endl
    6062    <<"Reduction : "<<red<<endl;
    6163
     
    6567int nlat = sphin.SizeIndex();
    6668int nlatr = nlat/red;
    67 cout<<"Opening Sphere Input :"<<endl
     69cout<<"Opening Input Sphere :"<<endl
    6870    <<"          Type of map : "<<sphin.TypeOfMap()<<endl
    6971    <<"     Number of pixels : "<<sphin.NbPixels()<<endl
     
    7274SphereHEALPix<r_8> sphinw;
    7375{FitsInFile sfits(fsphinw); sfits >> sphinw;}
    74 cout<<"Opening Weight Sphere Input :"<<endl
     76cout<<"Opening Input Weight Sphere :"<<endl
    7577    <<"          Type of map : "<<sphinw.TypeOfMap()<<endl
    7678    <<"     Number of pixels : "<<sphinw.NbPixels()<<endl
     
    8183}
    8284
    83 // Creation des spheres output
    84 cout<<"Creating Spheres for output"<<endl;
    85 SphereHEALPix<r_8> sphout(sphin,false);
    86 SphereHEALPix<r_8> sphoutw(sphinw,false);
    87 
    8885// Creation des spheres reduites
    8986cout<<"Creating Reducted Spheres : nlatr = "<<nlatr<<endl;
     
    9289SphereHEALPix<r_8> sphredw(nlatr);
    9390  sphredw.SetPixels(0.);
    94 cout<<"Creating Reducted Sphere :"<<endl
    95     <<"     Number of pixels : "<<sphred.NbPixels()<<endl
     91cout<<"     Number of pixels : "<<sphred.NbPixels()<<endl
    9692    <<"                 Nlat : "<<sphred.SizeIndex()<<endl;
    9793
    9894// Filling reducted spheres
    9995cout<<"...Filling Reducted Spheres"<<endl;
     96uint_4 n=0;
    10097for(int_4 i=0;i<sphin.NbPixels();i++) {
    10198  if(sphinw(i)<=0.) continue;
     
    105102  sphred(ir)  += sphin(i)*sphinw(i);
    106103  sphredw(ir) += sphinw(i);
     104  n++;
    107105}
     106cout<<"      Input Sphere: Number of filled pixels "<<n<<endl;
    108107cout<<"...Computing Reducted Spheres"<<endl;
    109 uint_4 n=0;
     108n=0;
    110109for(int_4 ir=0;ir<sphred.NbPixels();ir++)
    111110  if(sphredw(ir) > 0.) {sphred(ir) /= sphredw(ir); n++;}
    112 cout<<"      Number of filled pixels "<<n<<endl;
     111cout<<"      Reducted Sphere: Number of pixels filled "<<n<<endl;
    113112
    114113// Filling hole for Output Spheres
    115114cout<<"...Filling hole for Output Spheres"<<endl;
    116115n=0;
    117 for(int_4 i=0;i<sphout.NbPixels();i++) {
    118   if(sphoutw(i)>0.) continue;
     116for(int_4 i=0;i<sphin.NbPixels();i++) {
     117  if(sphinw(i)>0.) continue;
    119118  double theta,phi;
    120   sphout.PixThetaPhi(i,theta,phi);
     119  sphin.PixThetaPhi(i,theta,phi);
    121120  int_4 ir = sphred.PixIndexSph(theta,phi);
    122121  if(sphredw(ir)<=0.) continue;
    123   sphout(i)  = sphred(ir);
    124   sphoutw(i) = -sphredw(ir);
     122  sphin(i)  = sphred(ir);
     123  sphinw(i) = -sphredw(ir);
    125124  n++;
    126125}
    127 cout<<"      Number of filled pixels "<<n<<endl;
     126cout<<"      Output Sphere: Number of pixels filled "<<n<<endl;
    128127
    129128// Ecriture des spheres
     
    132131FitsOutFile sfits(fsphout);
    133132cout<<"Writing Output Sphere Fits file"<<endl;
    134 sfits<<sphout;
     133sfits<<sphin;
    135134}
    136135if(fsphoutw) {
     
    138137FitsOutFile sfits(fsphoutw);
    139138cout<<"Writing Output Sphere Weight Fits file"<<endl;
    140 sfits<<sphoutw;
     139sfits<<sphinw;
    141140}
    142141if(fsphred) {
Note: See TracChangeset for help on using the changeset viewer.