ucar.nc2.iosp.gempak
Class GempakStationFileIOSP

java.lang.Object
  extended by ucar.nc2.iosp.AbstractIOServiceProvider
      extended by ucar.nc2.iosp.gempak.GempakStationFileIOSP
All Implemented Interfaces:
IOServiceProvider
Direct Known Subclasses:
GempakSoundingIOSP, GempakSurfaceIOSP

public abstract class GempakStationFileIOSP
extends AbstractIOServiceProvider

An IOSP for Gempak Station (SF,SN) data.

Author:
Unidata Java Development Team

Field Summary
protected static Dimension DIM_LEN2
          static for shared dimension of length 2
protected static Dimension DIM_LEN4
          static for shared dimension of length 4
protected static Dimension DIM_LEN8
          static for shared dimension of length 4
protected  AbstractGempakStationFileReader gemreader
          Gempak file reader
protected static Number IMISS
          Integer missing attribute
protected static String MISSING_VAR
          name for the time variable
protected  NetcdfFile ncfile
          The netCDF file
protected  StringBuilder parseInfo
          place to store debug stuff
protected  RandomAccessFile raf
          the file we are reading
protected static Number RMISS
          Float missing attribute
protected static String TIME_VAR
          name for the time variable
 
Constructor Summary
GempakStationFileIOSP()
           
 
Method Summary
protected  void addGlobalAttributes()
          Add on global attributes for all types
protected  void buildNCFile()
          Build the netCDF file
 void close()
          Close this IOSP
protected abstract  void fillNCFile()
          Fill the contents of the netCDF file.
 String getCFFeatureType()
          Get the CF feature type, subclasses should override
 String getConventions()
          Get the netCDF conventions identifier.
 String getDetailInfo()
          Get the detail information
protected  String getStackTrace()
          Return the stack trace of this calling thread
protected  int getStnVarSize(String name)
          Get the size of a particular station variable
 boolean isValidFile(RandomAccessFile raf)
          Is this a valid file?
protected  Variable makeMissingVariable()
          Make the missing variable
protected  Variable makeParamVariable(GempakParameter param, List<Dimension> dims)
          Make a variable from a GempakParmaeter
protected abstract  AbstractGempakStationFileReader makeStationReader()
          Make the appropriate station file reader, subclasses need to implement this
protected  Variable makeStationVariable(String varname, Dimension firstDim)
          Make a station variable
protected  List<Variable> makeStationVars(List<GempakStation> stations, Dimension dim)
          Make the station variables from a representative station
protected  Structure makeStructure(String partName, List dimensions, boolean includeMissing)
          Make a structure for the part
 void open(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask)
          Open the service provider for reading.
protected  void printStack(String msg, int maxLines)
          Print the stack trace for a given line of code.
 boolean sync()
          Sync the file
 boolean syncExtend()
          Sync and extend
 
Methods inherited from class ucar.nc2.iosp.AbstractIOServiceProvider
getFileTypeVersion, getStructureIterator, readSection, readToByteChannel, sendIospMessage, 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, readData
 

Field Detail

ncfile

protected NetcdfFile ncfile
The netCDF file


raf

protected RandomAccessFile raf
the file we are reading


gemreader

protected AbstractGempakStationFileReader gemreader
Gempak file reader


parseInfo

protected StringBuilder parseInfo
place to store debug stuff


RMISS

protected static final Number RMISS
Float missing attribute


IMISS

protected static final Number IMISS
Integer missing attribute


DIM_LEN8

protected static final Dimension DIM_LEN8
static for shared dimension of length 4


DIM_LEN4

protected static final Dimension DIM_LEN4
static for shared dimension of length 4


DIM_LEN2

protected static final Dimension DIM_LEN2
static for shared dimension of length 2


TIME_VAR

protected static final String TIME_VAR
name for the time variable

See Also:
Constant Field Values

MISSING_VAR

protected static final String MISSING_VAR
name for the time variable

See Also:
Constant Field Values
Constructor Detail

GempakStationFileIOSP

public GempakStationFileIOSP()
Method Detail

isValidFile

public boolean isValidFile(RandomAccessFile raf)
                    throws IOException
Is this a valid file?

Parameters:
raf - RandomAccessFile to check
Returns:
true if a valid Gempak grid file
Throws:
IOException - problem reading file

makeStationReader

protected abstract AbstractGempakStationFileReader makeStationReader()
Make the appropriate station file reader, subclasses need to implement this

Returns:
the appropriate reader for that subclass

open

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

Specified by:
open in interface IOServiceProvider
Overrides:
open in class AbstractIOServiceProvider
Parameters:
raf - file to read from
ncfile - netCDF file we are writing to (memory)
cancelTask - task for cancelling
Throws:
IOException - problem reading file

close

public void close()
           throws IOException
Close this IOSP

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

syncExtend

public boolean syncExtend()
Sync and extend

Specified by:
syncExtend in interface IOServiceProvider
Overrides:
syncExtend in class AbstractIOServiceProvider
Returns:
false

getDetailInfo

public String getDetailInfo()
Get the detail information

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

sync

public boolean sync()
             throws IOException
Sync the file

Specified by:
sync in interface IOServiceProvider
Overrides:
sync in class AbstractIOServiceProvider
Returns:
true if needed to sync
Throws:
IOException - problem synching the file

buildNCFile

protected void buildNCFile()
                    throws IOException
Build the netCDF file

Throws:
IOException - problem reading the file

fillNCFile

protected abstract void fillNCFile()
                            throws IOException
Fill the contents of the netCDF file. Assumes that the file has been cleared.

Throws:
IOException - problem reading the file

makeStructure

protected Structure makeStructure(String partName,
                                  List dimensions,
                                  boolean includeMissing)
Make a structure for the part

Parameters:
partName - partname
dimensions - dimensions for the structure
includeMissing - true to include the missing variable
Returns:
a Structure

makeMissingVariable

protected Variable makeMissingVariable()
Make the missing variable

Returns:
the missing variable

makeParamVariable

protected Variable makeParamVariable(GempakParameter param,
                                     List<Dimension> dims)
Make a variable from a GempakParmaeter

Parameters:
param - GempakParameter
dims - Variable dimensions
Returns:
the Variable

addGlobalAttributes

protected void addGlobalAttributes()
Add on global attributes for all types


getConventions

public String getConventions()
Get the netCDF conventions identifier.

Returns:
the convention name

getCFFeatureType

public String getCFFeatureType()
Get the CF feature type, subclasses should override

Returns:
the feature type

getStnVarSize

protected int getStnVarSize(String name)
Get the size of a particular station variable

Parameters:
name - name of the variable (key)
Returns:
size or -1

makeStationVars

protected List<Variable> makeStationVars(List<GempakStation> stations,
                                         Dimension dim)
Make the station variables from a representative station

Parameters:
stations - list of stations
dim - station dimension
Returns:
the list of variables

makeStationVariable

protected Variable makeStationVariable(String varname,
                                       Dimension firstDim)
Make a station variable

Parameters:
varname - variable name
firstDim - station dimension
Returns:
corresponding variable

printStack

protected void printStack(String msg,
                          int maxLines)
Print the stack trace for a given line of code.

Parameters:
msg - message to print
maxLines - number of lines in the stack to print

getStackTrace

protected String getStackTrace()
Return the stack trace of this calling thread

Returns:
The stack trace


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