将gmt脚本转换为新的现代执行模式的工具

gmtmodernize的Python项目详细描述


Latest version on PyPITravis CI build statusTest coverage statusCompatible Python versions.

免责声明

这是正在工作。到目前为止,它可以转换一些测试和 GMT存储库中的示例脚本。

关于现代模式

GMT正在引入一种“现代”的执行模式,它可以减少 许多程序和处理Postscript层阻塞所需的参数 在后台。

例如,以下经典模式脚本:

ps=map.ps
gmt grdgradient -Nt0.2 -A45 data.nc -Gintens.nc
gmt makecpt -Cgeo -T-8000/2000 > t.cpt
gmt grdimage -Ct.cpt -Iintens.nc data.nc -JM6i -P -K > $ps
gmt pscoast -Rdata.nc -J -O -Dh -Baf -W0.75p -K >> $ps
echo "Japan Trench" | gmt pstext -F+f32p+cTC -Dj0/0.2i -Gwhite -R -J -O -K >> $ps
gmt psxy -W2p lines.txt -R -J -O -K >> $ps
gmt psscale -R -J -O -DjBL+w3i/0.1i+h+o0.3i/0.4i -Ct.cpt -W0.001 -F+gwhite+p0.5p -Bxaf -By+l"km" >> $ps

在现代模式下相当于以下各项:

ps=map

gmt begin $ps ps

gmt grdgradient -Nt0.2 -A45 data.nc -Gintens.nc
gmt makecpt -Cgeo -T-8000/2000 > t.cpt
gmt grdimage -Ct.cpt -Iintens.nc data.nc -JM6i -P
gmt pscoast -Rdata.nc -Dh -Baf -W0.75p
echo "Japan Trench" | gmt pstext -F+f32p+cTC -Dj0/0.2i -Gwhite
gmt psxy -W2p lines.txt
gmt psscale -DjBL+w3i/0.1i+h+o0.3i/0.4i -Ct.cpt -W0.001 -F+gwhite+p0.5p -Bxaf -By+l"km"
rm -f intens.nc t.cpt

gmt end

请参阅example文件夹中的脚本和数据。

阅读更多关于现代模式的信息 Modernization wiki page

安装

使用pippackage manager安装最新版本:

pip install gmtmodernize

从githubmaster分支安装开发版本:

git clone https://github.com/GenericMappingTools/gmtmodernize.git
cd gmtmodernize
pip install .

使用

命令行

包通过^{tt3}提供命令行接口$ 程序:

$ gmtmodernize --help
Convert GMT shell scripts from classic to modern mode.

Prints the converted modern mode script to standard output (stdout).

Usage:
    gmtmodernize SCRIPT
    gmtmodernize --recursive FOLDER_CLASSIC FOLDER_MODERN
    gmtmodernize --help
    gmtmodernize --version

Arguments:
    SCRIPT          Classic mode script to convert.
    FOLDER_CLASSIC  Folder with classic mode scripts (can have multiple
                    sub-folders).
    FOLDER_MODERN   Name of output folder with converted modern mode scripts.
                    Mirrors the folder structure of FOLDER_CLASSIC and copies
                    all non-script files.

Options:
    -r --recursive  Recursively transverse a folder structure with GMT scripts
                    and other files instead of converting a single file.
                    Creates a new folder with the same structure and non-script
                    files copied over, plus the converted GMT scripts.
    -h --help       Show this help message and exit.
    --version       Show the version and exit.

Examples:

    Convert a single GMT script to modern mode:

        $ gmtmodernize classic_script.sh > modern_script.sh

    Convert a folder with GMT scripts, data files, etc, (optionally inside
    multiple sub-folders):

        $ gmtmodernize -r gmt_classic_scripts/ gmt_modern_scripts/

    This will create a folder 'gmt_modern_scripts' with the same sub-folders
    and non-script files in 'gmt_classic_scripts' but with the scripts
    converted to modern mode.

或者,可以使用gmtmodernizepython运行转换 图书馆。它公开了一个modernize函数,该函数接受一个经典脚本(作为 并输出一个现代脚本(也作为一个字符串)。

示例:

from gmtmodernize import modernize

with open('classic_script.sh') as f:
    classic = f.read()
with open('modern_script.sh', 'w') as f:
    f.write(modernize(classic))

许可证

gmtmodernize是免费软件:您可以重新分发和/或修改它 根据bsd 3子句许可的条款。此许可证的副本是 以LICENSE.txt格式提供。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java HikariCP连接池Tomcat调试启用   java如何在javascript中访问JSON数组的元素?   jasper使用HttpServlet报告Java空白PDF   用于存储海量数据的java最佳集合   JBPM&springboot组织。流口水。坚持不懈jta。JtaTransactionManager在JNDI位置[java:comp/UserTransaction]未找到任何UserTransaction   java Grails maven插件需要Groovy 2.4.2   获取列表中访问最少的元素(Java 8)   java在IntelliJ中下载cn1lib不起作用   java Akka构造函数通过spring进行布线   swing在Java中创建JList时,如何更改条目的背景颜色?   为什么Java8Lambda允许访问非最终类变量?   javajavax。邮政MessaginException:无法连接到SMTP主机   java Android Webview高度在滚动后增加