Module: NumRu::GAnalysis::LogP

Defined in:
lib/numru/ganalysis/log_p.rb

Overview

module LogP : log-pressure coordinate support

Constant Summary collapse

P00 =

P00 = 1e5 Pa (1000 hPa)

UNumeric[1e5,"Pa"]
@@H =
UNumeric[7e3,"m"]

Class Method Summary collapse

Class Method Details

.hObject

returns the current value of the log-p scale height (in UNumeric)



27
28
29
# File 'lib/numru/ganalysis/log_p.rb', line 27

def h
  @@H.clone
end

.p2z(p) ⇒ Object

convert pressure to log-p height



32
33
34
35
36
37
38
# File 'lib/numru/ganalysis/log_p.rb', line 32

def p2z(p)
  z = (p/P00).convert_units("1").log * (-@@H)
  z.name = "z"
  z.long_name = "log-p z"
  z.del_att("positive")
  z
end

.pcdata_dz(gphys, pdim = nil) ⇒ Object

del/delz applied to data with the p coordinate



41
42
43
44
45
46
47
48
49
50
# File 'lib/numru/ganalysis/log_p.rb', line 41

def pcdata_dz(gphys, pdim=nil)
  pdim = Met.find_prs_d(gphys) if !pdim
  p = gphys.axis(pdim).to_gphys
  z = p2z(p.data)
  bc = Derivative::LINEAR_EXT
  delz = gphys.threepoint_O2nd_deriv(pdim, bc, z)
  delz.name = gphys.name+"_z"
  delz.long_name = "del/delz (#{gphys.long_name})"
  delz
end

.pcdata_dz2(gphys, pdim = nil) ⇒ Object

del2/del2z applied to data with the p coordinate



53
54
55
56
57
58
59
60
61
62
# File 'lib/numru/ganalysis/log_p.rb', line 53

def pcdata_dz2(gphys, pdim=nil)
  pdim = Met.find_prs_d(gphys) if !pdim
  p = gphys.axis(pdim).to_gphys
  z = p2z(p.data)
  bc = Derivative::LINEAR_EXT
  delz = gphys.deriv2nd(pdim, bc, z)
  delz.name = gphys.name+"_zz"
  delz.long_name = "del2/del2z (#{gphys.long_name})"
  delz
end

.pcdata_pi_dz_p_dz(gphys, pdim = nil) ⇒ Object

p^-1 del_z ( p del_z self ) where del_z = del/del z



66
67
68
69
70
71
72
73
74
75
# File 'lib/numru/ganalysis/log_p.rb', line 66

def pcdata_pi_dz_p_dz(gphys, pdim=nil)
  pdim = Met.find_prs_d(gphys) if !pdim
  p = gphys.axis(pdim).to_gphys
  z = p2z(p.data)
  bc = Derivative::LINEAR_EXT
  p_dz = gphys.threepoint_O2nd_deriv(pdim, bc, z) * p
  pi_dz_p_p_dz = p_dz.threepoint_O2nd_deriv(pdim, bc, z) / p
  pi_dz_p_p_dz.long_name = "1/p del_z (p del_z #{gphys.name})"
  pi_dz_p_p_dz
end

.set_h(h) ⇒ Object

set the constant log-p scale height (default 7e3 m)

Argument

  • h [Unumeric]



22
23
24
# File 'lib/numru/ganalysis/log_p.rb', line 22

def set_h(h)
  @@H = h
end