/// <summary> /// Enforces rule on file /// </summary> /// <param name="las">LAS file to check</param> public override void Enforce(LAS_File las) { foreach (LAS_Constant lc in las.Constants) { if (lc.Name.ToUpper() != Constant.ToUpper()) { continue; } if (lc.Unit == Value) { this.Status = "Pass"; this.Comment = "Constant " + Constant + " has unit [" + Value + "]"; return; } if (lc.Unit.ToUpper() == Value.ToUpper()) { this.Status = "Warning"; this.Comment = "Constant " + Constant + " has unit [" + lc.Unit + "], but [" + Value + "] is required."; return; } this.Status = Severity; this.Comment = "Constant " + Constant + " has unit [" + lc.Unit + "], but [" + Value + "] is required."; return; } this.Status = "NA"; this.Comment = "Constant " + Constant + " is not defined."; return; }
/// <summary> /// Enforces rule on file /// </summary> /// <param name="las">LAS file to check</param> public override void Enforce(LAS_File las) { LAS_Channel lc = (LAS_Channel)las.GetChannel(Channel); if (lc == null) { this.Status = "NA"; this.Comment = "Channel " + Channel + " is not defined."; return; } if (lc.Unit == Value) { this.Status = "Pass"; this.Comment = "Channel " + Channel + " has unit [" + Value + "]"; return; } if (lc.Unit.ToUpper() == Value.ToUpper()) { this.Status = "Warning"; this.Comment = "Channel " + Channel + " has unit [" + lc.Unit + "], but [" + Value + "] is required."; return; } this.Status = Severity; this.Comment = "Channel " + Channel + " has unit [" + lc.Unit + "], but [" + Value + "] is required."; return; }
public static Oilfield_File OpenData(string filename) { if (!File.Exists(filename)) { return(null); } if (CSV_File.IsCSVFile(filename)) { return(new CSV_File(filename)); } if (SEGY_File.IsSEGYFile(filename)) { return(new SEGY_File(filename)); } if (LAS_File.IsLASFile(filename)) { return(new LAS_File(filename, true)); } if (Petrolog_File.IsPetrologFile(filename)) { Petrolog_File pf = new Petrolog_File(filename); //Petrolog_Channel index = pf.GetIndex(); //index.LoadData(); pf.CreateIndexMetric(); return(pf); } return(null); }
/// <summary> /// Enforces rules on las file /// </summary> /// <param name="las">LAS fiel to check</param> public void Enforce(LAS_File las) { foreach (Rule r in Rules) { r.Enforce(las); } }
/// <summary> /// Enforces rule on file /// </summary> /// <param name="las">LAS file to check</param> public override void Enforce(LAS_File las) { string lc = las.GetParameter(Constant); if (lc.Length <= 0) { this.Status = Severity; this.Comment = "Parameter " + Constant + " is not defined"; return; } if (lc == this.Value) { this.Status = "Pass"; this.Comment = "Parameter " + Constant + " is set to [" + this.Value + "]"; return; } if (lc.ToUpper() == this.Value.ToUpper()) { this.Status = "Warning"; this.Comment = "Parameter " + Constant + " is set to [" + lc + "] but [" + this.Value + "] is required."; return; } this.Status = Severity; this.Comment = "Parameter " + Constant + " is set to [" + lc + "] but [" + this.Value + "] is required."; return; }
private void button3_Click(object sender, EventArgs e) { checkBox1.Enabled = false; button1.Enabled = false; button2.Enabled = false; button3.Enabled = false; button4.Enabled = false; button5.Enabled = false; int pass = 0; int warning = 0; int error = 0; try { if (!File.Exists(textBox1.Text)) { throw new Exception("File does not exist: " + textBox1.Text); } if (!File.Exists(textBox2.Text)) { throw new Exception("File does not exist: " + textBox2.Text); } las = new LAS_File(textBox1.Text, true); ruleList = new RuleList(textBox2.Text); ruleList.Enforce(las); checkBox1_CheckedChanged(this, new EventArgs()); pass = ruleList.GetPassCount(); warning = ruleList.GetWarningCount(); error = ruleList.GetErrorCount(); } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message, "Error", MessageBoxButtons.OK); } checkBox1.Enabled = true; button1.Enabled = true; button2.Enabled = true; button3.Enabled = true; button4.Enabled = true; button5.Enabled = true; if (error > 0) { MessageBox.Show("Check completed with " + error.ToString() + " error(s) and " + warning.ToString() + " warning(s). Do not deliver to Client before fixing it!", "Errors!", MessageBoxButtons.OK); return; } if (warning > 0) { MessageBox.Show("Check completed with no error(s) but " + warning.ToString() + " warning(s). Fix as many as you can before delivering to Client!", "Warnings!", MessageBoxButtons.OK); return; } if (pass > 0) { MessageBox.Show("Check completed with " + pass.ToString() + " rule(s) in Pass state. This log can be safely sent to client.", "Good job!", MessageBoxButtons.OK); return; } }
/// <summary> /// Enforces rule on file /// </summary> /// <param name="las">LAS file to check</param> public override void Enforce(LAS_File las) { FileInfo fi = new FileInfo(las.FileName); string filename = fi.Name; StringBuilder sb = new StringBuilder(); foreach (string s in Values) { string lc = las.GetConstant(s); if (lc.Length <= 0) { lc = las.GetParameter(s); } if (lc.Length > 0) { sb.Append(lc); } else { sb.Append(s); } } string mask = (Capitals == "YES")? sb.ToString().ToUpper(): sb.ToString(); if (Underscore == "YES") { mask = mask.Replace(' ', '_'); } if (filename.StartsWith(mask)) { if (Underscore == "YES" && filename.Contains(" ")) { this.Status = "Warning"; this.Comment = "File name should not contain spaces: " + filename; return; } this.Status = "Pass"; this.Comment = "Naming convention is followed in " + filename; return; } if (Capitals == "YES" && filename.ToUpper().StartsWith(mask)) { this.Status = "Warning"; this.Comment = "File name must be in capitals: " + filename; return; } this.Status = Severity; this.Comment = "Naming convention is not followed in file " + filename + ". Should start with [" + mask + "]"; return; }
/// <summary> /// Enforces rule on file /// </summary> /// <param name="las">LAS file to check</param> public override void Enforce(LAS_File las) { LAS_Channel lc = (LAS_Channel)las.GetChannel(Channel); if (lc == null) { this.Status = Severity; this.Comment = "Channel " + Channel + " is not defined"; return; } this.Status = "Pass"; this.Comment = "Channel " + Channel + " is present"; return; }
/// <summary> /// Enforces rule on file /// </summary> /// <param name="las">LAS file to check</param> public override void Enforce(LAS_File las) { string lc = las.GetConstant(Constant); if (lc.Length <= 0) { this.Status = Severity; this.Comment = "Constant " + Constant + " is not defined"; return; } this.Status = "Pass"; this.Comment = "Constant " + Constant + " is set to [" + lc + "]"; return; }
/// <summary> /// LAS file parsing /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void textBox1_TextChanged(object sender, EventArgs e) { textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; textBox6.Text = ""; textBox7.Text = ""; label5.Visible = false; if (!File.Exists(textBox1.Text)) { label7.Text = "File does not exist"; return; } try { LAS_File lf = new LAS_File(textBox1.Text, false); double start = 0.0; double stop = 0.0; foreach (LAS_Constant lc in lf.Constants) { if (lc.Name.ToUpper().StartsWith("LATI")) { textBox2.Text = ReplaceFunnyChars(lc.Value); } if (lc.Name.ToUpper().StartsWith("LONG")) { textBox3.Text = ReplaceFunnyChars(lc.Value); } if (lc.Name.ToUpper().StartsWith("DATE")) { textBox4.Text = lc.Value; } if (lc.Name.ToUpper().StartsWith("STRT")) { start = Convert.ToDouble(lc.Value); } if (lc.Name.ToUpper().StartsWith("STOP")) { stop = Convert.ToDouble(lc.Value); } } double d = (start + stop) * 0.5; textBox5.Text = d.ToString("0.0"); } catch (Exception ex) { label7.Text = "Error: " + ex.Message; } }
/// <summary> /// Enforces rule on file /// </summary> /// <param name="las">LAS file to check</param> public override void Enforce(LAS_File las) { string lc = las.GetConstant(Constant); if (lc.Length <= 0) { this.Status = Severity; this.Comment = "Constant " + Constant + " is not defined"; return; } Longitude lon = null; try { lon = new Longitude(ReplaceFunnyChars(lc)); } catch (Exception ex) { this.Status = Severity; this.Comment = "Constant " + Constant + " with value [" + lc + "] could not be read. " + ex.Message; return; } double val = lon.AngleD; if (Double.IsNaN(val)) { this.Status = Severity; this.Comment = "Constant " + Constant + " has incorrect value [" + lc + "]"; return; } if (val < MinValueError || MaxValueError < val) { this.Status = Severity; this.Comment = "Constant " + Constant + " [" + val.ToString("0.0000") + "] is set outside of range [" + MinValueError.ToString() + ", " + MaxValueError.ToString() + "]"; return; } if (val < MinValueWarning || MaxValueWarning < val) { this.Status = "Warning"; this.Comment = "Constant " + Constant + " [" + val.ToString("0.0000") + "] is set outside of range [" + MinValueWarning.ToString() + ", " + MaxValueWarning.ToString() + "]"; return; } this.Status = "Pass"; this.Comment = "Constant " + Constant + " [" + val.ToString("0.0000") + "] is within range [" + MinValueWarning.ToString() + ", " + MaxValueWarning.ToString() + "]"; return; }
/// <summary> /// Enforces rule on file /// </summary> /// <param name="las">LAS file to check</param> public override void Enforce(LAS_File las) { LAS_Channel lc = (LAS_Channel)las.GetChannel(Channel); if (lc == null) { this.Status = "NA"; this.Comment = "Channel " + Channel + " is not defined"; return; } if (!lc.IsLoaded) { this.Status = Severity; this.Comment = "Channel " + Channel + " contains no data"; return; } LAS_Channel index = (LAS_Channel)las.GetIndex(); if (Hole != "OPEN" && Hole != "CASED") { EnforceInRange(lc, index, Double.MinValue, Double.MaxValue); return; } string csgString = las.GetParameter("CSGL"); if (csgString.Length <= 0) { csgString = las.GetParameter("CSGD"); } double csg = Double.NaN; try { csg = Convert.ToDouble(csgString); } catch (Exception) { } if (Double.IsNaN(csg)) { EnforceInRange(lc, index, Double.MinValue, Double.MaxValue); return; } if (Hole == "OPEN") { EnforceInRange(lc, index, csg, Double.MaxValue); } else { EnforceInRange(lc, index, Double.MinValue, csg); } }
/// <summary> /// Enforces rule on file /// </summary> /// <param name="las">LAS file to check</param> public override void Enforce(LAS_File las) { string lc = las.GetConstant(Constant); if (lc.Length <= 0) { this.Status = Severity; this.Comment = "Constant " + Constant + " is not defined"; return; } double val = Double.NaN; try { val = Convert.ToDouble(lc); } catch (Exception) { }; if (Double.IsNaN(val)) { this.Status = Severity; this.Comment = "Constant " + Constant + " is not set to numeric value, but to [" + lc + "]"; return; } if (val == las.MissingValue) { this.Status = "Warning"; this.Comment = "Constant " + Constant + " is set to missing value [" + lc + "]"; return; } if (val < MinValueError || MaxValueError < val) { this.Status = Severity; this.Comment = "Constant " + Constant + " is set outside of range [" + MinValueError.ToString() + ", " + MaxValueError.ToString() + "]"; return; } if (val < MinValueWarning || MaxValueWarning < val) { this.Status = "Warning"; this.Comment = "Constant " + Constant + " is set outside of range [" + MinValueWarning.ToString() + ", " + MaxValueWarning.ToString() + "]"; return; } this.Status = "Pass"; this.Comment = "Constant " + Constant + " is within range [" + MinValueWarning.ToString() + ", " + MaxValueWarning.ToString() + "]"; return; }
/// <summary> /// Enforces rule on file /// </summary> /// <param name="las">LAS file to check</param> public override void Enforce(LAS_File las) { LAS_Channel lc = (LAS_Channel)las.GetChannel(Channel); if (lc == null) { this.Status = "NA"; this.Comment = "Channel " + Channel + " is not defined."; return; } string ret = FindValue(lc.Unit); if (ret.Length > 0) { this.Status = "Pass"; this.Comment = "Channel " + Channel + " unit is set to [" + lc.Unit + "]"; return; } ret = FindValueUpper(lc.Unit.ToUpper()); if (ret.Length > 0) { this.Status = "Warning"; this.Comment = "Channel " + Channel + " unit is set to [" + lc.Unit + "] but [" + ret + "] is required."; return; } this.Status = Severity; StringBuilder sb = new StringBuilder(); sb.Append("Channel " + Channel + " unit is set to [" + lc.Unit + "] but one of ["); for (int i = 0; i < Values.Count; i++) { sb.Append(Values[i]); if (i < Values.Count - 1) { sb.Append(", "); } } sb.Append("] is required."); Comment = sb.ToString(); return; }
/// <summary> /// Enforces rule on file /// </summary> /// <param name="las">LAS file to check</param> public override void Enforce(LAS_File las) { string lc = las.GetParameter(Constant); if (lc.Length <= 0) { this.Status = Severity; this.Comment = "Parameter " + Constant + " is not defined"; return; } string ret = FindValue(lc); if (ret.Length > 0) { this.Status = "Pass"; this.Comment = "Parameter " + Constant + " is set to [" + lc + "]"; return; } ret = FindValueUpper(lc.ToUpper()); if (ret.Length > 0) { this.Status = "Warning"; this.Comment = "Parameter " + Constant + " is set to [" + lc + "] but [" + ret + "] within is required."; return; } this.Status = Severity; StringBuilder sb = new StringBuilder(); sb.Append("Parameter " + Constant + " is set to [" + lc + "], but should contain one of ["); for (int i = 0; i < Values.Count; i++) { sb.Append(Values[i]); if (i < Values.Count - 1) { sb.Append(", "); } } sb.Append("]."); Comment = sb.ToString(); return; }
public static Oilfield_File OpenHeader(string filename) { if (!File.Exists(filename)) { return(null); } if (CSV_File.IsCSVFile(filename)) { return(new CSV_File(filename)); } if (SEGY_File.IsSEGYFile(filename)) { return(new SEGY_File(filename)); } if (LAS_File.IsLASFile(filename)) { return(new LAS_File(filename, false)); } if (Petrolog_File.IsPetrologFile(filename)) { return(new Petrolog_File(filename)); } return(null); }
/// <summary> /// Enforces the rule on LAS /// </summary> /// <param name="las">las file to check</param> public virtual void Enforce(LAS_File las) { }
/// <summary> /// Enforces rule on file /// </summary> /// <param name="las">LAS file to check</param> public override void Enforce(LAS_File las) { string lc = las.GetConstant(Constant); if (lc.Length <= 0) { this.Status = Severity; this.Comment = "Constant " + Constant + " is not defined"; return; } string lc2 = las.GetConstant(CompareWith); if (lc2.Length <= 0) { lc2 = las.GetParameter(CompareWith); } if (lc2.Length <= 0) { this.Status = Severity; this.Comment = "Constant " + CompareWith + " is not defined"; return; } double val = Double.NaN; double val2 = Double.NaN; try { val = Convert.ToDouble(lc); val2 = Convert.ToDouble(lc2); } catch (Exception) { this.Status = Severity; this.Comment = "Constants " + Constant + " and/or " + CompareWith + " are not numeric"; return; } if (val == -999.25 || val2 == -999.25) { this.Status = Severity; this.Comment = "Constants " + Constant + " and/or " + CompareWith + " are set to missing"; return; } if (Comparison == "LESS" && val >= val2) { this.Status = Severity; this.Comment = "Constant " + Constant + " is more or equal to " + CompareWith + " [" + val + ">=" + val2 + "]"; return; } if (Comparison == "LESS_OR_EQUAL" && val > val2) { this.Status = Severity; this.Comment = "Constant " + Constant + " is more than " + CompareWith + " [" + val + ">" + val2 + "]"; return; } if (Comparison == "EQUAL" && val != val2) { this.Status = Severity; this.Comment = "Constant " + Constant + " is not equal to " + CompareWith + " [" + val + "!=" + val2 + "]"; return; } if (Comparison == "MORE_OR_EQUAL" && val < val2) { this.Status = Severity; this.Comment = "Constant " + Constant + " is less than " + CompareWith + " [" + val + "<" + val2 + "]"; return; } if (Comparison == "MORE" && val <= val2) { this.Status = Severity; this.Comment = "Constant " + Constant + " is less or equal to " + CompareWith + " [" + val + "<=" + val2 + "]"; return; } if (Comparison == "NOT_EQUAL" && val == val2) { this.Status = Severity; this.Comment = "Constant " + Constant + " is equal to " + CompareWith + " [" + val + "==" + val2 + "]"; return; } this.Status = "Pass"; this.Comment = "Constant " + Constant + " is " + Comparison + " than/to " + CompareWith; return; }
/// <summary> /// Enforces rule on file /// </summary> /// <param name="las">LAS file to check</param> public override void Enforce(LAS_File las) { string lc2 = las.GetConstant(Constant); if (lc2.Length <= 0) { lc2 = las.GetParameter(Constant); } if (lc2.Length <= 0) { this.Status = Severity; this.Comment = "Constant " + Constant + " is not defined"; return; } double val2 = Double.NaN; try { val2 = Convert.ToDouble(lc2); } catch (Exception) { this.Status = Severity; this.Comment = "Constant " + Constant + " is not numeric"; return; } if (val2 == -999.25) { this.Status = Severity; this.Comment = "Constant " + Constant + " is set to missing value"; return; } Shift = val2; LAS_Channel lc = (LAS_Channel)las.GetChannel(Channel); if (lc == null) { this.Status = "NA"; this.Comment = "Channel " + Channel + " is not defined"; return; } if (!lc.IsLoaded) { this.Status = Severity; this.Comment = "Channel " + Channel + " contains no data"; return; } LAS_Channel index = (LAS_Channel)las.GetIndex(); if (Hole != "OPEN" && Hole != "CASED") { EnforceInRange(lc, index, Double.MinValue, Double.MaxValue); return; } string csgString = las.GetParameter("CSGL"); if (csgString.Length <= 0) { csgString = las.GetParameter("CSGD"); } double csg = Double.NaN; try { csg = Convert.ToDouble(csgString); } catch (Exception) { } if (Double.IsNaN(csg)) { EnforceInRange(lc, index, Double.MinValue, Double.MaxValue); return; } if (Hole == "OPEN") { EnforceInRange(lc, index, csg + SkipBelowCasing, Double.MaxValue); } else { EnforceInRange(lc, index, Double.MinValue, csg); } }