Exemplo n.º 1
0
        /// <summary>
        /// Returns a new LDF channel
        /// </summary>
        public new LDF_Channel GetNewChannel(string name, string unit, string description)
        {
            LDF_Channel lc = new LDF_Channel(this, name, unit);

            lc.Description = description;
            return(lc);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a deep copy of a given channel
        /// </summary>
        /// <param name="c"></param>
        public override Oilfield_Channel Clone()
        {
            LDF_Channel tmp = new LDF_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);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns a new LDF channel
        /// </summary>
        public LDF_Channel GetNewChannel(LDF_Channel template)
        {
            LDF_Channel c     = (LDF_Channel)template.Clone();
            LDF_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);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Returns the LDF channel, creating one as necessary
        /// </summary>
        public new LDF_Channel GetOrCreateChannel(string name, string unit, string description, string format)
        {
            LDF_Channel c = GetChannel(name);

            if (c != null)
            {
                return(c);
            }
            c             = GetIndexCopy();
            c.Name        = name;
            c.Unit        = unit;
            c.Description = description;
            c.Format      = format;
            Channels.Add(c);
            return(c);
        }
Exemplo n.º 5
0
        private void ParseFile(bool readdata)
        {
            FileStream fs = null;

            try
            {
                fs = File.Open(FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                fs.Read(CommonHeader, 0, CommonHeader.Length);
                foreach (LDF_Constant c in Constants)
                {
                    c.GetBuffer(CommonHeader);
                }

                long   nsamples       = Convert.ToInt64(GetConstant("Number of Samples"));
                double interval       = Convert.ToDouble(GetConstant("Sampling Rate"));
                string trace_measures = GetConstant("Along Measurement");
                if (interval <= 0.0)
                {
                    SetConstant("Sampling Rate", "1.0");
                    interval = 1.0;
                }

                // TODO -- change the along trace units as necessary

                LDF_Channel index = (trace_measures.ToUpper().StartsWith("D"))?
                                    new LDF_Channel(this, "Depth", "m") : new LDF_Channel(this, "Time", "ms");
                if (readdata)
                {
                    for (int i = 0; i < nsamples; i++)
                    {
                        index.Data.Add(interval * i);
                    }
                }
                Channels.Add(index);

                // Unlike SEG-Y, the traces in the LDF are always 4-byte floats
                // The trace header length is always 588 bytes
                long   channelLength = 588L + (nsamples << 2);
                byte[] Buffer        = new byte[channelLength];
                int    traceCount    = 0;

                // Note that in the LDF files all length units are in always ft
                // For most applications a conversion on the flight is required
                string globUnit = (GetConstant("Across Measurement") == "ft") ? "ft" : "m";
                int    ntraces  = Convert.ToInt32(GetConstant("Number of Levels"));

                // Read the file by the declared number of traces
                for (int i = 0; i < ntraces; i++)
                {
                    int read = fs.Read(Buffer, 0, Buffer.Length);
                    if (read < Buffer.Length)
                    {
                        break;
                    }
                    //    LDF_Channel c = new LDF_Channel(traceCount.ToString(), "sample", Buffer, readdata);
                    //    foreach (LDF_Constant cc in c.Parameters)
                    //    {
                    //        if (cc.Unit == "unitless") continue;
                    //        if (cc.Unit == "elevation") cc.Unit = globUnit;
                    //        if (cc.Unit == "coordinate") cc.Unit = globUnit;
                    //        if (cc.Unit == "velocity") cc.Unit = globUnit + "/s";
                    //    }
                    //    this.Channels.Add(c);
                    traceCount++;
                }

                // Determine how much left at the end
                // This may be a processing history or EBCDIC text
                long historyLocation = fs.Position;
                long historyLength   = fs.Length - historyLocation;
                if (historyLength > 0L)
                {
                    ProcessingHistory = new byte[historyLength];
                    fs.Read(ProcessingHistory, 0, ProcessingHistory.Length);
                }
                SetConstant("Number of Levels", traceCount.ToString());
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Returns the shallow copy of LDF channel
        /// </summary>
        public new LDF_Channel GetChannel(string name)
        {
            LDF_Channel lc = (LDF_Channel)base.GetChannel(name);

            return(lc);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Returns the shallow copy of LAS channel
        /// </summary>
        public new LDF_Channel GetChannel(int index)
        {
            LDF_Channel lc = (LDF_Channel)base.GetChannel(index);

            return(lc);
        }