Main Page | Class Hierarchy | Class List | File List | Class Members

appatt.h

00001 /* ======== IGeoS ===== Distribition full ===== IGeoS =========
00002 **                                                                         
00003 ** appatt.h     : Created by 'AMSS-developer' on Wed Sep 30 19:29:02 2015
00004 **                                                                         
00005 ** Product      : IGeoS - Integrated Geoscience Software
00006 **                                                                         
00007 ** Description  : System for seismic, well log, and potential-field data analysis
00008 **                                                                         
00009 ** =================== Limited License: ===================================
00010 ** 
00011 ** This software is provided free under the following terms and conditions:
00012 ** 
00013 ** 1. Permission to use, copy, and modify this software 
00014 ** for non-commercial purposes without fee is hereby granted, provided  
00015 ** that this copyright notice, the warranty disclaimer, and this
00016 ** permission notice appear in all copies.
00017 ** 
00018 ** 2. Distribution of this software or any part of it "bundled" in with
00019 ** any product is considered to be a 'commercial purpose'.
00020 ** 
00021 ** 3. Any new or adapted code developed to operate as a part of this
00022 ** software shall be contributed to the authors and distributed under
00023 ** the same license.
00024 ** 
00025 ** ================== Warranty Disclaimer: ================================
00026 ** 
00027 ** This software is provided "as is", with no support and without
00028 ** obligation on the part of the author to assist in its use, correction,
00029 ** modification, or enhancement. No guarantees or warranties,
00030 ** either express or implied, and regarding the accuracy, safety, or
00031 ** fitness for any particular purpose are provided by any contributor
00032 ** to this software package.
00033 ** 
00034 ** ======== IGeoS ===== Distribition full ===== IGeoS ========= */
00035 
00036 
00037 #ifndef MOD_APPATT_H
00038 #define MOD_APPATT_H
00039 
00040 #include "sia_module.C.h"
00041 #include "../_lib/if/if.h"
00042 #include "../_lib/dbase/dbase_sia.h"
00043 
00044 class APPATT;
00045 
00046 #define EPS             0.0001  /* margin by which the ranges are expanded */
00047 #define EPS_DOWN        0.9999
00048 #define EPS_UP          1.0001  
00049 
00050 #define X_TOLERANCE     1.0e-3
00051 #define T_STAR_FACTOR   366.4678        /* factor to scale t* 
00052                                         (1000 included to express it in ms):
00053                                                 1000 / TWO_PI / lg(e) */
00054 
00055 typedef float   MATRIX_FORMAT;
00056 
00057 struct FP                       /* frequency-power pairs */
00058 {
00059   DATA_SAMPLE   f, p;
00060 };
00061 
00062 struct IN_SOURCE                        /* input source table structure */
00063 {
00064   USER_DBTAB    *table;
00065   HEADER        *number,                /* trial number */
00066                 *freq,                  /* frequency */
00067                 *power, *variance;      /* source spectral power and its
00068                                                 variance */
00069   int           num_f;
00070   double        *spectrum;              /* array for the storage of the
00071                                                 input source spectrum */
00072 };
00073 
00074 struct OUT_TT                   /* output table structure */
00075 {
00076   USER_DBTAB    *table;
00077   HEADER        *number,                /* trial number */
00078                 *arg,                   /* X or frequency */
00079                 *value, *variance;      /* parameter found by inversion and its
00080                                                 variance */
00081 
00082   int entry_length() const { return table ? table->entry.length() : 0; }
00083 };
00084 
00085 struct OUT_RES_VAR                      /* output resolution and covariance table */
00086 {
00087   USER_DBTAB    *table;
00088   HEADER        *row, *column,                  /* rows and columns */
00089                 *resolution,  *covariance;
00090 };
00091 
00094 struct APPATT_RANGES
00095 {
00096   APPATT_RANGES(APPATT &a) : A(a) {}
00097   
00098   virtual double basis_fun ( const POINT &p, int k ) const = 0;
00100 
00101   virtual int prepare() = 0;
00105         
00106   virtual boolean check( const char *title ) { return OK; }
00110   
00111   virtual int num_points() const { return 0; }  
00112   
00113   virtual void prepare( const POINT &p ) {}     
00114   
00115   virtual void output_gamma() {}                
00116   virtual void output_kappa() {}                
00117   
00118   APPATT &A;    
00119 };
00120 
00121 class X_RANGES;
00122 
00123 struct X_RANGE                  /* subranges in the parameterization in X */
00124 {
00125   X_RANGE() : num(0), used(FALSE) {}
00126   X_RANGE(const X_RANGE &from) { _copy(from);}
00127   X_RANGE &operator=(const X_RANGE &from) { _copy(from); return *this; }
00128 
00129   int   num,            
00130         used;           
00131         
00132   float min,            
00133         max,            
00134         inc;            
00135                                 
00136   boolean read( const X_RANGES &current );      
00138 
00139   int num_points() const { return num; }        
00140 
00141 protected:
00142     void _copy(const X_RANGE &r) 
00143           { num = r.num; used = r.used; min = r.min; max = r.max; inc = r.inc; }
00144 };
00145 
00148 struct X_RANGES : public APPATT_RANGES, ARRAY<X_RANGE> 
00149 {
00150   X_RANGES( APPATT &a ) : APPATT_RANGES(a), ARRAY<X_RANGE>() {}
00151   
00152   double basis_fun ( const POINT &p, int k ) const { return basis_fun0(p.x,k); }
00154 
00155   int prepare();        
00159 
00160   void prepare( const POINT &p );       
00161   boolean check( const char *title );   
00162 
00163 
00164         
00165   void output_gamma();          
00166   void output_kappa();          
00167 
00168   int num_points() const;        
00169 
00170 private:
00171       double basis_fun0 ( double x, int k ) const;
00173 };
00174 
00177 struct APPATT : public SIA_MODULE, DBMODULE
00178 {
00179   APPATT();
00180 
00181   SELECT        *select;                
00182 
00183   /*---- parameters -------------------------------------*/
00184 
00185   int   num_freq,       /* number of values of parameterization in frequency */
00186         num_iter;       /* number of iterations of spectral balancing */
00187 
00188   HEADER_PARAM  xg,             /* trace position for G parameterization--
00189                                         channel number, or X, or offset, etc. */
00190                 xt,             /* trace position for t* parameterization--
00191                                         channel number, or X, or offset, etc. */
00192                 freq_min, freq_max, freq_inc,   /* frequency range */
00193                 weight,                         /* trace weight */
00194                 power_weight_min,               /* power-dependent weight */
00195                 power_weight_max,
00196                 power_range_width;
00197 
00198   int   trial_number;           
00199   float shift_t_star,           
00200         shift_g;                
00201   
00202   /*----- parameterization ranges in X, different for G and t* terms -----*/
00203 
00204   int           num_xg;         /* total number of basis functions in G */
00205   APPATT_RANGES *xg_range;      /* array of G-ranges in X */
00206 
00207   int           num_xt;         /* total number of basis functions in t* */
00208   APPATT_RANGES *xt_range;      /* array of t*-ranges in X */
00209 
00210   /*---- output tables -------------------------------------*/
00211 
00212   OUT_TT        t_star,         /* apparent attenuation terms */
00213                 amplitude,      /* amplitude terms */
00214                 source;         /* source terms */
00215 
00216   OUT_RES_VAR   quality;        /* output quality control table */
00217 
00218   /*---- input source table -------------------------------------*/
00219 
00220   IN_SOURCE     in_source;
00221 
00222   /*---- randomization -------------------------------------*/
00223 
00224   int   num_trials;
00225 
00226   float min_freq_min, max_freq_min,
00227         min_freq_max, max_freq_max;
00228 
00229   /*----- work areas ---------------------------------------*/
00230 
00231   float min_freq, max_freq, inc_freq;
00232 
00233   int           num_u;                  /* number of unknowns */
00234   MATRIX_FORMAT *u, *result;            /* row of Hessian and output */
00235 
00236   ARRAY<FP>     work;                   
00237 
00238   double *old_t_star, *old_source;      /* t* and source spectrum
00239                                                 from the previous iteration */
00240                                                 
00241   void proc ( boolean random_trial=TRUE );
00243 
00244   void compute_quality();
00246 
00247   void converge();
00250 
00251   void fill_source();
00253         
00254   CHARSTR module_name( boolean active );        
00255   int edit();                                   
00256   boolean process();                            
00257 
00258   int branch ( int range ) const;
00261 
00262   boolean trace_power ( TRACE *t, double freq, double &power ) const;
00265 
00266 protected:
00267 
00268   boolean pass_traces();        
00269 
00270   virtual double freq_basis ( double freq, int k );
00272 };
00273 
00274 #endif

Generated on Wed Apr 1 21:41:54 2020 for Module APPATT by  doxygen 1.3.9.1