private void ExtractVisiCoefficient(byte[] coefInfo, ref double[,] coefficient, int lineIndex, int channelIndex) { byte[] coef = new byte[4]; for (int j = 0; j < 5; j++) { for (int i = 0; i < 4; i++) { coef[i] = coefInfo[i + j * 4]; } switch (j) { case 0: case 2: coefficient[lineIndex, j + channelIndex * 5] = (float)ToLocalEndian.ToInt32FromLittle(coef) / Math.Pow(10, 10); break; case 1: case 3: coefficient[lineIndex, j + channelIndex * 5] = (float)ToLocalEndian.ToInt32FromLittle(coef) / Math.Pow(10, 7); break; case 4: coefficient[lineIndex, j + channelIndex * 5] = (float)ToLocalEndian.ToInt32FromLittle(coef); break; } } }
public static bool Is1A5(byte[] bytes, string fileExtension) { UInt16 satelliteId = ToLocalEndian.ToUInt16FromBig(new byte[] { bytes[0], bytes[1] }); if (satelliteId != 113 && satelliteId != 114) { return(false); } return(true); }
private void ExtractIRCoefficient(byte[] coefInfo, ref double[,] coefficient, int lineIndex, int channelIndex) { byte[] coef = new byte[4]; for (int j = 0; j < 3; j++) { for (int i = 0; i < 4; i++) { coef[i] = coefInfo[i + j * 4]; } coefficient[lineIndex, j + channelIndex * 3] = (float)ToLocalEndian.ToInt32FromLittle(coef) / Math.Pow(10, 6); } }
private static double[] GetAngles(byte[] datas) { byte[] angle = new byte[8]; double[] angles = new double[3]; for (int i = 0; i < 3; i++) { for (int j = 0; j < 8; j++) { angle[j] = datas[j + 8 * i]; } angles[i] = ToLocalEndian.ToDouble64FromBig(angle); } return(angles); }
private static D1A5Header CreateFileHeader(FileStream fs, BinaryReader br, int offset, int endOffset) { D1A5Header hInfo = new D1A5Header(); fs.Seek(offset, SeekOrigin.Begin); hInfo.SatelliteIdentify = ToLocalEndian.ToUInt16FromBig(br.ReadBytes(2)); hInfo.DataBeginYear = ToLocalEndian.ToUInt16FromBig(br.ReadBytes(2)); hInfo.DataBeginMilliSecond = ToLocalEndian.ToUInt32FromBig(br.ReadBytes(4)); hInfo.DataBeginDayNums = ToLocalEndian.ToUInt16FromBig(br.ReadBytes(2)); hInfo.DataEndYear = ToLocalEndian.ToUInt16FromBig(br.ReadBytes(2)); hInfo.DataEndMilliSecond = ToLocalEndian.ToUInt32FromBig(br.ReadBytes(4)); hInfo.DataEndDayNums = ToLocalEndian.ToUInt16FromBig(br.ReadBytes(2)); hInfo.RecordCount = ToLocalEndian.ToUInt16FromBig(br.ReadBytes(2)); hInfo.LastRecord = ToLocalEndian.ToUInt16FromBig(br.ReadBytes(2)); hInfo.ErrorFrameCount = ToLocalEndian.ToUInt16FromBig(br.ReadBytes(2)); hInfo.BitErrorRatio = ToLocalEndian.ToUInt16FromBig(br.ReadBytes(2)); fs.Seek(2, SeekOrigin.Current); hInfo.ErrorTimeOrder = ToLocalEndian.ToUInt16FromBig(br.ReadBytes(2)); hInfo.LostRecordCount = ToLocalEndian.ToUInt16FromBig(br.ReadBytes(2)); hInfo.SlopeAnalyseResult = ToLocalEndian.ToUInt16FromBig(br.ReadBytes(2)); fs.Seek(164, SeekOrigin.Current); hInfo.TrackNumber = ToLocalEndian.ToUInt16FromBig(br.ReadBytes(2)); hInfo.EpochTrackTime = ToLocalEndian.ToDouble64FromBig(br.ReadBytes(8)); hInfo.Time = GetTime(hInfo.EpochTrackTime); hInfo.OrbitSemiMajorAxis = ToLocalEndian.ToDouble64FromBig(br.ReadBytes(8)); hInfo.OrbitEccentricity = ToLocalEndian.ToDouble64FromBig(br.ReadBytes(8)); hInfo.OrbitInclination = ToLocalEndian.ToDouble64FromBig(br.ReadBytes(8)); hInfo.LongitudeAscendingNode = ToLocalEndian.ToDouble64FromBig(br.ReadBytes(8)); hInfo.PerigeeAngle = ToLocalEndian.ToDouble64FromBig(br.ReadBytes(8)); hInfo.MeanAnomaly = ToLocalEndian.ToDouble64FromBig(br.ReadBytes(8)); hInfo.AscDescendTag = ToLocalEndian.ToUInt16FromBig(br.ReadBytes(2)); hInfo.ResurceType = ToLocalEndian.ToUInt16FromBig(br.ReadBytes(2)); hInfo.OrbitNumber = ToLocalEndian.ToUInt16FromBig(br.ReadBytes(2)); fs.Seek(2, SeekOrigin.Current); hInfo.OrbitCycle = ToLocalEndian.ToDouble64FromBig(br.ReadBytes(8)); //角度信息 hInfo.Angles = GetAngles(br.ReadBytes(24)); fs.Seek(20, SeekOrigin.Current); float[] lats, lons; GetPosition(br.ReadBytes(32), out lats, out lons); hInfo.Lats = lats; hInfo.Lons = lons; fs.Seek(4, SeekOrigin.Current); hInfo.DataBeginSecond = ToLocalEndian.ToDouble64FromBig(br.ReadBytes(8)); hInfo.DataEndSecond = ToLocalEndian.ToDouble64FromBig(br.ReadBytes(8)); hInfo.SatelliteName = hInfo.SatelliteIdentify == 113 ? "FY1C" : "FY1D"; hInfo.OrbitBeginTime = DateTime.Parse(hInfo.DataBeginYear.ToString() + "-01-01").AddDays(hInfo.DataBeginDayNums - 1).AddMilliseconds(hInfo.DataBeginMilliSecond); return(hInfo); }
/// <summary> /// /// </summary> /// <param name="positions"></param> /// <param name="lats">左下 右下 左上 右上</param> /// <param name="lons">左下 右下 左上 右上</param> private static void GetPosition(byte[] positions, out float[] lats, out float[] lons) { lats = new float[4]; lons = new float[4]; byte[] lon = new byte[4]; byte[] lat = new byte[4]; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { lat[j] = positions[j + 8 * i]; lon[j] = positions[j + 4 + 8 * i]; } lats[i] = ToLocalEndian.ToFloatFromBig(lat); lons[i] = ToLocalEndian.ToFloatFromBig(lon); } }
private void ExtractLatAddLonInfo(byte[] geoInfo, out double[] lats, out double[] lons) { byte[] lon = new byte[4]; byte[] lat = new byte[4]; lons = new double[51]; lats = new double[51]; int pt = 0; for (int j = 0; j < 51; j++) { for (int k = 0, i = 4; i < 8 && k < 4; i++, k++) { lon[pt] = geoInfo[i + 8 * j]; lat[pt++] = geoInfo[k + 8 * j]; } pt = 0; lons[j] = (float)(ToLocalEndian.ToFloatFromBig(lon)); lats[j] = (float)(ToLocalEndian.ToFloatFromBig(lat)); } }