Ejemplo n.º 1
0
            //
            // Loop across all points in FaultInterpretation polylines:
            // 1. set context to Cube
            // 2. set attribute value from Cube (the same as for Horizon in main exercise)
            //
            private void calcFI(FaultInterpretation fi, SeismicCube cube, ITransaction tr)
            {
                // Check for Domain
                if (cube.Domain != fi.Domain)
                {
                    return;
                }
                // Lock FaultInterpretation for update
                tr.Lock(fi);
                FaultProperty fp = findOrCreateFProperty(fi, cube.Template, "Ocean Fault Property", tr);

                // Set Cube as a context for FaultInterpretation
                List <FaultInterpretationPolyline>        chgdPolylines = new List <FaultInterpretationPolyline>();
                IEnumerable <FaultInterpretationPolyline> fiPolylines   = fi.GetPolylines();

                // Process each poly line and set the context for each point.
                foreach (FaultInterpretationPolyline poly in fiPolylines)
                {
                    foreach (FaultInterpretationContextPoint pt in poly)
                    {
                        // Must cast as Context is IDomainObject and can be SeismicLine2D or SeismicCube.
                        pt.Context = (IDomainObject)cube;
                    }
                    chgdPolylines.Add(poly);
                }
                fi.SetPolylines(chgdPolylines);


                // set attribute's values via PointPropertyRecord, the same way as for Horizon

                Index3 cubeIndex = cube.NumSamplesIJK;

                foreach (PointPropertyRecord ppr in fp)
                {
                    ppr.Value = double.NaN;
                    Point3       p          = ppr.Geometry;
                    IndexDouble3 ptIndexDbl = cube.IndexAtPosition(p);
                    Index3       seisIndex  = ptIndexDbl.ToIndex3();
                    if (seisIndex.I >= 0 && seisIndex.J >= 0 &&
                        seisIndex.I < cubeIndex.I && seisIndex.J < cubeIndex.J)
                    {
                        ITrace trace = cube.GetTrace(seisIndex.I, seisIndex.J);
                        if (seisIndex.K >= 0 && seisIndex.K < cubeIndex.K)
                        {
                            ppr.Value = trace[seisIndex.K];
                        }
                    }
                }
                return;
            }
            public override void ExecuteSimple()
            {
                SeismicCube           cube      = arguments.Cube;
                HorizonInterpretation hzInterp1 = arguments.HzInterpretation1;
                HorizonInterpretation hzInterp2 = arguments.HzInterpretation2;
                int       interval = 3;
                Hashtable ht2      = new Hashtable();

                foreach (Point3 item in hzInterp2.GetPoints(cube.SeismicCollection))
                {
                    IndexDouble3 ptIndexDbl = cube.IndexAtPosition(item);
                    Index3       seisIndex  = ptIndexDbl.ToIndex3();
                    ht2.Add(seisIndex.I.ToString() + "-" + seisIndex.J.ToString(), ptIndexDbl.K);
                    //PetrelLogger.InfoOutputWindow(ptIndexDbl.I.ToString() + "-" + ptIndexDbl.J.ToString() + "-" + ptIndexDbl.K.ToString());
                    //PetrelLogger.InfoOutputWindow(seisIndex.I.ToString()+"-"+ seisIndex.J.ToString()+"-"+ seisIndex.K.ToString());
                }
                // Make sure we have input arguments
                if (cube == null || hzInterp1 == null || hzInterp2 == null)
                {
                    PetrelLogger.InfoOutputWindow("HelloSeismic: Arguments cannot be empty");
                    return;
                }

                // Make sure we have input arguments
                if (cube.Domain != hzInterp1.Domain)
                {
                    PetrelLogger.InfoOutputWindow("HelloSeismic: Cube and Horizon must be in the same domain");
                    return;
                }

                // Start a transaction
                using (ITransaction t = DataManager.NewTransaction())
                {
                    // Create an output horizon property if the user didn't supply one.
                    HorizonInterpretation3D hzInt3D = hzInterp1.GetHorizonInterpretation3D(cube.SeismicCollection);
                    t.Lock(hzInt3D);
                    // Create the property
                    // Template of the cube is the correct template
                    HorizonProperty3D horizonProp3D1 = hzInt3D.CreateProperty(cube.Template);
                    HorizonProperty3D horizonProp3D2 = hzInt3D.CreateProperty(cube.Template);


                    // cache cube indexes
                    Index3 cubeIndex = cube.NumSamplesIJK;
                    List <HorizonProperty3DSample> p1_1 = new List <HorizonProperty3DSample>();
                    List <HorizonProperty3DSample> p1_2 = new List <HorizonProperty3DSample>();
                    // Process the horizon property points.
                    foreach (PointPropertyRecord ppr in horizonProp3D1)
                    {
                        // do not need to initialize the output value, Petrel does this when the property is created initially
                        // ppr.Value = double.NaN;
                        // Get the location for the point
                        Point3 p = ppr.Geometry;
                        // Find the seismic sample at the point
                        IndexDouble3 ptIndexDbl = cube.IndexAtPosition(p);
                        Index3       seisIndex  = ptIndexDbl.ToIndex3();
                        object       obj        = ht2[seisIndex.I.ToString() + "-" + seisIndex.J.ToString()];
                        if (obj == null)
                        {
                            continue;
                        }
                        double z2   = double.Parse(obj.ToString());
                        double z1_1 = double.NaN;
                        double z1_2 = double.NaN;
                        if (z2 != null)
                        {
                            z1_1 = ptIndexDbl.K - (ptIndexDbl.K - z2) / 3;
                            z1_2 = ptIndexDbl.K - 2 * (ptIndexDbl.K - z2) / 3;
                        }
                        // Get the trace containing the seismic sample
                        // SeismicCube.GetTrace(i, j) will throw an exception if the indices (i,j) is out of range.
                        if (seisIndex.I >= 0 && seisIndex.J >= 0 &&
                            seisIndex.I < cubeIndex.I && seisIndex.J < cubeIndex.J)
                        {
                            ITrace trace = cube.GetTrace(seisIndex.I, seisIndex.J);
                            p1_1.Add(new HorizonProperty3DSample(seisIndex.I, seisIndex.J, trace[Convert.ToInt32(z1_1)]));
                            p1_2.Add(new HorizonProperty3DSample(seisIndex.I, seisIndex.J, trace[Convert.ToInt32(z1_2)]));
                        }
                    }
                    horizonProp3D1.Samples = p1_1;
                    horizonProp3D2.Samples = p1_2;
                    // Commit the changes to the data.
                    t.Commit();
                }

                return;
            }
Ejemplo n.º 3
0
            public override void ExecuteSimple()
            {
                #region main exercise
                SeismicCube           cube          = arguments.Cube;
                HorizonInterpretation hzInterp      = arguments.HzInterpretation;
                HorizonProperty3D     horizonProp3D = arguments.HorizonProp3D;

                // Make sure we have input arguments
                if (cube == null || hzInterp == null)
                {
                    PetrelLogger.InfoOutputWindow("HelloSeismic: Arguments cannot be empty");
                    return;
                }

                // Make sure we have input arguments
                if (cube.Domain != hzInterp.Domain)
                {
                    PetrelLogger.InfoOutputWindow("HelloSeismic: Cube and Horizon must be in the same domain");
                    return;
                }

                // Start a transaction
                using (ITransaction t = DataManager.NewTransaction())
                {
                    // Create an output horizon property if the user didn't supply one.
                    if (horizonProp3D == null)
                    {
                        // get 3D part of the interpretation corresponding to cube's seismic collection
                        HorizonInterpretation3D hzInt3D = hzInterp.GetHorizonInterpretation3D(cube.SeismicCollection);
                        if (hzInt3D == null)
                        {
                            PetrelLogger.InfoOutputWindow("HelloSeismic: Unable to get Horizon Interpretation 3D from HzInt");
                            return;
                        }
                        t.Lock(hzInt3D);
                        // Create the property
                        // Template of the cube is the correct template
                        horizonProp3D = hzInt3D.CreateProperty(cube.Template);
                    }
                    else
                    {
                        // Lock the property so we can update it
                        t.Lock(horizonProp3D);
                    }

                    // cache cube indexes
                    Index3 cubeIndex = cube.NumSamplesIJK;

                    // Process the horizon property points.
                    foreach (PointPropertyRecord ppr in horizonProp3D)
                    {
                        // do not need to initialize the output value, Petrel does this when the property is created initially
                        // ppr.Value = double.NaN;

                        // Get the location for the point
                        Point3 p = ppr.Geometry;

                        // Find the seismic sample at the point
                        IndexDouble3 ptIndexDbl = cube.IndexAtPosition(p);
                        Index3       seisIndex  = ptIndexDbl.ToIndex3();

                        // Get the trace containing the seismic sample
                        // SeismicCube.GetTrace(i, j) will throw an exception if the indices (i,j) is out of range.
                        if (seisIndex.I >= 0 && seisIndex.J >= 0 &&
                            seisIndex.I < cubeIndex.I && seisIndex.J < cubeIndex.J)
                        {
                            ITrace trace = cube.GetTrace(seisIndex.I, seisIndex.J);

                            // trace[k] will throw an exception if the index k is out of range.
                            // Set the property value to the corresponding trace sample value.
                            if (seisIndex.K >= 0 && seisIndex.K < cubeIndex.K)
                            {
                                ppr.Value = trace[seisIndex.K];
                            }
                        }
                    }

                    // Commit the changes to the data.
                    t.Commit();

                    // Set up the output argument value
                    arguments.HorizonProp3D = horizonProp3D;
                }
                #endregion

                #region Challenging part, body
                //
                // Compute an attribute for all fault's interpretations under the SeismicProject
                //

                // Navigate to SeismicProject and loop through all collections
                SeismicRoot    sr = SeismicRoot.Get(PetrelProject.PrimaryProject);
                SeismicProject sp = sr.SeismicProject;
                // First part of lab checked for a cube, so project exists at this point,
                // else something like: if (sp == SeismicProject.NullObject) return;

                // some object can be transaction locked inside, need to commit before exit
                using (ITransaction tr = DataManager.NewTransaction())
                {
                    foreach (InterpretationCollection ic in sp.InterpretationCollections)
                    {
                        loopIC(ic, cube, tr);
                    }
                    tr.Commit();
                }
                #endregion

                return;
            }