ucar.nc2.dt.fmrc
Class ForecastModelRunInventory

java.lang.Object
  extended by ucar.nc2.dt.fmrc.ForecastModelRunInventory

public class ForecastModelRunInventory
extends java.lang.Object

This reads and writes XML files to summarize the inventory for a single ForecastModelRun. The underlying dataset is a GridDataset.

Tracks unique TimeCoords (aka "valid times" aka "forecast times" aka "offset hours"), and tracks the list of variables (aka grids) that use that TimeCoord.

Tracks unique VertCoords; grids have a reference to one if they are 3D.

 Data Structures
  List VertCoord
    double[] values
 

List TimeCoord double[] offsetHour List Grid VertCoord (optional) List Misssing

Author:
caron

Nested Class Summary
static class ForecastModelRunInventory.Grid
          A Grid variable has a name, timeCoord and optionally a Vertical Coordinate, and list of Missing.
static class ForecastModelRunInventory.Missing
           
static class ForecastModelRunInventory.TimeCoord
          Represents a list of valid times.
static class ForecastModelRunInventory.VertCoord
          Represents a vertical coordinate.
 
Field Summary
static int OPEN_FORCE_NEW
           
static int OPEN_NORMAL
           
static int OPEN_XML_ONLY
           
 
Method Summary
 void close()
           
 ForecastModelRunInventory.Grid findGrid(java.lang.String name)
           
 LatLonRect getBB()
           
 java.lang.String getName()
           
static double getOffsetInHours(java.util.Date origin, java.util.Date date)
           
 java.util.Date getRunDate()
          Get the date of the ForecastModelRun
 java.lang.String getRunDateString()
          Get string representation of the date of the ForecastModelRun
 java.util.List<ForecastModelRunInventory.TimeCoord> getTimeCoords()
          Get a list of unique TimeCoords, which contain the list of variables that all use that TimeCoord.
 java.util.List<ForecastModelRunInventory.VertCoord> getVertCoords()
          Get a list of unique VertCoords.
static void main(java.lang.String[] args)
           
static void main2(java.lang.String[] args)
           
static ForecastModelRunInventory open(DiskCache2 cache, java.lang.String ncfileLocation, int mode, boolean isFile)
          Open a GridDataset and construct a ForecastModelRun.
static ForecastModelRunInventory open(GridDataset gds, java.util.Date runDate)
           
static ForecastModelRunInventory readXML(java.lang.String xmlLocation)
          Construct a ForecastModelRun from its XML representation
 void releaseDataset()
          Release and close the dataset, and allow CG.
 void setName(java.lang.String name)
           
 org.jdom.Document writeDocument()
          Create the XML representation
 java.lang.String writeXML()
          Write the XML representation to a String.
 void writeXML(java.io.OutputStream out)
          Write the XML representaion to an OutputStream.
 void writeXML(java.lang.String filename)
          Write the XML representation to a local file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OPEN_NORMAL

public static final int OPEN_NORMAL
See Also:
Constant Field Values

OPEN_FORCE_NEW

public static final int OPEN_FORCE_NEW
See Also:
Constant Field Values

OPEN_XML_ONLY

public static final int OPEN_XML_ONLY
See Also:
Constant Field Values
Method Detail

close

public void close()
           throws java.io.IOException
Throws:
java.io.IOException

setName

public void setName(java.lang.String name)

getName

public java.lang.String getName()

getRunDate

public java.util.Date getRunDate()
Get the date of the ForecastModelRun

Returns:
the date of the ForecastModelRun

getRunDateString

public java.lang.String getRunDateString()
Get string representation of the date of the ForecastModelRun

Returns:
string representation of the date of the ForecastModelRun

getTimeCoords

public java.util.List<ForecastModelRunInventory.TimeCoord> getTimeCoords()
Get a list of unique TimeCoords, which contain the list of variables that all use that TimeCoord.

Returns:
list of TimeCoord

getVertCoords

public java.util.List<ForecastModelRunInventory.VertCoord> getVertCoords()
Get a list of unique VertCoords.

Returns:
list of VertCoord

getBB

public LatLonRect getBB()

releaseDataset

public void releaseDataset()
                    throws java.io.IOException
Release and close the dataset, and allow CG.

Throws:
java.io.IOException - on io error

findGrid

public ForecastModelRunInventory.Grid findGrid(java.lang.String name)

getOffsetInHours

public static double getOffsetInHours(java.util.Date origin,
                                      java.util.Date date)

writeXML

public void writeXML(java.lang.String filename)
              throws java.io.IOException
Write the XML representation to a local file.

Parameters:
filename - wite to this local file
Throws:
java.io.IOException - on io error

writeXML

public void writeXML(java.io.OutputStream out)
              throws java.io.IOException
Write the XML representaion to an OutputStream.

Parameters:
out - write to this OutputStream
Throws:
java.io.IOException - on io error

writeXML

public java.lang.String writeXML()
Write the XML representation to a String.

Returns:
the XML representation to a String.

writeDocument

public org.jdom.Document writeDocument()
Create the XML representation

Returns:
the XML representation as a Document

readXML

public static ForecastModelRunInventory readXML(java.lang.String xmlLocation)
                                         throws java.io.IOException
Construct a ForecastModelRun from its XML representation

Parameters:
xmlLocation - location of xml - assumed to be a local file.
Returns:
ForecastModelRun
Throws:
java.io.IOException - on io error

open

public static ForecastModelRunInventory open(DiskCache2 cache,
                                             java.lang.String ncfileLocation,
                                             int mode,
                                             boolean isFile)
                                      throws java.io.IOException
Open a GridDataset and construct a ForecastModelRun. The information is serialized into am XML file at ncfileLocation.fmrInv.xml, and used if it exists.

Parameters:
cache - use this cache (may be null)
ncfileLocation - location of the grid dataset.
mode - one of OPEN_NORMAL, OPEN_FORCE_NEW, OPEN_XML_ONLY constants
isFile - if its a file: new File( ncfileLocation) makes sense, so we can check if its changed
Returns:
ForecastModelRun
Throws:
java.io.IOException - on io error

open

public static ForecastModelRunInventory open(GridDataset gds,
                                             java.util.Date runDate)

main2

public static void main2(java.lang.String[] args)
                  throws java.lang.Exception
Throws:
java.lang.Exception

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Throws:
java.io.IOException