ucar.nc2.dt.fmrc
Class ForecastModelRunInventory

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

public class ForecastModelRunInventory
extends 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.EnsCoord
          Represents a ensemble coordinate.
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(String name)
           
 LatLonRect getBB()
           
 String getName()
           
static double getOffsetInHours(Date origin, Date date)
           
 Date getRunDate()
          Get the date of the ForecastModelRun
 String getRunDateString()
          Get string representation of the date of the ForecastModelRun
 List<ForecastModelRunInventory.TimeCoord> getTimeCoords()
          Get a list of unique TimeCoords, which contain the list of variables that all use that TimeCoord.
 List<ForecastModelRunInventory.VertCoord> getVertCoords()
          Get a list of unique VertCoords.
static void main(String[] args)
           
static void main2(String[] args)
           
static ForecastModelRunInventory open(DiskCache2 cache, String ncfileLocation, int mode, boolean isFile)
          Open a GridDataset and construct a ForecastModelRun.
static ForecastModelRunInventory open(GridDataset gds, Date runDate)
           
static ForecastModelRunInventory readXML(String xmlLocation)
          Construct a ForecastModelRun from its XML representation
 void releaseDataset()
          Release and close the dataset, and allow CG.
 void setName(String name)
           
 org.jdom.Document writeDocument()
          Create the XML representation
 String writeXML()
          Write the XML representation to a String.
 void writeXML(OutputStream out)
          Write the XML representaion to an OutputStream.
 void writeXML(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 IOException
Throws:
IOException

setName

public void setName(String name)

getName

public String getName()

getRunDate

public Date getRunDate()
Get the date of the ForecastModelRun

Returns:
the date of the ForecastModelRun

getRunDateString

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

Returns:
string representation of the date of the ForecastModelRun

getTimeCoords

public 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 List<ForecastModelRunInventory.VertCoord> getVertCoords()
Get a list of unique VertCoords.

Returns:
list of VertCoord

getBB

public LatLonRect getBB()

releaseDataset

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

Throws:
IOException - on io error

findGrid

public ForecastModelRunInventory.Grid findGrid(String name)

getOffsetInHours

public static double getOffsetInHours(Date origin,
                                      Date date)

writeXML

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

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

writeXML

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

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

writeXML

public 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(String xmlLocation)
                                         throws IOException
Construct a ForecastModelRun from its XML representation

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

open

public static ForecastModelRunInventory open(DiskCache2 cache,
                                             String ncfileLocation,
                                             int mode,
                                             boolean isFile)
                                      throws 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 to look for fmrInv.xml files (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:
IOException - on io error

open

public static ForecastModelRunInventory open(GridDataset gds,
                                             Date runDate)

main2

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

main

public static void main(String[] args)
                 throws IOException
Throws:
IOException


Copyright © 1999-2011 UCAR/Unidata. All Rights Reserved.