Method: NumRu::GPhys#coord_data_reverse

Defined in:
lib/numru/gphys/interpolate.rb

#coord_data_reverse(axname, pos) ⇒ Object

Reverse the main data (i.e., the dependent variable) and one of the coordinates (an independent variable) through interpolation.

Returns a GPhys in which the main data is the specfied coordinate (argument: axname) sampled at specified locations (argument: pos) in terms of the main data of self. The main data of self is expected to be quai-monotonic with respect to the specfied coordinate.

ARGUMENTS

  • axname [String] : one of the names of the axes (i.e. main coordinates. Auxiliary coordinates are not supported as the target.)

  • pos [NArray] : grid locations. For example, if the current data is potential temperature theta, pos consists of the theta levels to make sampling.

RETURN VALUE

  • a GPhys



310
311
312
313
314
315
316
317
318
319
# File 'lib/numru/gphys/interpolate.rb', line 310

def coord_data_reverse(axname,pos)
  gp = self.axis(axname).to_gphys
  gp = self.shape_coerce_full(gp)[0]   # conform the shape to that of self
  gp = GPhys.new( gp.grid.copy, gp.data )  # copy grid to avoid side effect
                                           # on the grid of self
  gp.set_assoc_coords([self])
  pos = NArray[*pos].to_type(NArray::FLOAT) if pos.is_a?(Array)
  newcrd = VArray.new(pos,self.data,self.name)  # succeeds the attributes
  gp.interpolate(axname=>newcrd)
end