/// <summary> Creates an ensemble object for the product PDS.</summary> /// <param name="raf">RandomAccessFile. /// </param> /// <param name="parameterNumber"> /// </param> /// <throws> IOException </throws> //UPGRADE_TODO: Class 'java.io.RandomAccessFile' was converted to 'System.IO.FileStream' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioRandomAccessFile'" internal Grib1Ensemble(System.IO.Stream raf, int parameterNumber) { // skip 12 bytes to start of ensemble SupportClass.Skip(raf, 12); // octet 41 id's ensemble int app = raf.ReadByte(); if (app != 1) { System.Console.Out.WriteLine("not ensemble product"); return; } // octet 42 Type eType = raf.ReadByte(); // octet 43 Identification number eId = raf.ReadByte(); // octet 44 Product Identifier eProd = raf.ReadByte(); // octet 45 Spatial Identifier eSpatial = raf.ReadByte(); if (parameterNumber == 191 || parameterNumber == 192) { // octet 46 Probability product definition epd = raf.ReadByte(); // octet 47 Probability type ept = raf.ReadByte(); // octet 48-51 Probability lower limit epll = GribNumbers.int4(raf); // octet 52-55 Probability upper limit epul = GribNumbers.int4(raf); // octet 56-60 reserved int reserved = GribNumbers.int4(raf); if (eType == 4 || eType == 5) { // octet 61 Ensemble size eSize = raf.ReadByte(); // octet 62 Cluster size eCSize = raf.ReadByte(); // octet 63 Number of clusters eCNumber = raf.ReadByte(); // octet 64 Clustering Method eCMethod = raf.ReadByte(); // octet 65-67 Northern latitude of clustering domain nLat = GribNumbers.int3(raf); // octet 68-70 Southern latitude of clustering domain sLat = GribNumbers.int3(raf); // octet 71-73 Eastern latitude of clustering domain eLat = GribNumbers.int3(raf); // octet 74-76 Western latitude of clustering domain wLat = GribNumbers.int3(raf); if (eType == 4) { // octets 77-86 Cluster Membership cm = new sbyte[10]; SupportClass.ReadInput(raf, cm, 0, cm.Length); } } } }
/// <summary> Constructs a <tt>Grib1GridDefinitionSection</tt> object from a raf. /// /// </summary> /// <param name="raf">RandomAccessFile with GDS content /// /// </param> /// <throws> NoValidGribException if raf contains no valid GRIB info </throws> //UPGRADE_TODO: Class 'java.io.RandomAccessFile' was converted to 'System.IO.FileStream' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioRandomAccessFile'" public Grib1GridDefinitionSection(System.IO.FileStream raf) { int reserved; // used to read empty space // octets 1-3 (Length of GDS) length = (int)GribNumbers.uint3(raf); if (length == 0) { // there's a extra byte between PDS and GDS SupportClass.Skip(raf, -2); length = (int)GribNumbers.uint3(raf); } //System.out.println( "GDS length = " + length ); // TODO Fix Checksum stuff // get byte array for this gds, then reset raf to same position // calculate checksum for this gds via the byte array /* * long mark = raf.Position; * sbyte[] dst = new sbyte[length - 3]; * SupportClass.ReadInput(raf, dst, 0, dst.Length); * raf.Seek(mark, System.IO.SeekOrigin.Begin); * //UPGRADE_ISSUE: Class 'java.util.zip.CRC32' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javautilzipCRC32'" * //UPGRADE_ISSUE: Constructor 'java.util.zip.CRC32.CRC32' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javautilzipCRC32'" * CRC32 cs = new CRC32(); * //UPGRADE_ISSUE: Method 'java.util.zip.CRC32.update' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javautilzipCRC32'" * cs.update(dst); * //UPGRADE_ISSUE: Method 'java.util.zip.CRC32.getValue' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javautilzipCRC32'" * checksum = System.Convert.ToString(cs.getValue()); * //System.out.println( "GDS checksum =" + checksum ); */ // octets 4 NV int NV = raf.ReadByte(); //System.out.println( "GDS NV = " + NV ); // octet 5 PL the location (octet number) of the list of numbers of points in each row P_VorL = raf.ReadByte(); //System.out.println( "GDS PL = " + P_VorL ); // octet 6 (grid type) type = raf.ReadByte(); //System.out.println( "GDS grid type = " + type ); name = getName(type); if (type != 50) { // values same up to resolution // octets 7-8 (Nx - number of points along x-axis) nx = GribNumbers.int2(raf); nx = (nx == -1)?1:nx; // octets 9-10 (Ny - number of points along y-axis) ny = GribNumbers.int2(raf); ny = (ny == -1)?1:ny; // octets 11-13 (La1 - latitude of first grid point) lat1 = GribNumbers.int3(raf) / 1000.0; // octets 14-16 (Lo1 - longitude of first grid point) lon1 = GribNumbers.int3(raf) / 1000.0; // octet 17 (resolution and component flags). See Table 7 resolution = raf.ReadByte(); } switch (type) { // Latitude/Longitude grids , Arakawa semi-staggered e-grid rotated // Arakawa filled e-grid rotated case 0: case 4: case 40: case 201: case 202: // octets 18-20 (La2 - latitude of last grid point) lat2 = GribNumbers.int3(raf) / 1000.0; // octets 21-23 (Lo2 - longitude of last grid point) lon2 = GribNumbers.int3(raf) / 1000.0; // octets 24-25 (Dx - Longitudinal Direction Increment ) dx = GribNumbers.int2(raf) / 1000.0; // octets 26-27 (Dy - Latitudinal Direction Increment ) // Np - parallels between a pole and the equator if (type == 4) { np = GribNumbers.int2(raf); } else { dy = GribNumbers.int2(raf) / 1000.0; } // octet 28 (Scanning mode) See Table 8 scan = raf.ReadByte(); // octet 29-32 reserved reserved = GribNumbers.int4(raf); if (length > 32) { // getP_VorL(raf); // Vertical coordinates (NV) and thinned grids (PL) not supported - skip this SupportClass.Skip(raf, length - 32); } break; // end Latitude/Longitude grids case 1: // Mercator grids // octets 18-20 (La2 - latitude of last grid point) lat2 = GribNumbers.int3(raf) / 1000.0; // octets 21-23 (Lo2 - longitude of last grid point) lon2 = GribNumbers.int3(raf) / 1000.0; // octets 24-26 (Latin - latitude where cylinder intersects the earth latin1 = GribNumbers.int3(raf) / 1000.0; // octet 27 reserved reserved = raf.ReadByte(); // octet 28 (Scanning mode) See Table 8 scan = raf.ReadByte(); // octets 29-31 (Dx - Longitudinal Direction Increment ) dx = GribNumbers.int3(raf); // octets 32-34 (Dx - Longitudinal Direction Increment ) dy = GribNumbers.int3(raf); // octet 35-42 reserved reserved = GribNumbers.int4(raf); reserved = GribNumbers.int4(raf); if (length > 42) { // getP_VorL(raf); // Vertical coordinates (NV) and thinned grids (PL) not supported - skip this SupportClass.Skip(raf, length - 42); } break; // end Mercator grids case 3: // Lambert Conformal // octets 18-20 (Lov - Orientation of the grid - east lon parallel to y axis) lov = GribNumbers.int3(raf) / 1000.0; // octets 21-23 (Dx - the X-direction grid length) See Note 2 of Table D dx = GribNumbers.int3(raf); // octets 24-26 (Dy - the Y-direction grid length) See Note 2 of Table D dy = GribNumbers.int3(raf); // octets 27 (Projection Center flag) See Note 5 of Table D proj_center = raf.ReadByte(); // octet 28 (Scanning mode) See Table 8 scan = raf.ReadByte(); // octets 29-31 (Latin1 - first lat where secant cone cuts spherical earth latin1 = GribNumbers.int3(raf) / 1000.0; // octets 32-34 (Latin2 - second lat where secant cone cuts spherical earth) latin2 = GribNumbers.int3(raf) / 1000.0; // octets 35-37 (lat of southern pole) latsp = GribNumbers.int3(raf) / 1000.0; // octets 38-40 (lon of southern pole) lonsp = GribNumbers.int3(raf) / 1000.0; // octets 41-42 reserved = GribNumbers.int2(raf); if (length > 42) { // getP_VorL(raf); // Vertical coordinates (NV) and thinned grids (PL) not supported - skip this SupportClass.Skip(raf, length - 42); } break; // end Lambert Conformal case 5: // Polar Stereographic grids // octets 18-20 (Lov - Orientation of the grid - east lon parallel to y axis) lov = GribNumbers.int3(raf) / 1000.0; // octets 21-23 (Dx - Longitudinal Direction Increment ) dx = GribNumbers.int3(raf); // octets 24-26(Dy - Latitudinal Direction Increment ) dy = GribNumbers.int3(raf); // octets 27 (Projection Center flag) See Note 5 of Table D proj_center = raf.ReadByte(); // octet 28 (Scanning mode) See Table 8 scan = raf.ReadByte(); // octet 29-32 reserved reserved = GribNumbers.int4(raf); if (length > 32) { // getP_VorL(raf); // Vertical coordinates (NV) and thinned grids (PL) not supported - skip this SupportClass.Skip(raf, length - 32); } break; // end Polar Stereographic grids //rotated grid case 10: //18-20 this.lat2 = GribNumbers.int3(raf) / 1000.0; //21-23 this.lon2 = GribNumbers.int3(raf) / 1000.0; //24-25 var tmpDx = GribNumbers.int2(raf); this.dx = tmpDx == -1 ? -9999.0 : tmpDx / 1000.0; //26-27 var tmpDy = GribNumbers.int2(raf); this.dy = tmpDy == -1 ? -9999.0 : tmpDy / 1000.0; //28 scan = raf.ReadByte(); //29-32 GribNumbers.int4(raf); //33-35 this.latsp = GribNumbers.int3(raf) / 1000.0; //36-38 this.lonsp = GribNumbers.int3(raf) / 1000.0; //39-42 - angle GribNumbers.float4(raf); if (length > 42) { SupportClass.Skip(raf, length - 42); } break; default: System.Console.Out.WriteLine("Unknown Grid Type : " + type); break; } // end switch grid_type //System.out.println( "scan=" + scan ); if ((scan & 63) != 0) { throw new NoValidGribException("GDS: This scanning mode (" + scan + ") is not supported."); } } // end Grib1GridDefinitionSection( raf )