コード例 #1
0
ファイル: Oilfield_Channel.cs プロジェクト: myak555/PETRONODE
        /// <summary>
        /// Creates a deep copy of a given channel
        /// </summary>
        /// <param name="c"></param>
        public virtual Oilfield_Channel Clone()
        {
            Oilfield_Channel tmp = new Oilfield_Channel();

            tmp.Name           = this.Name;
            tmp.Unit           = this.Unit;
            tmp.Description    = this.Description;
            tmp.DepthOffset    = this.DepthOffset;
            tmp.Decimals_Count = this.Decimals_Count;
            tmp.Format         = this.Format;
            tmp.PaddedWidth    = this.PaddedWidth;
            tmp.ValidCount     = this.ValidCount;
            tmp.MissingCount   = this.MissingCount;
            tmp.DataStart      = this.DataStart;
            tmp.DataEnd        = this.DataEnd;
            tmp.DataStartIndex = this.DataStartIndex;
            tmp.DataEndIndex   = this.DataEndIndex;
            tmp.MinValue       = this.MinValue;
            tmp.MaxValue       = this.MaxValue;
            tmp.Average        = this.Average;
            foreach (Oilfield_Constant d in this.Parameters)
            {
                tmp.Parameters.Add(d.Clone());
            }
            foreach (double d in this.Data)
            {
                tmp.Data.Add(d);
            }
            return(tmp);
        }
コード例 #2
0
ファイル: Oilfield_Channel.cs プロジェクト: myak555/PETRONODE
        /// <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 virtual double GetAverage(double start, double end, Oilfield_Channel index)
        {
            double average      = 0.0;
            double averageCount = 0.0;

            for (int i = 0; i < Data.Count; i++)
            {
                double d = index.Data[i];
                if (d < start || end < d)
                {
                    continue;
                }
                d = Data[i];
                if (Double.IsNaN(d))
                {
                    continue;
                }
                average      += d;
                averageCount += 1.0;
            }
            if (averageCount <= 0.0)
            {
                return(Double.NaN);
            }
            return(average /= averageCount);
        }
コード例 #3
0
ファイル: Oilfield_Channel.cs プロジェクト: myak555/PETRONODE
 /// <summary>
 /// Creates a deep copy of a given channel
 /// </summary>
 /// <param name="c"></param>
 public Oilfield_Channel(Oilfield_Channel c)
 {
     this.Name           = c.Name;
     this.Unit           = c.Unit;
     this.Description    = c.Description;
     this.DepthOffset    = c.DepthOffset;
     this.Decimals_Count = c.Decimals_Count;
     this.Format         = c.Format;
     this.PaddedWidth    = c.PaddedWidth;
     this.ValidCount     = c.ValidCount;
     this.MissingCount   = c.MissingCount;
     this.DataStart      = c.DataStart;
     this.DataEnd        = c.DataEnd;
     this.DataStartIndex = c.DataStartIndex;
     this.DataEndIndex   = c.DataEndIndex;
     this.MinValue       = c.MinValue;
     this.MaxValue       = c.MaxValue;
     this.Average        = c.Average;
     foreach (Oilfield_Constant d in c.Parameters)
     {
         this.Parameters.Add(d);
     }
     foreach (double d in c.Data)
     {
         this.Data.Add(d);
     }
 }
コード例 #4
0
        /// <summary>
        /// Loads the channel info from disk
        /// </summary>
        /// <param name="filename">filename to load from</param>
        /// <returns>true if file exists and loaded</returns>
        public bool Load(string filename)
        {
            if (!File.Exists(filename))
            {
                return(false);
            }
            StreamReader sr  = File.OpenText(filename);
            bool         ret = true;

            while (true)
            {
                string s = sr.ReadLine();
                if (s == null)
                {
                    break;
                }
                if (s.Length <= 0)
                {
                    continue;
                }
                if (s.StartsWith("#"))
                {
                    continue;
                }
                s = Dequote(s);
                string[] tmp = s.Split(c_Splitters, StringSplitOptions.None);
                if (tmp.Length < 9)
                {
                    ret = false;
                    continue;
                }
                Oilfield_Channel oc = null;
                foreach (Oilfield_Channel c in m_Channels)
                {
                    if (c.Name != tmp[0] || c.Unit != tmp[1])
                    {
                        continue;
                    }
                    oc = c;
                    break;
                }
                if (oc == null)
                {
                    ret = false;
                    continue;
                }
                try
                {
                    oc.FromStrings(tmp);
                }
                catch (Exception)
                {
                    ret = false;
                    continue;
                }
            }
            sr.Close();
            return(ret);
        }
コード例 #5
0
ファイル: Oilfield_File.cs プロジェクト: myak555/PETRONODE
 /// <summary>
 /// Updates the channel statistics for all channels in file
 /// </summary>
 public virtual void UpdateChannelStatistics()
 {
     for (int i = 0; i < Channels.Count; i++)
     {
         Oilfield_Channel oc = GetChannel(i);
         oc.LocateDataBoundaries(this.GetIndex());
     }
 }
コード例 #6
0
ファイル: Oilfield_File.cs プロジェクト: myak555/PETRONODE
        /// <summary>
        /// Applies a simple depth offset on the channel data
        /// </summary>
        /// <param name="step"></param>
        public void ApplyDepthOffsets()
        {
            Oilfield_Channel index = GetIndex();
            double           step  = index.Data[1] - index.Data[0];

            for (int i = 1; i < Channels.Count; i++)
            {
                Channels[i].ApplyDepthOffset(step);
            }
        }
コード例 #7
0
ファイル: Oilfield_File.cs プロジェクト: myak555/PETRONODE
 /// <summary>
 /// Creates the same channes as in the given file
 /// </summary>
 /// <param name="file"></param>
 public virtual void CreateSameChannels(Oilfield_File file)
 {
     for (int i = 1; i < file.Channels.Count; i++)
     {
         Oilfield_Channel lc  = file.Channels[i];
         Oilfield_Channel tmp = this.GetChannel(lc.Name);
         if (tmp != null)
         {
             continue;
         }
         this.GetOrCreateChannel(lc.Name, lc.Unit, lc.Description, lc.Format);
     }
 }
コード例 #8
0
ファイル: Oilfield_File.cs プロジェクト: myak555/PETRONODE
        /// <summary>
        /// Returns a new channel
        /// </summary>
        public virtual Oilfield_Channel GetNewChannel(string name, string unit, string description)
        {
            Oilfield_Channel c = GetIndexCopy();

            if (c != null)
            {
                c.Name        = name;
                c.Unit        = unit;
                c.Description = description;
                c.SetData(Double.NaN);
            }
            return(c);
        }
コード例 #9
0
ファイル: Oilfield_File.cs プロジェクト: myak555/PETRONODE
        /// <summary>
        /// Returns a new LAS channel
        /// </summary>
        public virtual Oilfield_Channel GetNewChannel(Oilfield_Channel template)
        {
            Oilfield_Channel c     = new Oilfield_Channel(template);
            Oilfield_Channel index = GetIndex();

            if (c != null)
            {
                c.Data.Clear();
                for (int i = 0; i < index.Data.Count; i++)
                {
                    c.Data.Add(Double.NaN);
                }
            }
            return(c);
        }
コード例 #10
0
ファイル: Oilfield_File.cs プロジェクト: myak555/PETRONODE
        /// <summary>
        /// Returns the channel, creating one as necessary
        /// </summary>
        public virtual Oilfield_Channel GetOrCreateChannel(string name, string unit, string description, string format)
        {
            Oilfield_Channel c = GetChannel(name);

            if (c != null)
            {
                return(c);
            }
            c             = GetIndexCopy();
            c.Name        = name;
            c.Unit        = unit;
            c.Description = description;
            c.Format      = format;
            c.SetData(Double.NaN);
            Channels.Add(c);
            return(c);
        }
コード例 #11
0
ファイル: Oilfield_Channel.cs プロジェクト: myak555/PETRONODE
        /// <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 virtual bool LocateDataBoundaries(Oilfield_Channel index)
        {
            ValidCount     = 0;
            MissingCount   = 0;
            DataStart      = Double.NaN;
            DataEnd        = Double.NaN;
            DataStartIndex = -1;
            DataEndIndex   = -1;
            MinValue       = Double.NaN;
            MaxValue       = Double.NaN;
            Average        = Double.NaN;
            if (Data.Count <= 0)
            {
                return(false);
            }
            if (index != null)
            {
                DataStart = index.Data[0];
                DataEnd   = index.Data[Data.Count - 1];
            }
            DataStartIndex = 0;
            DataEndIndex   = Data.Count - 1;
            bool data_located = false;

            for (int i = 0; i < Data.Count; i++)
            {
                DataStartIndex = i;
                if (!Double.IsNaN(Data[i]))
                {
                    data_located = true;
                    break;
                }
            }
            if (!data_located)
            {
                ValidCount   = 0;
                MissingCount = Data.Count;
                return(false);
            }
            if (index != null)
            {
                DataStart = index.Data[DataStartIndex];
            }
            data_located = false;
            for (int i = Data.Count - 1; i >= 0; i--)
            {
                DataEndIndex = i;
                if (!Double.IsNaN(Data[i]))
                {
                    data_located = true;
                    break;
                }
            }
            if (!data_located)
            {
                ValidCount   = 0;
                MissingCount = Data.Count;
                return(false);
            }
            if (index != null)
            {
                DataEnd = index.Data[DataEndIndex];
            }
            MinValue = Double.MaxValue;
            MaxValue = Double.MinValue;
            Average  = 0.0;
            double AverageCount = 0.0;

            for (int i = 0; i < Data.Count; i++)
            {
                double d = Data[i];
                if (Double.IsNaN(d))
                {
                    MissingCount++;
                    continue;
                }
                ValidCount++;
                if (MinValue > d)
                {
                    MinValue = d;
                }
                if (MaxValue < d)
                {
                    MaxValue = d;
                }
                Average      += d;
                AverageCount += 1.0;
            }
            Average /= AverageCount;
            return(true);
        }