cdm/src/main/java/ucar/nc2/iosp/nids/Nidsheader.java
int pcode_raster( ByteBuffer bos, short pkcode, int hoff, int hedsiz, boolean isZ, byte[] data )
    {
        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;

        short[] rasp_code = new short[3];

        rasp_code[0] = pkcode;

        bos.get(b2, 0, 2);
        rasp_code[1] = (short)getInt(b2, 2);
        bos.get(b2, 0, 2);
        rasp_code[2] = (short)getInt(b2, 2);
        bos.get(b2, 0, 2);
//        short rasp_i = (short)getInt(b2, 2);
        bos.get(b2, 0, 2);
//        short rasp_j = (short)getInt(b2, 2);
        bos.get(b2, 0, 2);
        short rasp_xscale = (short)getInt(b2, 2);
        bos.get(b2, 0, 2);
//        short rasp_xscalefract = (short)getInt(b2, 2);
        bos.get(b2, 0, 2);
//        short rasp_yscale = (short)getInt(b2, 2);
        bos.get(b2, 0, 2);
//        short rasp_yscalefract = (short)getInt(b2, 2);
        bos.get(b2, 0, 2);
        short num_rows = (short)getInt(b2, 2);
        bos.get(b2, 0, 2);
//        short packing = (short)getInt(b2, 2);
        soff= 20;
        hedsiz = hedsiz + soff;

        int nlevel = code_levelslookup( pcode );
        double ddx = code_reslookup( pcode );
        int [] levels = getLevels(nlevel, threshold);

        //prod_info_size = (int) (num_rows * scale);
        //out.println( "resp scale " + (int)rasp_xscale + " and " + (int)rasp_xscalefract+ " and " + (int)rasp_yscale+ " and " + (int)rasp_yscalefract );
        numY0 = 0; //rasp_j;
        numX0 = 0; //rasp_i;
        numX = num_rows;
        numY = num_rows;
        Dimension jDim = new Dimension("y", numY, true, false, false);
        Dimension iDim = new Dimension("x", numX, true, false, false);
        dims.add( jDim);
        dims.add( iDim);
        ncfile.addDimension( null, iDim);
        ncfile.addDimension( null, jDim);
        //ncfile.addAttribute(null, new Attribute("cdm_data_type", thredds.catalog.DataType.GRID.toString()));
        if(cname.startsWith("Precip")) {
            ncfile.addAttribute(null, new Attribute("isRadial", new Integer(3)));
            ddx = ddx * rasp_xscale;
        }
        ncfile.addAttribute(null, new Attribute("cdm_data_type", FeatureType.GRID.toString()));
        //Variable dist = new Variable(ncfile, null, null, "distance");
        //dist.setDataType(DataType.INT);
        //dist.setDimensions(dims);
        //ncfile.addVariable(null, dist);
        //dist.setSPobject( new Vinfo ( numX, numX0, numY, numY0, hoff, hedsiz, isR, isZ, null, null, pkcode, 0));


        String coordinates = "x y time latitude longitude altitude";

        Variable v = new Variable(ncfile, null, null, cname+ "_RAW");
        v.setDataType(DataType.BYTE);
        v.setDimensions(dims);
        ncfile.addVariable(null, v);
        v.addAttribute( new Attribute(CDM.LONG_NAME, ctitle));
        v.addAttribute( new Attribute(CDM.UNITS, cunit));
        v.setSPobject( new Vinfo (numX, numX0, numY, numY0, hoff, hedsiz, isR, isZ, null, null, pkcode, 0));
        v.addAttribute( new Attribute(_Coordinate.Axes, coordinates));

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

        // create coordinate variables
        Variable xaxis = new Variable( ncfile, null, null, "x");
        xaxis.setDataType( DataType.DOUBLE);
        xaxis.setDimensions("x");
        xaxis.addAttribute( new Attribute(CDM.LONG_NAME, "projection x coordinate"));
        xaxis.addAttribute( new Attribute(CDM.UNITS, "km"));
        xaxis.addAttribute( new Attribute(_Coordinate.AxisType, "GeoX"));
        double[] data1 = new double[numX];
        for (int i = 0; i < numX; i++)
          data1[i] = numX0 + i*ddx;
        Array dataA = Array.factory(DataType.DOUBLE, new int[] {numX}, data1);
        xaxis.setCachedData( dataA, false);
        ncfile.addVariable(null, xaxis);

        Variable yaxis = new Variable( ncfile, null, null, "y");
        yaxis.setDataType( DataType.DOUBLE);
        yaxis.setDimensions( "y");
        yaxis.addAttribute( new Attribute(CDM.LONG_NAME, "projection y coordinate"));
        yaxis.addAttribute( new Attribute(CDM.UNITS, "km"));
        yaxis.addAttribute( new Attribute(_Coordinate.AxisType, "GeoY"));
        data1 = new double[numY];
        for (int i = 0; i < numY; i++)
          data1[i] = numY0 + i*ddx;
        dataA = Array.factory(DataType.DOUBLE, new int[] {numY}, data1);
        yaxis.setCachedData( dataA, false);
        ncfile.addVariable(null, yaxis);

        ProjectionImpl projection = new FlatEarth(lat_min, lon_max);
        //ProjectionImpl projection = new LambertConformal(latitude, longitude, latitude, latitude);
        // coordinate transform variable
        Variable ct = new Variable( ncfile, null, null, projection.getClassName());
        ct.setDataType( DataType.CHAR);
        ct.setDimensions( "");
        List params = projection.getProjectionParameters();
        for (int i = 0; i < params.size(); i++) {
          Parameter p = (Parameter) params.get(i);
          ct.addAttribute( new Attribute(p));
        }
        ct.addAttribute( new Attribute(_Coordinate.TransformType, "Projection"));
        ct.addAttribute( new Attribute(_Coordinate.Axes, "x y"));
        // fake data
        dataA = Array.factory(DataType.CHAR, new int[] {});
        dataA.setChar(dataA.getIndex(), ' ');
        ct.setCachedData(dataA, false);

        ncfile.addVariable(null, ct);
        return soff;

    }
int pcode_raster( ByteBuffer bos, short pkcode, int hoff, int hedsiz, boolean isZ, byte[] data )
    {
        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;

        short[] rasp_code = new short[3];

        rasp_code[0] = pkcode;

        bos.get(b2, 0, 2);
        rasp_code[1] = (short)getInt(b2, 2);
        bos.get(b2, 0, 2);
        rasp_code[2] = (short)getInt(b2, 2);
        bos.get(b2, 0, 2);
//        short rasp_i = (short)getInt(b2, 2);
        bos.get(b2, 0, 2);
//        short rasp_j = (short)getInt(b2, 2);
        bos.get(b2, 0, 2);
        short rasp_xscale = (short)getInt(b2, 2);
        bos.get(b2, 0, 2);
//        short rasp_xscalefract = (short)getInt(b2, 2);
        bos.get(b2, 0, 2);
//        short rasp_yscale = (short)getInt(b2, 2);
        bos.get(b2, 0, 2);
//        short rasp_yscalefract = (short)getInt(b2, 2);
        bos.get(b2, 0, 2);
        short num_rows = (short)getInt(b2, 2);
        bos.get(b2, 0, 2);
//        short packing = (short)getInt(b2, 2);
        soff= 20;
        hedsiz = hedsiz + soff;

        int nlevel = code_levelslookup( pcode );
        double ddx = code_reslookup( pcode );
        int [] levels = getLevels(nlevel, threshold);

        //prod_info_size = (int) (num_rows * scale);
        //out.println( "resp scale " + (int)rasp_xscale + " and " + (int)rasp_xscalefract+ " and " + (int)rasp_yscale+ " and " + (int)rasp_yscalefract );
        numY0 = 0; //rasp_j;
        numX0 = 0; //rasp_i;
        numX = num_rows;
        numY = num_rows;
        Dimension jDim = new Dimension("y", numY, true, false, false);
        Dimension iDim = new Dimension("x", numX, true, false, false);
        dims.add( jDim);
        dims.add( iDim);
        ncfile.addDimension( null, iDim);
        ncfile.addDimension( null, jDim);
        //ncfile.addAttribute(null, new Attribute("cdm_data_type", thredds.catalog.DataType.GRID.toString()));
        if(cname.startsWith("Precip")) {
            ncfile.addAttribute(null, new Attribute("isRadial", new Integer(3)));
            ddx = ddx * rasp_xscale;
        }
        ncfile.addAttribute(null, new Attribute("cdm_data_type", FeatureType.GRID.toString()));
        //Variable dist = new Variable(ncfile, null, null, "distance");
        //dist.setDataType(DataType.INT);
        //dist.setDimensions(dims);
        //ncfile.addVariable(null, dist);
        //dist.setSPobject( new Vinfo ( numX, numX0, numY, numY0, hoff, hedsiz, isR, isZ, null, null, pkcode, 0));


        String coordinates = "x y time latitude longitude altitude";

        Variable v = new Variable(ncfile, null, null, cname+ "_RAW");
        v.setDataType(DataType.BYTE);
        v.setDimensions(dims);
        ncfile.addVariable(null, v);
        v.addAttribute( new Attribute(CDM.LONG_NAME, ctitle));
        v.addAttribute( new Attribute(CDM.UNITS, cunit));
        v.setSPobject( new Vinfo (numX, numX0, numY, numY0, hoff, hedsiz, isR, isZ, null, null, pkcode, 0));
        v.addAttribute( new Attribute(_Coordinate.Axes, coordinates));

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

        // create coordinate variables
        Variable xaxis = new Variable( ncfile, null, null, "x");
        xaxis.setDataType( DataType.DOUBLE);
        xaxis.setDimensions("x");
        xaxis.addAttribute( new Attribute(CDM.LONG_NAME, "projection x coordinate"));
        xaxis.addAttribute( new Attribute(CDM.UNITS, "km"));
        xaxis.addAttribute( new Attribute(_Coordinate.AxisType, "GeoX"));
        double[] data1 = new double[numX];
        for (int i = 0; i < numX; i++)
          data1[i] = numX0 + i*ddx;
        Array dataA = Array.factory(DataType.DOUBLE, new int[] {numX}, data1);
        xaxis.setCachedData( dataA, false);
        ncfile.addVariable(null, xaxis);

        Variable yaxis = new Variable( ncfile, null, null, "y");
        yaxis.setDataType( DataType.DOUBLE);
        yaxis.setDimensions( "y");
        yaxis.addAttribute( new Attribute(CDM.LONG_NAME, "projection y coordinate"));
        yaxis.addAttribute( new Attribute(CDM.UNITS, "km"));
        yaxis.addAttribute( new Attribute(_Coordinate.AxisType, "GeoY"));
        data1 = new double[numY];
        for (int i = 0; i < numY; i++)
          data1[i] = numY0 + i*ddx;
        dataA = Array.factory(DataType.DOUBLE, new int[] {numY}, data1);
        yaxis.setCachedData( dataA, false);
        ncfile.addVariable(null, yaxis);

        ProjectionImpl projection = new FlatEarth(lat_min, lon_max);
        //ProjectionImpl projection = new LambertConformal(latitude, longitude, latitude, latitude);
        // coordinate transform variable
        Variable ct = new Variable( ncfile, null, null, projection.getClassName());
        ct.setDataType( DataType.CHAR);
        ct.setDimensions( "");
        List params = projection.getProjectionParameters();
        for (int i = 0; i < params.size(); i++) {
          Parameter p = (Parameter) params.get(i);
          ct.addAttribute( new Attribute(p));
        }
        ct.addAttribute( new Attribute(_Coordinate.TransformType, "Projection"));
        ct.addAttribute( new Attribute(_Coordinate.Axes, "x y"));
        // fake data
        dataA = Array.factory(DataType.CHAR, new int[] {});
        dataA.setChar(dataA.getIndex(), ' ');
        ct.setCachedData(dataA, false);

        ncfile.addVariable(null, ct);
        return soff;

    }
construct a raster dataset for NIDS raster products;


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

@return  soff -- not used