Commit 8b846289 authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

proceeding

This is a legacy commit from before 2015-03-01.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 1249
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 1fd49334
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: polymodel.h,v 1.3 2002-12-30 18:08:29 forbrig Exp $
* $Id: polymodel.h,v 1.4 2002-12-31 11:57:12 forbrig Exp $
* \author Thomas Forbriger
* \date 30/12/2002
*
......@@ -13,6 +13,7 @@
*
* REVISIONS and CHANGES
* - 30/12/2002 V1.0 Thomas Forbriger
* - 31/12/2002 V1.1 introduced read access to arrays
*
* ============================================================================
*/
......@@ -21,12 +22,13 @@
#ifndef TF_POLYMODEL_H_VERSION
#define TF_POLYMODEL_H_VERSION \
"TF_POLYMODEL_H V1.0 "
"TF_POLYMODEL_H V1.0"
#define TF_POLYMODEL_H_CVSID \
"$Id: polymodel.h,v 1.3 2002-12-30 18:08:29 forbrig Exp $"
"$Id: polymodel.h,v 1.4 2002-12-31 11:57:12 forbrig Exp $"
#include<iostream>
#include<aff/array.h>
#include<aff/subarray.h>
//! contains all gremlin1 stuff
namespace gremlin1 {
......@@ -42,6 +44,8 @@ namespace gremlin1 {
typedef double Tvalue;
//! my array type
typedef aff::Array<Tvalue> Tarray;
//! read access array type
typedef Tarray::Tcoc TCarray;
//! bool array
typedef aff::Array<bool> Tbarray;
//! int array
......@@ -102,6 +106,13 @@ namespace gremlin1 {
//! return agrument of polynomial for given depth and section
Tvalue polyarg(const Tvalue& depth, const int& isec) const;
//! read access to parameters
TCarray parameters() const
{ return (aff::subarray(Mpara)()(nsections())()); }
//! read access to depth values
TCarray depth() const
{ return (aff::subarray(Mdepth)(1,nsections())); }
private:
//! check for valid section index
int valid_section_index(const int& i) const;
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: mocox.cc,v 1.1 2002-12-30 18:08:29 forbrig Exp $
* $Id: mocox.cc,v 1.2 2002-12-31 11:57:12 forbrig Exp $
* \author Thomas Forbriger
* \date 30/12/2002
*
......@@ -13,24 +13,93 @@
*
* REVISIONS and CHANGES
* - 30/12/2002 V1.0 Thomas Forbriger
* - 31/12/2002 V1.1 started work on conversion to flnode model
*
* ============================================================================
*/
#define MOCOX_VERSION \
"MOCOX V1.0 convert gremlin1 model (modversion2)"
"MOCOX V1.1 convert gremlin1 model (modversion2)"
#define MOCOX_CVSID \
"$Id: mocox.cc,v 1.1 2002-12-30 18:08:29 forbrig Exp $"
"$Id: mocox.cc,v 1.2 2002-12-31 11:57:12 forbrig Exp $"
#include <iostream>
#include <fstream>
#include <gremlin1/polymodel.h>
#include <tfxx/commandline.h>
#include <tfxx/error.h>
#include <aff/array.h>
#include <aff/slice.h>
#include <aff/subarray.h>
#include <aff/iterator.h>
using std::cout;
using std::cerr;
using std::endl;
typedef gremlin1::PolynomialModelFile::Tarray Tarray;
typedef gremlin1::PolynomialModelFile::Tiarray Tiarray;
typedef gremlin1::PolynomialModelFile::TCarray TCarray;
/*======================================================================*/
// functions
// =========
// find nodes for flnode file
Tarray defnodes(const PolynomialModelFile& modelfile,
const bool& verbose)
{
if (verbose) cout << " define nodes:" << endl
<< " find appropriate number of nodes per section" << endl;
// create local alias
int nsections=modelfile.nsections();
TCarray para=modelfile.parameters();
TCarray depth=modelfile.depth();
/* scale factor
* May be passed as function argument in future versions.
* For velocities it has the meaning of
*
* v*dl/l
*
* where v is some reference velocity (in km/s - the unit of gremlin1
* files) and dl/l is the relative change of the vertical wavelength due to
* inappropriate sampling.
*
* For other parameters v is a reference parameter value and dl/l is the
* change of an integral property defined by the parameter (wavelength is
* velocity times period and wavelength variation is the integral over the
* velocity residual times the period - the period cancels in dl/l). I doubt
* that there might exist a physical meaning of dl/l for other parameters
* than velocity.
*
* However this parameter is not critical. The sampling is mainly based on
* the curvature parameter (second order polynomial coefficient) and the
* scale parameter allows some fine-tuning if desired.
*/
double scalefactor=0.01;
// array to store number of node layers per section
Tiarray nlay(nsections);
nlay=1;
// find number of layers per section
for (int i=1,i<=nsections; ++i)
{
if (verbose) cout << " sec #" << i <<":";
// all second order coefficients in this section
TCarray c(aff::slice(para)(3)(i));
for (int j=c.f(0); j<=c.l(0); ++)
{
}
}
} // defnodes
/*======================================================================*/
// main program
// ============
int main(int iargc, char* argv[])
{
......@@ -38,7 +107,7 @@ int main(int iargc, char* argv[])
char usage_text[]=
{
MOCOX_VERSION "\n"
"usage: mocox file [-w file]" "\n"
"usage: mocox file [-w file] [-v] [-dump] [-flnode file]" "\n"
" or: mocox --help|-h" "\n"
};
......@@ -49,7 +118,10 @@ int main(int iargc, char* argv[])
"\n"
"file file name of model file" "\n"
"\n"
"-v be verbose" "\n"
"-dump dump model to terminal" "\n"
"-w file write model to gremlin1 format \"file\"" "\n"
"-flnode file convert to FLNODE model \"file\"" "\n"
"\n"
MOCOX_CVSID
};
......@@ -62,8 +134,12 @@ int main(int iargc, char* argv[])
{"help",arg_no,"-"},
// 1: verbose mode
{"v",arg_no,"-"},
// 2: verbose mode
// 2: write polynomial model
{"w",arg_yes,"-"},
// 3: dump input model to terminal
{"dump",arg_no,"-"},
// 4: convert to FLNODE model
{"flnode",arg_yes,"-"},
{NULL}
};
......@@ -91,6 +167,9 @@ int main(int iargc, char* argv[])
bool opt_verbose=cmdline.optset(1);
bool opt_writeg1=cmdline.optset(2);
std::string arg_writeg1=cmdline.string_arg(2);
bool opt_dump=cmdline.optset(3);
bool opt_flnode=cmdline.optset(4);
std::string arg_flnode=cmdline.string_arg(4);
TFXX_assert(cmdline.extra(), "ERROR (mocox): missing file name!");
std::string filename=cmdline.next();
......@@ -101,7 +180,7 @@ int main(int iargc, char* argv[])
if (opt_verbose) cout << "read model from \""
<< filename << "\"" << endl;
gremlin1::PolynomialModelFile modelfile(filename.c_str());
if (opt_verbose)
if (opt_dump)
{
cout << endl;
cout << "Model values are:" << endl
......@@ -119,6 +198,18 @@ int main(int iargc, char* argv[])
std::ofstream ofs(arg_writeg1.c_str());
ofs << modelfile;
}
/*======================================================================*/
// convert to flnode is requested
if (opt_flnode)
{
if (opt_verbose) cout << endl << "convert to FLNODE model:" << endl;
// first find out the number of nodes we beed
Tarray nodes=defnodes(modelfile, opt_verbose);
} // if (opt_flnode)
}
/* ----- END OF mocox.cc ----- */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment