Esempio n. 1
0
        public void LogExtensions_GetByMnemonic_Returns_131_LogCurveInfo_By_Mnemonic()
        {
            var log = new Witsml131.Log();

            var logCurveInfo = log.LogCurveInfo.GetByMnemonic("depth");

            Assert.IsNull(logCurveInfo);

            log.LogCurveInfo = new List <Witsml131.ComponentSchemas.LogCurveInfo>();

            logCurveInfo = log.LogCurveInfo.GetByMnemonic("depth");
            Assert.IsNull(logCurveInfo);

            // Add curves
            log.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);

            logCurveInfo = log.LogCurveInfo.GetByMnemonic("depth");
            Assert.IsNotNull(logCurveInfo);
            Assert.AreEqual(lci0, logCurveInfo);
        }
Esempio n. 2
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]);
        }
Esempio n. 3
0
        public void LogExtensions_IsIncreasing_Returns_Bool_If_131_Log_Is_Timelog()
        {
            var log = new Witsml131.Log
            {
                IndexType = Witsml131.ReferenceData.LogIndexType.datetime
            };

            Assert.IsTrue(log.IsTimeLog());

            log.IndexType = Witsml131.ReferenceData.LogIndexType.elapsedtime;
            Assert.IsTrue(log.IsTimeLog(true));

            log.IndexType = Witsml131.ReferenceData.LogIndexType.measureddepth;
            Assert.IsFalse(log.IsTimeLog());

            log.IndexType = null;
            Assert.IsTrue(log.IsTimeLog());

            log.LogData = new List <string>()
            {
                "2016-01-01T00:00:00.001Z,1,2,3"
            };

            Assert.IsTrue(log.IsTimeLog());

            log.LogData = new List <string>()
            {
                "1023.3,1,2,3"
            };

            Assert.IsFalse(log.IsTimeLog());
        }
Esempio n. 4
0
        public void LogExtensions_GetIndexRange_Returns_Range_From_131_DepthLog()
        {
            double start, end;

            InitDepthIndexes(out start, out end);

            var log = new Witsml131.Log
            {
                LogCurveInfo = new List <Witsml131.ComponentSchemas.LogCurveInfo>()
            };

            var result = new Witsml131.ComponentSchemas.LogCurveInfo().GetIndexRange();

            Assert.IsNull(result.Start);
            Assert.IsNull(result.End);

            // Add logCurveInfo with just start index
            var lci0 = _log131Generator.CreateDoubleLogCurveInfo("DEPTH", "m", 0);

            lci0.NullValue = "-1000.00";
            lci0.MinIndex  = new Witsml131.ComponentSchemas.GenericMeasure(start, "m");
            log.LogCurveInfo.Add(lci0);

            result = log.LogCurveInfo[0].GetIndexRange();

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Start.HasValue);
            Assert.IsFalse(result.End.HasValue);
            Assert.AreEqual(start, result.Start.Value);

            // Decreasing log
            result = log.LogCurveInfo[0].GetIndexRange(false);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.End.HasValue);
            Assert.IsFalse(result.Start.HasValue);
            Assert.AreEqual(start, result.End.Value);

            // Update end index
            lci0.MaxIndex = new Witsml131.ComponentSchemas.GenericMeasure(end, "m");

            result = log.LogCurveInfo[0].GetIndexRange();

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Start.HasValue);
            Assert.IsTrue(result.End.HasValue);
            Assert.AreEqual(start, result.Start.Value);
            Assert.AreEqual(end, result.End.Value);

            // Decreasing with end index
            result = log.LogCurveInfo[0].GetIndexRange(false);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Start.HasValue);
            Assert.IsTrue(result.End.HasValue);
            Assert.AreEqual(start, result.End.Value);
            Assert.AreEqual(end, result.Start.Value);
        }
Esempio n. 5
0
        public void ChannelDataExtensions_GetReader_Returns_ChannelDataReader_For_131_Log()
        {
            var log = new Witsml131.Log();

            log = null;
            var reader = log.GetReader();

            Assert.IsNull(reader);

            log = new Witsml131.Log();

            reader = log.GetReader();
            Assert.IsNull(reader);

            log.LogData = new List <string>();

            reader = log.GetReader();
            Assert.IsNull(reader);

            log.IndexType = Witsml131.ReferenceData.LogIndexType.measureddepth;
            log.Direction = Witsml131.ReferenceData.LogIndexDirection.increasing;

            log.IndexCurve   = new Witsml131.ComponentSchemas.IndexCurve("MD");
            log.LogCurveInfo = new List <Witsml131.ComponentSchemas.LogCurveInfo>
            {
                new Witsml131.ComponentSchemas.LogCurveInfo
                {
                    Mnemonic    = "MD",
                    Unit        = "m",
                    ColumnIndex = 0
                },
                new Witsml131.ComponentSchemas.LogCurveInfo
                {
                    Mnemonic    = "A",
                    Unit        = "ft",
                    ColumnIndex = 1,
                    TypeLogData = new Witsml131.ReferenceData.LogDataType?(Witsml131.ReferenceData.LogDataType.@double)
                },
                new Witsml131.ComponentSchemas.LogCurveInfo
                {
                    Mnemonic    = "B",
                    Unit        = "ft/hr",
                    ColumnIndex = 2
                },
            };
            log.LogData = new List <string>()
            {
                "10,1,2",
                "11,3,4"
            };
            reader = log.GetReader();
            Assert.IsNotNull(reader);

            AssertReaderAndData(DevKit.List(reader));
        }
Esempio n. 6
0
        public void LogExtensions_IsIncreasing_Returns_Bool_For_131_Log_Direction()
        {
            var log = new Witsml131.Log
            {
                Direction = Witsml131.ReferenceData.LogIndexDirection.increasing
            };

            Assert.IsTrue(log.IsIncreasing());

            log.Direction = Witsml131.ReferenceData.LogIndexDirection.decreasing;
            Assert.IsFalse(log.IsIncreasing());
        }
Esempio n. 7
0
 /// <summary>
 /// Sets the log data.
 /// </summary>
 /// <param name="log">The log.</param>
 /// <param name="keepGridData">True if not clearing data when querying partial results</param>
 /// <param name="errorHandler">The error handler.</param>
 private void SetLogData(Witsml131.Log log, bool keepGridData, Action <WitsmlException> errorHandler)
 {
     ClearDataTable(log.GetUri(), keepGridData);
     Task.Run(() =>
     {
         try
         {
             SetChannelData(log.GetReader());
         }
         catch (WitsmlException ex)
         {
             _log.WarnFormat("Error setting log data: {0}", ex);
             errorHandler(ex);
         }
     });
 }
Esempio n. 8
0
        /// <summary>
        /// Determines whether the <see cref="Witsml131.Log"/> is a time log.
        /// </summary>
        /// <param name="log">The log.</param>
        /// <param name="includeElapsedTime">if set to <c>true</c>, include elapsed time.</param>
        /// <returns>
        /// <c>true</c> if the <see cref="Witsml131.Log"/> is a time log; otherwise, false.
        /// </returns>
        public static bool IsTimeLog(this Witsml131.Log log, bool includeElapsedTime = false)
        {
            if (log.IndexType.HasValue)
            {
                return(log.IndexType.Value == Witsml131.ReferenceData.LogIndexType.datetime ||
                       (log.IndexType.Value == Witsml131.ReferenceData.LogIndexType.elapsedtime && includeElapsedTime));
            }

            // Use LogIndexType default if logData not available
            if (log.LogData == null)
            {
                return(true);
            }

            var data = log.LogData.FirstOrDefault();

            return(data.IsFirstValueDateTime());
        }
Esempio n. 9
0
        public void EtpUris_GetUri_Can_Get_LogCurveInfo_131_Uri()
        {
            var logCurve = new Witsml131.ComponentSchemas.LogCurveInfo {
                Mnemonic = "ROP"
            };

            var log = new Witsml131.Log
            {
                Uid          = _data.Uid(),
                UidWell      = _data.Uid(),
                UidWellbore  = _data.Uid(),
                LogCurveInfo = new List <Witsml131.ComponentSchemas.LogCurveInfo> {
                    logCurve
                }
            };

            var uri = logCurve.GetUri(log);

            Assert.IsTrue($"eml://witsml13/well({log.UidWell})/wellbore({log.UidWellbore})/log({log.Uid})/logCurveInfo({logCurve.Mnemonic})".EqualsIgnoreCase(uri.ToString()));
            Assert.AreEqual(ObjectTypes.LogCurveInfo, uri.ObjectType);
            Assert.AreEqual(logCurve.Mnemonic, uri.ObjectId);
        }
Esempio n. 10
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    = logCurveInfos.Select(x => x.NullValue).ToArray();

            return(new ChannelDataReader(log.LogData, mnemonics.Length + 1, mnemonics, units, dataTypes, nullValues, log.GetUri())
                   // Add index curve to separate collection
                   .WithIndex(indexCurve.Mnemonic, indexCurve.Unit, increasing, isTimeIndex));
        }
Esempio n. 11
0
        public void LogExtensions_GetIndexRange_Returns_Range_From_131_TimeLog()
        {
            Timestamp start, end;

            InitTimeIndexes(out start, out end);
            var startAsLong = start.ToUnixTimeMicroseconds();
            var endAsLong   = end.ToUnixTimeMicroseconds();

            var log = new Witsml131.Log
            {
                LogCurveInfo = new List <Witsml131.ComponentSchemas.LogCurveInfo>()
            };

            var logCurveInfo = new Witsml131.ComponentSchemas.LogCurveInfo();

            logCurveInfo = null;
            var result = logCurveInfo.GetIndexRange();

            Assert.IsNull(result.Start);
            Assert.IsNull(result.End);

            // Add logCurveInfo with just start index
            var lci0 = _log131Generator.CreateDoubleLogCurveInfo("DEPTH", "m", 0);

            lci0.NullValue        = "-1000.00";
            lci0.MinDateTimeIndex = start;
            log.LogCurveInfo.Add(lci0);

            result = log.LogCurveInfo[0].GetIndexRange(true, true);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Start.HasValue);
            Assert.IsFalse(result.End.HasValue);
            Assert.AreEqual(startAsLong, result.Start.Value);

            // Decreasing log
            result = log.LogCurveInfo[0].GetIndexRange(false, true);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.End.HasValue);
            Assert.IsFalse(result.Start.HasValue);
            Assert.AreEqual(startAsLong, result.End.Value);

            // Update end index
            lci0.MaxDateTimeIndex = end;

            result = log.LogCurveInfo[0].GetIndexRange(true, true);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Start.HasValue);
            Assert.IsTrue(result.End.HasValue);
            Assert.AreEqual(startAsLong, result.Start.Value);
            Assert.AreEqual(endAsLong, result.End.Value);

            // Decreasing with end index
            result = log.LogCurveInfo[0].GetIndexRange(false, true);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Start.HasValue);
            Assert.IsTrue(result.End.HasValue);
            Assert.AreEqual(startAsLong, result.End.Value);
            Assert.AreEqual(endAsLong, result.Start.Value);
        }
Esempio n. 12
0
 /// <summary>
 /// Determines whether the <see cref="Witsml131.Log"/> is increasing.
 /// </summary>
 /// <param name="log">The log.</param>
 /// <returns>
 /// <c>true</c> if the <see cref="Witsml131.Log"/> is increasing; otherwise, false.
 /// </returns>
 public static bool IsIncreasing(this Witsml131.Log log)
 {
     return(log.Direction.GetValueOrDefault(Witsml131.ReferenceData.LogIndexDirection.increasing) == Witsml131.ReferenceData.LogIndexDirection.increasing);
 }
Esempio n. 13
0
 /// <summary>
 /// Gets the channels null value of the m
 /// </summary>
 /// <param name="log">The log.</param>
 /// <param name="mnemonics">The mnemonics.</param>
 /// <returns>
 /// A <see cref="IDictionary{TKey, TValue}" /> with the column index as key and the log curve null value as the value.
 /// </returns>
 public static IEnumerable <string> GetNullValues(this Witsml131.Log log, string[] mnemonics)
 {
     return(mnemonics
            .Select(x => log.LogCurveInfo.GetByMnemonic(x))
            .Select(n => GetNullValue(log.NullValue, n?.NullValue)));
 }
Esempio n. 14
0
 /// <summary>
 /// Gets the <see cref="EtpUri"/> for a given <see cref="Energistics.DataAccess.WITSML131.ComponentSchemas.LogCurveInfo"/>.
 /// </summary>
 /// <param name="entity">The <see cref="Energistics.DataAccess.WITSML131.ComponentSchemas.LogCurveInfo"/> entity.</param>
 /// <param name="log">The log.</param>
 /// <returns>An <see cref="EtpUri"/> instance.</returns>
 public static EtpUri GetUri(this Witsml131.ComponentSchemas.LogCurveInfo entity, Witsml131.Log log)
 {
     return(log.GetUri()
            .Append(ObjectTypes.LogCurveInfo, entity.Mnemonic, true));
 }