示例#1
0
        /// <summary>
        /// Returns the shallow copy of LAS index (first channel)
        /// </summary>
        //public new LAS_Channel GetIndex()
        //{
        //    return GetChannel( 0);
        //}

        /// <summary>
        /// Returns the deep copy of LAS index (first channel)
        /// </summary>
        //public new LAS_Channel GetIndexCopy()
        //{
        //    return GetChannelCopy(0);
        //}

        /// <summary>
        /// Returns the shallow copy of LAS channel
        /// </summary>
        //public new LAS_Channel GetChannel(int index)
        //{
        //    LAS_Channel lc = (LAS_Channel)base.GetChannel(index);
        //    return lc;
        //}

        /// <summary>
        /// Returns the shallow copy of LAS channel
        /// </summary>
        //public new LAS_Channel GetChannel(string name)
        //{
        //    LAS_Channel lc = (LAS_Channel)base.GetChannel(name);
        //    return lc;
        //}

        /// <summary>
        /// Returns the deep copy of LAS channel
        /// </summary>
        public override Oilfield_Channel GetChannelCopy(int index)
        {
            if (index < 0 || index >= Channels.Count)
            {
                return(null);
            }
            LAS_Channel lc = new LAS_Channel(GetChannel(index));

            return((Oilfield_Channel)lc);
        }
示例#2
0
 /// <summary>
 /// Returns the deep copy of LAS channel
 /// </summary>
 public override Oilfield_Channel GetChannelCopy(string name)
 {
     foreach (LAS_Channel c in Channels)
     {
         if (c.Name != name)
         {
             continue;
         }
         LAS_Channel lc = new LAS_Channel(c);
         return((Oilfield_Channel)lc);
     }
     return(null);
 }
示例#3
0
        /// <summary>
        /// Crops all file data between min index and max index
        /// </summary>
        /// <param name="minIndex">minimum value of index</param>
        /// <param name="maxIndex">maximum value of index</param>
        public override void CropByIndex(double minIndex, double maxIndex)
        {
            base.CropByIndex(minIndex, maxIndex);
            LAS_Channel index = (LAS_Channel)GetIndex();

            if (index == null || index.Data.Count <= 0)
            {
                SetConstant("STRT", "0.000");
                SetConstant("STOP", "0.000");
                return;
            }
            SetConstant("STRT", index.Data[0].ToString(index.Format));
            SetConstant("STOP", index.Data[index.Data.Count - 1].ToString(index.Format));
        }
示例#4
0
        /// <summary>
        /// Returns a new LAS channel
        /// </summary>
        public LAS_Channel GetNewChannel(LAS_Channel template)
        {
            LAS_Channel c     = new LAS_Channel(template);
            LAS_Channel index = (LAS_Channel)GetIndex();

            if (c != null)
            {
                c.Data.Clear();
                for (int i = 0; i < index.Data.Count; i++)
                {
                    c.Data.Add(Double.NaN);
                }
            }
            return(c);
        }
示例#5
0
        /// <summary>
        /// Returns the LAS channel, creating one as necessary
        /// </summary>
        public override Oilfield_Channel GetOrCreateChannel(string name, string unit, string description, string format)
        {
            LAS_Channel c = (LAS_Channel)GetChannel(name);

            if (c != null)
            {
                return((Oilfield_Channel)c);
            }
            c             = (LAS_Channel)GetIndexCopy();
            c.Name        = name;
            c.Unit        = unit;
            c.Description = description;
            c.Format      = format;
            c.SetData(Double.NaN);
            Channels.Add(c);
            return((Oilfield_Channel)c);
        }
示例#6
0
        /// <summary>
        /// This is used for files that lie about the index step, such as sometimes in WellCAD
        /// </summary>
        /// <returns></returns>
        public double EstimateIndexStep(bool SkipIfDefined)
        {
            double st = Convert.ToDouble(this.GetConstant("STEP"));

            if (st != 0.0 && SkipIfDefined)
            {
                return(st);
            }
            LAS_Channel index = (LAS_Channel)GetIndex();

            if (!index.IsLoaded || index.Data.Count <= 1)
            {
                return(st);
            }
            st = index.Data[1] - index.Data[0];
            SetConstant("STEP", st.ToString("0.000000"));
            return(st);
        }
示例#7
0
        /// <summary>
        /// Returns a new LAS channel
        /// </summary>
        public override Oilfield_Channel GetNewChannel(string name, string unit, string description)
        {
            LAS_Channel lc = (LAS_Channel)base.GetNewChannel(name, unit, description);

            return((Oilfield_Channel)lc);
        }
示例#8
0
        /// <summary>
        /// Construsctor; reads the LAS file header to memory
        /// </summary>
        /// <param name="filename">File name</param>
        /// <param name="ParseData">Set to true is data parsing is needed</param>
        public LAS_File(string filename, bool ParseData) : base(filename)
        {
            FileStream   fs = null;
            StreamReader sr = null;

            try
            {
                fs = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
                sr = new StreamReader(fs);
                bool version_info_block_on   = false;
                bool well_info_block_on      = false;
                bool curve_info_block_on     = false;
                bool parameter_info_block_on = false;
                bool other_info_block_on     = false;
                bool data_on = false;
                while (!sr.EndOfStream)
                {
                    string s  = sr.ReadLine();
                    string s2 = s.ToLower();

                    if (s2.StartsWith("~version"))
                    {
                        version_info_block_on   = true;
                        well_info_block_on      = false;
                        curve_info_block_on     = false;
                        parameter_info_block_on = false;
                        other_info_block_on     = false;
                        data_on = false;
                        continue;
                    }
                    if (s2.StartsWith("~well"))
                    {
                        version_info_block_on   = false;
                        well_info_block_on      = true;
                        curve_info_block_on     = false;
                        parameter_info_block_on = false;
                        other_info_block_on     = false;
                        data_on = false;
                        continue;
                    }
                    if (s2.StartsWith("~curv") || s2.StartsWith("~log_definition"))
                    {
                        version_info_block_on   = false;
                        well_info_block_on      = false;
                        curve_info_block_on     = true;
                        parameter_info_block_on = false;
                        other_info_block_on     = false;
                        data_on = false;
                        continue;
                    }
                    if (s2.StartsWith("~paramet") || s2.StartsWith("~log_parameter"))
                    {
                        version_info_block_on   = false;
                        well_info_block_on      = false;
                        curve_info_block_on     = false;
                        parameter_info_block_on = true;
                        other_info_block_on     = false;
                        data_on = false;
                        continue;
                    }
                    if (s2.ToLower().StartsWith("~other"))
                    {
                        version_info_block_on   = false;
                        well_info_block_on      = false;
                        curve_info_block_on     = false;
                        parameter_info_block_on = false;
                        other_info_block_on     = true;
                        data_on = false;
                        continue;
                    }
                    if (s2.ToUpper().StartsWith("~A") || s2.StartsWith("~log_data"))
                    {
                        version_info_block_on   = false;
                        well_info_block_on      = false;
                        curve_info_block_on     = false;
                        parameter_info_block_on = false;
                        other_info_block_on     = false;
                        data_on = true;
                        if (!ParseData)
                        {
                            break;
                        }
                        continue;
                    }
                    if (version_info_block_on)
                    {
                        if (s.StartsWith("#"))
                        {
                            continue;
                        }
                        if (s.Length <= 1)
                        {
                            continue;
                        }
                        LAS_Constant lc = new LAS_Constant(s);
                        if (lc.Name.ToUpper() == "VERS" && !lc.Value.StartsWith("2."))
                        {
                            throw new Exception("LAS version other than 2.x cannot be handled.");
                        }
                        if (lc.Name.ToUpper() == "WRAP" && !lc.Value.StartsWith("N"))
                        {
                            throw new Exception("Wrapped data cannot be handled by most clients. Do not use LAS wrap.");
                        }
                        Version.Add(lc);
                    }
                    if (well_info_block_on)
                    {
                        if (s.StartsWith("#"))
                        {
                            continue;
                        }
                        if (s.Length <= 1)
                        {
                            continue;
                        }
                        LAS_Constant lc = new LAS_Constant(s);
                        if (lc.Name == "NULL")
                        {
                            MissingValue = Convert.ToDouble(lc.Value);
                        }
                        Constants.Add(lc);
                    }
                    if (curve_info_block_on)
                    {
                        if (s.StartsWith("#"))
                        {
                            continue;
                        }
                        if (s.Length <= 1)
                        {
                            continue;
                        }
                        LAS_Channel lc = new LAS_Channel(s);
                        Channels.Add(lc);
                    }
                    if (parameter_info_block_on)
                    {
                        if (s.StartsWith("#"))
                        {
                            continue;
                        }
                        if (s.Length <= 1)
                        {
                            continue;
                        }
                        LAS_Constant lc = new LAS_Constant(s);
                        Parameters.Add(lc);
                    }
                    if (other_info_block_on)
                    {
                        if (s.Length <= 1)
                        {
                            continue;
                        }
                        LAS_InfoLine lil = new LAS_InfoLine(s);
                        InfoLines.Add(lil);
                    }
                    if (data_on)
                    {
                        if (s.StartsWith("#"))
                        {
                            continue;
                        }
                        if (s.Length <= 1)
                        {
                            continue;
                        }
                        if (s.StartsWith("~A"))
                        {
                            continue;
                        }
                        m_RawData.Add(s);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                if (sr != null)
                {
                    sr.Close();
                }
                if (fs != null)
                {
                    fs.Close();
                }
            }
            ConvertConstantsFromEarlierLAS();

            // parse data to channels
            if (Channels.Count <= 0)
            {
                throw new Exception("No curves have been declared in the file.");
            }
            foreach (string s in m_RawData)
            {
                string[] ss = s.Split(_space_split, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < ss.Length; i++)
                {
                    Channels[i].AddData(ss[i], MissingValue);
                }
            }
            m_RawData.Clear();
        }
示例#9
0
        /// <summary>
        /// Writes the LAS into a file
        /// </summary>
        /// <param name="filename">File name to write to</param>
        public override void Write(string filename)
        {
            StreamWriter sw = File.CreateText(filename);

            sw.WriteLine("~Version Information");
            sw.WriteLine("VERS.              2.00:     CWLS log ASCII Standard -VERSION 2.00");
            sw.WriteLine("WRAP.                NO:     One line per depth step");
            sw.WriteLine("#");
            sw.WriteLine("#");
            sw.WriteLine("~Well Information Block");
            sw.WriteLine("#MNEM.UNIT     Data Type                      Description");
            sw.WriteLine("#---------     -----------                    ----------------");
            foreach (LAS_Constant c in Constants)
            {
                sw.WriteLine(c.ToString());
            }
            sw.WriteLine("#");
            sw.WriteLine("#");
            sw.WriteLine("~Curve Information Block");
            sw.WriteLine("#MNEM.UNIT   API Codes           Curve Description");
            sw.WriteLine("#---------    -----------         -----------------------------");
            foreach (LAS_Channel c in Channels)
            {
                sw.WriteLine(c.ToString());
            }
            sw.WriteLine("#");
            sw.WriteLine("#");
            sw.WriteLine("~Parameter Information Block");
            sw.WriteLine("#MNEM.UNIT     Data                           Description");
            sw.WriteLine("#---------     -----------                    ----------------");
            foreach (LAS_Constant c in Parameters)
            {
                sw.WriteLine(c.ToString());
            }
            sw.WriteLine("#");
            sw.WriteLine("#");
            sw.WriteLine("~Other Information");
            foreach (LAS_InfoLine c in InfoLines)
            {
                sw.WriteLine(c.ToString());
            }
            sw.WriteLine("#");
            sw.WriteLine("#");
            if (NewDataHeaderStyle)
            {
                sw.WriteLine("# --- LOG MNEMONICS AND UNITS ---");
                sw.WriteLine(LogMnemonicsToString());
                sw.WriteLine(DataUnitsToString());
                sw.WriteLine("~A");
            }
            else
            {
                sw.WriteLine(DataHeaderToString());
            }

            // write data
            LAS_Channel indexChannel = (LAS_Channel)GetIndex();

            if (indexChannel == null)
            {
                sw.Close();
                return;
            }
            for (int i = 0; i < indexChannel.Data.Count; i++)
            {
                StringBuilder sb = new StringBuilder(indexChannel.ToString(i, MissingValue));
                for (int j = 1; j < Channels.Count; j++)
                {
                    sb.Append(' ');
                    sb.Append(Channels[j].ToString(i, MissingValue));
                }
                string tmp = sb.ToString();
                sw.WriteLine(tmp);
            }
            sw.Close();
        }
示例#10
0
 /// <summary>
 /// Returns the channel average from start to end depth inclusive.
 /// </summary>
 /// <param name="start">start index</param>
 /// <param name="end">end index</param>
 /// <param name="index">index channel</param>
 /// <returns>ariphmetic average or NaN</returns>
 public double GetAverage(double start, double end, LAS_Channel index)
 {
     return base.GetAverage(start, end, (Oilfield_Channel)index);
 }
示例#11
0
 /// <summary>
 /// Locates the upper and lower boundaries for the channel
 /// </summary>
 /// <param name="index">index channel or null</param>
 /// <returns>true is boundearies are located</returns>
 public bool LocateDataBoundaries( LAS_Channel index)
 {
     return base.LocateDataBoundaries((Oilfield_Channel)index);
 }