class_docstr: A g-h filter of aspecified order 0, 1, or 2.
  
  Strictly speaking, the g-h filter is order 1, and the 2nd order
  filter is called the g-h-k filter. I'm not aware of any filter name
  that encompasses orders 0, 1, and 2 under one name, or I would use it.
  
  
  Parameters
  ----------
  
  x0 : 1D np.array or scalar
      Initial value for the filter state. Each value can be a scalar
      or a np.array.
  
      You can use a scalar for x0. If order > 0, then 0.0 is assumed
      for the higher order terms.
  
      x[0] is the value being tracked
      x[1] is the first derivative (for order 1 and 2 filters)
      x[2] is the second derivative (for order 2 filters)
  
  dt : scalar
      timestep
  
  order : int
      order of the filter. Defines the order of the system
      0 - assumes system of form x = a_0 + a_1*t
      1 - assumes system of form x = a_0 +a_1*t + a_2*t^2
      2 - assumes system of form x = a_0 +a_1*t + a_2*t^2 + a_3*t^3
  
  g : float
      filter g gain parameter.
  
  h : float, optional
      filter h gain parameter, order 1 and 2 only
  
  k : float, optional
      filter k gain parameter, order 2 only
  
  Atrributes
  -------
  
  x : np.array
      State of the filter.
  
      x[0] is the value being tracked
      x[1] is the derivative of x[0] (order 1 and 2 only)
      x[2] is the 2nd derivative of x[0] (order 2 only)
  
      This is always an np.array, even for order 0 where you can
      initialize x0 with a scalar.
  
  y : np.array
      Residual - difference between the measurement and the prediction
  
  dt : scalar
      timestep
  
  order : int
      order of the filter. Defines the order of the system
      0 - assumes system of form x = a_0 + a_1*t
      1 - assumes system of form x = a_0 +a_1*t + a_2*t^2
      2 - assumes system of form x = a_0 +a_1*t + a_2*t^2 + a_3*t^3
  
  g : float
      filter g gain parameter.
  
  h : float
      filter h gain parameter, order 1 and 2 only
  
  k : float
      filter k gain parameter, order 2 only
  
  z : 1D np.array or scalar
      measurement passed into update()
class_docstr_tok: ["A","g-h","filter","of","aspecified","order","0",",","1",",","or","2",".","Strictly","speaking",",","the","g-h","filter","is","order","1",",","and","the","2nd","order","filter","is","called","the","g-h-k","filter",".","I","'m","not","aware","of","any","filter","name","that","encompasses","orders","0",",","1",",","and","2","under","one","name",",","or","I","would","use","it",".","Parameters","--","--","--","--","--","x0",":","1D","np.array","or","scalar","Initial","value","for","the","filter","state",".","Each","value","can","be","a","scalar","or","a","np.array",".","You","can","use","a","scalar","for","x0",".","If","order",">","0",",","then","0.0","is","assumed","for","the","higher","order","terms",".","x","[","0","]","is","the","value","being","tracked","x","[","1","]","is","the","first","derivative","(","for","order","1","and","2","filters",")","x","[","2","]","is","the","second","derivative","(","for","order","2","filters",")","dt",":","scalar","timestep","order",":","int","order","of","the","filter",".","Defines","the","order","of","the","system","0","-","assumes","system","of","form","x","=","a_0","+","a_1","*","t","1","-","assumes","system","of","form","x","=","a_0","+a_1","*","t","+","a_2","*","t^2","2","-","assumes","system","of","form","x","=","a_0","+a_1","*","t","+","a_2","*","t^2","+","a_3","*","t^3","g",":","float","filter","g","gain","parameter",".","h",":","float",",","optional","filter","h","gain","parameter",",","order","1","and","2","only","k",":","float",",","optional","filter","k","gain","parameter",",","order","2","only","Atrributes","--","--","--","-","x",":","np.array","State","of","the","filter",".","x","[","0","]","is","the","value","being","tracked","x","[","1","]","is","the","derivative","of","x","[","0","]","(","order","1","and","2","only",")","x","[","2","]","is","the","2nd","derivative","of","x","[","0","]","(","order","2","only",")","This","is","always","an","np.array",",","even","for","order","0","where","you","can","initialize","x0","with","a","scalar",".","y",":","np.array","Residual","-","difference","between","the","measurement","and","the","prediction","dt",":","scalar","timestep","order",":","int","order","of","the","filter",".","Defines","the","order","of","the","system","0","-","assumes","system","of","form","x","=","a_0","+","a_1","*","t","1","-","assumes","system","of","form","x","=","a_0","+a_1","*","t","+","a_2","*","t^2","2","-","assumes","system","of","form","x","=","a_0","+a_1","*","t","+","a_2","*","t^2","+","a_3","*","t^3","g",":","float","filter","g","gain","parameter",".","h",":","float","filter","h","gain","parameter",",","order","1","and","2","only","k",":","float","filter","k","gain","parameter",",","order","2","only","z",":","1D","np.array","or","scalar","measurement","passed","into","update","(",")"]
docstr: Update the filter with measurement z. z must be the same type
  or treatable as the same type as self.x[0].
docstr_tok: ["Update","the","filter","with","measurement","z.","z","must","be","the","same","type","or","treatable","as","the","same","type","as","self.x","[","0","]","."]
code: def update(self, z, g=None, h=None, k=None):
      """
      Update the filter with measurement z. z must be the same type
      or treatable as the same type as self.x[0].
      """
  
      if self.order == 0:
          if g is None:
              g = self.g
          self.y = z - self.x[0]
          self.x += dot(g, self.y)
  
      elif self.order == 1:
          if g is None:
              g = self.g
          if h is None:
              h = self.h
          x = self.x[0]
          dx = self.x[1]
          dxdt = dot(dx, self.dt)
  
          self.y = z - (x + dxdt)
          self.x[0] = x + dxdt + g * self.y
          self.x[1] = dx + h * self.y / self.dt
  
          self.z = z
  
      else:  # order == 2
          if g is None:
              g = self.g
          if h is None:
              h = self.h
          if k is None:
              k = self.k
  
          x = self.x[0]
          dx = self.x[1]
          ddx = self.x[2]
          dxdt = dot(dx, self.dt)
          T2 = self.dt**2.0
  
          self.y = z - (x + dxdt + 0.5 * ddx * T2)
  
          self.x[0] = x + dxdt + 0.5 * ddx * T2 + g * self.y
          self.x[1] = dx + ddx * self.dt + h * self.y / self.dt
          self.x[2] = ddx + 2 * k * self.y / (self.dt**2)
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import numpy
  from numpy import dot
  from filterpy.common import pretty_str
label_desc: Use image node_id 2 for calling the GHFilterOrder obj's underlying member method code with example usage: obj.update(z, g, h, k) without return types