[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dennou-ruby:001827] Re: GPhys::EP_Flux
���͡�
��ή��ץ٥��ȥ��ѤΥ�åɤ���ޤ�����ggraph.rb �� DCLExt��
���塼�������Ƥ���ޤ�(CVS�Τ�)��ugvect �����˻Ȥ���ΤǤ�����
�����ä����̤ꡢfactor �����Τ�Ĺ������Ĵ���Ǥ��ޤ���
�ޤ���xintv, yintv �ǻ��ꤹ��ְ�����ǽ��Ĥ��ޤ�����
ugvect ��Ƥ�Ǥޤ��Τǡ������ɸ���ѤǤ�(ugvect)��
����˸����С�itr=1 �Ǥʤ��ȡ�������ή��ˤʤ�ޤ���
����Ū�ˤ� ugvect ��Ȥ�ʤ����Ͽ���Ƥ��б������Τ��ߤ����Ǥ�
�͡�
factor=1.0�� x, y ��ʬ��Ĺ���κ��礬ʿ�ѥ���åɴֳ֤ˤʤ�褦
�ˤȤ��� ugvect Ū���ͤǤ���ή���ɽ�����ᡢ�٥��ȥ�νIJ����
��U ��ɸ�νIJ��桿V��ɸ�νIJ���ˤ�Ĵ�����ޤ���®�پ��ե�å�
����ɽ���˹�Ŭ��
def ug_flow_vect( fx, fy, factor=1.0, xintv=1, yintv=1)
raise ArgumentError,"Expect 2D arrays" if fx.rank != 2 || fy.rank != 2
raise ArgumentError,"fx.shape != fy.shape" if fx.shape != fy.shape
raise ArgumentError,"xintv must be a positive integer" if xintv < 0
raise ArgumentError,"yintv must be a positive integer" if yintv < 0
nx, ny = fx.shape
if xintv >= 2
idx = NArray.int(nx/xintv).indgen!*xintv # [0,xintv,2*xintv,..]
fx = fx[idx, true]
fy = fy[idx, true]
end
if yintv >= 2
idx = NArray.int(ny/yintv).indgen!*yintv # [0,yintv,2*yintv,..]
fx = fx[true, idx]
fy = fy[true, idx]
end
nx, ny = fx.shape # again, because of xintv & yintv
vx0,vx1,vy0,vy1 = DCL.sgqvpt
ux0,ux1,uy0,uy1 = DCL.sgqwnd
dvx = (vx1-vx0)/nx
dvy = (vy1-vy0)/ny
ax = (vx1-vx0)/(ux1-ux0) # factor to convert from U to V coordinate
ay = (vy1-vy0)/(uy1-uy0) # factor to convert from U to V coordinate
fxmx = fx.abs.max
fymx = fy.abs.max
raise "fx has no data or all zero" if fxmx == 0
raise "fy has no data or all zero" if fymx == 0
cn = [ dvx/(ax*fxmx), dvy/(ay*fymx) ].min # normarization constant
lnrmal = DCL.ugpget('LNRMAL') # save
DCL.ugpset('LNRMAL', false)
DCL.ugvect( factor*cn*ax*fx, factor*cn*ay*fy )
DCL.ugpset('LNRMAL', lnrmal) # recover
end
�ʲ����ƥ��ȥץ������Ǥ���U��ɸ�νIJ���ˤ�����餺��ή�줬
�ɤ���Τ��狼��Ȼפ��ޤ���
---
require "numru/ggraph"
include NumRu
nx = 20
ny = 10
ux = 10.0
uy = 1.0
fx = ux*NArray.sfloat(nx,ny).indgen!
fy = uy*NArray.sfloat(nx,ny).indgen!
DCL.gropn(1)
DCL.grfrm
DCL.grswnd(0,ux,0,uy)
DCL.grsvpt(0.2,0.8,0.2,0.8)
DCL.grstrn(1)
DCL.grstrf
DCL.usdaxs
DCLExt.ug_flow_vect(fx, fy, 2.0)
DCL.grfrm
DCL.grswnd(0,ux,0,uy)
DCL.grsvpt(0.2,0.8,0.2,0.8)
DCL.grstrn(1)
DCL.grstrf
DCL.usdaxs
DCLExt.ug_flow_vect(fx, fy, 1.0, 2, 1)
DCL.grcls
---
��Ƿ��