Java Code Examples for ucar.unidata.io.RandomAccessFile#readUnsignedShort()

The following examples show how to use ucar.unidata.io.RandomAccessFile#readUnsignedShort() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Cinrad2Record.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
SweepInfo(RandomAccessFile din, int hoff) throws IOException {
  din.seek(hoff);
  amb = din.readByte();
  arotate = (short) din.readUnsignedShort();
  pref1 = (short) din.readUnsignedShort();
  pref2 = (short) din.readUnsignedShort();
  spulseW = (short) din.readUnsignedShort();
  maxV = (short) din.readUnsignedShort();
  maxL = (short) din.readUnsignedShort();
  binWidth = (short) din.readUnsignedShort();
  binnumber = (short) din.readUnsignedShort();
  recordnumber = (short) din.readUnsignedShort();
  elevationAngle = (short) din.readUnsignedShort() / 100.0f;
}
 
Example 2
Source File: Cinrad2Record.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void readSCHeader(RandomAccessFile din) throws IOException {

    message_offset = 0;
    din.seek(message_offset);
    // site info 170
    din.skipBytes(90);
    byte[] b10 = new byte[10];
    // Message Header
    din.read(b10);
    String stationNId = new String(b10);

    din.skipBytes(52);

    // latlon
    int lon = din.readInt();
    int lat = din.readInt();
    int hhh = din.readInt();

    din.skipBytes(6);
    //
    message_type = 1;

    // PerformanceInfo
    din.skipBytes(31);

    // ObservationInfo
    vcp = convertunsignedByte2Short(din.readByte());
    short syear = (short) din.readUnsignedShort();
    short smm = convertunsignedByte2Short(din.readByte());
    short sdd = convertunsignedByte2Short(din.readByte());
    short shh = convertunsignedByte2Short(din.readByte());
    short smi = convertunsignedByte2Short(din.readByte());
    short sss = convertunsignedByte2Short(din.readByte());

    dateTime0 = CalendarDate.of(null, syear, smm, sdd, shh, smi, sss);

    din.skipBytes(8);
    long offset = din.getFilePointer();
    sweepInfo = new SweepInfo[30];
    for (int i = 0; i < 30; i++) {
      sweepInfo[i] = new SweepInfo(din, (int) offset);
      offset = offset + 21;
    }

    din.skipBytes(6);

    syear = (short) din.readUnsignedShort();
    smm = convertunsignedByte2Short(din.readByte());
    sdd = convertunsignedByte2Short(din.readByte());
    shh = convertunsignedByte2Short(din.readByte());
    smi = convertunsignedByte2Short(din.readByte());
    sss = convertunsignedByte2Short(din.readByte());

    dateTimeE = CalendarDate.of(null, syear, smm, sdd, shh, smi, sss);

  }
 
Example 3
Source File: Cinrad2Record.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void readCCHeader(RandomAccessFile din) throws IOException {

    message_offset = 0;
    din.seek(message_offset);
    // site info 170
    din.skipBytes(66);

    // Message Header
    String stationId = din.readString(40);
    String stationNbr = din.readString(10);

    din.skipBytes(20);

    String clon = din.readString(16);
    String clat = din.readString(16);
    // latlon
    int lon = din.readInt();
    int lat = din.readInt();
    int hhh = din.readInt();

    din.skipBytes(4);

    // ObservationInfo

    short syear1 = convertunsignedByte2Short(din.readByte());
    short syear2 = convertunsignedByte2Short(din.readByte());
    short syear = (short) (syear1 * 100 + syear2);
    short smm = convertunsignedByte2Short(din.readByte());
    short sdd = convertunsignedByte2Short(din.readByte());
    short shh = convertunsignedByte2Short(din.readByte());
    short smi = convertunsignedByte2Short(din.readByte());
    short sss = convertunsignedByte2Short(din.readByte());

    dateTime0 = CalendarDate.of(null, syear, smm, sdd, shh, smi, sss);

    din.skipBytes(1);

    syear1 = convertunsignedByte2Short(din.readByte());
    syear2 = convertunsignedByte2Short(din.readByte());
    syear = (short) (syear1 * 100 + syear2);
    smm = convertunsignedByte2Short(din.readByte());
    sdd = convertunsignedByte2Short(din.readByte());
    shh = convertunsignedByte2Short(din.readByte());
    smi = convertunsignedByte2Short(din.readByte());
    sss = convertunsignedByte2Short(din.readByte());

    dateTimeE = CalendarDate.of(null, syear, smm, sdd, shh, smi, sss);
    short scanMode = convertunsignedByte2Short(din.readByte());
    if (scanMode == 10) {
      sweepN = 1;
    } else if (scanMode >= 100) {
      sweepN = scanMode - 100;
    } else {
      throw new IOException("Error reading CINRAD CC data: Unsupported product: RHI/FFT");
    }

    elev = new int[sweepN];
    din.skipBytes(4);
    short sRHIA = (short) din.readUnsignedShort();

    din.skipBytes(4);

    echoType = din.readUnsignedShort();
    if (echoType != 0x408a) // only support vppi at this moment
      throw new IOException("Error reading CINRAD CC data: Unsupported level 2 data");

    int prodCode = din.readUnsignedShort();

    if (prodCode != 0x8003) // only support vppi at this moment
      throw new IOException("Error reading CINRAD CC data: Unsupported product: RHI/FFT");
    din.skipBytes(4);

    // remain2[660]
    for (int i = 0; i < sweepN; i++) {
      int maxV = din.readUnsignedShort();
      int maxL = din.readUnsignedShort();
      int binWidth = din.readUnsignedShort();
      int binNum = din.readUnsignedShort();
      int recordTotalNum = din.readUnsignedShort();
      din.skipBytes(8);
      elev[i] = din.readUnsignedShort();
      din.skipBytes(2);
      // System.out.println("bin num: " + binNum + " maxL " + maxL + " totalRNumber " + recordTotalNum);
    }
    // din.seek(1020);
    // int doffset = din.readInt();
    // System.out.println(" Offset: " + doffset);
  }
 
Example 4
Source File: Cinrad2Record.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void readCC20Header(RandomAccessFile din) throws IOException {

    message_offset = 0;
    din.seek(message_offset);
    // site info 170
    din.skipBytes(62);

    // Message Header
    String stationId = din.readString(40);
    String stationNbr = din.readString(10);

    din.skipBytes(20);

    String clon = din.readString(16);
    String clat = din.readString(16);
    // latlon
    int lon = din.readInt();
    int lat = din.readInt();
    int hhh = din.readInt();

    din.skipBytes(40);

    // ObservationInfo
    short scanMode = convertunsignedByte2Short(din.readByte());
    if (scanMode == 10) {
      sweepN = 1;
    } else if (scanMode >= 100) {
      sweepN = scanMode - 100;
    } else {
      throw new IOException("Error reading CINRAD CC data: Unsupported product: RHI/FFT");
    }

    short syear = (short) din.readUnsignedShort();
    short smm = convertunsignedByte2Short(din.readByte());
    short sdd = convertunsignedByte2Short(din.readByte());
    short shh = convertunsignedByte2Short(din.readByte());
    short smi = convertunsignedByte2Short(din.readByte());
    short sss = convertunsignedByte2Short(din.readByte());

    dateTime0 = CalendarDate.of(null, syear, smm, sdd, shh, smi, sss);

    din.skipBytes(14); // 14+ (35 - 21)

    // remain2[660]
    elev = new int[sweepN];
    recordNum = new int[sweepN];
    for (int i = 0; i < sweepN; i++) {
      din.skipBytes(14);
      int zbinWidth = din.readUnsignedShort();
      int vbinWidth = din.readUnsignedShort();
      int sbinWidth = din.readUnsignedShort();
      int zbinNum = din.readUnsignedShort();
      int vbinNum = din.readUnsignedShort();
      int sbinNum = din.readUnsignedShort();
      recordNum[i] = din.readUnsignedShort();
      // if(i > 0)
      // recordNum[i] = recordNum[i] + recordNum[i-1];
      elev[i] = din.readShort();
      cDataForm = din.readByte();
      if (cDataForm != 22 && cDataForm != 23 && cDataForm != 24)
        throw new IOException("Unsupported CC data format");
      int dataP = din.readInt();
      // din.skipBytes(2);
      // System.out.println("zbin num: " + zbinNum + " vbin num: " + vbinNum + " sbin num: " + sbinNum + " dataForm " +
      // cDataForm);
    }

    for (int i = sweepN; i < 32; i++) {
      din.skipBytes(35);
    }

    din.skipBytes(6);

    syear = (short) din.readUnsignedShort();
    smm = convertunsignedByte2Short(din.readByte());
    sdd = convertunsignedByte2Short(din.readByte());
    shh = convertunsignedByte2Short(din.readByte());
    smi = convertunsignedByte2Short(din.readByte());
    sss = convertunsignedByte2Short(din.readByte());

    dateTimeE = CalendarDate.of(null, syear, smm, sdd, shh, smi, sss);

  }