cdm/src/main/java/ucar/atd/dorade/DoradePARM.java
public float[] getParamValues(DoradeRDAT rdat,float[] workingArray)
            throws DescriptorException {


        if (! paramName.equals(rdat.getParamName()))
            throw new DescriptorException("parameter name mismatch");

        byte[] paramData = rdat.getRawData();

        int nCells = myRADD.getNCells();

        float[] values;
	if(workingArray!=null && workingArray.length == nCells) {
	    values = workingArray;
	} else {
	    values = new float[nCells];
	}

        short[] svalues = null;
        if (myRADD.getCompressionScheme() == DoradeRADD.COMPRESSION_HRD) {
            if (binaryFormat != DoradePARM.FORMAT_16BIT_INT) {
                throw new DescriptorException("Cannot unpack " +
                           "compressed data with binary format " +
                           binaryFormat);
            }
            svalues = uncompressHRD(paramData, nCells);
        }

        for (int cell = 0; cell < nCells; cell++) {
            switch (binaryFormat) {
                case DoradePARM.FORMAT_8BIT_INT:
                    byte bval = paramData[cell];
                    values[cell] = (bval == badDataFlag) ?
                                   BAD_VALUE : (bval - bias) / scale;
                    break;
                case DoradePARM.FORMAT_16BIT_INT:
                    short sval = (svalues != null) ?
                                 svalues[cell] : grabShort(paramData, 2 * cell);
                    values[cell] = (sval == badDataFlag) ?
                                   BAD_VALUE : (sval - bias) / scale;
                    break;
                case DoradePARM.FORMAT_32BIT_INT:
                    int ival = grabInt(paramData, 4 * cell);
                    values[cell] = (ival == badDataFlag) ?
                                   BAD_VALUE : (ival - bias) / scale;
                    break;
                case DoradePARM.FORMAT_32BIT_FLOAT:
                    float fval = grabFloat(paramData, 4 * cell);
                    values[cell] = (fval == badDataFlag) ?
                                   BAD_VALUE : (fval - bias) / scale;
                    break;
                case DoradePARM.FORMAT_16BIT_FLOAT:
                    throw new DescriptorException("can't unpack 16-bit " +
                                                        "float data yet");
                default:
                    throw new DescriptorException("bad binary format (" +
                                                        binaryFormat + ")");
            }
        }
        return values;
    }
public float[] getParamValues(DoradeRDAT rdat,float[] workingArray)
            throws DescriptorException {


        if (! paramName.equals(rdat.getParamName()))
            throw new DescriptorException("parameter name mismatch");

        byte[] paramData = rdat.getRawData();

        int nCells = myRADD.getNCells();

        float[] values;
	if(workingArray!=null && workingArray.length == nCells) {
	    values = workingArray;
	} else {
	    values = new float[nCells];
	}

        short[] svalues = null;
        if (myRADD.getCompressionScheme() == DoradeRADD.COMPRESSION_HRD) {
            if (binaryFormat != DoradePARM.FORMAT_16BIT_INT) {
                throw new DescriptorException("Cannot unpack " +
                           "compressed data with binary format " +
                           binaryFormat);
            }
            svalues = uncompressHRD(paramData, nCells);
        }

        for (int cell = 0; cell < nCells; cell++) {
            switch (binaryFormat) {
                case DoradePARM.FORMAT_8BIT_INT:
                    byte bval = paramData[cell];
                    values[cell] = (bval == badDataFlag) ?
                                   BAD_VALUE : (bval - bias) / scale;
                    break;
                case DoradePARM.FORMAT_16BIT_INT:
                    short sval = (svalues != null) ?
                                 svalues[cell] : grabShort(paramData, 2 * cell);
                    values[cell] = (sval == badDataFlag) ?
                                   BAD_VALUE : (sval - bias) / scale;
                    break;
                case DoradePARM.FORMAT_32BIT_INT:
                    int ival = grabInt(paramData, 4 * cell);
                    values[cell] = (ival == badDataFlag) ?
                                   BAD_VALUE : (ival - bias) / scale;
                    break;
                case DoradePARM.FORMAT_32BIT_FLOAT:
                    float fval = grabFloat(paramData, 4 * cell);
                    values[cell] = (fval == badDataFlag) ?
                                   BAD_VALUE : (fval - bias) / scale;
                    break;
                case DoradePARM.FORMAT_16BIT_FLOAT:
                    throw new DescriptorException("can't unpack 16-bit " +
                                                        "float data yet");
                default:
                    throw new DescriptorException("bad binary format (" +
                                                        binaryFormat + ")");
            }
        }
        return values;
    }
public float [ ] getParamValues ( DoradeRDAT rdat , float [ ] workingArray ) throws DescriptorException { if ( ! paramName . equals ( rdat . getParamName ( ) ) ) throw new DescriptorException ( "parameter name mismatch" ) ; byte [ ] paramData = rdat . getRawData ( ) ; int nCells = myRADD . getNCells ( ) ; float [ ] values ; if ( workingArray != null && workingArray . length == nCells ) { values = workingArray ; } else { values = new float [ nCells ] ; } short [ ] svalues = null ; if ( myRADD . getCompressionScheme ( ) == DoradeRADD . COMPRESSION_HRD ) { if ( binaryFormat != DoradePARM . FORMAT_16BIT_INT ) { throw new DescriptorException ( "Cannot unpack " + "compressed data with binary format " + binaryFormat ) ; } svalues = uncompressHRD ( paramData , nCells ) ; } for ( int cell = 0 ; cell < nCells ; cell ++ ) { switch ( binaryFormat ) { case DoradePARM . FORMAT_8BIT_INT : byte bval = paramData [ cell ] ; values [ cell ] = ( bval == badDataFlag ) ? BAD_VALUE : ( bval - bias ) / scale ; break ; case DoradePARM . FORMAT_16BIT_INT : short sval = ( svalues != null ) ? svalues [ cell ] : grabShort ( paramData , 2 * cell ) ; values [ cell ] = ( sval == badDataFlag ) ? BAD_VALUE : ( sval - bias ) / scale ; break ; case DoradePARM . FORMAT_32BIT_INT : int ival = grabInt ( paramData , 4 * cell ) ; values [ cell ] = ( ival == badDataFlag ) ? BAD_VALUE : ( ival - bias ) / scale ; break ; case DoradePARM . FORMAT_32BIT_FLOAT : float fval = grabFloat ( paramData , 4 * cell ) ; values [ cell ] = ( fval == badDataFlag ) ? BAD_VALUE : ( fval - bias ) / scale ; break ; case DoradePARM . FORMAT_16BIT_FLOAT : throw new DescriptorException ( "can't unpack 16-bit " + "float data yet" ) ; default : throw new DescriptorException ( "bad binary format (" + binaryFormat + ")" ) ; } } return values ; }
Get the unpacked data values for a selected parameter.
@param rdat the name of the desired parameter
@param workingArray If non-null and the same length as needed then use this.
@return the unpacked data values for all cells, using BAD_VALUE
for bad data cells
@throws DescriptorException
Get the unpacked data values for a selected parameter .