Changeset 1528 in Sophya for trunk/SophyaProg/PrgMap


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

optimisation cmv 14/6/01

Location:
trunk/SophyaProg/PrgMap
Files:
3 edited

Legend:

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

    r1522 r1528  
    11// Creation d'une sphere de masque a partir d'une sphere de valeurs
    22//         cmv 13/6/01
     3// cremskfrsph -m 0.1 -v 1.,0. sph143k05_e.fits sphmskw.fits
     4// cremskfrsph -n -m -1.e-30. -M 1.e-30. -v 1.,0. sph143k05.fits sphmsk.fits
    35#include "machdefs.h"
    46#include <unistd.h>
     
    1719    <<" -m min : min value"<<endl
    1820    <<" -M max : max value"<<endl
    19     <<"    condition for filling masque is : min<=V<=max"<<endl
     21    <<"    condition for filling masque is : min<=sphere value<=max"<<endl
     22    <<"                                      (bounds are included)"<<endl
    2023    <<" -n : negate the condition"<<endl
    2124    <<" -v valmsk,inimsk:"<<endl
     
    5659char * sphmsk = arg[optind+1];
    5760
    58 {
    5961cout<<"Sphere values : "<<sphval<<endl
    6062    <<"Sphere mask   : "<<sphmsk<<endl
     
    6567cout<<"Condition : ";
    6668if(negate) cout<<"!";
    67 cout<<"( "<<vmin<<" <= V <= "<<vmax<<" )"<<endl;
    68 }
     69cout<<"( "<<vmin<<" <= V <= "<<vmax<<" ) bounds are included"<<endl;
    6970
    7071// Lecture de la sphere Healpix des valeurs
  • 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
  • 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.