Esempio n. 1
0
        /// <summary>
        /// Constructor. Crates a merge class. Note: the merge is performed on memory only.
        /// </summary>
        /// <param name="source">File to take information from</param>
        /// <param name="destination">File to save the information into</param>
        public Data_Merge(Oilfield_File source, Oilfield_File destination)
        {
            m_src = source;
            m_dst = destination;
            double step  = 0.0;
            double step2 = 0.0;

            try
            {
                step  = Math.Abs(Convert.ToDouble(m_dst.GetConstant("STEP")));
                step2 = Math.Abs(Convert.ToDouble(m_src.GetConstant("STEP")));
            }
            catch (Exception) { }
            if (step < 0.001)
            {
                step = 0.001;
            }
            Oilfield_Channel src_Index  = source.GetIndex();
            Oilfield_Channel dest_Index = destination.GetIndex();

            if (step2 < 0.001 && src_Index.Data.Count > 2)
            {
                step2 = Math.Abs(src_Index.Data[1] - src_Index.Data[0]);
            }
            step2       = 2.0 * Math.Max(step, step2);
            m_Resampler = new Channel_Resample(src_Index, dest_Index, step * 0.5, step2);
        }
Esempio n. 2
0
        /// <summary>
        /// Computes the classic min curvature algorithm
        /// </summary>
        /// <param name="azimuth_channel_name"></param>
        /// <param name="tilt_channel_name"></param>
        /// <param name="northing_channel_name"></param>
        /// <param name="easting_channel_name"></param>
        /// <param name="tvd_channel_name"></param>
        /// <param name="dls_channel_name"></param>
        public void Compute(string azimuth_channel_name, string tilt_channel_name,
                            string northing_channel_name, string easting_channel_name,
                            string tvd_channel_name, string dls_channel_name)
        {
            if (m_file == null)
            {
                return;
            }
            Oilfield_Channel depth = m_file.GetIndex();
            Oilfield_Channel azim  = m_file.GetChannel(azimuth_channel_name);

            if (azim == null)
            {
                throw new Exception("Channel " + azimuth_channel_name + " is not found in file " + m_file.FileName);
            }
            Oilfield_Channel tilt = m_file.GetChannel(tilt_channel_name);

            if (tilt == null)
            {
                throw new Exception("Channel " + tilt_channel_name + " is not found in file " + m_file.FileName);
            }
            Oilfield_Channel northing = m_file.GetOrCreateChannel(northing_channel_name, "M", "Northing coordinate", "0.000");

            if (northing == null)
            {
                throw new Exception("Channel " + northing_channel_name + " cannot be created");
            }
            Oilfield_Channel easting = m_file.GetOrCreateChannel(easting_channel_name, "M", "Easting coordinate", "0.000");

            if (easting == null)
            {
                throw new Exception("Channel " + easting_channel_name + " cannot be created");
            }
            Oilfield_Channel tvd = m_file.GetOrCreateChannel(tvd_channel_name, "M", "True vertical depth", "0.000");

            if (tvd == null)
            {
                throw new Exception("Channel " + tvd_channel_name + " cannot be created");
            }
            Oilfield_Channel dls = m_file.GetOrCreateChannel(dls_channel_name, "deg/30M", "Dogleg severity", "0.000");

            if (dls == null)
            {
                throw new Exception("Channel " + dls_channel_name + " cannot be created");
            }
            if (depth.Data[0] < depth.Data[depth.Data.Count - 1])
            {
                ComputeFromTop(depth, azim, tilt, northing, easting, tvd, dls);
            }
            else
            {
                ComputeFromBottom(depth, azim, tilt, northing, easting, tvd, dls);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Filter the channel using Ganning Algorithm
        /// </summary>
        /// <param name="name">channel name in the source file</param>
        /// <param name="n">half-size of filter</param>
        /// <param name="k">number of rejected values</param>
        public void FilterChannelGunning(string name, int n, int k)
        {
            Oilfield_Channel src_index = m_src.GetIndex();

            if (src_index == null)
            {
                return;
            }
            Oilfield_Channel src_channel = m_src.GetChannel(name);

            if (src_channel == null)
            {
                return;
            }

            // locate upper and lower boundaries
            DataStart      = Double.NaN;
            DataEnd        = Double.NaN;
            DataStartIndex = -1;
            DataEndIndex   = -1;
            if (!src_channel.LocateDataBoundaries(src_index))
            {
                return;
            }
            DataStart      = src_channel.DataStart;
            DataEnd        = src_channel.DataEnd;
            DataStartIndex = src_channel.DataStartIndex;
            DataEndIndex   = src_channel.DataEndIndex;

            // perform Gunning filtering
            int           l    = src_channel.Data.Count;
            List <double> buff = new List <double>(l);

            buff.AddRange(src_channel.Data);
            for (int i = 0; i < l; i++)
            {
                src_channel.Data[i] = Double.NaN;
                if (i < DataStartIndex)
                {
                    continue;
                }
                if (i > DataEndIndex)
                {
                    continue;
                }
                List <double> tmp = new List <double>((n << 1) + 1);
                for (int j = i - n; j <= i + n; j++)
                {
                    if (j < 0 || j >= l)
                    {
                        continue;
                    }
                    if (Double.IsNaN(buff[j]))
                    {
                        continue;
                    }
                    tmp.Add(buff[j]);
                }
                if (tmp.Count <= 0)
                {
                    continue;
                }
                tmp.Sort();
                int kk = k;
                while (tmp.Count < (kk + 5 + kk))
                {
                    kk--;
                }
                double avearge       = 0.0;
                double avearge_count = 0.0;
                for (int j = kk; j < tmp.Count - kk; j++)
                {
                    avearge       += tmp[j];
                    avearge_count += 1.0;
                }
                if (avearge_count <= 0.0)
                {
                    continue;
                }
                src_channel.Data[i] = avearge / avearge_count;
            }
        }