|
5 | 5 |
|
6 | 6 | package ucar.nc2.grib.grib2; |
7 | 7 |
|
8 | | -import javax.annotation.Nullable; |
9 | 8 | import ucar.nc2.grib.GribNumbers; |
10 | 9 | import ucar.nc2.time.CalendarDate; |
11 | 10 | import ucar.unidata.util.Format; |
12 | 11 | import ucar.unidata.util.StringUtil2; |
13 | | -import javax.annotation.concurrent.Immutable; |
| 12 | + |
14 | 13 | import java.util.Formatter; |
15 | 14 | import java.util.zip.CRC32; |
16 | 15 |
|
| 16 | +import javax.annotation.Nullable; |
| 17 | +import javax.annotation.concurrent.Immutable; |
| 18 | + |
17 | 19 | /** |
18 | 20 | * Abstract superclass for GRIB2 PDS handling. |
19 | 21 | * Inner classes are specific to each template. |
@@ -64,6 +66,8 @@ public static Grib2Pds factory(int template, byte[] input) { |
64 | 66 | return new Grib2Pds31(input); |
65 | 67 | case 32: |
66 | 68 | return new Grib2Pds32(input); |
| 69 | + case 40: |
| 70 | + return new Grib2Pds40(input); |
67 | 71 | case 48: |
68 | 72 | return new Grib2Pds48(input); |
69 | 73 | case 60: |
@@ -1578,6 +1582,122 @@ public int templateLength() { |
1578 | 1582 |
|
1579 | 1583 | /////////////////////////////////////////////////////////////////////////////// |
1580 | 1584 |
|
| 1585 | + /* |
| 1586 | + * Product definition template 4.40 – atmospheric constituents |
| 1587 | + * Octet No. Contents |
| 1588 | + * 10 Parameter category (see Code table 4.1) |
| 1589 | + * 11 Parameter number (see Code table 4.2) |
| 1590 | + * 12–13 Constituent Type (see Code Table 4.230) |
| 1591 | + * 14 Type of Generating Process (see Code table 4.3) |
| 1592 | + * 15 Background Process |
| 1593 | + * 16 Generating Process Identifier |
| 1594 | + * 17–18 Hours of observational data cut-off after reference time (see Note) |
| 1595 | + * 19 Minutes of observational data cut-off after reference time |
| 1596 | + * 20 Indicator of unit of time range (see Code table 4.4) |
| 1597 | + * 21-24 Forecast time in units defined by octet 18 |
| 1598 | + * 25 Type of first fixed surface (see Code table 4.5) |
| 1599 | + * 26 Scale factor of first fixed surface |
| 1600 | + * 27–30 Scaled value of first fixed surface |
| 1601 | + * 31 Type of second fixed surface (see Code table 4.5) |
| 1602 | + * 32 Scale factor of second fixed surface |
| 1603 | + * 33-36 Scaled value of second fixed surface |
| 1604 | + * Note: Hours greater than 65534 will be coded as 65534. |
| 1605 | + */ |
| 1606 | + |
| 1607 | + private static class Grib2Pds40 extends Grib2Pds { |
| 1608 | + |
| 1609 | + Grib2Pds40(byte[] input) { |
| 1610 | + super(input); |
| 1611 | + } |
| 1612 | + |
| 1613 | + // 12–13 Constituent type (see Code Table 4.230) |
| 1614 | + public int getConstituentType() { |
| 1615 | + return GribNumbers.uint2(getOctet(12), getOctet(13)); |
| 1616 | + } |
| 1617 | + |
| 1618 | + // 14 Type of generating process (see Code table 4.3) |
| 1619 | + @Override |
| 1620 | + public int getGenProcessType() { |
| 1621 | + return getOctet(14); |
| 1622 | + } |
| 1623 | + |
| 1624 | + // 15 Background generating process identifier (defined by originating centre) |
| 1625 | + @Override |
| 1626 | + public int getBackProcessId() { |
| 1627 | + return getOctet(15); |
| 1628 | + } |
| 1629 | + |
| 1630 | + // 16 Analysis or forecast generating process identifier (defined by originating centre) |
| 1631 | + @Override |
| 1632 | + public int getGenProcessId() { |
| 1633 | + return getOctet(16); |
| 1634 | + } |
| 1635 | + |
| 1636 | + // 17–18 Hours of observational data cut-off after reference time (see Note) |
| 1637 | + // Note: Hours greater than 65534 will be coded as 65534. |
| 1638 | + public int getHoursAfterCutoff() { |
| 1639 | + return GribNumbers.int2(getOctet(17), getOctet(18)); |
| 1640 | + } |
| 1641 | + |
| 1642 | + // 19 Minutes of observational data cut-off after reference time |
| 1643 | + public int getMinutesAfterCutoff() { |
| 1644 | + return getOctet(19); |
| 1645 | + } |
| 1646 | + |
| 1647 | + // 20 Indicator of unit of time range (see Code table 4.4) |
| 1648 | + @Override |
| 1649 | + public int getTimeUnit() { |
| 1650 | + return getOctet(20); |
| 1651 | + } |
| 1652 | + |
| 1653 | + // 21–24 Forecast time in units defined by octet 20 |
| 1654 | + public int getForecastTime() { |
| 1655 | + return GribNumbers.int4(getOctet(21), getOctet(22), getOctet(23), getOctet(24)); |
| 1656 | + } |
| 1657 | + |
| 1658 | + // 25 Type of first fixed surface (see Code table 4.5) |
| 1659 | + @Override |
| 1660 | + public int getLevelType1() { |
| 1661 | + return getOctet(25); |
| 1662 | + } |
| 1663 | + |
| 1664 | + // 26 Scale factor of first fixed surface |
| 1665 | + @Override |
| 1666 | + public int getLevelScale1() { |
| 1667 | + return getOctet(26); |
| 1668 | + } |
| 1669 | + |
| 1670 | + // 27–30 Scaled value of first fixed surface |
| 1671 | + @Override |
| 1672 | + public double getLevelValue1() { |
| 1673 | + return getScaledValue(26); |
| 1674 | + } |
| 1675 | + |
| 1676 | + // 31 Type of second fixed surface (see Code table 4.5) |
| 1677 | + @Override |
| 1678 | + public int getLevelType2() { |
| 1679 | + return getOctet(31); |
| 1680 | + } |
| 1681 | + |
| 1682 | + // 32 Scale factor of second fixed surface |
| 1683 | + @Override |
| 1684 | + public int getLevelScale2() { |
| 1685 | + return getOctet(32); |
| 1686 | + } |
| 1687 | + |
| 1688 | + // 33–36 Scaled value of second fixed surface |
| 1689 | + @Override |
| 1690 | + public double getLevelValue2() { |
| 1691 | + return getScaledValue(32); |
| 1692 | + } |
| 1693 | + |
| 1694 | + public int templateLength() { |
| 1695 | + return 36; |
| 1696 | + } |
| 1697 | + } |
| 1698 | + |
| 1699 | + /////////////////////////////////////////////////////////////////////////////// |
| 1700 | + |
1581 | 1701 | /* |
1582 | 1702 | * Product definition template 4.48 – analysis or forecast at a horizontal level or in a horizontal layer at a point |
1583 | 1703 | * in time for optical properties of aerosol |
|
0 commit comments