OOC Methods which return Metadata

Table of Contents

  1. Introduction
  2. Method coordinate
  3. Method count
  4. Method datatype
  5. Method dimension
  6. Method format
  7. Method header
  8. Method label
  9. Method link
  10. Method missing
  11. Method ooc
  12. Method rank
  13. Method sequence
  14. Method shape
  15. Method slot
  16. Method step
  17. Method unit

Introduction

The following code defines vectors "x" and "y" for use in the examples below:
% nap "x = 0 .. 2 ... 0.5"
::NAP::58-58
% nap "y = x ** 2"
::NAP::61-61
% $y val -format %0.3f
0.000 0.250 1.000 2.250 4.000

Method coordinate

ooc_name coordinate ?dim_name|dim_number? ?dim_name|dim_number? …

This returns the OOC-names of the coordinate variables of selected dimensions. If no dimensions are specified then the effect is the same as:
ooc_name coo 0 1 2 … rank-1"

Example:

% $y set coo x
% $y coo
::NAP::58-58
% [$y coo]
0 0.5 1 1.5 2

Method count

ooc_name count -keep

This returns the reference count.

Example (using x defined in previous example):

% $x count
2
Note that the reference count is 2 because this NAO is referenced by both
  • Tcl variable x
  • coordinate variable pointer of NAO ::NAP::61-61

    Method datatype

    ooc_name datatype

    This returns the data-type.

    Example:

    % [nap "'hello'"] dat
    c8
    

    Method dimension

    ooc_name dimension ?dim_number? ?dim_number? …

    This returns the dimension names.

    ooc_name di
    is equivalent to:
    ooc_name di 0 1 2 … rank-1"

    Example (again continuing above example):

    % $y dim
    x
    

    Method format

    ooc_name format

    This returns the C format for printing the NAO.

    Example:

    % $y set format %.4f
    % $y format
    %.4f
    % $y value
    0.0000 0.2500 1.0000 2.2500 4.0000
    

    Method header

    ooc_name header -keep

    This returns similar information to the following (but using a different format):
    ooc_name ooc
    ooc_name datatype
    ooc_name missing
    ooc_name count
    ooc_name unit
    ooc_name shape
    ooc_name dimension
    ooc_name coordinate

    Example (continuing above example):

    % $y header
    ::NAP::61-61  f64  MissingValue: NaN  References: 1  Unit: (NULL)
    Dimension 0   Size: 5      Name: x         Coordinate-variable: ::NAP::58-58
    % 
    

    Method label

    ooc_name label

    This returns the label (title, etc.) of the NAO.

    Example:

    % $y set label "areas of squares"
    % $y label
    areas of squares
    

    Method link

    ooc_name link

    This returns the OOC-name of the link NAO.

    Example:

    % $y set link [nap 42]
    % [$y link]
    42
    

    Method missing

    ooc_name missing

    This returns the missing value. This is the value used to indicate null or undefined data.

    Example:

    % $y miss
    NaN
    

    Method ooc

    ooc_name ooc -keep

    This returns the OOC-name of the NAO.

    Example:

    $y ooc
    ::NAP::61-61
    

    Method rank

    ooc_name rank

    This returns the rank (number of dimensions).

    Example:

    % $y rank
    1
    

    Method sequence

    ooc_name sequence -keep

    This returns the sequence number of the NAO. E.g. 42 for nao.42-9

    -keep: Do not delete NAO with reference count of 0

    Example:

    % $y seq
    61
    

    Method shape

    ooc_name shape

    This returns the shape, which is a vector of dimension sizes.

    Example:

    % $y shape
    5
    

    Method slot

    ooc_name slot -keep

    This returns the slot number of the NAO. E.g. 9 for nao.42-9

    Example:

    % $y sl
    61
    

    Method step

    ooc_name step

    This returns a code which indicates whether step sizes of a vector are equal, and if not, their sign. NAP uses this information for efficiency. It indicates whether a vector (not relevant for other ranks) is monotonically ascending/descending, and if so whether it is an arithmetic progression (AP). The result code is one of following strings:

  • "+-": at least one positive step and one negative step
  • ">= 0": all steps >= 0
  • "<= 0": all steps <= 0
  • "AP": equal steps (except final one which may be shorter)

    Example:

    % [nap "{3 5 7 7.1}"] step
    AP
    

    Method unit

    ooc_name unit

    This returns the unit of measure. This may be used in the future to support arithmetic with automatic unit conversion, but at the moment it is just descriptive information.

    Example:

    % $y set unit seconds
    % $y unit
    seconds
    

    Author: Harvey Davies       © 2002, CSIRO Australia.       Legal Notice and Disclaimer
    CVS Version Details: $Id: ooc_meta.html,v 1.2 2004/10/25 09:01:26 dav480 Exp $