/// <summary> /// Resamples all channels in a file /// </summary> public void Resample(Oilfield_File srcFile, Oilfield_File dstFile, int default_method) { for (int i = 1; i < dstFile.Channels.Count; i++) { Oilfield_Channel c = dstFile.GetChannel(i); if ((c.Name.ToLower().Contains("az") || c.Name.ToLower().Contains("ti")) && c.Unit.ToLower().StartsWith("deg")) { this.Resample(srcFile.GetChannel(i), c, LinearInterpolateAngle); continue; } if (c.Unit.ToLower().Equals("m") || c.Unit.ToLower().Equals("ft") || c.Unit.ToLower().Equals("ms") || c.Unit.ToLower().Equals("s")) { this.Resample(srcFile.GetChannel(i), c, LinearInterpolate); continue; } if (c.Unit.ToLower().StartsWith("ohm")) { this.Resample(srcFile.GetChannel(i), c, LogarithmicAverage); continue; } if (c.Unit.ToLower().StartsWith("mho")) { this.Resample(srcFile.GetChannel(i), c, HarmonicAverage); continue; } this.Resample(srcFile.GetChannel(i), c, default_method); } }
/// <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); } }
/// <summary> /// Extract the channel from source and merges to the destination /// </summary> /// <param name="name">channel name in the source file</param> public void MergeChannel(string name, int method) { Oilfield_Channel src_channel = m_src.GetChannel(name); if (src_channel == null) { return; } Oilfield_Channel dst_channel = m_dst.GetChannel(name); if (dst_channel == null) { dst_channel = m_dst.GetNewChannel(src_channel); m_dst.Channels.Add(dst_channel); } else { dst_channel.SetData(Double.NaN); } m_Resampler.Resample(src_channel, dst_channel, method); }
/// <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; } }