爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 2719|回复: 2

关于函数的参数

[复制链接]

新浪微博达人勋

发表于 2022-3-8 22:32:41 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 redersun 于 2022-3-8 22:34 编辑

比如quiverm函数,其帮助文档如下:

quiverm(*args, **kwargs)
    Plot a 2-D field of arrows in a map.

    :param x: (*array_like*) Optional. X coordinate array.
    :param y: (*array_like*) Optional. Y coordinate array.
    :param u: (*array_like*) U component of the arrow vectors (wind field) or wind direction.
    :param v: (*array_like*) V component of the arrow vectors (wind field) or wind speed.
    :param z: (*array_like*) Optional, 2-D z value array.
    :param levs: (*array_like*) Optional. A list of floating point numbers indicating the level
        vectors to draw, in increasing order.
    :param cmap: (*string*) Color map string.
    :param fill_value: (*float*) Fill_value. Default is ``-9999.0``.
    :param isuv: (*boolean*) Is U/V or direction/speed data array pairs. Default is True.
    :param size: (*float*) Base size of the arrows.
    :param proj: (*ProjectionInfo*) Map projection of the data. Default is None.
    :param zorder: (*int*) Z-order of created layer for display.
    :param select: (*boolean*) Set the return layer as selected layer or not.

    :returns: (*VectoryLayer*) Created quiver VectoryLayer.




其调用示例如下:
f = addfile('D:/Temp/GrADS/model.ctl')u = f['U'][0,'500','10:60','60:140']
v = f['V'][0,'500','10:60','60:140']
speed = sqrt(u*u+v*v)#Plot
axesm()
lworld = shaperead('D:/Temp/Map/country1.shp')
geoshow(lworld)
layer = quiverm(u, v, speed, 10, size=8)
quiverkey(layer, 0.74, 0.18, 15, bbox={'edge':True, 'fill':True})
colorbar(layer)
title('Wind field')
yticks([20,40,60])
上面调用quiverm函数的示例中,size=8是关键字参数,那么它前面的参数都应该是位置参数了,那么实参u,v,speed,10对应的形参分别是哪个?为什么?




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

新浪微博达人勋

发表于 2022-3-8 22:51:10 | 显示全部楼层
如果 U, V 是 DimArray (自带各维的值),x, y 坐标信息可以省略。具体可以看源代码:https://github.com/meteoinfo/Met ... axes.py#L1411-L1500
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2022-3-9 09:34:27 | 显示全部楼层
看了一下代码,虽然看不太懂,但参数处理那块看明白了,程序会根据参数的数量及类型自动进行处理,感谢老师的指点
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

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