public class GempakFileReader extends java.lang.Object implements GempakConstants
Modifier and Type | Class and Description |
---|---|
protected static class |
GempakFileReader.DMFileHeaderInfo
Class to hold the DM File header info
|
protected static class |
GempakFileReader.DMHeaders
Class to mimic the DMHDRS common block.
|
protected class |
GempakFileReader.DMKeys
Class to mimic the DMKEYS common block.
|
protected static class |
GempakFileReader.DMParam
Class to hold DM Parameter info
|
protected static class |
GempakFileReader.DMPart
Class to mimic the DMKEYS common block.
|
protected static class |
GempakFileReader.Key
Class to hold information about a key.
|
protected static class |
GempakFileReader.PackingInfo
Class to hold DM Integer packing info
|
static class |
GempakFileReader.RData
A class to hold real (float) data
|
Modifier and Type | Field and Description |
---|---|
protected ucar.nc2.iosp.gempak.GempakFileReader.DMLabel |
dmLabel
The label common param
|
protected java.util.List<GempakFileReader.DMFileHeaderInfo> |
fileHeaderInfo
header info
|
protected long |
fileSize
file size
|
protected GempakFileReader.DMHeaders |
headers
headers
|
protected GempakFileReader.DMKeys |
keys
key
|
protected int |
MTMACH
the machine type byte order
|
protected boolean |
mvmst
swap flag
|
protected boolean |
needToSwap
swap flag
|
protected java.util.List<GempakFileReader.DMPart> |
parts
part
|
protected RandomAccessFile |
rf
The file
|
COL, IMISSD, LLGDHD, LLNANL, LLNNAV, LLSTHL, MBLKSZ, MDCHAR, MDGDEC, MDGDIF, MDGGRB, MDGNMC, MDGNON, MDGRB2, MDGRID, MDINTG, MDREAL, MDRPCK, MFGD, MFSF, MFSN, MTALPH, MTAPOL, MTHP, MTIBM, MTIGPH, MTIRIS, MTLNUX, MTSUN, MTULTX, MTVAX, RDIFFD, RMISSD, ROW
Modifier and Type | Method and Description |
---|---|
GempakFileReader.RData |
DM_RDTR(int irow,
int icol,
java.lang.String partName)
Read the data
|
GempakFileReader.RData |
DM_RDTR(int irow,
int icol,
java.lang.String partName,
int decimalScale)
Read the real (float) data
|
float |
DM_RFLT(int word)
Read a float
|
void |
DM_RFLT(int word,
float[] rarray)
Convenience method to fully read into an array of floats
|
void |
DM_RFLT(int word,
int num,
float[] rarray,
int start)
Read into an array of ints.
|
int |
DM_RINT(int word)
Read an integer
|
void |
DM_RINT(int word,
int[] iarray)
Convenience method to fully read into an array of ints
|
void |
DM_RINT(int word,
int num,
int[] iarray,
int start)
Read into an array of ints.
|
float[] |
DM_RPKG(int isword,
int nword,
int decimalScale)
subclass should implement
|
java.lang.String |
DM_RSTR(int isword)
Read a 4-byte String
|
java.lang.String |
DM_RSTR(int isword,
int nchar)
Read a String
|
float[] |
DM_UNPK(GempakFileReader.DMPart part,
int[] ibitst)
Unpack an array of packed integers.
|
GempakFileReader.DMFileHeaderInfo |
findFileHeader(java.lang.String name)
Find the file header with this name
|
GempakFileReader.Key |
findKey(java.lang.String name)
Find a key with the given name
|
protected static java.lang.String |
getBits(int b)
Get a bit string for an integer
|
int |
getByteOrder()
Get the byte order for this system
|
int |
getByteOrder(int kmachn)
Get the byte order for the machine type.
|
int |
getDataPointer(int irow,
int icol,
java.lang.String partName)
Get the pointer to the data.
|
java.lang.String |
getErrorMessage() |
static RandomAccessFile |
getFile(java.lang.String filename)
Get a RandomAccessFile for the file location
|
float[] |
getFileHeader(java.lang.String name)
Read in the values for the file header
|
java.lang.String |
getFilename()
Get the file name.
|
long |
getInitFileSize()
Get initial file size
|
static GempakFileReader |
getInstance(RandomAccessFile raf,
boolean fullCheck)
Initialize the file, read in all the metadata (ala DM_OPEN)
|
static long |
getOffset(int fortranWord)
Get the byte offset in 0 based space from a 1 based 4 byte
FORTRAN word.
|
GempakFileReader.DMPart |
getPart(java.lang.String name)
Find the part with the particular name.
|
int |
getPartNumber(java.lang.String name)
Find the part with the particular name.
|
protected boolean |
init()
Initialize this reader.
|
protected boolean |
init(boolean fullCheck)
Initialize the file, read in all the metadata (ala DM_OPEN)
|
boolean |
init(RandomAccessFile raf,
boolean fullCheck)
Initialize the file, read in all the metadata (ala DM_OPEN)
|
protected void |
logError(java.lang.String errMsg)
Log an error
|
static void |
main(java.lang.String[] args)
Run the program
|
void |
printFileLabel()
Print the file label
|
void |
printHeaders()
Print the row and column keys
|
void |
printKeys()
Print the row and column keys
|
void |
printParts()
Print the part information
|
protected void |
readFileHeaderInfo()
Read the file header info (DM_RFIL)
|
protected void |
readHeaders()
Read the headers (DM_RHDA)
|
protected void |
readKeys()
Read in the row and column keys (DM_KEY)
|
protected void |
readParts()
Read the parts (DM_RPRT)
|
protected RandomAccessFile rf
protected ucar.nc2.iosp.gempak.GempakFileReader.DMLabel dmLabel
protected java.util.List<GempakFileReader.DMFileHeaderInfo> fileHeaderInfo
protected GempakFileReader.DMHeaders headers
protected GempakFileReader.DMKeys keys
protected java.util.List<GempakFileReader.DMPart> parts
protected int MTMACH
protected boolean mvmst
protected boolean needToSwap
protected long fileSize
public static RandomAccessFile getFile(java.lang.String filename) throws java.io.IOException
filename
- filename to read.java.io.IOException
- problem reading filepublic static GempakFileReader getInstance(RandomAccessFile raf, boolean fullCheck) throws java.io.IOException
raf
- RandomAccessFile to read.fullCheck
- if true, check entire structurejava.io.IOException
- problem reading filepublic boolean init(RandomAccessFile raf, boolean fullCheck) throws java.io.IOException
raf
- RandomAccessFile to read.fullCheck
- if true, check entire structurejava.io.IOException
- problem reading fileprotected boolean init() throws java.io.IOException
java.io.IOException
- problem reading the dataprotected boolean init(boolean fullCheck) throws java.io.IOException
fullCheck
- if true, check entire structurejava.io.IOException
- problem reading filepublic java.lang.String getFilename()
public java.lang.String getErrorMessage()
public long getInitFileSize()
public int getByteOrder()
public int getByteOrder(int kmachn)
kmachn
- maching typeprotected void readFileHeaderInfo() throws java.io.IOException
java.io.IOException
- problem reading fileprotected void readKeys() throws java.io.IOException
java.io.IOException
- problem reading fileprotected void readHeaders() throws java.io.IOException
java.io.IOException
- problem reading fileprotected void readParts() throws java.io.IOException
java.io.IOException
- problem reading filepublic static long getOffset(int fortranWord)
fortranWord
- 1 based word offsetpublic static void main(java.lang.String[] args) throws java.io.IOException
args
- filenamejava.io.IOException
- problem reading the filepublic GempakFileReader.Key findKey(java.lang.String name)
name
- the name of the keypublic GempakFileReader.DMFileHeaderInfo findFileHeader(java.lang.String name)
name
- name of headerpublic float[] getFileHeader(java.lang.String name) throws java.io.IOException
name
- name of headerjava.io.IOException
- problem reading fileprotected void logError(java.lang.String errMsg)
errMsg
- message to logpublic void printFileLabel()
public void printKeys()
public void printHeaders()
public void printParts()
public int getPartNumber(java.lang.String name)
name
- name of part to findpublic GempakFileReader.DMPart getPart(java.lang.String name)
name
- name of part to findpublic int getDataPointer(int irow, int icol, java.lang.String partName)
irow
- row numbericol
- column numberpartName
- name of the partpublic int DM_RINT(int word) throws java.io.IOException
word
- word in file (1 based) to readjava.io.IOException
- problem reading filepublic void DM_RINT(int word, int[] iarray) throws java.io.IOException
word
- word in file (1 based) to readiarray
- array to read intojava.io.IOException
- problem reading filepublic void DM_RINT(int word, int num, int[] iarray, int start) throws java.io.IOException
word
- word in file (1 based) to readiarray
- array to read intostart
- starting word in the array (0 based)num
- number of words to readjava.io.IOException
- problem reading filepublic float DM_RFLT(int word) throws java.io.IOException
word
- word in file (1 based) to readjava.io.IOException
- problem reading filepublic void DM_RFLT(int word, float[] rarray) throws java.io.IOException
word
- word in file (1 based) to readrarray
- array to read intojava.io.IOException
- problem reading filepublic void DM_RFLT(int word, int num, float[] rarray, int start) throws java.io.IOException
word
- word in file (1 based) to readnum
- number of words to readrarray
- array to read intostart
- starting word in the array (0 based)java.io.IOException
- problem reading filepublic java.lang.String DM_RSTR(int isword) throws java.io.IOException
isword
- offset in file (1 based FORTRAN word)java.io.IOException
- problem reading filepublic java.lang.String DM_RSTR(int isword, int nchar) throws java.io.IOException
isword
- offset in file (1 based FORTRAN word)nchar
- number of characters to readjava.io.IOException
- problem reading filepublic GempakFileReader.RData DM_RDTR(int irow, int icol, java.lang.String partName) throws java.io.IOException
irow
- row to readicol
- column to readpartName
- part namejava.io.IOException
- problem reading filepublic GempakFileReader.RData DM_RDTR(int irow, int icol, java.lang.String partName, int decimalScale) throws java.io.IOException
irow
- row to readicol
- column to readpartName
- part namedecimalScale
- scaling factor (power of 10);java.io.IOException
- problem reading filepublic float[] DM_UNPK(GempakFileReader.DMPart part, int[] ibitst)
part
- the part with packing infoibitst
- packed integer bit stringprotected static java.lang.String getBits(int b)
b
- the integerpublic float[] DM_RPKG(int isword, int nword, int decimalScale) throws java.io.IOException
isword
- starting word (1 based)nword
- number of words to readdecimalScale
- decimal scalejava.io.IOException
- problem reading data