Package ucar.grib.grib1

Examples of ucar.grib.grib1.Grib1SplitByGridID


      if (ggr1.getEdition() == 2) {
        Grib2Data g2read = new Grib2Data(raf);
        data1 =  g2read.getData(ggr1.getGdsOffset(), ggr1.getPdsOffset(), ggr1.getReferenceTimeInMsecs());
        data2 =  g2read.getData(ggr2.getGdsOffset(), ggr2.getPdsOffset(), ggr2.getReferenceTimeInMsecs());
      } else  {
        Grib1Data g1read = new Grib1Data(raf);
        data1 =  g1read.getData(ggr1.getGdsOffset(), ggr1.getPdsOffset(), ggr1.getDecimalScale(), ggr1.isBmsExists());
        data2 =  g1read.getData(ggr2.getGdsOffset(), ggr2.getPdsOffset(), ggr2.getDecimalScale(), ggr2.isBmsExists());
      }
    } catch (IOException e) {
      log.error("Failed to read data", e);
      return false;
    }
View Full Code Here


   * check for Sigma Pressure Levels
   */

  boolean checkForPressureLevels( List<GridRecord> records, GridHorizCoordSys hcs ) {
      GridDefRecord gdr = hcs.getGds();
      Grib1GDSVariables g1dr = (Grib1GDSVariables) gdr.getGdsv();
      if( g1dr == null || ! g1dr.hasVerticalPressureLevels() )
        return false;

      // add hybrid numbers
      coordValues = new double[ levels.size()];
        for (int i = 0; i < levels.size(); i++ ) {
          LevelCoord lc = levels.get( i );
          coordValues[ i ] =   lc.value1  ;
        }
      int NV = g1dr.getNV();
      // add new variables
      if NV > 2 && NV < 255 ) { // Some data doesn't add Pressure Level values
         factors = g1dr.getVerticalPressureLevels();
      }
      return true;
  }
View Full Code Here

        dis.read(gdsData);
        if (grid_edition_2) {
          Grib2GDSVariables gdsv = new Grib2GDSVariables(gdsData);
          gdsMap.put(Integer.toString(gdsv.getGdsKey()), gdsv);
        } else {
          Grib1GDSVariables gdsv = new Grib1GDSVariables(gdsData);
          gdsMap.put(Integer.toString(gdsv.getGdsKey()), gdsv);
        }
      }
    } finally {
      if (dis != null)
        dis.close();
View Full Code Here

          byte[] gdsData = new byte[gdsSize];
          dis.readFully(gdsData);

          int gdskey;
          if (grid_edition_1) {
            Grib1GDSVariables gdsv = new Grib1GDSVariables(gdsData);
            GribGridDefRecord ggdr = new GribGridDefRecord(gdsv);
            if (index_version.startsWith("8.0")) {
              gdskey = gdsv.get80TypeGdsKey();
            } else {
              gdskey = gdsv.getGdsKey();
            }
            populateGDS1(ggdr, gdsv, gdskey);
            gridIndex.addHorizCoordSys(ggdr);
            //System.out.println("GDS length =" + gdsv.getLength());
            //System.out.println("GDS GdsKey =" + gdsv.getOldTypeGdsKey());
          } else {
            Grib2GDSVariables gdsv = new Grib2GDSVariables(gdsData);
            GribGridDefRecord ggdr = new GribGridDefRecord(gdsv);
            if (index_version.startsWith("8.0")) {
              gdskey = gdsv.get80TypeGdsKey();
            } else {
              gdskey = gdsv.getGdsKey(); // version higher than 8.0
            }
            populateGDS2(ggdr, gdsv, gdskey);
            gridIndex.addHorizCoordSys(ggdr);
            //System.out.println("GDS length =" + gdsv.getLength());
            //System.out.println("GDS GdsKey =" + gdsv.getGdsKey());
View Full Code Here

      if (null != g2lookup.getFirstProductStatusName())
        ncfile.addAttribute(null, new Attribute("Product_Status", g2lookup.getFirstProductStatusName()));
      ncfile.addAttribute(null, new Attribute("Product_Type", g2lookup.getFirstProductTypeName()));

    } else if ( lookup instanceof Grib1GridTableLookup ) {
      Grib1GridTableLookup g1lookup = (Grib1GridTableLookup) lookup;
      center = g1lookup.getFirstCenterName();
      subcenter = g1lookup.getFirstSubcenterName();
      ncfile.addAttribute(null, new Attribute("Originating_center", center));
      if (subcenter != null)
      ncfile.addAttribute(null, new Attribute("Originating_subcenter", subcenter));

      String model = g1lookup.getModel();
      if (model != null)
        ncfile.addAttribute(null, new Attribute("Generating_Model", model));
      if (null != g1lookup.getFirstProductStatusName())
        ncfile.addAttribute(null, new Attribute("Product_Status", g1lookup.getFirstProductStatusName()));
      ncfile.addAttribute(null, new Attribute("Product_Type", g1lookup.getFirstProductTypeName()));
    }

    // CF Global attributes
    ncfile.addAttribute(null, new Attribute("title", lookup.getTitle()));
    if (lookup.getInstitution() != null)
View Full Code Here

        v.addAttribute(new Attribute("GRIB_probability_upper_limit", new Double(pdsProb.getProbabilityUpperLimit()) ));
      }
      v.addAttribute(new Attribute("GRIB_" + GridDefRecord.VECTOR_COMPONENT_FLAG, flag));

    } else if (lookup instanceof Grib1GridTableLookup) {
      Grib1GridTableLookup g1lookup = (Grib1GridTableLookup) lookup;
      int[] paramId = g1lookup.getParameterId(firstRecord);
      v.addAttribute(new Attribute("GRIB_param_name", param.getDescription()));
      v.addAttribute(new Attribute("GRIB_param_short_name", param.getName()));
      v.addAttribute(new Attribute("GRIB_center_id", new Integer(paramId[1])));
      v.addAttribute(new Attribute("GRIB_table_id", new Integer(paramId[2])));
      v.addAttribute(new Attribute("GRIB_param_number", new Integer(paramId[3])));
      v.addAttribute(new Attribute("GRIB_param_id", Array.factory(int.class, new int[]{paramId.length}, paramId)));
      v.addAttribute(new Attribute("GRIB_product_definition_type", g1lookup.getProductDefinitionName(firstRecord)));
      v.addAttribute(new Attribute("GRIB_level_type", new Integer(firstRecord.getLevelType1())));
      v.addAttribute(new Attribute("GRIB_" + GridDefRecord.VECTOR_COMPONENT_FLAG, flag));

    } else {
      v.addAttribute(new Attribute(GridDefRecord.VECTOR_COMPONENT_FLAG, flag));
View Full Code Here

   * @return decimal scale
   */
  @Override
  public int getDecimalScale() {
    if (edition == 1) {
      Grib1Pds pds1 = (Grib1Pds) pds;
      return pds1.getDecimalScale();
    } else {
      return GribNumbers.UNDEFINED;
    }
  }
View Full Code Here

*/
public abstract class GribPds {

  static public GribPds factory(int edition, byte[] raw, long baseTime, Calendar cal) throws IOException {
    if (edition == 1)
      return new Grib1Pds(raw, cal);
    else
      return Grib2Pds.factory(raw, baseTime, cal);
  }
View Full Code Here

          GribPds pdsv = GribPds.factory(ggr.edition, pdsData, refTime, calendar);
          if (pdsv == null) continue;
          ggr.setPds(pdsv);

          if (grid_edition_1) {
            Grib1Pds pds1 = (Grib1Pds) pdsv;
            ggr.bmsExists = pds1.bmsExists();
            ggr.center = pds1.getCenter();
            ggr.subCenter = pds1.getSubCenter();
            ggr.tableVersion = pds1.getParameterTableVersion();

          } else {
            ggr.center = center;
            ggr.subCenter = sub_center;
            ggr.tableVersion = table_version;
View Full Code Here

  /*
   * init
   */
  protected final void setUp() {
    testPath = TestAll.testdataDir + "grid/grib/duplicates/";
    g1wi = new Grib1WriteIndex();
    g2wi = new Grib2WriteIndex();
  }
View Full Code Here

TOP

Related Classes of ucar.grib.grib1.Grib1SplitByGridID

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.