cdm/src/main/java/ucar/nc2/iosp/nids/Nidsheader.java
int pcode_radial( ByteBuffer  bos, int hoff, int hedsiz, boolean isZ, byte[] data, short[] threshold ) throws IOException
    {
        byte[] b2 = new byte[2];
        int soff;
        ArrayList dims =  new ArrayList();
        int iscale = 1;                         /* data scale                    */
        int ival;

        ival = convertShort2unsignedInt(threshold[0]);
        if ( (ival & ( 1 << 13 )) != 0 ) iscale = 20;
        if ( (ival & ( 1 << 12 )) != 0 ) iscale = 10;


        bos.get(b2, 0, 2);
        short first_bin = (short)getInt(b2, 2);
        bos.get(b2, 0, 2);
        short num_bin = (short)(getUInt(b2, 2));
        if(this.pcode == 94 || this.pcode == 99)
            num_bin = addBinSize(num_bin);
        bos.get(b2, 0, 2);
//        short radp_i = (short)getInt(b2, 2);
        bos.get(b2, 0, 2);
//        short radp_j = (short)getInt(b2, 2);
        bos.get(b2, 0, 2);
        short radp_scale = (short)getInt(b2, 2);
        if(this.pcode == 134 || this.pcode == 135)
             radp_scale = (short)(radp_scale * 1000);
        bos.get(b2, 0, 2);
        short num_radials = (short)getInt(b2, 2);
        soff = 12;
        hedsiz = hedsiz + soff;
        numY0 = 0;
        numY = num_radials;
        numX0 = first_bin;
        numX = num_bin;
        int nlevel = code_levelslookup( pcode );
        int [] levels;

        //prod_info_size = 2 * (int) (num_bin * scale + 0.5);
        //dimensions: radial, bin
        ncfile.addAttribute(null, new Attribute("cdm_data_type", FeatureType.RADIAL.toString()));
        Dimension radialDim = new Dimension("azimuth", num_radials);
        ncfile.addDimension( null, radialDim);

        Dimension binDim = new Dimension("gate", num_bin);
        ncfile.addDimension( null, binDim);
        dims.add( radialDim);
        dims.add( binDim);

        ArrayList dims1 =  new ArrayList();
        ArrayList dims2 =  new ArrayList();
        dims1.add(radialDim);
        dims2.add(binDim);
        // Variable aziVar = new Variable(ncfile, null, null, "azimuth");
        // aziVar.setDataType(DataType.FLOAT);
        // aziVar.setDimensions(dims1);
        // ncfile.addVariable(null, aziVar);
        // aziVar.addAttribute( new Attribute(CDM.LONG_NAME, "azimuth angle in degrees: 0 = true north, 90 = east"));
        // aziVar.addAttribute( new Attribute(CDM.UNITS, "degrees"));
        // aziVar.setSPobject( new Vinfo (numX, numX0, numY, numY0, hoff, hedsiz, isR, isZ, null, null, 0));

        // dims1 =  new ArrayList();
        // dims1.add(binDim);
        //Variable gateV = new Variable(ncfile, null, null, "gate1");
        //gateV.setDataType(DataType.FLOAT);
        //gateV.setDimensions(dims2);
        //ncfile.addVariable(null, gateV);
        //gateV.addAttribute( new Attribute(CDM.LONG_NAME, "radial distance to start of gate"));
        //gateV.addAttribute( new Attribute(CDM.UNITS, "m"));
        //gateV.setSPobject( new Vinfo (numX, numX0, numY, radp_scale, hoff, hedsiz, isR, isZ, null, null, 0, 0));
        isR = true;

        // add elevation coordinate variable
        String vName = "elevation";
        String lName = "elevation angle in degres: 0 = parallel to pedestal base, 90 = perpendicular";
        Attribute att = new Attribute(_Coordinate.AxisType, AxisType.RadialElevation.toString());
        addParameter(vName, lName, ncfile, dims1, att, DataType.FLOAT, "degrees",hoff, hedsiz, isZ, p3);

        // add azimuth coordinate variable
        vName = "azimuth";
        lName = "azimuth angle in degrees: 0 = true north, 90 = east";
        att = new Attribute(_Coordinate.AxisType, AxisType.RadialAzimuth.toString());
        addParameter(vName, lName, ncfile, dims1, att, DataType.FLOAT, "degrees",hoff, hedsiz, isZ, 0);


        // add gate coordinate variable
        vName = "gate";
        lName = "Radial distance to the start of gate";
        att = new Attribute(_Coordinate.AxisType, AxisType.RadialDistance.toString());
        addParameter(vName, lName, ncfile, dims2, att, DataType.FLOAT, "meters",hoff, hedsiz, isZ, radp_scale);

        // add radial coordinate variable

        vName = "latitude";
        lName = "Latitude of the instrument";
        att = new Attribute(_Coordinate.AxisType, AxisType.Lat.toString());
        addParameter(vName, lName, ncfile, dims1, att, DataType.FLOAT, "degrees",hoff, hedsiz, isZ, 0);

        vName = "longitude";
        lName = "Longitude of the instrument";
        att = new Attribute(_Coordinate.AxisType, AxisType.Lon.toString());
        addParameter(vName, lName, ncfile, dims1, att, DataType.FLOAT, "degrees",hoff, hedsiz, isZ, 0);

        vName = "altitude";
        lName = "Altitude in meters (asl) of the instrument";
        att = new Attribute(_Coordinate.AxisType, AxisType.Height.toString());
        addParameter(vName, lName, ncfile, dims1, att, DataType.FLOAT, "meters",hoff, hedsiz, isZ, 0);

        vName = "rays_time";
        lName = "rays time";
        att = new Attribute(_Coordinate.AxisType, AxisType.Time.toString());
        addParameter(vName, lName, ncfile, dims1, att, DataType.DOUBLE, "milliseconds since 1970-01-01 00:00 UTC"
                    ,hoff, hedsiz, isZ, 0);
        //add RAW, BRIT variables for all radial variable
        if(pcode == 182 || pcode == 99 ) {
            levels = getTDWRLevels(nlevel, threshold);
            iscale = 10;
        } else if (pcode == 186 || pcode == 94) {
            threshold[0] = -320;
            threshold[1] = 5;
            threshold[2] = 254;
            levels = getTDWRLevels(nlevel, threshold);
            iscale = 10;
        } else if (pcode == 32  ) {
            levels = getTDWRLevels1(nlevel, threshold);
            iscale = 10;
        } else if (pcode == 138) {
            levels = getTDWRLevels1(nlevel, threshold);
            iscale = 100;
        } else if (pcode == 134 ||  pcode == 135) {
            levels = getTDWRLevels2(nlevel, threshold);
            iscale = 1;
        } else if (pcode ==159 || pcode ==161 || pcode == 163
                || pcode == 170 || pcode == 172 || pcode == 173
                || pcode == 174 || pcode == 175
                || pcode == 165 || pcode == 177) {

            levels = getDualpolLevels(threshold);
            iscale = 100;
        } else {
            levels = getLevels(nlevel, threshold);
        }



        Variable v = new Variable(ncfile, null, null, cname + "_RAW");
        v.setDataType(DataType.UBYTE);
        v.setDimensions(dims);
        ncfile.addVariable(null, v);
        v.addAttribute( new Attribute(CDM.UNITS, cunit));
        String coordinates = "elevation azimuth gate rays_time latitude longitude altitude";
        v.addAttribute( new Attribute(_Coordinate.Axes, coordinates));
        // v.addAttribute( new Attribute(CDM.UNSIGNED, "true"));
        v.setSPobject( new Vinfo (numX, numX0, numY, numY0, hoff, hedsiz, isR, isZ, null, levels, 0, nlevel));

        // addVariable(cname + "_Brightness", ctitle + " Brightness", ncfile, dims, coordinates, DataType.FLOAT,
        //                 cunit, hoff, hedsiz, isZ, nlevel, levels, iscale);
        if (cname.startsWith("CorrelationCoefficient") || cname.startsWith("HydrometeorClassification") ||
                cname.startsWith("DifferentialReflectivity") ||   cname.startsWith("DifferentialPhase")
                ||   cname.startsWith("HypridHydrometeorClassification") ) {
            addVariable(cname, ctitle, ncfile, dims, coordinates, DataType.FLOAT,
                    cunit, hoff, hedsiz, isZ, nlevel, levels, iscale);
        } else if (cname.startsWith("OneHourAccumulation") || cname.startsWith("DigitalAccumulationArray") ||
                cname.startsWith("StormTotalAccumulation") ||   cname.startsWith("DigitalStormTotalAccumulation") ||
                cname.startsWith("Accumulation3Hour") ||   cname.startsWith("Accumulation24Hour") ||
                cname.startsWith("Digital1HourDifferenceAccumulation") ||
                cname.startsWith("DigitalInstantaneousPrecipitationRate") ||
                cname.startsWith("DigitalInstantaneousPrecipitationRate") ||
                cname.startsWith("DigitalTotalDifferenceAccumulation") ) {
            addVariable(cname, ctitle, ncfile, dims, coordinates, DataType.FLOAT,
                    cunit, hoff, hedsiz, isZ, nlevel, levels, iscale);
        }
        else if( cname.startsWith("BaseReflectivity") || cname.endsWith("Reflectivity") ||
                cname.startsWith("SpectrumWidth")){

          //addVariable(cname + "_VIP", ctitle + " VIP Level", ncfile, dims, coordinates, DataType.FLOAT,
          //             cunit, hoff, hedsiz, isZ, nlevel, levels, iscale);

          addVariable(cname, ctitle, ncfile, dims, coordinates, DataType.FLOAT,
                       cunit, hoff, hedsiz, isZ, nlevel, levels, iscale);
        }
        else if (cname.startsWith("RadialVelocity") || cname.startsWith("StormMeanVelocity") ||
                cname.startsWith("BaseVelocity")) {

          addVariable(cname, ctitle, ncfile, dims, coordinates, DataType.FLOAT,
                       cunit, hoff, hedsiz, isZ, nlevel, levels, iscale);
        }
        else if (cname.startsWith("Precip") || cname.endsWith("Precip") ||
            cname.startsWith("EnhancedEchoTop") ||   cname.startsWith("DigitalIntegLiquid")){

           addVariable(cname, ctitle, ncfile, dims, coordinates, DataType.FLOAT,
                       cunit, hoff, hedsiz, isZ, nlevel, levels, iscale);
        }


        return soff;
    }
int pcode_radial( ByteBuffer  bos, int hoff, int hedsiz, boolean isZ, byte[] data, short[] threshold ) throws IOException
    {
        byte[] b2 = new byte[2];
        int soff;
        ArrayList dims =  new ArrayList();
        int iscale = 1;                         /* data scale                    */
        int ival;

        ival = convertShort2unsignedInt(threshold[0]);
        if ( (ival & ( 1 << 13 )) != 0 ) iscale = 20;
        if ( (ival & ( 1 << 12 )) != 0 ) iscale = 10;


        bos.get(b2, 0, 2);
        short first_bin = (short)getInt(b2, 2);
        bos.get(b2, 0, 2);
        short num_bin = (short)(getUInt(b2, 2));
        if(this.pcode == 94 || this.pcode == 99)
            num_bin = addBinSize(num_bin);
        bos.get(b2, 0, 2);
//        short radp_i = (short)getInt(b2, 2);
        bos.get(b2, 0, 2);
//        short radp_j = (short)getInt(b2, 2);
        bos.get(b2, 0, 2);
        short radp_scale = (short)getInt(b2, 2);
        if(this.pcode == 134 || this.pcode == 135)
             radp_scale = (short)(radp_scale * 1000);
        bos.get(b2, 0, 2);
        short num_radials = (short)getInt(b2, 2);
        soff = 12;
        hedsiz = hedsiz + soff;
        numY0 = 0;
        numY = num_radials;
        numX0 = first_bin;
        numX = num_bin;
        int nlevel = code_levelslookup( pcode );
        int [] levels;

        //prod_info_size = 2 * (int) (num_bin * scale + 0.5);
        //dimensions: radial, bin
        ncfile.addAttribute(null, new Attribute("cdm_data_type", FeatureType.RADIAL.toString()));
        Dimension radialDim = new Dimension("azimuth", num_radials);
        ncfile.addDimension( null, radialDim);

        Dimension binDim = new Dimension("gate", num_bin);
        ncfile.addDimension( null, binDim);
        dims.add( radialDim);
        dims.add( binDim);

        ArrayList dims1 =  new ArrayList();
        ArrayList dims2 =  new ArrayList();
        dims1.add(radialDim);
        dims2.add(binDim);
        // Variable aziVar = new Variable(ncfile, null, null, "azimuth");
        // aziVar.setDataType(DataType.FLOAT);
        // aziVar.setDimensions(dims1);
        // ncfile.addVariable(null, aziVar);
        // aziVar.addAttribute( new Attribute(CDM.LONG_NAME, "azimuth angle in degrees: 0 = true north, 90 = east"));
        // aziVar.addAttribute( new Attribute(CDM.UNITS, "degrees"));
        // aziVar.setSPobject( new Vinfo (numX, numX0, numY, numY0, hoff, hedsiz, isR, isZ, null, null, 0));

        // dims1 =  new ArrayList();
        // dims1.add(binDim);
        //Variable gateV = new Variable(ncfile, null, null, "gate1");
        //gateV.setDataType(DataType.FLOAT);
        //gateV.setDimensions(dims2);
        //ncfile.addVariable(null, gateV);
        //gateV.addAttribute( new Attribute(CDM.LONG_NAME, "radial distance to start of gate"));
        //gateV.addAttribute( new Attribute(CDM.UNITS, "m"));
        //gateV.setSPobject( new Vinfo (numX, numX0, numY, radp_scale, hoff, hedsiz, isR, isZ, null, null, 0, 0));
        isR = true;

        // add elevation coordinate variable
        String vName = "elevation";
        String lName = "elevation angle in degres: 0 = parallel to pedestal base, 90 = perpendicular";
        Attribute att = new Attribute(_Coordinate.AxisType, AxisType.RadialElevation.toString());
        addParameter(vName, lName, ncfile, dims1, att, DataType.FLOAT, "degrees",hoff, hedsiz, isZ, p3);

        // add azimuth coordinate variable
        vName = "azimuth";
        lName = "azimuth angle in degrees: 0 = true north, 90 = east";
        att = new Attribute(_Coordinate.AxisType, AxisType.RadialAzimuth.toString());
        addParameter(vName, lName, ncfile, dims1, att, DataType.FLOAT, "degrees",hoff, hedsiz, isZ, 0);


        // add gate coordinate variable
        vName = "gate";
        lName = "Radial distance to the start of gate";
        att = new Attribute(_Coordinate.AxisType, AxisType.RadialDistance.toString());
        addParameter(vName, lName, ncfile, dims2, att, DataType.FLOAT, "meters",hoff, hedsiz, isZ, radp_scale);

        // add radial coordinate variable

        vName = "latitude";
        lName = "Latitude of the instrument";
        att = new Attribute(_Coordinate.AxisType, AxisType.Lat.toString());
        addParameter(vName, lName, ncfile, dims1, att, DataType.FLOAT, "degrees",hoff, hedsiz, isZ, 0);

        vName = "longitude";
        lName = "Longitude of the instrument";
        att = new Attribute(_Coordinate.AxisType, AxisType.Lon.toString());
        addParameter(vName, lName, ncfile, dims1, att, DataType.FLOAT, "degrees",hoff, hedsiz, isZ, 0);

        vName = "altitude";
        lName = "Altitude in meters (asl) of the instrument";
        att = new Attribute(_Coordinate.AxisType, AxisType.Height.toString());
        addParameter(vName, lName, ncfile, dims1, att, DataType.FLOAT, "meters",hoff, hedsiz, isZ, 0);

        vName = "rays_time";
        lName = "rays time";
        att = new Attribute(_Coordinate.AxisType, AxisType.Time.toString());
        addParameter(vName, lName, ncfile, dims1, att, DataType.DOUBLE, "milliseconds since 1970-01-01 00:00 UTC"
                    ,hoff, hedsiz, isZ, 0);
        //add RAW, BRIT variables for all radial variable
        if(pcode == 182 || pcode == 99 ) {
            levels = getTDWRLevels(nlevel, threshold);
            iscale = 10;
        } else if (pcode == 186 || pcode == 94) {
            threshold[0] = -320;
            threshold[1] = 5;
            threshold[2] = 254;
            levels = getTDWRLevels(nlevel, threshold);
            iscale = 10;
        } else if (pcode == 32  ) {
            levels = getTDWRLevels1(nlevel, threshold);
            iscale = 10;
        } else if (pcode == 138) {
            levels = getTDWRLevels1(nlevel, threshold);
            iscale = 100;
        } else if (pcode == 134 ||  pcode == 135) {
            levels = getTDWRLevels2(nlevel, threshold);
            iscale = 1;
        } else if (pcode ==159 || pcode ==161 || pcode == 163
                || pcode == 170 || pcode == 172 || pcode == 173
                || pcode == 174 || pcode == 175
                || pcode == 165 || pcode == 177) {

            levels = getDualpolLevels(threshold);
            iscale = 100;
        } else {
            levels = getLevels(nlevel, threshold);
        }



        Variable v = new Variable(ncfile, null, null, cname + "_RAW");
        v.setDataType(DataType.UBYTE);
        v.setDimensions(dims);
        ncfile.addVariable(null, v);
        v.addAttribute( new Attribute(CDM.UNITS, cunit));
        String coordinates = "elevation azimuth gate rays_time latitude longitude altitude";
        v.addAttribute( new Attribute(_Coordinate.Axes, coordinates));
        // v.addAttribute( new Attribute(CDM.UNSIGNED, "true"));
        v.setSPobject( new Vinfo (numX, numX0, numY, numY0, hoff, hedsiz, isR, isZ, null, levels, 0, nlevel));

        // addVariable(cname + "_Brightness", ctitle + " Brightness", ncfile, dims, coordinates, DataType.FLOAT,
        //                 cunit, hoff, hedsiz, isZ, nlevel, levels, iscale);
        if (cname.startsWith("CorrelationCoefficient") || cname.startsWith("HydrometeorClassification") ||
                cname.startsWith("DifferentialReflectivity") ||   cname.startsWith("DifferentialPhase")
                ||   cname.startsWith("HypridHydrometeorClassification") ) {
            addVariable(cname, ctitle, ncfile, dims, coordinates, DataType.FLOAT,
                    cunit, hoff, hedsiz, isZ, nlevel, levels, iscale);
        } else if (cname.startsWith("OneHourAccumulation") || cname.startsWith("DigitalAccumulationArray") ||
                cname.startsWith("StormTotalAccumulation") ||   cname.startsWith("DigitalStormTotalAccumulation") ||
                cname.startsWith("Accumulation3Hour") ||   cname.startsWith("Accumulation24Hour") ||
                cname.startsWith("Digital1HourDifferenceAccumulation") ||
                cname.startsWith("DigitalInstantaneousPrecipitationRate") ||
                cname.startsWith("DigitalInstantaneousPrecipitationRate") ||
                cname.startsWith("DigitalTotalDifferenceAccumulation") ) {
            addVariable(cname, ctitle, ncfile, dims, coordinates, DataType.FLOAT,
                    cunit, hoff, hedsiz, isZ, nlevel, levels, iscale);
        }
        else if( cname.startsWith("BaseReflectivity") || cname.endsWith("Reflectivity") ||
                cname.startsWith("SpectrumWidth")){

          //addVariable(cname + "_VIP", ctitle + " VIP Level", ncfile, dims, coordinates, DataType.FLOAT,
          //             cunit, hoff, hedsiz, isZ, nlevel, levels, iscale);

          addVariable(cname, ctitle, ncfile, dims, coordinates, DataType.FLOAT,
                       cunit, hoff, hedsiz, isZ, nlevel, levels, iscale);
        }
        else if (cname.startsWith("RadialVelocity") || cname.startsWith("StormMeanVelocity") ||
                cname.startsWith("BaseVelocity")) {

          addVariable(cname, ctitle, ncfile, dims, coordinates, DataType.FLOAT,
                       cunit, hoff, hedsiz, isZ, nlevel, levels, iscale);
        }
        else if (cname.startsWith("Precip") || cname.endsWith("Precip") ||
            cname.startsWith("EnhancedEchoTop") ||   cname.startsWith("DigitalIntegLiquid")){

           addVariable(cname, ctitle, ncfile, dims, coordinates, DataType.FLOAT,
                       cunit, hoff, hedsiz, isZ, nlevel, levels, iscale);
        }


        return soff;
    }
construct a radial dataset for NIDS radial products;


@param bos, hoff, hedsiz, isZ, data, threshold

@return  soff -- not used