Changeset 1626 in Sophya


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

Uniformisation des programmes + doc cmv 7/8/01

Location:
trunk/SophyaProg/PrgMap
Files:
5 edited

Legend:

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

    r1607 r1626  
    1313#include "fitsspherehealpix.h"
    1414#include "fitstarray.h"
     15
     16/*!
     17  \defgroup PrgMap PrgMap module
     18  This module contains simple programs to perform various tasks
     19  on spherical maps.
     20*/
    1521
    1622/*!
  • trunk/SophyaProg/PrgMap/cremskfrsph.cc

    r1535 r1626  
    1313#include "fitsspherehealpix.h"
    1414
     15/*!
     16  \ingroup PrgMap
     17  \file cremskfrsph.cc
     18  \brief \b cremskfrsph: Create a masked sphere from a sphere of datas
     19  \verbatim
     20csh> cremskfrsph -h
     21cremskfrsph [-n -m min -M max -v valmsk,inimsk] sphval.fits sphmask.fits
     22 -m min : min value
     23 -M max : max value
     24    condition for filling masque is: min<=sphere_value<=max
     25          (fill mask with valmsk)     (bounds are included)
     26 -n : negate the condition
     27      (switch to: sphere_value<min || max<sphere_value)
     28 -v valmsk,inimsk:
     29    valmsk: value to be put into mask if ok (def=1.)
     30    inimsk: initialisation value for the mask (def=0.)
     31  \endverbatim
     32*/
     33
    1534void usage();
    1635void usage()
     
    1938    <<" -m min : min value"<<endl
    2039    <<" -M max : max value"<<endl
    21     <<"    condition for filling masque is : min<=sphere value<=max"<<endl
    22     <<"                                      (bounds are included)"<<endl
     40    <<"    condition for filling masque is: min<=sphere_value<=max"<<endl
     41    <<"          (fill mask with valmsk)     (bounds are included)"<<endl
    2342    <<" -n : negate the condition"<<endl
     43    <<"      (switch to: sphere_value<min || max<sphere_value)"<<endl
    2444    <<" -v valmsk,inimsk:"<<endl
    2545    <<"    valmsk: value to be put into mask if ok (def=1.)"<<endl
     
    3252double vmin=-1.e30,vmax=1.e30,vmask=1.,vmaskini=0.;
    3353bool tstmin=false,tstmax=false,negate=false;
     54string dum;
    3455int c;
    3556while((c = getopt(narg,arg,"hnm:M:v:")) != -1) {
     
    5980char * sphmsk = arg[optind+1];
    6081
     82if(negate) dum = ".NOT."; else dum = "";
    6183cout<<"Sphere values : "<<sphval<<endl
    6284    <<"Sphere mask   : "<<sphmsk<<endl
    63     <<"  ...min("<<tstmin<<") "<<vmin<<"  max("<<tstmax<<") "<<vmax<<endl
     85    <<"  ...min("<<tstmin<<") "<<vmin<<endl
     86    <<"     max("<<tstmax<<") "<<vmax<<endl
    6487    <<"  ...negate "<<negate<<endl
    6588    <<"  ...mask set value "<<vmask<<endl
    66     <<"     mask init value "<<vmaskini<<endl;
    67 cout<<"Condition : ";
    68 if(negate) cout<<"!";
    69 cout<<"( "<<vmin<<" <= V <= "<<vmax<<" ) bounds are included"<<endl;
     89    <<"     mask init value "<<vmaskini<<endl
     90    <<"Condition on data to set the mask: "
     91    <<dum<<"( "<<vmin<<" <= V <= "<<vmax<<" )"<<endl;
    7092
    7193// Lecture de la sphere Healpix des valeurs
    72 SphereHEALPix<r_8> sph;       
     94SphereHEALPix<r_8> sph;
    7395FitsInFile sfits(sphval);
    7496sfits >> sph;
     
    87109for(int_4 i=0;i<sph.NbPixels();i++) {
    88110  sphm(i) = vmaskini;
    89   r_8 v = sph(i);
    90   bool intoint = true;
    91   if(tstmin && v<vmin) intoint=false;
    92   if(tstmax && v>vmax) intoint=false;
    93   //                    [vmin , vmax]
    94   // intoint :   false  [    true   ]  false  (si tstmin && tstmax)
    95   // intoint :   false  [    true             (si tstmin && !tstmax)
    96   // intoint :               true   ]  false  (si !tstmin && tstmax)
    97   if(negate && intoint) continue;
    98   else if(!negate && !intoint) continue;
     111
     112  bool skp = (tstmin || tstmax) ? negate : false;
     113  if((tstmin && sph(i)<vmin) || (tstmax && sph(i)>vmax)) skp = !negate;
     114  if(skp) continue;   // Do nothing
     115
    99116  sphm(i) = vmask;
    100117  nmask++;
     
    106123// Ecriture de la sphere Healpix sur fits
    107124{
    108 string dum = "rm -f "; dum += sphmsk; system(dum.c_str());
     125dum = "rm -f "; dum += sphmsk; system(dum.c_str());
    109126FitsOutFile swfits(sphmsk);
    110127cout<<"Writing Mask Sphere Fits file"<<endl;
  • 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;
  • trunk/SophyaProg/PrgMap/extrapsph.cc

    r1545 r1626  
    1 // Pour boucher les trous d'une sphere HEALPIX en clusterisant dans une sphere
    2 // plus petite             cmv 13/6/01
     1// Pour boucher les trous d'une sphere HEALPIX en la clusterisant
     2// dans une sphere plus petite puis en la re-extrapolant.
     3//                    cmv 13/6/01
    34// extrapsph -r 2 sph143k05.fits sph143k05_e.fits
    45//                sphout.fits sphoutw.fits sphred.fits sphredw.fits
     
    1314#include "fitsspherehealpix.h"
    1415
     16/*!
     17  \ingroup PrgMap
     18  \file extrapsph.cc
     19  \brief \b extrapsph: Fill holes in a sphere of datas by reducing
     20  it size and re-extrapolating.
     21  \verbatim
     22csh> extrapsph -h
     23extrapsph [-r reduc_factor] sphin.fits sphinw.fits
     24          sphout.fits [sphout_w.fits sphred.fits sphred_w.fits]
     25 -r reduc : reduction factor for clustering (must be 2^n, def=2)
     26 sphin.fits    : input sphere
     27 sphin_w.fits  : input sphere filling weight
     28 sphout.fits   : output sphere
     29 sphout_w.fits : output sphere filling weight
     30 sphred.fits   : output reducted sphere
     31 sphred_w.fits : output reducted sphere filling weight
     32  \endverbatim
     33*/
     34
    1535void usage();
    1636void usage()
    1737{
    18 cout<<"extrapsph [-r reduc] sphin.fits sphinw.fits"<<endl
    19     <<"                     sphout.fits [sphout_w.fits"
     38cout<<"extrapsph [-r reduc_factor] sphin.fits sphinw.fits"<<endl
     39    <<"          sphout.fits [sphout_w.fits"
    2040    <<" sphred.fits sphred_w.fits]"<<endl
    2141    <<" -r reduc : reduction factor for clustering (must be 2^n, def=2)"<<endl
     
    3151{
    3252int red=2;
     53string dum;
    3354int c;
    3455while((c = getopt(narg,arg,"hr:")) != -1) {
     
    122143  if(sphredw(ir)<=0.) continue;
    123144  sphin(i)  = sphred(ir);
     145  // On passe en negatif les pixels qui ont ete extrapoles
    124146  sphinw(i) = -sphredw(ir);
    125147  n++;
     
    129151// Ecriture des spheres
    130152{
    131 string dum = "rm -f "; dum += fsphout; system(dum.c_str());
     153dum = "rm -f "; dum += fsphout; system(dum.c_str());
    132154FitsOutFile sfits(fsphout);
    133155cout<<"Writing Output Sphere Fits file"<<endl;
     
    135157}
    136158if(fsphoutw) {
    137 string dum = "rm -f "; dum += fsphoutw; system(dum.c_str());
     159dum = "rm -f "; dum += fsphoutw; system(dum.c_str());
    138160FitsOutFile sfits(fsphoutw);
    139161cout<<"Writing Output Sphere Weight Fits file"<<endl;
     
    141163}
    142164if(fsphred) {
    143 string dum = "rm -f "; dum += fsphred; system(dum.c_str());
     165dum = "rm -f "; dum += fsphred; system(dum.c_str());
    144166FitsOutFile sfits(fsphred);
    145167cout<<"Writing Reducted Sphere Fits file"<<endl;
     
    147169}
    148170if(fsphredw) {
    149 string dum = "rm -f "; dum += fsphredw; system(dum.c_str());
     171dum = "rm -f "; dum += fsphredw; system(dum.c_str());
    150172FitsOutFile sfits(fsphredw);
    151173cout<<"Writing Reducted Sphere Weight Fits file"<<endl;
  • trunk/SophyaProg/PrgMap/msksphere.cc

    r1535 r1626  
    1111#include "fitsspherehealpix.h"
    1212
     13/*!
     14  \ingroup PrgMap
     15  \file msksphere.cc
     16  \brief \b msksphere: mask a sphere of datas with a mask sphere.
     17  \verbatim
     18csh> msksphere -h
     19msksphere [-m min -M max -v valmsk] sphval.fits sphmask.fits sphout.fits
     20 sphval.fits : inpout sphere of datas where the pixels have to be masked
     21 sphmask.fits : inpout masked sphere used to mask pixels
     22 sphout.fits : output masked sphere of datas
     23 -m min : min mask_sphere_value for MASKING the sphere pixel
     24 -M max : max mask_sphere_value for MASKING the sphere pixel
     25    condition for MASKING sphere pixel is (min<=mask_sphere_value<=max)
     26 -n : negate the previous condition, condition for MASKING sphere pixel
     27      becomes: (mask_sphere_value<minval || maxval<mask_sphere_value)
     28 Default (no -m and -M): mask pixel if mask_sphere_value<0.
     29 -v valmsk : set sphere value for masked pixels (def=0.)
     30  \endverbatim
     31*/
     32
    1333void usage();
    1434void usage()
    1535{
    16 cout<<"msksphere [-m min -M max -v valmsk]"<<endl
    17     <<"          sphval.fits sphmask.fits sphout.fits"<<endl
    18     <<" -m min : min value"<<endl
    19     <<" -M max : max value"<<endl
    20     <<"        condition for masking is :"<<endl
    21     <<"           mask_sphere_value <= min"<<endl
    22     <<"        OR"<<endl
    23     <<"           mask_sphere_value >= max"<<endl
    24     <<"        (bounds are included)"<<endl
    25     <<"        Default is mask_sphere_value <=0. (no -m and -M)"<<endl
    26     <<" -v valmsk : set value for masked pixels (def=0.)"<<endl;
     36cout<<"msksphere [-m min -M max -v valmsk]"
     37    <<" sphval.fits sphmask.fits sphout.fits"<<endl
     38    <<" sphval.fits : inpout sphere of datas where the pixels have to be masked"<<endl
     39    <<" sphmask.fits : inpout masked sphere used to mask pixels"<<endl
     40    <<" sphout.fits : output masked sphere of datas"<<endl
     41    <<" -m min : min mask_sphere_value for MASKING the sphere pixel"<<endl
     42    <<" -M max : max mask_sphere_value for MASKING the sphere pixel"<<endl
     43    <<"    condition for MASKING sphere pixel is (min<=mask_sphere_value<=max)"<<endl
     44    <<" -n : negate the previous condition, condition for MASKING sphere pixel"<<endl
     45    <<"      becomes: (mask_sphere_value<minval || maxval<mask_sphere_value)"<<endl
     46    <<" Default (no -m and -M): mask pixel if mask_sphere_value<0."<<endl
     47    <<" -v valmsk : set sphere value for masked pixels (def=0.)"<<endl;
    2748}
    2849
     
    3051{
    3152double vmask=0.,vmin=-1.e30,vmax=1.e30;
    32 bool tstmin=false,tstmax=false;
     53bool tstmin=false,tstmax=false,negate=false;
     54string dum;
    3355int c;
    34 while((c = getopt(narg,arg,"hm:M:v:")) != -1) {
     56while((c = getopt(narg,arg,"hnm:M:v:")) != -1) {
    3557  switch (c) {
     58  case 'n' :
     59    negate = true;
     60    break;
    3661  case 'm' :
    3762    sscanf(optarg,"%lf",&vmin);
     
    5681char * sphout = arg[optind+2];
    5782
     83if(!tstmin && !tstmax) {tstmin=true; vmin=0.; negate=true;}
     84
     85if(negate) dum = ".NOT."; else dum="";
    5886cout<<"Sphere values : "<<sphval<<endl
    5987    <<"Sphere mask   : "<<sphmsk<<endl
    6088    <<"Sphere out    : "<<sphout<<endl
    61     <<"  ...min("<<tstmin<<") "<<vmin<<"  max("<<tstmax<<") "<<vmax<<endl
     89    <<"  ...min("<<tstmin<<") "<<vmin<<endl
     90    <<"     max("<<tstmax<<") "<<vmax<<endl
    6291    <<"  ...mask set value "<<vmask<<endl
    63     <<"Condition for masking pixel is : "
    64     <<"( Vmsk <= "<<vmin<<" OR Vmsk >= "<<vmax<<" ) bounds are included"<<endl;
     92    <<"  Condition for masking pixel is :"<<endl
     93    <<"    "<<dum<<"( "<<vmin<<" <= V <= "<<vmax<<" )"<<endl;
    6594
    6695// Lecture de la sphere Healpix des valeurs
     
    88117uint_4 nmask = 0;
    89118for(int_4 i=0;i<sph.NbPixels();i++) {
    90   r_8 v = msph(i);
    91   bool masked=false;
    92   if(tstmin && v<=vmin) {sph(i) = vmask; masked = true;}
    93   if(tstmax && v>=vmax) {sph(i) = vmask; masked = true;}
    94   if(!tstmin && !tstmax && v<=0.)
    95                         {sph(i) = vmask; masked = true;}
    96   if(masked) nmask++;
     119
     120  bool skp = (tstmin || tstmax) ? negate : false;
     121  if((tstmin && msph(i)<vmin) || (tstmax && msph(i)>vmax)) skp = !negate;
     122  if(skp) continue;   // Do nothing
     123
     124  sph(i) = vmask;
     125  nmask++;
    97126}
    98127cout<<"    .... Number of values masked   : "<<nmask<<endl;
     
    102131// Ecriture de la sphere Healpix sur fits
    103132{
    104 string dum = "rm -f "; dum += sphout; system(dum.c_str());
     133dum = "rm -f "; dum += sphout; system(dum.c_str());
    105134FitsOutFile sfits(sphout);
    106135cout<<"Writing Output Masked Sphere Fits file"<<endl;
Note: See TracChangeset for help on using the changeset viewer.