/** * Return the earth radius in kilometers at the given geocentric latitude. * * @param gcLatitude - the given geocentric latitude * @return the earth radius at the given location in kilometers */ static double earthRadiusKm(double gcLatitude) { return (earthRadius(gcLatitude) * EARTH_MEAN_EQUATORIAL_RADIUS_KM); }
public boolean isValidFile(ucar.unidata.io.RandomAccessFile raf) { DMSPHeader localHeader = new DMSPHeader(); return (localHeader.isValidFile(raf)); }
/** * Change a vector into a vector with magnitude of one. * * @param vector 3d vector */ static double[] unitVector(double[] vector) { if (vector.length != 3) throw new IllegalArgumentException("Argument not a 3-D vector <dim=" + vector.length + ">."); double magnitude = vectorMagnitude(vector); double[] resultingVector = {vector[0] / magnitude, vector[1] / magnitude, vector[2] / magnitude}; return (resultingVector); }
Object readDoubleArray1D(int offsetInRecord) throws IOException { int elementSizeInBytes = 8; double[] array = new double[header.getNumDataRecords()]; this.raf.seek(header.getRecordSizeInBytes() * header.getNumHeaderRecords() + offsetInRecord); for (int i = 0; i < header.getNumDataRecords(); i++) { this.raf.readDouble(array, i, 1); this.raf.skipBytes(header.getRecordSizeInBytes() - elementSizeInBytes); } return (array); }
public String toString() { StringBuilder retVal = new StringBuilder(); retVal.append("Variable(").append(this.getName()).append(",") .append(this.getLongName()).append(",") .append(this.getUnits()).append(",") .append(this.getDataType()).append(",") .append(this.getByteOffsetInRecord()).append(",") .append(this.getNumElementsInRecord()).append(")"); return (retVal.toString()); } }
Object readFloatArray1D(int offsetInRecord) throws IOException { int elementSizeInBytes = 4; float[] array = new float[header.getNumDataRecords()]; this.raf.seek(header.getRecordSizeInBytes() * header.getNumHeaderRecords() + offsetInRecord); for (int i = 0; i < header.getNumDataRecords(); i++) { this.raf.readFloat(array, i, 1); this.raf.skipBytes(header.getRecordSizeInBytes() - elementSizeInBytes); } return (array); }
public String toString() { StringBuilder retVal = new StringBuilder(); retVal.append("Variable(").append(this.getName()).append(",") .append(this.getLongName()).append(",") .append(this.getUnits()).append(",") .append(this.getDataType()).append(",") .append(this.getByteOffsetInRecord()).append(",") .append(this.getNumElementsInRecord()).append(")"); return (retVal.toString()); } }
public boolean isValidFile(ucar.unidata.io.RandomAccessFile raf) { DMSPHeader localHeader = new DMSPHeader(); return (localHeader.isValidFile(raf)); }
/** * Return the earth radius in kilometers at the given geocentric latitude. * * @param gcLatitude - the given geocentric latitude * @return the earth radius at the given location in kilometers */ static double earthRadiusKm(double gcLatitude) { return (earthRadius(gcLatitude) * EARTH_MEAN_EQUATORIAL_RADIUS_KM); }
/** * Change a vector into a vector with magnitude of one. * * @param vector 3d vector */ static double[] unitVector(double[] vector) { if (vector.length != 3) throw new IllegalArgumentException("Argument not a 3-D vector <dim=" + vector.length + ">."); double magnitude = vectorMagnitude(vector); double[] resultingVector = {vector[0] / magnitude, vector[1] / magnitude, vector[2] / magnitude}; return (resultingVector); }
Object readFloatArray1D(int offsetInRecord) throws IOException { int elementSizeInBytes = 4; float[] array = new float[header.getNumDataRecords()]; this.raf.seek(header.getRecordSizeInBytes() * header.getNumHeaderRecords() + offsetInRecord); for (int i = 0; i < header.getNumDataRecords(); i++) { this.raf.readFloat(array, i, 1); this.raf.skipBytes(header.getRecordSizeInBytes() - elementSizeInBytes); } return (array); }
public boolean isValidFile(ucar.unidata.io.RandomAccessFile raf) { DMSPHeader localHeader = new DMSPHeader(); return (localHeader.isValidFile(raf)); }
/** * Return the earth radius in kilometers at the given geocentric latitude. * * @param gcLatitude - the given geocentric latitude * @return the earth radius at the given location in kilometers */ static double earthRadiusKm(double gcLatitude) { return (earthRadius(gcLatitude) * EARTH_MEAN_EQUATORIAL_RADIUS_KM); }
Object readByteArray2D(int offsetInRecord, int numElementsInRecord) throws IOException { byte[] array = new byte[header.getNumDataRecords() * numElementsInRecord]; this.raf.seek(header.getRecordSizeInBytes() * header.getNumHeaderRecords() + offsetInRecord); for (int i = 0; i < header.getNumDataRecords(); i++) { this.raf.read(array, i * numElementsInRecord, numElementsInRecord); this.raf.skipBytes(header.getRecordSizeInBytes() - numElementsInRecord); } return (array); }
Object readFloatArray1D(int offsetInRecord) throws IOException { int elementSizeInBytes = 4; float[] array = new float[header.getNumDataRecords()]; this.raf.seek(header.getRecordSizeInBytes() * header.getNumHeaderRecords() + offsetInRecord); for (int i = 0; i < header.getNumDataRecords(); i++) { this.raf.readFloat(array, i, 1); this.raf.skipBytes(header.getRecordSizeInBytes() - elementSizeInBytes); } return (array); }
Object readIntArray1D(int offsetInRecord) throws IOException { int elementSizeInBytes = 4; int[] array = new int[header.getNumDataRecords()]; this.raf.seek(header.getRecordSizeInBytes() * header.getNumHeaderRecords() + offsetInRecord); for (int i = 0; i < header.getNumDataRecords(); i++) { this.raf.readInt(array, i, 1); this.raf.skipBytes(header.getRecordSizeInBytes() - elementSizeInBytes); } return (array); }
Object readDoubleArray1D(int offsetInRecord) throws IOException { int elementSizeInBytes = 8; double[] array = new double[header.getNumDataRecords()]; this.raf.seek(header.getRecordSizeInBytes() * header.getNumHeaderRecords() + offsetInRecord); for (int i = 0; i < header.getNumDataRecords(); i++) { this.raf.readDouble(array, i, 1); this.raf.skipBytes(header.getRecordSizeInBytes() - elementSizeInBytes); } return (array); }
Object readByteArray2D(int offsetInRecord, int numElementsInRecord) throws IOException { byte[] array = new byte[header.getNumDataRecords() * numElementsInRecord]; this.raf.seek(header.getRecordSizeInBytes() * header.getNumHeaderRecords() + offsetInRecord); for (int i = 0; i < header.getNumDataRecords(); i++) { this.raf.readFully(array, i * numElementsInRecord, numElementsInRecord); this.raf.skipBytes(header.getRecordSizeInBytes() - numElementsInRecord); } return (array); }
Object readIntArray1D(int offsetInRecord) throws IOException { int elementSizeInBytes = 4; int[] array = new int[header.getNumDataRecords()]; this.raf.seek(header.getRecordSizeInBytes() * header.getNumHeaderRecords() + offsetInRecord); for (int i = 0; i < header.getNumDataRecords(); i++) { this.raf.readInt(array, i, 1); this.raf.skipBytes(header.getRecordSizeInBytes() - elementSizeInBytes); } return (array); }
Object readDoubleArray1D(int offsetInRecord) throws IOException { int elementSizeInBytes = 8; double[] array = new double[header.getNumDataRecords()]; this.raf.seek(header.getRecordSizeInBytes() * header.getNumHeaderRecords() + offsetInRecord); for (int i = 0; i < header.getNumDataRecords(); i++) { this.raf.readDouble(array, i, 1); this.raf.skipBytes(header.getRecordSizeInBytes() - elementSizeInBytes); } return (array); }