## visad.data.vis5d
Class V5DStruct

    java.lang.Object
      visad.data.vis5d.V5DStruct

public class V5DStruct
extends Object

An object representing the structure of a .v5d file.

Field Summary
`int` `CompressMode` 1, 2 or 4 = # bytes per grid point
`(package private) int` `CurPos` current position of file pointer
`int[]` `DateStamp` Date in YYDDD format
`String` `FileVersion` 9-character version number
`(package private) int` `FirstGridPos` position of first grid in file
`(package private) int[]` `GridSize` size of each grid
`int[]` `LowLev` Lowest level per variable
`float[]` `MaxVal` Maximum variable data values
`short[][]` `McFile` McIDAS file number in 1..9999
`short[][]` `McGrid` McIDAS grid number in 1..?
`float[]` `MinVal` Minimum variable data values
`(package private) char` `Mode` 'r' = read, 'w' = write
`int` `Nc` Number of columns
`int[]` `Nl` Number of levels per variable
`int` `Nr` Number of rows
`int` `NumTimes` Number of time steps
`int` `NumVars` Number of variables
`float[]` `ProjArgs` Map projection arguments.
`int` `Projection` Which map projection
`(package private) int` `SumGridSizes` sum of GridSize[0..NumVars-1]
`static int` `TAG_BOTTOMBOUND` real*4 BottomBound (PHASED OUT)
`static int` `TAG_CENTCOL` real*4 CentralCol (PHASED OUT)
`static int` `TAG_CENTLAT` real*4 CentralLat (PHASED OUT)
`static int` `TAG_CENTLON` real*4 CentralLon (PHASED OUT)
`static int` `TAG_CENTROW` real*4 CentralRow (PHASED OUT)
`static int` `TAG_COLINC` real*4 ColInc (PHASED OUT)
`static int` `TAG_COMPRESS` int*4 CompressMode; (#bytes/grid)
`static int` `TAG_DATE` int*4 t; int*4 DateStamp[t]
`static int` `TAG_END`
`static int` `TAG_HEIGHT` int*4 l; real*4 Height[l] (PHASED OUT)
`static int` `TAG_ID` hex encoding of "V5D\n"
`static int` `TAG_LAT1` real*4 Lat1 (PHASED OUT)
`static int` `TAG_LAT2` real*4 Lat2 (PHASED OUT)
`static int` `TAG_LEVINC` real*4 LevInc (PHASED OUT)
`static int` `TAG_LOWLEV_VAR` int*4 var; int*4 LowLev[var]
`static int` `TAG_MAXVAL` int*4 var; real*4 MaxVal[var]
`static int` `TAG_MINVAL` int*4 var; real*4 MinVal[var]
`static int` `TAG_NC` int*4 Nc
`static int` `TAG_NL` int*4 Nl (Nl for all vars)
`static int` `TAG_NL_VAR` int*4 var; int*4 Nl[var]
`static int` `TAG_NORTHBOUND` real*4 NorthBound (PHASED OUT)
`static int` `TAG_NR` int*4 Nr
`static int` `TAG_NUMTIMES` int*4 NumTimes
`static int` `TAG_NUMVARS` int*4 NumVars
`static int` `TAG_POLE_COL` real*4 PoleCol (PHASED OUT)
`static int` `TAG_POLE_ROW` real*4 PoleRow (PHASED OUT)
`static int` `TAG_PROJ_ARGS` int*4 n; real*4 ProjArgs[0..n-1]
`static int` `TAG_PROJECTION` int*4 projection.
`static int` `TAG_ROTATION` real*4 Rotation (PHASED OUT)
`static int` `TAG_ROWINC` real*4 RowInc (PHASED OUT)
`static int` `TAG_TIME` int*4 t; int*4 TimeStamp[t]
`static int` `TAG_UNITS` int *4 var; char*20 Units[var]
`static int` `TAG_VARNAME` int*4 var; char*10 VarName[var]
`static int` `TAG_VERSION` char*10 FileVersion
`static int` `TAG_VERT_ARGS` int*4 n; real*4 VertArgs[0..n-1]
`static int` `TAG_VERTICAL_SYSTEM` int*4 VerticalSystem
`static int` `TAG_WESTBOUND` real*4 WestBound (PHASED OUT)
`int[]` `TimeStamp` Time in HHMMSS format
`char[][]` `Units` 19-character units for variables
`char[][]` `VarName` 9-character variable names
`float[]` `VertArgs` Vertical Coordinate System arguments.
`int` `VerticalSystem` Which vertical coordinate system

Constructor Summary
`(package private)` `V5DStruct()` Construct and initialize a V5DStruct to reasonable initial values.

Method Summary
`static int` `getUnsignedByte(byte b)` Convert a signed byte to an unsigned one, and return it in an int
`static int` `getUnsignedInt(byte b1, byte b2, byte b3, byte b4)` Convert four signed bytes to an unsigned short, and return it in an int
`static int` `getUnsignedShort(byte b1, byte b2)` Convert two signed bytes to an unsigned short, and return it in an int
`(package private) int` `grid_position(int time, int vr)` Compute the location of a compressed grid within a file.
`(package private) boolean` `read_comp_grid(int time, int vr, float[] ga, float[] gb, byte[] compdata1)` Read a compressed grid from a COMP* file.
`(package private) boolean` `read_comp_header()` Read the header from a COMP* file and return results in the V5DStruct.
`(package private) boolean` `read_v5d_header()` Read a v5d file header.
`static V5DStruct` `v5d_open(byte[] name, int name_length, int[] sizes, int[] n_levels, String[] var_names, String[] var_units, int[] map_proj, float[] projargs, int[] vert_sys, float[] vert_args, double[] times)` Open a Vis5D file
`void` `v5d_read(int time, int vr, float[] ranges, float[] data)` Read from a Vis5D file
`(package private) boolean` `v5dCloseFile()` Close a v5d file which was opened with open_v5d_file() or create_v5d_file().
`(package private) boolean` `v5dCreateFile(String filename)` Open a v5d file for writing.
`(package private) boolean` `v5dGetMcIDASgrid(int time, int vr, int[] mcfile, int[] mcgrid)` Get the McIDAS file number and grid number associated with the grid identified by time and var.
`(package private) boolean` `v5dReadCompressedGrid(int time, int vr, float[] ga, float[] gb, byte[] compdata)` Read a compressed grid from a v5d file.
`(package private) boolean` `v5dReadGrid(int time, int vr, float[] data)` Read a grid from a v5d file, decompress it and return it.
`(package private) boolean` `v5dSetMcIDASgrid(int time, int vr, int mcfile, int mcgrid)` Set the McIDAS file number and grid number associated with the grid identified by time and var.
`(package private) int` `v5dSizeofGrid(int time, int vr)` Return the size (in bytes) of the 3-D grid specified by time and var.
`(package private) boolean` `v5dVerifyStruct()` Do some checking that the information in a V5DStruct is valid.
`(package private) boolean` `v5dWriteCompressedGrid(int time, int vr, float[] ga, float[] gb, byte[] compdata)` Write a compressed grid to a v5d file.
`(package private) boolean` `v5dWriteGrid(int time, int vr, float[] data)` Compress a grid and write it to a v5d file.
`(package private) boolean` `write_tag(int tag, int length, boolean newfile)`
`(package private) boolean` `write_v5d_header()` Write the information in the given V5DStruct as a v5d file header.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### TAG_ID

    public static final int TAG_ID

  hex encoding of "V5D\n"

  See Also:
    Constant Field Values

### TAG_VERSION

    public static final int TAG_VERSION

  char*10 FileVersion

  See Also:
    Constant Field Values

### TAG_NUMTIMES

    public static final int TAG_NUMTIMES

  int*4 NumTimes

  See Also:
    Constant Field Values

### TAG_NUMVARS

    public static final int TAG_NUMVARS

  int*4 NumVars

  See Also:
    Constant Field Values

### TAG_VARNAME

    public static final int TAG_VARNAME

  int*4 var; char*10 VarName[var]

  See Also:
    Constant Field Values

### TAG_NR

    public static final int TAG_NR

  int*4 Nr

  See Also:
    Constant Field Values

### TAG_NC

    public static final int TAG_NC

  int*4 Nc

  See Also:
    Constant Field Values

### TAG_NL

    public static final int TAG_NL

  int*4 Nl (Nl for all vars)

  See Also:
    Constant Field Values

### TAG_NL_VAR

    public static final int TAG_NL_VAR

  int*4 var; int*4 Nl[var]

  See Also:
    Constant Field Values

### TAG_LOWLEV_VAR

    public static final int TAG_LOWLEV_VAR

  int*4 var; int*4 LowLev[var]

  See Also:
    Constant Field Values

### TAG_TIME

    public static final int TAG_TIME

  int*4 t; int*4 TimeStamp[t]

  See Also:
    Constant Field Values

### TAG_DATE

    public static final int TAG_DATE

  int*4 t; int*4 DateStamp[t]

  See Also:
    Constant Field Values

### TAG_MINVAL

    public static final int TAG_MINVAL

  int*4 var; real*4 MinVal[var]

  See Also:
    Constant Field Values

### TAG_MAXVAL

    public static final int TAG_MAXVAL

  int*4 var; real*4 MaxVal[var]

  See Also:
    Constant Field Values

### TAG_COMPRESS

    public static final int TAG_COMPRESS

  int*4 CompressMode; (#bytes/grid)

  See Also:
    Constant Field Values

### TAG_UNITS

    public static final int TAG_UNITS

  int *4 var; char*20 Units[var]

  See Also:
    Constant Field Values

### TAG_VERTICAL_SYSTEM

    public static final int TAG_VERTICAL_SYSTEM

  int*4 VerticalSystem

  See Also:
    Constant Field Values

### TAG_VERT_ARGS

    public static final int TAG_VERT_ARGS

  int*4 n; real*4 VertArgs[0..n-1]

  See Also:
    Constant Field Values

### TAG_BOTTOMBOUND

    public static final int TAG_BOTTOMBOUND

  real*4 BottomBound (PHASED OUT)

  See Also:
    Constant Field Values

### TAG_LEVINC

    public static final int TAG_LEVINC

  real*4 LevInc (PHASED OUT)

  See Also:
    Constant Field Values

### TAG_HEIGHT

    public static final int TAG_HEIGHT

  int*4 l; real*4 Height[l] (PHASED OUT)

  See Also:
    Constant Field Values

### TAG_PROJECTION

    public static final int TAG_PROJECTION

  int*4 projection.
  - 0 = generic linear
  - 1 = cylindrical equidistant
  - 2 = Lambert conformal/Polar Stereo
  - 3 = rotated equidistant

    See Also:
      Constant Field Values

### TAG_PROJ_ARGS

    public static final int TAG_PROJ_ARGS

  int*4 n; real*4 ProjArgs[0..n-1]

  See Also:
    Constant Field Values

### TAG_NORTHBOUND

    public static final int TAG_NORTHBOUND

  real*4 NorthBound (PHASED OUT)

  See Also:
    Constant Field Values

### TAG_WESTBOUND

    public static final int TAG_WESTBOUND

  real*4 WestBound (PHASED OUT)

  See Also:
    Constant Field Values

### TAG_ROWINC

    public static final int TAG_ROWINC

  real*4 RowInc (PHASED OUT)

  See Also:
    Constant Field Values

### TAG_COLINC

    public static final int TAG_COLINC

  real*4 ColInc (PHASED OUT)

  See Also:
    Constant Field Values

### TAG_LAT1

    public static final int TAG_LAT1

  real*4 Lat1 (PHASED OUT)

  See Also:
    Constant Field Values

### TAG_LAT2

    public static final int TAG_LAT2

  real*4 Lat2 (PHASED OUT)

  See Also:
    Constant Field Values

### TAG_POLE_ROW

    public static final int TAG_POLE_ROW

  real*4 PoleRow (PHASED OUT)

  See Also:
    Constant Field Values

### TAG_POLE_COL

    public static final int TAG_POLE_COL

  real*4 PoleCol (PHASED OUT)

  See Also:
    Constant Field Values

### TAG_CENTLON

    public static final int TAG_CENTLON

  real*4 CentralLon (PHASED OUT)

  See Also:
    Constant Field Values

### TAG_CENTLAT

    public static final int TAG_CENTLAT

  real*4 CentralLat (PHASED OUT)

  See Also:
    Constant Field Values

### TAG_CENTROW

    public static final int TAG_CENTROW

  real*4 CentralRow (PHASED OUT)

  See Also:
    Constant Field Values

### TAG_CENTCOL

    public static final int TAG_CENTCOL

  real*4 CentralCol (PHASED OUT)

  See Also:
    Constant Field Values

### TAG_ROTATION

    public static final int TAG_ROTATION

  real*4 Rotation (PHASED OUT)

  See Also:
    Constant Field Values

### TAG_END

    public static final int TAG_END

See Also:
  Constant Field Values

### NumTimes

    public int NumTimes

  Number of time steps

### NumVars

    public int NumVars

  Number of variables

### Nr

    public int Nr

  Number of rows

### Nc

    public int Nc

  Number of columns

### Nl

    public int[] Nl

  Number of levels per variable

### LowLev

    public int[] LowLev

  Lowest level per variable

### VarName

    public char[][] VarName

  9-character variable names

### Units

    public char[][] Units

  19-character units for variables

### TimeStamp

    public int[] TimeStamp

  Time in HHMMSS format

### DateStamp

    public int[] DateStamp

  Date in YYDDD format

### MinVal

    public float[] MinVal

  Minimum variable data values

### MaxVal

    public float[] MaxVal

  Maximum variable data values

### McFile

    public short[][] McFile

  McIDAS file number in 1..9999

### McGrid

    public short[][] McGrid

  McIDAS grid number in 1..?

### VerticalSystem

    public int VerticalSystem

  Which vertical coordinate system

### VertArgs

    public float[] VertArgs

  Vertical Coordinate System arguments.

            IF VerticalSystem==0 THEN
                -- Linear scale, equally-spaced levels in generic units
                VertArgs[0] = Height of bottom-most grid level in generic units
                VertArgs[1] = Increment between levels in generic units
            ELSE IF VerticalSystem==1 THEN
                -- Linear scale, equally-spaced levels in km
                VertArgs[0] = Height of bottom grid level in km
                VertArgs[1] = Increment between levels in km
            ELSE IF VerticalSystem==2 THEN
                -- Linear scale, Unequally spaced levels in km
                VertArgs[0] = Height of grid level 0 (bottom) in km
                ...                ...
                VertArgs[n] = Height of grid level n in km
            ELSE IF VerticalSystem==3 THEN
                -- Linear scale, Unequally spaced levels in mb
                VertArgs[0] = Pressure of grid level 0 (bottom) in mb
                ...             ...
                VertArgs[n] = Pressure of grid level n in mb
            ENDIF

### Projection

    public int Projection

  Which map projection

### ProjArgs

    public float[] ProjArgs

  Map projection arguments.

            IF Projection==0 THEN
                -- Rectilinear grid, generic units
                ProjArgs[0] = North bound, Y coordinate of grid row 0
                ProjArgs[1] = West bound, X coordiante of grid column 0
                ProjArgs[2] = Increment between rows
                ProjArgs[3] = Increment between colums
                NOTES: X coordinates increase to the right, Y increase upward.
                NOTES: Coordinate system is right-handed.
           ELSE IF Projection==1 THEN
                -- Cylindrical equidistant (Old VIS-5D)
                -- Rectilinear grid in lat/lon
                ProjArgs[0] = Latitude of grid row 0, north bound, in degrees
                ProjArgs[1] = Longitude of grid column 0, west bound, in deg.
                ProjArgs[2] = Increment between rows in degrees
                ProjArgs[3] = Increment between rows in degrees
                NOTES: Coordinates (degrees) increase to the left and upward.
           ELSE IF Projection==2 THEN
                -- Lambert conformal
                ProjArgs[0] = Standared Latitude 1 of conic projection
                ProjArgs[1] = Standared Latitude 2 of conic projection
                ProjArgs[2] = Row of North/South pole
                ProjArgs[3] = Column of North/South pole
                ProjArgs[4] = Longitude which is parallel to columns
                ProjArgs[5] = Increment between grid columns in km
            ELSE IF Projection==3 THEN
                -- Polar Stereographic
                ProjArgs[0] = Latitude of center of projection
                ProjArgs[1] = Longitude of center of projection
                ProjArgs[2] = Grid row of center of projection
                ProjArgs[3] = Grid column of center of projection
                ProjArgs[4] = Increment between grid columns at center in km
            ELSE IF Projection==4 THEN
                -- Rotated
                ProjArgs[0] = Latitude on rotated globe of grid row 0
                ProjArgs[1] = Longitude on rotated globe of grid column 0
                ProjArgs[2] = Degrees of latitude on rotated globe between
                              grid rows
                ProjArgs[3] = Degrees of longitude on rotated globe between
                              grid columns
                ProjArgs[4] = Earth latitude of (0, 0) on rotated globe
                ProjArgs[5] = Earth longitude of (0, 0) on rotated globe
                ProjArgs[6] = Clockwise rotation of rotated globe in degrees
            ENDIF

### CompressMode

    public int CompressMode

  1, 2 or 4 = # bytes per grid point

### FileVersion

    public String FileVersion

  9-character version number

### Mode

    char Mode

  'r' = read, 'w' = write

### CurPos

    int CurPos

  current position of file pointer

### FirstGridPos

    int FirstGridPos

  position of first grid in file

### GridSize

    int[] GridSize

  size of each grid

### SumGridSizes

    int SumGridSizes

  sum of GridSize[0..NumVars-1]

Constructor Detail

### V5DStruct

    V5DStruct()

  Construct and initialize a V5DStruct to reasonable initial values.

Method Detail

### v5d_open

    public static V5DStruct v5d_open(byte[] name,
                                     int name_length,
                                     int[] sizes,
                                     int[] n_levels,
                                     String[] var_names,
                                     String[] var_units,
                                     int[] map_proj,
                                     float[] projargs,
                                     int[] vert_sys,
                                     float[] vert_args,
                                     double[] times)
                              throws IOException,
                                     BadFormException

  Open a Vis5D file

  Throws:
    `IOException`
    `BadFormException`

### v5d_read

    public void v5d_read(int time,
                         int vr,
                         float[] ranges,
                         float[] data)
                  throws IOException,
                         BadFormException

  Read from a Vis5D file

  Throws:
    `IOException`
    `BadFormException`

### getUnsignedByte

    public static int getUnsignedByte(byte b)

  Convert a signed byte to an unsigned one, and return it in an int

### getUnsignedShort

    public static int getUnsignedShort(byte b1,
                                       byte b2)

  Convert two signed bytes to an unsigned short, and return it in an int

### getUnsignedInt

    public static int getUnsignedInt(byte b1,
                                     byte b2,
                                     byte b3,
                                     byte b4)

  Convert four signed bytes to an unsigned short, and return it in an int

### v5dSizeofGrid

    int v5dSizeofGrid(int time,
                      int vr)

  Return the size (in bytes) of the 3-D grid specified by time and var.

  Parameters:
    `time` - timestep
    `vr` - variable
  Returns:
    number of data points

### grid_position

    int grid_position(int time,
                      int vr)
                throws BadFormException

  Compute the location of a compressed grid within a file.

  Parameters:
    `time` - timestep vr variable
  Returns:
    file offset in bytes
  Throws:
    `BadFormException`

### v5dVerifyStruct

    boolean v5dVerifyStruct()

  Do some checking that the information in a V5DStruct is valid.

  Returns:
    true if V5DStruct is ok, false if V5DStruct is invalid

### v5dGetMcIDASgrid

    boolean v5dGetMcIDASgrid(int time,
                             int vr,
                             int[] mcfile,
                             int[] mcgrid)

  Get the McIDAS file number and grid number associated with the grid identified by time and var.

  Parameters:
    `time` - timestep
    `vr` - variable
    `mcfile` - one-element int array for storing McIDAS grid file number
    `mcgrid` - one-element int array for storing McIDAS grid number

### v5dSetMcIDASgrid

    boolean v5dSetMcIDASgrid(int time,
                             int vr,
                             int mcfile,
                             int mcgrid)

  Set the McIDAS file number and grid number associated with the grid identified by time and var.

  Parameters:
    `time` - timestep
    `vr` - variable
    `mcfile` - McIDAS grid file number
    `mcgrid` - McIDAS grid number
  Returns:
    true = ok, false = error (bad time or var)

### read_comp_header

    boolean read_comp_header()
                       throws IOException

  Read the header from a COMP* file and return results in the V5DStruct.

  Returns:
    true = ok, false = error.
  Throws:
    `IOException`

### read_comp_grid

    boolean read_comp_grid(int time,
                           int vr,
                           float[] ga,
                           float[] gb,
                           byte[] compdata1)
                     throws IOException,
                            BadFormException

  Read a compressed grid from a COMP* file.

  Returns:
    true = ok, false = error.
  Throws:
    `IOException`
    `BadFormException`

### read_v5d_header

    boolean read_v5d_header()
                      throws IOException,
                             BadFormException

  Read a v5d file header.

  Returns:
    true = ok, false = error.
  Throws:
    `IOException`
    `BadFormException`

### v5dReadCompressedGrid

    boolean v5dReadCompressedGrid(int time,
                                  int vr,
                                  float[] ga,
                                  float[] gb,
                                  byte[] compdata)
                            throws IOException,
                                   BadFormException

  Read a compressed grid from a v5d file.

  Parameters:
    `time` - timestep
    `vr` - variable
    `ga` - array to store grid (de)compression values
    `gb` - array to store grid (de)compression values
    `compdata` - address of where to store compressed grid data
  Returns:
    true = ok, false = error
  Throws:
    `IOException`
    `BadFormException`

### v5dReadGrid

    boolean v5dReadGrid(int time,
                        int vr,
                        float[] data)
                  throws IOException,
                         BadFormException

  Read a grid from a v5d file, decompress it and return it.

  Parameters:
    `time` - timestep
    `vr` - variable
    `data` - array to put grid data
  Returns:
    true = ok, false = error.
  Throws:
    `IOException`
    `BadFormException`

### write_tag

    boolean write_tag(int tag,
                      int length,
                      boolean newfile)
                throws IOException

  Throws:
    `IOException`

### write_v5d_header

    boolean write_v5d_header()
                       throws IOException

  Write the information in the given V5DStruct as a v5d file header. Note that the current file position is restored when this function returns normally.

  Returns:
    true = ok, false = error.
  Throws:
    `IOException`

### v5dCreateFile

    boolean v5dCreateFile(String filename)
                    throws IOException

  Open a v5d file for writing. If the named file already exists, it will be deleted.

  Parameters:
    `filename` - name of v5d file to create
  Returns:
    true = ok, false = error.
  Throws:
    `IOException`

### v5dWriteCompressedGrid

    boolean v5dWriteCompressedGrid(int time,
                                   int vr,
                                   float[] ga,
                                   float[] gb,
                                   byte[] compdata)
                             throws IOException,
                                    BadFormException

  Write a compressed grid to a v5d file.

  Parameters:
    `time` - timestep
    `vr` - variable
    `ga` - the GA (de)compression value array
    `gb` - the GB (de)compression value array
    `compdata` - array of compressed data values
  Returns:
    true = ok, false = error
  Throws:
    `IOException`
    `BadFormException`

### v5dWriteGrid

    boolean v5dWriteGrid(int time,
                         int vr,
                         float[] data)
                   throws IOException,
                          BadFormException

  Compress a grid and write it to a v5d file.

  Parameters:
    `time` - timestep
    `vr` - variable
    `data` - array of uncompressed grid data
  Returns:
    true = ok, false = error
  Throws:
    `IOException`
    `BadFormException`

### v5dCloseFile

    boolean v5dCloseFile()
                   throws IOException

  Close a v5d file which was opened with open_v5d_file() or create_v5d_file().

  Returns:
    true = ok, false = error
  Throws:
    `IOException`