96 lines
5.6 KiB
C++
96 lines
5.6 KiB
C++
/********************************************************
|
|
* ██████╗ ██████╗████████╗██╗
|
|
* ██╔════╝ ██╔════╝╚══██╔══╝██║
|
|
* ██║ ███╗██║ ██║ ██║
|
|
* ██║ ██║██║ ██║ ██║
|
|
* ╚██████╔╝╚██████╗ ██║ ███████╗
|
|
* ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝
|
|
* Geophysical Computational Tools & Library (GCTL)
|
|
*
|
|
* Copyright (c) 2022 Yi Zhang (yizhang-geo@zju.edu.cn)
|
|
*
|
|
* GCTL is distributed under a dual licensing scheme. You can redistribute
|
|
* it and/or modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation, either version 2
|
|
* of the License, or (at your option) any later version. You should have
|
|
* received a copy of the GNU Lesser General Public License along with this
|
|
* program. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
* If the terms and conditions of the LGPL v.2. would prevent you from using
|
|
* the GCTL, please consider the option to obtain a commercial license for a
|
|
* fee. These licenses are offered by the GCTL's original author. As a rule,
|
|
* licenses are provided "as-is", unlimited in time for a one time fee. Please
|
|
* send corresponding requests to: yizhang-geo@zju.edu.cn. Please do not forget
|
|
* to include some description of your company and the realm of its activities.
|
|
* Also add information on how to contact you by electronic and paper mail.
|
|
******************************************************/
|
|
|
|
#include "func.h"
|
|
|
|
int main(int argc, char* argv[]) try
|
|
{
|
|
gctl::flags_parser fp;
|
|
fp.set_proname("shc2xyz");
|
|
fp.set_proinfo("Forward modeling spherical harmonic coefficients to table data. \
|
|
This program is a toolkit of the GCTL package. The GCTL comes with ABSOLUTE NO WARRANTY. \
|
|
Please see instructions or contact the author for more information.");
|
|
|
|
fp.add_opt('t', "coeff-table", required_argument, NULL, "Input spherical harmonic coefficients.", "<filename>", true);
|
|
fp.add_opt('r', "range", required_argument, NULL, "Range of calculation.", "<lonmin>/<lonmax>/<latmin>/<latmax>[/<altitude>]", true);
|
|
fp.add_opt('i', "interval", required_argument, NULL, "Intervals of calculation.", "<dlon>/<dlat>", true);
|
|
fp.add_opt('d', "data-type", required_argument, NULL, "Objective data type. enter 'n' for null-specified (default), 't' for topography, 'd' for gravity disturbance, 'dlon' for gravity disturbance in the longitudinal direction, 'dlat' for gravity disturbance in the latitudinal direction, 'g' for gravity anomaly, 'p' for geo-potential, 'h' for height anomlay, and 'r' for radial gravity gradient", "<type>", true);
|
|
fp.add_opt('o', "order-degree", required_argument, NULL, "Start and end orders and degrees used for calculation.", "<ln>/<lm>/<hn>/<hm>", true);
|
|
fp.add_opt('s', "refer-system", required_argument, NULL, "Set reference system.", "<refr>/<refR>|WGS84|Earth|Moon|Mars", true);
|
|
fp.add_opt('l', "location", required_argument, NULL, "Read output locations from an input file, every line of the file has a longitudinal and a latitudinal value.", "<loc-file>", false);
|
|
fp.add_opt('g', "grav-para", required_argument, NULL, "GM and R multipliers for gravitational data's calculation.", "<GM>/<R>", false);
|
|
fp.add_opt('n', "normalization", required_argument, NULL, "Set normalized sum of associated Legendre functions. Enter 'm' for mathematic normalization which equal 1 and 'g' for geodetic normalization which equal 4*pi (default).", "<type>", false);
|
|
fp.add_opt('c', "columns", required_argument, NULL, "Select data columns of the input table data. the default is 0,1,2,3.", "<col1>,<col2>,<col3>,<col4>", false);
|
|
fp.add_opt('j', "jump-lines", required_argument, NULL, "Jump the first <num> lines of the input file.", "<num>", false);
|
|
fp.add_opt('a', "altitude", required_argument, NULL, "Provide a input file for observations' altitudes. use +d to select input data columns, the default is 0,1,2", "<alti-file>[+d<col1>,<col2>,<col3>]", false);
|
|
fp.add_opt('h', "help", no_argument, NULL, "Show help information.", 0, false);
|
|
fp.configure(argc, argv);
|
|
|
|
if(argc == 1 || fp.set_opt('h'))
|
|
{
|
|
fp.show_help_page(std::clog, " > <outfile>");
|
|
return 0;
|
|
}
|
|
|
|
std::string infilename, interfilename, range, interval;
|
|
std::string type, referSystem, coffPara, columns, jumps, gravPara, norType, altiFile;
|
|
|
|
fp.get_argv({'t', 'r', 'i', 'd', 'o', 's', 'l', 'g', 'n', 'c', 'j', 'a'},
|
|
{&infilename, &range, &interval, &type, &coffPara, &referSystem, &interfilename, &gravPara, &norType, &columns, &jumps, &altiFile});
|
|
if (type == "NULL") type = "n";
|
|
if (columns == "NULL") columns = "0,1,2,3";
|
|
if (norType == "NULL") norType = "g";
|
|
if (jumps == "NULL") jumps = "0";
|
|
|
|
// 查看是否通过强制参数检查
|
|
if (!fp.pass_mandatory()) return 0;
|
|
|
|
shc2xyz sx;
|
|
//读入球谐系数文件
|
|
if(sx.readSHC(infilename.c_str(), coffPara.c_str(), columns.c_str(), jumps)) return 0;
|
|
//初始化观测点位置
|
|
if(sx.initObs(range.c_str(), interval.c_str(), referSystem.c_str())) return 0;
|
|
//重定位观测点高程
|
|
if(sx.relocateAltitude(altiFile.c_str())) return 0;
|
|
//确定计算类型
|
|
if(sx.initTargetType(type.c_str())) return 0;
|
|
//初始化矩阵
|
|
sx.initMatrix(type.c_str(), gravPara.c_str(), norType.c_str(), altiFile.c_str());
|
|
//计算
|
|
if (altiFile == "NULL")
|
|
{
|
|
sx.calSolution();
|
|
}
|
|
else sx.calSolution2(type.c_str());
|
|
//输出
|
|
sx.outObs(interfilename.c_str());
|
|
return 0;
|
|
}
|
|
catch(std::exception &e)
|
|
{
|
|
GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, 0, 0);
|
|
} |