Module: NumRu

Included in:
TC_GPhys_grid_op
Defined in:
lib/numru/gphys/axis.rb,
lib/numru/gdir.rb,
lib/numru/htdir.rb,
lib/numru/dclext.rb,
lib/numru/ggraph.rb,
lib/numru/dcl_mouse.rb,
lib/numru/ganalysis.rb,
lib/numru/derivative.rb,
lib/numru/gphys/grib.rb,
lib/numru/gphys/grid.rb,
lib/numru/gphys/gphys.rb,
lib/numru/ganalysis/qg.rb,
lib/numru/gphys/gtool3.rb,
lib/numru/gphys/varray.rb,
lib/numru/ganalysis/eof.rb,
lib/numru/ganalysis/met.rb,
lib/numru/ganalysis/pde.rb,
lib/numru/gphys/ep_flux.rb,
lib/numru/gphys/version.rb,
lib/numru/gphys/gphys_io.rb,
lib/numru/gphys/unumeric.rb,
lib/numru/ganalysis/log_p.rb,
lib/numru/ganalysis/met_z.rb,
lib/numru/gphys/attribute.rb,
lib/numru/gphys/gphys_fft.rb,
lib/numru/gphys/mdstorage.rb,
lib/numru/ganalysis/planet.rb,
lib/numru/gphys/derivative.rb,
lib/numru/gphys/varraygrib.rb,
lib/numru/ganalysis/fitting.rb,
lib/numru/gphys/assoccoords.rb,
lib/numru/gphys/interpolate.rb,
lib/numru/gphys/interpolate.rb,
lib/numru/gphys/varraygrads.rb,
lib/numru/gphys/coordmapping.rb,
lib/numru/gphys/gphys_dim_op.rb,
lib/numru/gphys/varraygtool3.rb,
lib/numru/gphys/varraynetcdf.rb,
lib/numru/gphys/varraynusdas.rb,
lib/numru/ganalysis/histogram.rb,
lib/numru/gphys/gphys_grib_io.rb,
lib/numru/gphys/grads_gridded.rb,
lib/numru/gphys/subsetmapping.rb,
lib/numru/gphys/varrayhdfeos5.rb,
lib/numru/ganalysis/beta_plane.rb,
lib/numru/ganalysis/covariance.rb,
lib/numru/gphys/coordtransform.rb,
lib/numru/gphys/gphys_grads_io.rb,
lib/numru/ganalysis/sigma_coord.rb,
lib/numru/gphys/attributenetcdf.rb,
lib/numru/gphys/gphys_gtool3_io.rb,
lib/numru/gphys/gphys_io_common.rb,
lib/numru/gphys/gphys_netcdf_io.rb,
lib/numru/gphys/gphys_nusdas_io.rb,
lib/numru/gphys/varraycomposite.rb,
lib/numru/gphys/gphys_hdfeos5_io.rb,
lib/numru/gphys/netcdf_convention.rb,
lib/numru/ggraph_on_merdional_section.rb,
lib/numru/ganalysis/sph_harmonic_iso_g.rb,
ext/numru/gphys/dim_op.c,
ext/numru/gphys/interpo.c,
ext/numru/gphys/ext_coord.c,
ext/numru/gphys/multibitIO.c,
ext/numru/ganalysis/pde_ext.c,
ext/numru/gphys/quad_mesh_sample.c,
ext/numru/ganalysis/narray_ext_dfloat.c

Overview

INDEX

  • ((<module NumRu::NetCDF_Conventions>))

  • ((<module NumRu::NetCDF_Convention_Users_Guide>))

    • ((<module NumRu::NetCDF_Convention_Users_Guide::Attribute_Mixin>))

    • ((<module NumRu::NetCDF_Convention_Users_Guide::VArray_Mixin>))

  • ((<module NumRu::NetCDF_Convention_Wind_Profiler>))

module NumRu::NetCDF_Conventions

NetCDF_Conventions is the general handler of NetCDF conventions for the GPhys library.

Module Functions

—find( netcdf )

Figures out what NetCDF convention a netcdf file is following.

ARGUMENTS
* ((|netcdf|)) (NetCDF): the file

RETURN VALUE
* a Module (NumRu::NetCDF_Convention_Users_Guide etc.)

REMARK
* The convention is figured out from the 'Conventions' global attribute.
  You can instead fix the convention by using ((<fix_to>)).

—fix_to( convention )

Fix the convention to be returned by ((<find>)) regardless the value
of the 'Conventions' attribute.

ARGUMENTS
* ((|convention|)) (Module): NumRu::NetCDF_Convention_Users_Guide etc.

RETURN VALUE
* convention

—add_history(netcdf, str=nil)

Adds a line to the 'history' global convention of ((|netcdf|)).
The line consists of date, time, user name, and ((|str|)) 
if present (e.g., '2004-03-02 17:52:25 JST horinout> '+str).

ARGUMENTS
* ((|netcdf|)) (NetCDF): the file in which the history is updated
* ((|str|)) (nil or String): if present, added to the end of the line.

module NumRu::NetCDF_Convention_Users_Guide

The NetCDF Users Guide Convention (www.unidata.ucar.edu/packages/netcdf/docs.html).

Constants

—Attribute_Mixin

See below: ((<module NumRu::NetCDF_Convention_Users_Guide::Attribute_Mixin>)).

—VArray_Mixin

See below: ((<module NumRu::NetCDF_Convention_Users_Guide::VArray_Mixin>)).

Module Functions

—to_s

Returns a string to be used as representing the convention.
The Users Guide Convention does not have one, so a string 
was tentatively assigned by Horinouchi.

—coord_var_names(ncvar)

Returns the names of coordinate variables for all the dimensions
of ((|ncvar|)).

ARGUMENTS
* ((|ncvar|)) (NetCDFVar)

RETURN VALUE
* Array of strings, whose length is the rank of ((|ncvar|)).

—cell_bounds?(coord_var)

Document to be written. (returns false&nil in this convention.)
Might be reorganized in future when the gtool4 convention is supported.

—cell_center?(coord_var)

Document to be written. (returns false&nil in this convention.)
Might be reorganized in future when the gtool4 convention is supported.

module NumRu::NetCDF_Convention_Users_Guide::Attribute_Mixin

The module to be mixed in NumRu::AttributeNetCDF.

Instance Methods

Methods below will become sigular methods of NumRu::AttributeNetCDF.

—copy(to=nil)

Same as (('super')) (the one overridden by this method), 
but edits some standard attributes if (('to')) is nil (copy onto memory)):
* scale_factor, add_offset: removed, since data copying includes 
  "unpaking" by interpreting them
* valid_*, missing_value: unpacked if packed.
* _FillValue, FORTRAN_format, C_format: eliminated

module NumRu::NetCDF_Convention_Users_Guide::VArray_Mixin

The module to be mixed in NumRu::VArrayNetCDF.

Instance Methods

Currently none, meaning is that no modification is made in VArrayNetCDF.


module NumRu::NetCDF_Convention_Wind_Profiler

The Wind Profiler convention (www.kurasc.kyoto-u.ac.jp/radar-group/wind_profiler_conventions/).

Inherits NetCDF_Convention_Users_Guide and makes appropriate redefinitions. See ((<module NumRu::NetCDF_Convention_Users_Guide>)) for the description of constants and module functions.

Defined Under Namespace

Modules: DCLExt, Derivative, GAnalysis, GGraph, IndexMixin, NArrayExt, NetCDFDeferred, NetCDFVarDeferred, NetCDF_Convention_CF, NetCDF_Convention_Users_Guide, NetCDF_Convention_Wind_Profiler, NetCDF_Conventions Classes: AssocCoords, Attribute, AttributeNetCDF, Axis, CoordMapping, DCLMouseLine, DCLMousePt, GDir, GPhys, GrADSVar, GrADS_Gridded, Grid, Gtool3, Gtool3TimeVal, Gtool3Var, LinearCoordMapping, MDStorage, MultibitIO, NetCDF, NetCDFVar, SubsetMapping, SubsetMapping1D, UNumeric, Units, VArray, VArrayComposite, VArrayGrADS, VArrayGrib, VArrayGtool3, VArrayGtool3Time, VArrayHE5GdField, VArrayHE5SwField, VArrayHE5ZaField, VArrayNetCDF, VArrayNuSDaS

Constant Summary collapse

ATTR_CF_CONV =
{
  "DSET" => "dataset",
  "TITLE" => "long_name",
  "UNIT" => "units",
  "MISS" => "missing_value"
#    "ITEM" => nil,       # identical to name
#    "TIME" => nil,       # treated in the time axis
#    "DATE" => nil,       # treated in the time axis
#    "UTIM" => nil,       # treated in the time axis
#    "TDUR" => nil,       # in Future, should be treaded with cell_* in CF
#    "CSIGN" => nil,      # will be in history in convination
#    "CDATE" => nil       # will be in history in convination
#    "MDATE" => nil,      # will be in history in convination
#    "MSIGN" =>  nil,     # will be in history in convination
}

Instance Method Summary collapse

Instance Method Details

#linear_reg_slope_error(x, y, a, b) ⇒ Object



3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
# File 'lib/numru/ggraph.rb', line 3380

def linear_reg_slope_error(x,y,a,b)
  if x.respond_to?(:count_sum)
    n = x.count_sum
  else
    n = x.size
  end
  raise("data length (#{n}) must be greater than 2") if n<=2
  dy = y - (a + b*x)
  sig2y = (dy*dy).sum / (n-2)  # \sig_y^2    : Taylor (8.15)
  xe = x - x.mean
  delta_n = (xe*xe).sum        # \Delta / N  : Taylor (8.12)
  err = NMMath.sqrt( sig2y / delta_n )       # Taylor (8.17)
end

#linear_regression(x, y) ⇒ Object



3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
# File 'lib/numru/ggraph.rb', line 3368

def linear_regression(x,y)
  cxy, ndiv = NMMath.covariance(x,y)
  cxx, ndiv = NMMath.covariance(x,x)
  mx = x.mean
  my = y.mean
  b = cxy/cxx
  a = my - b*mx
  cyy, ndiv = NMMath.covariance(y,y)
  r = cxy/Math.sqrt(cxx*cyy)
  [a,b,r]
end