将GMT脚本转换为新的现代执行模式的工具
项目描述
免责声明
这是一个正在进行的**工作**。到目前为止,它可以转换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”文件夹中的脚本和数据。
更多关于现代模式的信息请参阅现代化维基页面。
安装
使用包管理器pip安装最新版本
pip install gmtmodernize
要从Github master分支安装开发版本
git clone https://github.com/GenericMappingTools/gmtmodernize.git cd gmtmodernize pip install .
使用
命令行
该软件包通过gmtmodernize程序提供命令行界面
$ 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.
库
或者,您可以使用gmtmodernize Python库运行转换。它公开了一个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-clause许可证的条款下重新分发和/或修改它。许可证的副本提供在LICENSE.txt中。
项目详情
下载文件
下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。
源代码分发
gmtmodernize-1.2.tar.gz (30.6 kB 查看哈希值)
构建分发
gmtmodernize-1.2-py3-none-any.whl (24.8 kB 查看哈希值)
关闭
gmtmodernize-1.2.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 49836b36762be5f43b99f128cff48cd192149c9abb6a823b07dcef495aaddce0 |
|
MD5 | 7f206e6ba8e0255c00d316e036840767 |
|
BLAKE2b-256 | 632ccb01c20e2a5c383af4a154f0c91248d6c23c40889845bddb4da2baf54a80 |
关闭
gmtmodernize-1.2-py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 4c9904daa987800cae2d2f4d44d83340aad9cb2d2fee5541a77d130e98949483 |
|
MD5 | ccd3465a9de50766b8af6b593b772c1c |
|
BLAKE2b-256 | 995084f921f54247736d8fa8a061f1a3ed0f46c3360b106dc082bd7adbaf822d |