ucar.nc2.iosp.grid
Class GridServiceProvider

java.lang.Object
  extended by ucar.nc2.iosp.AbstractIOServiceProvider
      extended by ucar.nc2.iosp.grid.GridServiceProvider
All Implemented Interfaces:
IOServiceProvider
Direct Known Subclasses:
GempakGridServiceProvider, GribGridServiceProvider, McIDASGridServiceProvider

public abstract class GridServiceProvider
extends AbstractIOServiceProvider

An IOSP for Gempak Grid data

Author:
IDV Development Team

Nested Class Summary
static class GridServiceProvider.IndexExtendMode
           
 
Field Summary
protected static boolean addLatLon
           
protected static boolean alwaysInCache
           
protected static boolean debugMissing
          debug flags
protected static boolean debugMissingDetails
          debug flags
protected static boolean debugOpen
          debug flags
protected static boolean debugProj
          debug flags
protected static boolean debugTiming
          debug flags
protected static boolean debugVert
          debug flags
protected  FmrcCoordSys fmrcCoordSys
          set by the FMRC from the inventory definition, otherwise null
protected static boolean forceNewIndex
           
protected static GridServiceProvider.IndexExtendMode indexFileModeOnOpen
           
protected static GridServiceProvider.IndexExtendMode indexFileModeOnSync
           
protected  NetcdfFile ncfile
          The netCDF file that the iosp is part of
protected  java.lang.StringBuilder parseInfo
          place to store debug stuff
protected  RandomAccessFile raf
          the RandomAccessFile we are reading from
protected static boolean useMaximalCoordSys
           
 
Constructor Summary
GridServiceProvider()
           
 
Method Summary
protected abstract  float[] _readData(ucar.grid.GridRecord gr)
          Read the data for this GridRecord
 void close()
          Close this IOSP
 java.lang.String getDetailInfo()
          Get the detail information
 boolean isMissingXY(Variable v2, int timeIdx, int levIdx)
          Is this XY level missing?
protected abstract  void open(ucar.grid.GridIndex index, CancelTask cancelTask)
          Use the given index to fill the NetcdfFile object with attributes and variables.
 void open(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask)
          Open the service provider for reading.
 Array readData(Variable v2, Section section)
          Read the data for the variable
 java.lang.Object sendIospMessage(java.lang.Object special)
          Send an IOSP message
static void setDebugFlags(DebugFlags debugFlag)
          Set the debug flags
static void setExtendIndex(boolean b)
          Deprecated. use setIndexFileModeOnSync and setIndexFileModeOnOpen
static void setIndexAlwaysInCache(boolean b)
          Set disk cache policy for index files.
static void setIndexFileModeOnOpen(GridServiceProvider.IndexExtendMode mode)
          This controls what happens when a GRIB file is opened, and the data file has changed since the index was written.
static void setIndexFileModeOnSync(GridServiceProvider.IndexExtendMode mode)
          This controls what happens when a GRIB file is synced (usually from FileCache), and the data or index file has changed since the file was placed in the cache.
static void useMaximalCoordSys(boolean b)
          Set whether to use the maximal coordinate system or not
 
Methods inherited from class ucar.nc2.iosp.AbstractIOServiceProvider
copyToByteChannel, createValidNetcdfObjectName, getFileTypeVersion, getStructureIterator, readSection, readToByteChannel, sync, syncExtend, toStringDebug
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ucar.nc2.iosp.IOServiceProvider
getFileTypeDescription, getFileTypeId, isValidFile
 

Field Detail

indexFileModeOnOpen

protected static GridServiceProvider.IndexExtendMode indexFileModeOnOpen

indexFileModeOnSync

protected static GridServiceProvider.IndexExtendMode indexFileModeOnSync

addLatLon

protected static boolean addLatLon

useMaximalCoordSys

protected static boolean useMaximalCoordSys

forceNewIndex

protected static boolean forceNewIndex

alwaysInCache

protected static boolean alwaysInCache

debugOpen

protected static boolean debugOpen
debug flags


debugMissing

protected static boolean debugMissing
debug flags


debugMissingDetails

protected static boolean debugMissingDetails
debug flags


debugProj

protected static boolean debugProj
debug flags


debugTiming

protected static boolean debugTiming
debug flags


debugVert

protected static boolean debugVert
debug flags


fmrcCoordSys

protected FmrcCoordSys fmrcCoordSys
set by the FMRC from the inventory definition, otherwise null


ncfile

protected NetcdfFile ncfile
The netCDF file that the iosp is part of


raf

protected RandomAccessFile raf
the RandomAccessFile we are reading from


parseInfo

protected java.lang.StringBuilder parseInfo
place to store debug stuff

Constructor Detail

GridServiceProvider

public GridServiceProvider()
Method Detail

useMaximalCoordSys

public static void useMaximalCoordSys(boolean b)
Set whether to use the maximal coordinate system or not

Parameters:
b - true to use

setDebugFlags

public static void setDebugFlags(DebugFlags debugFlag)
Set the debug flags

Parameters:
debugFlag - debug flags

setIndexFileModeOnOpen

public static void setIndexFileModeOnOpen(GridServiceProvider.IndexExtendMode mode)
This controls what happens when a GRIB file is opened, and the data file has changed since the index was written.
  1. IndexExtendMode.extendwrite: when GRIB file length increases, extend the index. This is the case when the file is being appended to, as new data arrives.
  2. IndexExtendMode.rewrite: when GRIB file length changes, rewrite the index. This is the safest thing to do, at the expense of performance.
  3. IndexExtendMode.readonly: never modify an existing index, just use it. However, if there is no index, created one

Parameters:
mode - IndexExtendMode when file is opened

setIndexFileModeOnSync

public static void setIndexFileModeOnSync(GridServiceProvider.IndexExtendMode mode)
This controls what happens when a GRIB file is synced (usually from FileCache), and the data or index file has changed since the file was placed in the cache.
  1. IndexExtendMode.extendwrite: when GRIB file or index length increases, extend the index. If file or index length decreases, rewrite it.
  2. IndexExtendMode.rewrite: when GRIB file length changes, rewrite the index.
  3. IndexExtendMode.readonly: never modify an existing index, just use it. However, if there is no index, created one

Parameters:
mode - IndexExtendMode when file is opened

setExtendIndex

public static void setExtendIndex(boolean b)
Deprecated. use setIndexFileModeOnSync and setIndexFileModeOnOpen

Set how indexes are used for both open and sync

Parameters:
b - if true, set modes to IndexExtendMode.extendwrite, else IndexExtendMode.readonly

setIndexAlwaysInCache

public static void setIndexAlwaysInCache(boolean b)
Set disk cache policy for index files. Default = false, meaning try to write index files in same directory as grib file. True means always use the DiskCache area. TDS sets this to true, so it wont interfere with external indexer.

Parameters:
b - set to this value

open

protected abstract void open(ucar.grid.GridIndex index,
                             CancelTask cancelTask)
                      throws java.io.IOException
Use the given index to fill the NetcdfFile object with attributes and variables.

Parameters:
index - GridIndex to use
cancelTask - cancel task
Throws:
java.io.IOException - problem reading the file

open

public void open(RandomAccessFile raf,
                 NetcdfFile ncfile,
                 CancelTask cancelTask)
          throws java.io.IOException
Open the service provider for reading.

Parameters:
raf - file to read from
ncfile - netCDF file we are writing to (memory)
cancelTask - task for cancelling
Throws:
java.io.IOException - problem reading file

close

public void close()
           throws java.io.IOException
Close this IOSP

Specified by:
close in interface IOServiceProvider
Overrides:
close in class AbstractIOServiceProvider
Throws:
java.io.IOException - problem closing file

getDetailInfo

public java.lang.String getDetailInfo()
Get the detail information

Specified by:
getDetailInfo in interface IOServiceProvider
Overrides:
getDetailInfo in class AbstractIOServiceProvider
Returns:
the detail info

sendIospMessage

public java.lang.Object sendIospMessage(java.lang.Object special)
Send an IOSP message

Specified by:
sendIospMessage in interface IOServiceProvider
Overrides:
sendIospMessage in class AbstractIOServiceProvider
Parameters:
special - isn't that special?
Returns:
opaque return, may be null.

readData

public Array readData(Variable v2,
                      Section section)
               throws java.io.IOException,
                      InvalidRangeException
Read the data for the variable

Parameters:
v2 - Variable to read
section - section infomation
Returns:
Array of data
Throws:
java.io.IOException - problem reading from file
InvalidRangeException - invalid Range
See Also:
Range

isMissingXY

public boolean isMissingXY(Variable v2,
                           int timeIdx,
                           int levIdx)
                    throws InvalidRangeException
Is this XY level missing?

Parameters:
v2 - Variable
timeIdx - time index
levIdx - level index
Returns:
true if missing
Throws:
InvalidRangeException - invalid range

_readData

protected abstract float[] _readData(ucar.grid.GridRecord gr)
                              throws java.io.IOException
Read the data for this GridRecord

Parameters:
gr - grid identifier
Returns:
the data (or null)
Throws:
java.io.IOException - problem reading the data