NCSpatialVariable Class Reference

Spatial NetCDF variable (corresponding to a 2D or 3D scalar field). More...

#include <NCSpatialVariable.hh>

Inheritance diagram for NCSpatialVariable:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 NCSpatialVariable ()
virtual void init (string name, IceGrid &g, GridType d)
virtual PetscErrorCode read (const char filename[], unsigned int time, Vec v)
 Read a variable from a file into a global Vec v.
virtual PetscErrorCode reset ()
 Reset all the attributes.
virtual PetscErrorCode write (const char filename[], nc_type nctype, bool write_in_glaciological_units, Vec v)
 Write a global Vec v to a variable.
virtual PetscErrorCode regrid (const char filename[], LocalInterpCtx &lic, bool critical, bool set_default_value, PetscScalar default_value, MaskInterp *, Vec v)
 Regrid from a NetCDF file into a global Vec v.
virtual PetscErrorCode to_glaciological_units (Vec v)
 Converts v from internal to glaciological units.

Public Attributes

bool time_independent

Protected Member Functions

PetscErrorCode define (int ncid, nc_type nctype, int &varid)
 Define a NetCDF variable corresponding to a NCVariable object.
PetscErrorCode report_range (Vec v, bool found_by_standard_name)
 Report the range of a global Vec v.
PetscErrorCode change_units (Vec v, utUnit *from, utUnit *to)
 Converts v from the units corresponding to from to the ones corresponding to to.
PetscErrorCode check_range (Vec v)
 Check if the range of a global Vec v is in the range specified by valid_min and valid_max attributes.

Protected Attributes

GridType dims
IceGridgrid

Detailed Description

Spatial NetCDF variable (corresponding to a 2D or 3D scalar field).

Definition at line 9 of file NCSpatialVariable.hh.


Constructor & Destructor Documentation

Definition at line 94 of file NCVariable.cc.

References grid, and reset().


Member Function Documentation

PetscErrorCode change_units ( Vec  v,
utUnit *  from,
utUnit *  to 
) [protected]

Converts v from the units corresponding to from to the ones corresponding to to.

Does nothing if this transformation is trivial.

Definition at line 374 of file NCVariable.cc.

References NCVariable.com, e, and NCVariable.short_name.

Referenced by read(), regrid(), to_glaciological_units(), and write().

PetscErrorCode check_range ( Vec  v  )  [protected]

Check if the range of a global Vec v is in the range specified by valid_min and valid_max attributes.

Definition at line 567 of file NCVariable.cc.

References NCVariable.com, grid, NCVariable.has(), NCVariable.short_name, NCVariable.strings, fill_missing.valid_max, fill_missing.valid_min, and verbPrintf().

Referenced by regrid().

PetscErrorCode define ( int  ncid,
nc_type  nctype,
int &  varid 
) [protected]

Define a NetCDF variable corresponding to a NCVariable object.

Definition at line 607 of file NCVariable.cc.

References check_err(), NCVariable.com, dims, grid, GRID_2D, GRID_3D, GRID_3D_BEDROCK, NCVariable.rank, NCVariable.short_name, and time_independent.

Referenced by write().

void init ( string  name,
IceGrid g,
GridType  d 
) [virtual]

Definition at line 99 of file NCVariable.cc.

References IceGrid.com, dims, grid, IceGrid.rank, and NCVariable.short_name.

PetscErrorCode read ( const char  filename[],
unsigned int  time,
Vec  v 
) [virtual]

Read a variable from a file into a global Vec v.

This also converts the data from input units to internal units if needed.

Definition at line 109 of file NCVariable.cc.

References change_units(), NCTool.close(), NCVariable.com, IceGrid.da2, dims, NCTool.find_variable(), NCTool.get_units(), PISMIO.get_var(), grid, NCVariable.has(), vnreport.nc, NCTool.open_for_reading(), NCVariable.short_name, NCVariable.strings, NCVariable.units, and verbPrintf().

PetscErrorCode regrid ( const char  filename[],
LocalInterpCtx lic,
bool  critical,
bool  set_default_value,
PetscScalar  default_value,
MaskInterp interpolation_mask,
Vec  v 
) [virtual]

Regrid from a NetCDF file into a global Vec v.

  • stops if critical == true and the variable was not found
  • sets v to default_value if set_default_value == true and the variable was not found
  • interpolation mask can be NULL if it is not used.

Definition at line 213 of file NCVariable.cc.

References change_units(), check_range(), NCTool.close(), NCVariable.com, IceGrid.da2, dims, NCTool.find_variable(), NCTool.get_units(), NCVariable.glaciological_units, grid, NCVariable.has(), vnreport.nc, NCTool.open_for_reading(), NCVariable.read_valid_range(), PISMIO.regrid_var(), report_range(), LocalInterpCtx.report_range, PISMIO.set_MaskInterp(), NCVariable.short_name, NCVariable.strings, NCVariable.units, and verbPrintf().

PetscErrorCode report_range ( Vec  v,
bool  found_by_standard_name 
) [protected]

Report the range of a global Vec v.

Definition at line 523 of file NCVariable.cc.

References NCVariable.com, NCVariable.glaciological_units, NCVariable.has(), NCVariable.short_name, NCVariable.strings, NCVariable.units, and verbPrintf().

Referenced by regrid().

PetscErrorCode reset (  )  [virtual]

Reset all the attributes.

Reimplemented from NCVariable.

Definition at line 85 of file NCVariable.cc.

References NCVariable.strings, and time_independent.

Referenced by NCSpatialVariable().

PetscErrorCode to_glaciological_units ( Vec  v  )  [virtual]

Converts v from internal to glaciological units.

Definition at line 366 of file NCVariable.cc.

References change_units(), NCVariable.glaciological_units, and NCVariable.units.

PetscErrorCode write ( const char  filename[],
nc_type  nctype,
bool  write_in_glaciological_units,
Vec  v 
) [virtual]

Member Data Documentation

GridType dims [protected]

Definition at line 23 of file NCSpatialVariable.hh.

Referenced by define(), init(), read(), regrid(), and write().

IceGrid* grid [protected]

Definition at line 24 of file NCSpatialVariable.hh.

Referenced by check_range(), define(), init(), NCSpatialVariable(), read(), regrid(), and write().

Definition at line 21 of file NCSpatialVariable.hh.

Referenced by define(), and reset().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Defines
Generated by  doxygen 1.6.2-20100124