Пример #1
0
        public void LogExtensions_GetNullValues_For_131_Log()
        {
            var log = new Witsml131.Log
            {
                NullValue    = "-9999.25",
                LogCurveInfo = new List <Witsml131.ComponentSchemas.LogCurveInfo>()
            };

            var lci0 = _log131Generator.CreateDoubleLogCurveInfo("DEPTH", "m", 0);

            lci0.NullValue = "-1000.00";
            log.LogCurveInfo.Add(lci0);
            var lci1 = _log131Generator.CreateDoubleLogCurveInfo("CH1", "m/h", 1);

            lci1.NullValue = "-1111.11";
            log.LogCurveInfo.Add(lci1);
            var lci2 = _log131Generator.CreateDoubleLogCurveInfo("CH2", "gAPI", 2);

            log.LogCurveInfo.Add(lci2);

            string[] mnemonic      = new string[] { "DEPTH", "CH2", "CH1" };
            var      nullValueList = log.GetNullValues(mnemonic).ToArray();

            Assert.AreEqual(3, nullValueList.Length);
            Assert.AreEqual("-1000.00", nullValueList[0]);
            Assert.AreEqual("-9999.25", nullValueList[1]);
            Assert.AreEqual("-1111.11", nullValueList[2]);
        }
Пример #2
0
        /// <summary>
        /// Gets a <see cref="ChannelDataReader" /> for a <see cref="Witsml131.Log" />.
        /// </summary>
        /// <param name="log">The <see cref="Witsml131.Log" /> instance.</param>
        /// <returns>A <see cref="ChannelDataReader" />.</returns>
        public static ChannelDataReader GetReader(this Witsml131.Log log)
        {
            if (log?.LogData == null || !log.LogData.Any())
            {
                return(null);
            }

            _log.DebugFormat("Creating ChannelDataReader for {0}", log.GetType().FullName);

            var isTimeIndex = log.IsTimeLog();
            var increasing  = log.IsIncreasing();

            // Split index curve from other value curves
            var indexCurve    = log.LogCurveInfo.GetByMnemonic(log.IndexCurve?.Value);
            var logCurveInfos = log.LogCurveInfo.Where(x => x != indexCurve).OrderBy(x => x.ColumnIndex.GetValueOrDefault()).ToList();
            var mnemonics     = logCurveInfos.Select(x => x.Mnemonic).ToArray();
            var units         = logCurveInfos.Select(x => x.Unit).ToArray();
            var dataTypes     = logCurveInfos.Select(x => x.TypeLogData?.ToString()).ToArray();
            var nullValues    = log.GetNullValues(mnemonics).ToArray();

            return(new ChannelDataReader(log.LogData, mnemonics.Length + 1, (int)log.IndexCurve?.ColumnIndex, mnemonics, units, dataTypes, nullValues, log.GetUri())
                   // Add index curve to separate collection
                   .WithIndex(indexCurve.Mnemonic, indexCurve.Unit, increasing, isTimeIndex));
        }