Difference between revisions of "Workdocumentation 2018-08-18"

From BITPlan Wiki
Jump to navigation Jump to search
Line 33: Line 33:
 
return float32(value) * float32(math.Pow10(c.precision))
 
return float32(value) * float32(math.Pow10(c.precision))
 
}
 
}
 +
</source>
 +
<source lang='java'>
 +
// rvp6LittleEndian converts the raw two byte tuple of little endian encoded
 +
  // composite products
 +
  // to radar video processor values (rvp-6). NaN may be returned when the
 +
  // no-data flag is set.
 +
  public static float rvp6LittleEndian(Composite c, byte... tuple) {
 +
    int value = 0x0F & tuple[1];
 +
    value = (value << 8) | (tuple[0]&0x0f);
 +
 +
    if ((tuple[1] & (1 << 5)) != 0) { // error code: no-data
 +
      return Float.NaN;
 +
    }
 +
 +
    if ((tuple[1] & (1 << 6)) != 0) { // flag: negative value
 +
      value *= -1;
 +
    }
 +
 +
    float conv = (float) c.rvp6Raw(value); // set decimal point
 +
 +
    // little endian encoded formats are also used for mm/h
 +
    if (c.getDataUnit() != Unit.Unit_dBZ) {
 +
      return conv;
 +
    }
 +
 +
    // Even though this format supports negative values and custom
 +
    // precision they do not make use of this and we still have to subtract
 +
    // the bias and scale it (RADVOR FX, dBZ)
 +
    return Conversion.toDBZ(conv);
 +
  }
 +
 +
  // rvp6Raw converts the raw value to radar video processor values (rvp-6) by applying the
 +
  // products precision field.
 +
  public static double rvp6Raw(Composite c, int value)  {
 +
    double rvalue=value * c.getPrecisionFactor();
 +
    return rvalue;
 +
  }
 
</source>
 
</source>

Revision as of 18:37, 18 August 2018

go:Sf-history2018-05-30 1650JS.pngjava:Sf-history2018-05-30 1650.png

// rvp6LittleEndian converts the raw two byte tuple of little endian encoded composite products
// to radar video processor values (rvp-6). NaN may be returned when the no-data flag is set.
func (c *Composite) rvp6LittleEndian(tuple [2]byte) float32 {
	var value int = 0x0F & int(tuple[1])
	value = (value << 8) + int(tuple[0])

	if tuple[1]&(1<<5) != 0 { // error code: no-data
		return NaN
	}

	if tuple[1]&(1<<6) != 0 { // flag: negative value
		value *= -1
	}

	conv := c.rvp6Raw(value) // set decimal point

	// little endian encoded formats are also used for mm/h
	if c.DataUnit != Unit_dBZ {
		return conv
	}

	// Even though this format supports negative values and custom
	// precision they do not make use of this and we still have to subtract
	// the bias and scale it (RADVOR FX, dBZ)
	return toDBZ(conv)
}

// rvp6Raw converts the raw value to radar video processor values (rvp-6) by applying the
// products precision field.
func (c *Composite) rvp6Raw(value int) float32 {
	return float32(value) * float32(math.Pow10(c.precision))
}
 // rvp6LittleEndian converts the raw two byte tuple of little endian encoded
  // composite products
  // to radar video processor values (rvp-6). NaN may be returned when the
  // no-data flag is set.
  public static float rvp6LittleEndian(Composite c, byte... tuple) {
    int value = 0x0F & tuple[1];
    value = (value << 8) | (tuple[0]&0x0f);

    if ((tuple[1] & (1 << 5)) != 0) { // error code: no-data
      return Float.NaN;
    }

    if ((tuple[1] & (1 << 6)) != 0) { // flag: negative value
      value *= -1;
    }

    float conv = (float) c.rvp6Raw(value); // set decimal point

    // little endian encoded formats are also used for mm/h
    if (c.getDataUnit() != Unit.Unit_dBZ) {
      return conv;
    }

    // Even though this format supports negative values and custom
    // precision they do not make use of this and we still have to subtract
    // the bias and scale it (RADVOR FX, dBZ)
    return Conversion.toDBZ(conv);
  }

  // rvp6Raw converts the raw value to radar video processor values (rvp-6) by applying the
  // products precision field.
  public static double rvp6Raw(Composite c, int value)  {
    double rvalue=value * c.getPrecisionFactor();
    return rvalue;
  }