Exemple #1
0
        /// <summary>
        /// Returns a new LAS channel
        /// </summary>
        public new CSV_Channel GetNewChannel(string name, string unit, string description)
        {
            CSV_Channel lc = new CSV_Channel(name, unit);

            lc.Description = description;
            return(lc);
        }
Exemple #2
0
        /// <summary>
        /// Creates a deep copy of a given channel
        /// </summary>
        /// <param name="c"></param>
        public override Oilfield_Channel Clone()
        {
            CSV_Channel tmp = new CSV_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);
        }
Exemple #3
0
        /// <summary>
        /// Returns a new LAS channel
        /// </summary>
        public CSV_Channel GetNewChannel(CSV_Channel template)
        {
            CSV_Channel c     = (CSV_Channel)template.Clone();
            CSV_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);
        }
Exemple #4
0
        /// <summary>
        /// Returns the LAS channel, creating one as necessary
        /// </summary>
        public new CSV_Channel GetOrCreateChannel(string name, string unit, string description, string format)
        {
            CSV_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);
        }
Exemple #5
0
        /// <summary>
        /// Writes the CSV into a file
        /// </summary>
        /// <param name="filename">File name to write to</param>
        public override void Write(string filename)
        {
            FileStream   fs = File.Open(filename, FileMode.Create, FileAccess.Write, FileShare.Read);
            StreamWriter sw = new StreamWriter(fs);

            if (SaveConstants)
            {
                foreach (CSV_Constant c in Constants)
                {
                    sw.WriteLine(c.ToString());
                }
            }
            sw.WriteLine(LogMnemonicsToString());
            if (SaveUnits)
            {
                sw.WriteLine(DataUnitsToString());
            }
            if (SaveDescriptions)
            {
                sw.WriteLine(DescriptionsToString());
            }

            // write data
            CSV_Channel indexChannel = GetIndex();

            if (indexChannel == null)
            {
                sw.Close();
                fs.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("," + Channels[j].ToString(i, MissingValue));
                }
                string tmp = sb.ToString();
                sw.WriteLine(tmp);
            }
            sw.Close();
            fs.Close();
        }
Exemple #6
0
        /// <summary>
        /// Returns the shallow copy of LAS channel
        /// </summary>
        public new CSV_Channel GetChannel(string name)
        {
            CSV_Channel lc = (CSV_Channel)base.GetChannel(name);

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

            return(lc);
        }