Esempio n. 1
0
        public static string WellIdentifier(this LasLog lasLog)
        {
            if (lasLog == null)
            {
                return(string.Empty);
            }

            var wellInformationSection = lasLog.GetSection(LasSectionType.WellInformation);

            if (wellInformationSection == null)
            {
                return(string.Empty);
            }

            var uwiMnemonic = wellInformationSection.GetUwiMnemonic();

            if (uwiMnemonic != null)
            {
                return(uwiMnemonic.Data);
            }

            var apiMnemonic = wellInformationSection.GetApiMnemonic();

            if (apiMnemonic != null)
            {
                return(apiMnemonic.Data);
            }

            return(string.Empty);
        }
Esempio n. 2
0
        public void LasLogHelpers_FileVersion_Pass_NoVersionInfo()
        {
            var lasLog = new LasLog {
                Sections = new LasSection[] { new LasSection() }
            };

            Assert.AreEqual(LasFileVersion.LAS_2_0, lasLog.FileVersion());
        }
Esempio n. 3
0
        public void LasLogHelpers_FileVersion_Pass_NoVersionMnemonic()
        {
            var lasLog = new LasLog {
                Sections = new LasSection[] { new LasSection {
                                                  SectionType = LasSectionType.VersionInformation
                                              } }
            };

            Assert.AreEqual(LasFileVersion.LAS_2_0, lasLog.FileVersion());
        }
Esempio n. 4
0
 public static LasSection GetSection(this LasLog lasLog, LasSectionType lasSectionType)
 {
     if (lasLog == null)
     {
         return(null);
     }
     if (lasLog.Sections == null)
     {
         return(null);
     }
     return(lasLog.Sections.FirstOrDefault(x => x.SectionType == lasSectionType));
 }
Esempio n. 5
0
 public static int SectionCount(this LasLog lasLog, LasSectionType lasSectionType)
 {
     if (lasLog == null)
     {
         return(0);
     }
     if (lasLog.Sections == null)
     {
         return(0);
     }
     return(lasLog.Sections.Count(x => x.SectionType == lasSectionType));
 }
Esempio n. 6
0
 public static bool HasSection(this LasLog lasLog, LasSectionType lasSectionType)
 {
     if (lasLog == null)
     {
         return(false);
     }
     if (lasLog.Sections == null)
     {
         return(false);
     }
     return(lasLog.Sections.Any(x => x.SectionType == lasSectionType));
 }
 public void Write(string fileName, LasLog lasLog)
 {
     if (string.IsNullOrEmpty(fileName))
     {
         throw new ArgumentNullException(nameof(fileName));
     }
     if (lasLog == null)
     {
         throw new ArgumentNullException(nameof(lasLog));
     }
     using var lasFile = File.Open(fileName, FileMode.Create, FileAccess.Write);
     _lasLogBusiness.WriteStream(lasFile, lasLog);
 }
        public void LasLogBusiness_WriteStream_Pass()
        {
            var lasStream = new MemoryStream();
            var lasLog    = new LasLog
            {
                Sections = new LasSection[]
                {
                    new LasSection(),
                    new LasSection()
                }
            };

            Assert.DoesNotThrow(() => _lasLogBusiness.WriteStream(lasStream, lasLog));
        }
Esempio n. 9
0
        public void WriteStream(Stream lasStream, LasLog lasLog)
        {
            if (lasStream == null)
            {
                throw new ArgumentNullException(nameof(lasStream));
            }

            if (lasLog == null)
            {
                return;
            }
            foreach (var section in lasLog.Sections)
            {
                _lasSectionBusiness.WriteSection(lasStream, section);
            }
        }
Esempio n. 10
0
        public void PrintLasLog(LasLog lasLog, IEnumerable <ValidationError> validationErrors)
        {
            if (lasLog == null)
            {
                throw new ArgumentNullException(nameof(lasLog));
            }
            if (validationErrors == null)
            {
                throw new ArgumentNullException(nameof(validationErrors));
            }

            DisplaySectionInfo(lasLog);
            _textWriter.WriteLine();
            _textWriter.WriteLine("----------");
            _textWriter.WriteLine();
            DisplayValidationErrors(validationErrors);
        }
Esempio n. 11
0
        public static LasFileVersion FileVersion(this LasLog lasLog)
        {
            if (lasLog == null)
            {
                return(LasFileVersion.LAS_2_0);
            }

            var versionMnemonic = lasLog.VersionInformation.GetVersionMnemonic();

            if (versionMnemonic == null)
            {
                return(LasFileVersion.LAS_2_0);
            }

            if (string.Compare(versionMnemonic.Data, LAS_VERSION_1_2, true) == 0)
            {
                return(LasFileVersion.LAS_1_2);
            }
            return(LasFileVersion.LAS_2_0);
        }
Esempio n. 12
0
        public void LasLogHelpers_FileVersion_Pass_Version20()
        {
            var lasLog = new LasLog
            {
                Sections = new LasSection[]
                {
                    new LasSection
                    {
                        SectionType    = LasSectionType.VersionInformation,
                        MnemonicsLines = new LasMnemonicLine[]
                        {
                            new LasMnemonicLine {
                                Mnemonic = "VERS", Data = "2.0"
                            }
                        }
                    }
                }
            };

            Assert.AreEqual(LasFileVersion.LAS_2_0, lasLog.FileVersion());
        }
Esempio n. 13
0
        public static bool UsesLineWrap(this LasLog lasLog)
        {
            var versionInformation = lasLog.GetSection(LasSectionType.VersionInformation);

            if (versionInformation == null)
            {
                return(false);
            }

            var wrapMnemonic = versionInformation.GetMnemonic(MNEM_WRAP);

            if (wrapMnemonic == null)
            {
                return(false);
            }

            if (string.Compare(wrapMnemonic.Data, WRAP_YES, true) == 0)
            {
                return(true);
            }
            return(false);
        }
Esempio n. 14
0
        private void DisplaySectionInfo(LasLog lasLog)
        {
            foreach (var section in lasLog.Sections)
            {
                _textWriter.WriteLine($"{section.SectionType}");

                if (section.MnemonicsLines != null)
                {
                    foreach (var mnemonicLine in section.MnemonicsLines)
                    {
                        _textWriter.WriteLine($"\tMnemonic: {mnemonicLine.Mnemonic}; Units: {mnemonicLine.Units}; Data: {mnemonicLine.Data}; Description: {mnemonicLine.Description}");
                    }
                }

                if (section.AsciiLogDataLines != null)
                {
                    foreach (var asciiLine in section.AsciiLogDataLines.Take(25))
                    {
                        _textWriter.WriteLine($"\t{string.Join('\t', asciiLine.Values)}");
                    }
                }
            }
        }
Esempio n. 15
0
        public LasLog ReadStream(Stream lasStream)
        {
            if (lasStream == null)
            {
                throw new ArgumentNullException(nameof(lasStream));
            }

            var lasLog   = new LasLog();
            var sections = new List <LasSection>();

            lasStream.Seek(0, SeekOrigin.Begin);
            var lasLine = lasStream.ReadLasLine();

            while (!string.IsNullOrEmpty(lasLine))
            {
                if (lasLine.IsLasSectionHeader())
                {
                    lasStream.SeekBackLine(lasLine);
                    sections.Add(_lasSectionBusiness.ReadSection(lasStream));
                }

                lasLine = lasStream.ReadLasLine();
            }
            lasLog.Sections = sections.ToArray();

            if (lasLog.UsesLineWrap)
            {
                _asciiLogDataBusiness.UnWrapAsciiLogData(lasLog.AsciiLogData);
            }

            if (lasLog.FileVersion == LasFileVersion.LAS_1_2)
            {
                _wellInformationBusiness.FixWellInformation(lasLog.WellInformation);
            }

            return(lasLog);
        }
Esempio n. 16
0
        public static bool AsciiLogDataHasCurveChannels(this LasLog lasLog)
        {
            if (lasLog == null)
            {
                return(true);
            }

            var curveInformation = lasLog.GetSection(LasSectionType.CurveInformation);

            if (curveInformation == null)
            {
                return(true);
            }
            if (curveInformation.MnemonicsLines == null)
            {
                return(true);
            }

            var asciiLogData = lasLog.GetSection(LasSectionType.AsciiLogData);

            if (asciiLogData == null)
            {
                return(true);
            }
            if (asciiLogData.AsciiLogDataLines == null)
            {
                return(true);
            }

            if (asciiLogData.AsciiLogDataLines.Any(x => x.Values.Count() > 0 && x.Values.Count() != curveInformation.MnemonicsLines.Count()))
            {
                return(false);
            }

            return(true);
        }
Esempio n. 17
0
        public void PerTestSetup()
        {
            _versionMnemonic = new LasMnemonicLine {
                Mnemonic = "VERS", Data = "2.0", Description = "LAS VERSION"
            };
            _wrapMnemonic = new LasMnemonicLine {
                Mnemonic = "WRAP", Data = "NO", Description = "LINE WRAP"
            };

            _versionInformationSection = new LasSection
            {
                SectionType    = LasSectionType.VersionInformation,
                MnemonicsLines = new List <LasMnemonicLine> {
                    _versionMnemonic, _wrapMnemonic
                }
            };


            _startMnemonic = new LasMnemonicLine {
                Mnemonic = "STRT", Units = "FEET", Data = "100.0", Description = "START DEPTH"
            };
            _stopMnemonic = new LasMnemonicLine {
                Mnemonic = "STOP", Units = "FEET", Data = "101.0", Description = "STOP DEPTH"
            };
            _stepMnemonic = new LasMnemonicLine {
                Mnemonic = "STEP", Units = "FEET", Data = "0.5", Description = "STEP INCREMENT"
            };
            _nullMnemonic = new LasMnemonicLine {
                Mnemonic = "NULL", Data = "-999.25", Description = "NULL VALUE"
            };
            _companyMnemonic = new LasMnemonicLine {
                Mnemonic = "COMP", Data = "DAVIS PETROLEUM CORP", Description = "COMPANY"
            };
            _wellNameMnemonic = new LasMnemonicLine {
                Mnemonic = "WELL", Data = "TYLER DEEP UNIT #1", Description = "WELL NAME"
            };
            _fieldMnemonic = new LasMnemonicLine {
                Mnemonic = "FLD", Data = "WILDCAT", Description = "FIELD"
            };
            _locationMnemonic = new LasMnemonicLine {
                Mnemonic = "LOC", Data = "630' FSL & 1790' FWL", Description = "LOCATION"
            };
            _provinceMnemonic = new LasMnemonicLine {
                Mnemonic = "PROV", Data = "", Description = "PROVINCE"
            };
            _countyMnemonic = new LasMnemonicLine {
                Mnemonic = "CNTY", Data = "CONVERSE", Description = "COUNTY"
            };
            _stateMnemonic = new LasMnemonicLine {
                Mnemonic = "STAT", Data = "WYOMING", Description = "STATE"
            };
            _countryMnemonic = new LasMnemonicLine {
                Mnemonic = "CTRY", Data = "USA", Description = "COUNTRY"
            };
            _serviceCompanyMnemonic = new LasMnemonicLine {
                Mnemonic = "SRVC", Data = "BAKER ATLAS", Description = "SERVICE COMPANY"
            };
            _dateLoggedMnemonic = new LasMnemonicLine {
                Mnemonic = "DATE", Data = "2008-10-18", Description = "DATE LOGGED"
            };
            _uniqueWellIdMnemonic = new LasMnemonicLine {
                Mnemonic = "UWI", Data = WELL_ID, Description = "UNIQUE WELL ID"
            };
            _apiNumberMnemonic = new LasMnemonicLine {
                Mnemonic = "API", Data = WELL_ID, Description = "API NUMBER"
            };

            _wellInformationSection = new LasSection
            {
                SectionType    = LasSectionType.WellInformation,
                MnemonicsLines = new List <LasMnemonicLine>
                {
                    _startMnemonic,
                    _stopMnemonic,
                    _stepMnemonic,
                    _nullMnemonic,
                    _companyMnemonic,
                    _wellNameMnemonic,
                    _fieldMnemonic,
                    _locationMnemonic,
                    _provinceMnemonic,
                    _countyMnemonic,
                    _stateMnemonic,
                    _countryMnemonic,
                    _serviceCompanyMnemonic,
                    _dateLoggedMnemonic,
                    _uniqueWellIdMnemonic,
                    _apiNumberMnemonic
                }
            };

            _depthChannelMnemonic = new LasMnemonicLine {
                Mnemonic = "DEPT", Units = "FEET", Description = "DEPTH"
            };
            _gammaChannelMnemonic = new LasMnemonicLine {
                Mnemonic = "GR", Units = "RAD", Description = "GAMMA RAY"
            };

            _curveInformationSection = new LasSection
            {
                SectionType    = LasSectionType.CurveInformation,
                MnemonicsLines = new List <LasMnemonicLine>
                {
                    _depthChannelMnemonic,
                    new LasMnemonicLine {
                        Mnemonic = "PRSR", Units = "PSI", Description = "PRESSURE"
                    },
                    new LasMnemonicLine {
                        Mnemonic = "TEMP", Units = "DEGC", Description = "TEMPURATURE"
                    }
                }
            };

            _parameterInformationSection = new LasSection
            {
                SectionType = LasSectionType.ParameterInformation
            };

            _otherInformationSection = new LasSection
            {
                SectionType = LasSectionType.OtherInformation
            };

            _asciiLogDataSection = new LasSection
            {
                SectionType       = LasSectionType.AsciiLogData,
                AsciiLogDataLines = new List <LasAsciiLogDataLine>
                {
                    new LasAsciiLogDataLine {
                        Values = new string[] { "100.0", "0.500", "90.0" }
                    },
                    new LasAsciiLogDataLine {
                        Values = new string[] { "100.5", "0.510", "92.0" }
                    },
                    new LasAsciiLogDataLine {
                        Values = new string[] { "101.0", "0.520", "94.0" }
                    }
                }
            };

            _lasLog = new LasLog
            {
                Sections = new List <LasSection>
                {
                    _versionInformationSection,
                    _wellInformationSection,
                    _curveInformationSection,
                    _parameterInformationSection,
                    _otherInformationSection,
                    _asciiLogDataSection
                }
            };

            _lasLogValidator = new LasLogValidator();
        }