MacOS环境下安装Tesseroids的过程

2018-03-27
#Unix

1. 下载源代码

在GitHub上面的地址为:GitHub - leouieda/tesseroids: Forward modeling of gravity fields in spherical coordinates。下载所有的文档为一个压缩文件:tesseroids-master.zip,并解压为:tesseroids-master文件。

2. 编译安装

GitHub - leouieda/tesseroids: Forward modeling of gravity fields in spherical coordinates官方文档中默认的是给出了Windows (32 bit only) and GNU/Linux (32 and 64 bit)的可执行程序,这些可执行程序放在bin目录下面,只需要添加bin目录到环境变量中,Windows下面添加环境变量可以参考:How to set the path in Microsoft Windows

而对于Mac环境下面,需要编译生成bin目录。Tesseroids 使用的是SCons管理编译文件,Mac环境下面可以通过 Homebrew 来安装scons。

2.1 安装Scons包

  • 在Terminal里面输入以下命令安装HomeBrew:

    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    
  • 而后,通过HomeBrew直接安装scons包:

    brew install scons 
    

2.2 编译Tesseroids文件

cd切换到tesseroids-master文件里面,输入scons命令编译

  scons

这里,相关的编译文件都会生成在bin目录下。

2.3 添加bin目录到环境变量

注意:Terminal使用的是zsh,如果使用的是bash,以下的zshrc则改为bashrc文件。

  • 打开.zshrc文件:

    vi ~/.zshrc
    
  • 写入以下代码,并保存退出。

    # add the tesseroid
    TESSHOME=/Users/name/Documents/2017tesseroid/Tesseroid-1.2.0/tesseroids-master
    export PATH="$TESSHOME/bin:$PATH"
    
  • source下.zshrc文件:

    source ~/.zshrc
    
  • 查看环境变量是否添加成功:

    echo $PATH
    

如果显示的是有:/Users/name/Documents/2017tesseroid/Tesseroid-1.2.0/tesseroids-master/bin,则添加成功 。

3. 检测是否安装成功

输入tessgrd -h 检验是否安装成功。

  ➜  ~ tessgrd -h
  Usage: tessgrd [PARAMS] [OPTIONS]

  Make a regular grid of points.

  All units either SI or degrees!

  Output:
    Printed to standard output (stdout) in the format:
      lon1    lat1    height
      lon2    lat1    height
      ...     ...     ...
      lonNLON lat1    height
      lon1    lat2    height
      ...     ...     ...
      ...     ...     ...
      lonNLON latNLAT height

    * Comments about the provenance of the data are inserted into
the top of the output

  Parameters:
    -r           W/E/S/N: Bounding region of the grid.
    -b           NLON/NLAT: Number of grid points in the
                 longitudinal and latitudinal directions.
    -z           HEIGHT: Height of the grid with respect to the
           mean Earth radius.
    -h           Print instructions.
    --version    Print version and license information.

  Options:
    -v           Enable verbose printing to stderr.
    -lFILENAME   Print log messages to file FILENAME.

    Part of the Tesseroids package (v1.2.0).

    Project site: <http://www.leouieda.com/tesseroids/>
    Report bugs at: <https://github.com/leouieda/tesseroids/issues>

    Copyright (C) 2011-2016, Leonardo Uieda.
    This software is distributed under the terms of the BSD License:
    <http://tesseroids.readthedocs.org/en/latest/license.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.