爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 30572|回复: 16

[求助] python 调用NCL的命令

[复制链接]

新浪微博达人勋

发表于 2016-7-28 20:14:54 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
请问python直接调用NCL画图的命令是什么?百度了很久没找到,是subprocess吗?还有分解时间应该怎么分解呢?比如说在shell里是这样的:
worktime=`date -u +%Y%m%d%H%M`
        runtime=`date -u -d -${i}minute +%Y%m%d%H%M`
        rytime=`echo $runtime | cut -c 1-4`
        rmtime=`echo $runtime | cut -c 5-6`
        rdtime=`echo $runtime | cut -c 7-8`
        rhtime=`echo $runtime | cut -c 9-10`
        Mtime=`echo $runtime | cut -c 11-11`
        rMtime=${Mtime}0       
       
新手求指教


密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-8-24 09:41:15 | 显示全部楼层
编写shell脚本,在shell脚本中设置环境变量,然后在ncl脚本中使用getenv函数接收外来参数。至于getenv如何使用,自己动手去查看ncl官网上的函数。
密码修改失败请联系微信:mofangbao
回复 支持 1 反对 0

使用道具 举报

新浪微博达人勋

发表于 2016-7-29 09:32:08 | 显示全部楼层
如果不传递参数给ncl脚本,只是调用脚本,利用OS.system(command line)语句;如果想传递环境参数,我的建议是:1.增加shell脚本作为中转,2.利用pyton的PyNGL和PyNIO模块实现NCL式的编程画图。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-7-29 10:22:42 | 显示全部楼层
有大神说这个没有更新维护了
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-8-23 14:53:28 | 显示全部楼层
本帖最后由 xuebiz 于 2016-8-23 15:05 编辑
风之精灵 发表于 2016-7-29 09:32
如果不传递参数给ncl脚本,只是调用脚本,利用OS.system(command line)语句;如果想传递环境参数,我的建议 ...

第一种方法,怎么用shell脚本传递参数,能给个小例子么,不知道ncl怎么接收参数?

    cmd='------   这里写linux中可以直接运行的命令行   ------‘
    os.system(cmd)

只会用这种命令行
ncl mynclfile.ncl
不懂怎么挂参数,请教~~
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-8-24 16:37:08 | 显示全部楼层
风之精灵 发表于 2016-8-24 09:41
编写shell脚本,在shell脚本中设置环境变量,然后在ncl脚本中使用getenv函数接收外来参数。至于getenv如何 ...

谢谢,收获了一个  getenv ~~
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-8-24 16:38:55 | 显示全部楼层
本帖最后由 xuebiz 于 2016-8-24 16:40 编辑

http://ncl.ucar.edu/Document/Functions/Built-in/getenv.shtml

getenv

Returns the string value of a shell environment variable.

Prototype


        function getenv (
                env_name [1] : string   
        )

        return_val [1] :  string

Return value

Returns a string containing the value of the shell environment variable requested, if that environment variable is set, or a missing value if it is not set.

Description


This function returns the value of the shell environment variable requested, if set, or a missing value if the environment variable is not set.

See Also


system, systemfunc
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-3-1 15:26:59 | 显示全部楼层
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

发表于 2017-3-1 15:27:10 | 显示全部楼层
不错
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

发表于 2017-3-1 15:27:19 | 显示全部楼层
可以
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表