Ignore:
Timestamp:
Aug 7, 2001, 6:20:32 PM (24 years ago)
Author:
cmv
Message:

Uniformisation des programmes + doc cmv 7/8/01

File:
1 edited

Legend:

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

    r1528 r1626  
    1 // Pour boucher les trous d'une sphere HEALPIX utilisant une autre sphere
     1// Pour boucher les trous d'une sphere HEALPIX en utilisant
     2// une autre sphere HEALPIX
    23//             cmv 13/6/01
    34// extrap2sph -w sph143k05_e.fits sph143k05.fits sphred.fits sphout_2.fits
     
    1314#include "fitsspherehealpix.h"
    1415
     16/*!
     17  \ingroup PrgMap
     18  \file extrap2sph.cc
     19  \brief \b extrap2sph: Fill holes in a sphere of datas by using
     20  an other sphere of datas.
     21  A mask to define the place to be tested in the sphere might be given.
     22  \verbatim
     23csh> extrap2sph -h
     24extrap2sph [-m valmin -M valmax -r rvalmin -R rvalmax]
     25           [-w sphinw.fits] sphin.fits sphred.fits sphout.fits
     26 -w sphinw.fits : input sphere  weight, if sphinw_value<=0. (def=NULL)
     27                  if sphinw_value<=0. pixel has not to be filled
     28 -m minval : min value to identify EMPTY pixel of sphin (def=no_test)
     29 -M maxval : max value to identify EMPTY pixel of sphin (def=no_test)
     30    condition for EMPTY pixel is (minval<=val<=maxval)
     31 -n : negate the previous condition, condition for EMPTY pixel
     32      becomes: (val<minval || maxval<val)
     33 -r rminval : min value to identify GOOD pixel of sphred (def=no_test)
     34 -R rmaxval : max value to identify GOOD pixel of sphred (def=no_test)
     35    condition for GOOD pixel is (minval<=val<=maxval)
     36 -n : negate the previous condition, condition for GOOD pixel
     37      becomes: (val<minval || maxval<val)
     38 sphin.fits   : input sphere
     39 sphred.fits  : input reducted sphere
     40 sphout.fits  : output sphere
     41  \endverbatim
     42*/
     43
    1544void usage();
    1645void usage()
    1746{
    18 cout<<"extrap2sph [-w sphinw.fits -m valmin -M valmax]"<<endl
    19     <<"           sphin.fits sphred.fits sphout.fits"<<endl
    20     <<" -w sphinw.fits : input sphere  weight (def=NULL)"<<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
     47cout<<"extrap2sph [-m valmin -M valmax -r rvalmin -R rvalmax]"<<endl
     48    <<"           [-w sphinw.fits] sphin.fits sphred.fits sphout.fits"<<endl
     49    <<" -w sphinw.fits : input sphere  weight, if sphinw_value<=0. (def=NULL)"<<endl
     50    <<"                  if sphinw_value<=0. pixel has not to be filled"<<endl
     51    <<" -m minval : min value to identify EMPTY pixel of sphin (def=no_test)"<<endl
     52    <<" -M maxval : max value to identify EMPTY pixel of sphin (def=no_test)"<<endl
     53    <<"    condition for EMPTY pixel is (minval<=val<=maxval)"<<endl
     54    <<" -n : negate the previous condition, condition for EMPTY pixel"<<endl
     55    <<"      becomes: (val<minval || maxval<val)"<<endl
     56    <<" -r rminval : min value to identify GOOD pixel of sphred (def=no_test)"<<endl
     57    <<" -R rmaxval : max value to identify GOOD pixel of sphred (def=no_test)"<<endl
     58    <<"    condition for GOOD pixel is (minval<=val<=maxval)"<<endl
     59    <<" -n : negate the previous condition, condition for GOOD pixel"<<endl
     60    <<"      becomes: (val<minval || maxval<val)"<<endl
    2561    <<" sphin.fits   : input sphere"<<endl
    2662    <<" sphred.fits  : input reducted sphere"<<endl
     
    3066int main(int narg, char* arg[])
    3167{
    32 bool tstmin=false, tstmax=false;
    33 double valmin=-1.e30, valmax=+1.e30;
     68bool tstmin=false,  tstmax=false,  neg=false;
     69bool rtstmin=false, rtstmax=false, rneg=false;
     70double valmin=0., valmax=0., rvalmin=0., rvalmax=0.;
    3471char * fsphinw = NULL;
     72string dum;
    3573int c;
    36 while((c = getopt(narg,arg,"hm:M:w:")) != -1) {
     74while((c = getopt(narg,arg,"hnNm:M:r:R:w:")) != -1) {
    3775  switch (c) {
     76  case 'n' :
     77    neg = true;
     78    break;
     79  case 'N' :
     80    rneg = true;
     81    break;
    3882  case 'm' :
    3983    sscanf(optarg,"%lf",&valmin);
     
    4387    sscanf(optarg,"%lf",&valmax);
    4488    tstmax=true;
     89    break;
     90  case 'r' :
     91    sscanf(optarg,"%lf",&rvalmin);
     92    rtstmin=true;
     93    break;
     94  case 'R' :
     95    sscanf(optarg,"%lf",&rvalmax);
     96    rtstmax=true;
    4597    break;
    4698  case 'w' :
     
    54106
    55107if(optind+2>=narg) {usage(); exit(1);}
    56 char * fsphin   = arg[optind];
     108char * fsphin  = arg[optind];
    57109char * fsphred = arg[optind+1];
    58 char * fsphout  = arg[optind+2];
     110char * fsphout = arg[optind+2];
    59111
    60112cout<<"Input Sphere          : "<<fsphin<<endl
     
    62114    <<"Input Reducted Sphere : "<<fsphred<<endl
    63115    <<"Output Sphere         : "<<fsphout<<endl;
    64 if(!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;
     116if(neg) dum = ".NOT."; else dum="";
     117cout<<"- Sphere - test min("<<tstmin<<") : "<<valmin<<endl
     118    <<"           test max("<<tstmax<<") : "<<valmax<<endl
     119    <<"           negate("<<neg<<")"<<endl
     120    <<"  - Condition for EMPTY pixel in Sphere is :"<<endl
     121    <<"    "<<dum<<"( "<<valmin<<" <= V <= "<<valmax<<" )"<<endl;
     122if(rneg) dum = ".NOT."; else dum="";
     123cout<<"- Reducted Sphere - test min("<<rtstmin<<") : "<<rvalmin<<endl
     124    <<"                    test max("<<rtstmax<<") : "<<rvalmax<<endl
     125    <<"                    negate("<<rneg<<")"<<endl
     126    <<"  - Condition for GOOD pixel in Reducted Sphere is :"<<endl
     127    <<"    "<<dum<<"( "<<rvalmin<<" <= V <= "<<rvalmax<<" )"<<endl;
    69128
    70129// Lecture des spheres
     
    102161uint_4 n=0, n0=0;
    103162for(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   }
     163  bool skp;
     164  if(fsphinw) if(sphinw(i)<=0.) continue; // Pixel out of acceptance!
     165
     166  // Test if pixel of Sphere has to be extrapolated
     167  skp = (tstmin || tstmax) ? neg : false;
     168  if((tstmin && sphin(i)<valmin) || (tstmax && sphin(i)>valmax)) skp = !neg;
     169  if(skp) continue;   // Do nothing
     170
    112171  double theta,phi;
    113172  sphin.PixThetaPhi(i,theta,phi);
    114173  int_4 ir = sphred.PixIndexSph(theta,phi);
     174
     175  // Test if pixel of Reducted Sphere is good
     176  skp = (rtstmin || rtstmax) ? rneg : false;
     177  if((rtstmin && sphred(i)<rvalmin) || (rtstmax && sphred(i)>rvalmax)) skp = !rneg;
     178  if(skp) continue;   // Do nothing
     179
    115180  sphin(i) = sphred(ir);
    116181  n++; if(sphred(ir)!=0.) n0++;
     
    121186// Ecriture de la sphere
    122187{
    123 string dum = "rm -f "; dum += fsphout; system(dum.c_str());
     188dum = "rm -f "; dum += fsphout; system(dum.c_str());
    124189FitsOutFile sfits(fsphout);
    125190cout<<"Writing Output Sphere Fits file"<<endl;
Note: See TracChangeset for help on using the changeset viewer.