public override void ExecuteSimple()
            {
                // TODO: Implement the workstep logic here.
                SeismicCube       cube = arguments.Cube;
                SeismicCollection sc   = cube.SeismicCollection;
                SeismicProject    proj = null;
                SeismicRoot       sroot;

                sroot = SeismicRoot.Get(PetrelProject.PrimaryProject);
                if (!sroot.HasSeismicProject)
                {
                    return;
                }
                proj = sroot.SeismicProject;
                using (ITransaction t = DataManager.NewTransaction()) {
                    t.Lock(proj);
                    InterpretationCollection             aaa            = proj.CreateInterpretationCollection("aaa");
                    HorizonInterpretation                h              = aaa.CreateHorizonInterpretation("surface", cube.Domain);
                    HorizonInterpretation3D              h3d            = h.CreateHorizonInterpretation3D(sc);
                    List <HorizonInterpretation3DSample> horizonsamples = new List <HorizonInterpretation3DSample>();
                    for (int i = 0; i < cube.NumSamplesIJK.I; i++)
                    {
                        for (int j = 0; j < cube.NumSamplesIJK.J; j++)
                        {
                            horizonsamples.Add(new HorizonInterpretation3DSample(i, j, -2000));
                        }
                    }
                    h3d.Samples = horizonsamples;
                    t.Commit();
                }
            }
示例#2
0
 //
 // Loop across all FaultInterpretation within a InterpretationCollection,
 // then check for sub-collections
 private void loopIC(InterpretationCollection ic, SeismicCube cube, ITransaction tr)
 {
     foreach (FaultInterpretation fi in ic.FaultInterpretations)
     {
         calcFI(fi, cube, tr);
     }
     foreach (InterpretationCollection ics in ic.InterpretationCollections)
     {
         loopIC(ics, cube, tr);
     }
     return;
 }
示例#3
0
        public void StartServer()
        {
            if (ChatClient.ClientForm.serverBusy == true)
            {
                return;
            }
            try
            {
                ChatClient.ClientForm.serverBusy = true;
                listener.Start();
                TcpClient     client    = listener.AcceptTcpClient();
                NetworkStream stream    = client.GetStream();
                IFormatter    formatter = new BinaryFormatter();
                switch (objType)
                {
                case OBJTYPE.SIESMIC_CUBE:
                    SerializableSeismicCube scube = (SerializableSeismicCube)formatter.Deserialize(stream);
                    using (ITransaction t = DataManager.NewTransaction())
                    {
                        t.Lock(parent);
                        SeismicCollection c = (SeismicCollection)parent;
                        if (scube == null)
                        {
                            MessageBox.Show("Error in transmission!");
                        }
                        else
                        {
                            SeismicCube cube = scube.cube;

                            if (c.CanCreateSeismicCube(cube))
                            {
                                c.CreateSeismicCube(cube, cube.PropertyVersion);
                            }
                            else
                            {
                                MessageBox.Show("Unable to create the Seismic Cube");
                            }
                        }
                    }
                    break;
                }
                client.Close();
                listener.Stop();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Object Recieving Failed!" + ex.Message, "File Transfer",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            ChatClient.ClientForm.serverBusy = false;
        }
        private void visual_dropTarget_DragDrop(object sender, DragEventArgs e)
        {
            SeismicCube droppedCube = e.Data.GetData(typeof(SeismicCube)) as SeismicCube;

            if (droppedCube != null)
            {
                visual_textBox.Text = droppedCube.Name;
                visual_cube         = droppedCube;
            }
            else
            {
                MessageBox.Show("INVALID CUBE");
            }
        }
示例#5
0
        private void callback(object sender, ContextMenuClickedEventArgs <SeismicCube> clickedCube)
        {
            try
            {
                SeismicCube getcube = ((SeismicCube)clickedCube.ContextObject);
                Index3      start   = new Index3(0, 0, 0);
                Index3      end     = new Index3(getcube.NumSamplesIJK.I - 1, getcube.NumSamplesIJK.J - 1, getcube.NumSamplesIJK.K - 1);
                ISubCube    from    = getcube.GetSubCube(start, end);
                float[, ,] vals = from.ToArray();

                new Plot3D.Plot3DMainForm(vals).Show();
            }
            catch { }
        }
 private void dropRHO_DragDrop(object sender, DragEventArgs e)
 {
     RHO = (SeismicCube)e.Data.GetData(typeof(SeismicCube));
     if (RHO != null)
     {
         textRHO.Text = RHO.Name;
     }
     else
     {
         textRHO.Text = "";
         MessageBox.Show("Invalid Cube");
         return;
     }
 }
示例#7
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;
            }
示例#8
0
        public void convertToSeismic(string fileName)
        {
            // Check if parent collection contains any 2D data
            SeismicCollection coll = (SeismicCollection)FTReciever.parent;

            while (coll.MemberType == typeof(SeismicLine2DCollection))
            {
                MessageBox.Show("The Seismic Collection you selected was of SeismicLine2DCollection");
                List <SeismicCollection> cols  = Discuss.getAllSeismicCollections();
                List <string>            names = new List <string>();
                foreach (SeismicCollection col in cols)
                {
                    names.Add(col.Name);
                }
                objSelect selector = new objSelect("Select a Seismic collection to add the cube to", names);
                if (selector.ShowDialog() == DialogResult.Cancel)
                {
                    return;
                }
                coll = cols[objSelect.SelectedIndex];
            }
            // Get Service

            ISegyFormat segyFormat = CoreSystem.GetService <ISegyFormat>();
            // Find property version
            IPropertyVersionService pvService = PetrelSystem.PropertyVersionService;
            ITemplate       seisTemplate      = PetrelUnitSystem.TemplateGroupSeismicColor.SeismicDefault;
            PropertyVersion pv   = pvService.FindOrCreate(PetrelSystem.GetGlobalPropertyVersionContainer(), seisTemplate);
            SeismicCube     cube = SeismicCube.NullObject;

            // Lock the parent
            using (ITransaction txn = DataManager.NewTransaction())
            {
                try
                {
                    txn.Lock(coll);
                    cube = segyFormat.ImportSeismic3D(fileName, (SeismicCollection)FTReciever.parent, "", Domain.ELEVATION_DEPTH, pv);
                }
                catch (InvalidOperationException e)
                {
                    MessageBox.Show(e.Message);
                }
                finally
                {
                    txn.Commit();
                }
            }
        }
            public OceanSeismicMultithreaded(int n, int m)
            {
                // Create new output cube
                SeismicCube       outputCube = SeismicCube.NullObject;
                SeismicCollection coll       = SeismicCollection.NullObject;
                SeismicRoot       seisRoot;

                seisRoot = SeismicRoot.Get(PetrelProject.PrimaryProject);
                if (!seisRoot.HasSeismicProject)
                {
                    using (ITransaction tr = DataManager.NewTransaction())
                    {
                        tr.Lock(seisRoot);
                        seisRoot.CreateSeismicProject();
                        tr.Commit();
                    }
                }
                SeismicProject proj = seisRoot.SeismicProject;

                using (ITransaction tr = DataManager.NewTransaction())
                {
                    tr.Lock(proj);
                    coll = proj.CreateSeismicCollection("Test Survey Async " + n.ToString() + "x" + m.ToString());
                    tr.Lock(coll);
                    Index3  size             = new Index3(n, n, m);
                    Point3  origin           = new Point3(13579.75, 24680.08, 0.0);
                    Vector3 iSpacing         = new Vector3(100.0, 0.0, 0.000);
                    Vector3 jSpacing         = new Vector3(0.0, 100.0, 0.000);
                    Vector3 kSpacing         = new Vector3(0.0, 0.0, -100.0);
                    Index2  annotationOrigin = new Index2(0, 0);
                    Index2  annotationInc    = new Index2(1, 1);
                    if (coll.CanCreateSeismicCube(size, origin, iSpacing, jSpacing, kSpacing))
                    {
                        Type     dataType = typeof(float);
                        Domain   vDomain  = Domain.ELEVATION_DEPTH;
                        Template tmpl     = PetrelProject.WellKnownTemplates
                                            .SeismicColorGroup.SeismicDefault;
                        Range1 <double> r = new Range1 <double>(0.0, 140.0);
                        _cube = coll.CreateSeismicCube(size, origin, iSpacing, jSpacing, kSpacing, annotationOrigin, annotationInc, dataType, vDomain, tmpl, r);
                    }
                    if (_cube.IsWritable)
                    {
                        MakeCube(_cube);
                    }
                    tr.Commit();
                }
            }
        public override void Execute(Slb.Ocean.Petrel.Contexts.Context context)
        {
            //TODO: Add command execution logic here
            foreach (object obj in context.GetSelectedObjects())
            {
                SeismicCube scube  = obj as SeismicCube;
                Template    t_cube = scube.Template;
                PetrelLogger.InfoOutputWindow(scube.SampleSpacingIJK.Z.ToString());
                ITemplateService service = PetrelSystem.TemplateService;
                Template         t1      = service.FindTemplateByName("Elevation time");
                double           val_UI  = PetrelUnitSystem.ConvertToUI(t1, scube.SampleSpacingIJK.Z);

                //HorizonInterpretation3D h3d0 = Htop.GetHorizonInterpretation3D(args.srcSeisCube.SeismicCollection);
                //foreach (HorizonInterpretation3DSample horSample in h3d0.Samples) {
                //    scube.IndexAtPosition(new Point3(scube.Origin.X,scube.Origin.Y, horSample.Value));
                //}
            }
        }
 private void dropRHO_DragDrop(object sender, DragEventArgs e)
 {
     RHO = (SeismicCube)e.Data.GetData(typeof(SeismicCube));
     if (RHO != null)
     {
         textRHO.Text = RHO.Name;
     }
     else
     {
         textRHO.Text = "";
         MessageBox.Show("Invalid Cube");
         return;
     }
 }
            public void MakeCube(SeismicCube outputCube)
            {
                _threadCounter    = 0;
                _completedThreads = 0;
                int nwork;
                int compThreads;
                int ncreated = 0;

                ThreadPool.GetMaxThreads(out nwork, out compThreads);
                using (IProgress progress = PetrelLogger.NewProgress(0, 100, ProgressType.Cancelable, Cursors.WaitCursor))
                {
                    // Size of our cubes
                    int    ni       = outputCube.NumSamplesIJK.I;
                    int    nj       = outputCube.NumSamplesIJK.J;
                    int    nk       = outputCube.NumSamplesIJK.K;
                    Index3 cubeSize = outputCube.NumSamplesIJK;
                    var    ranges   = new Queue <Index3[]>();
                    //Calculate subcube ranges
                    var subsize = new[] { 64, 64, outputCube.NumSamplesIJK.K };
                    for (int i = 0; i < cubeSize.I; i += subsize[0])
                    {
                        for (int j = 0; j < cubeSize.J; j += subsize[1])
                        {
                            for (int k = 0; k < cubeSize.K; k += subsize[2])
                            {
                                var range = new[]
                                {
                                    new Index3(i, j, k),
                                    new Index3(Math.Min(i + subsize[0] - 1, cubeSize.I - 1),
                                               Math.Min(j + subsize[1] - 1, cubeSize.J - 1),
                                               Math.Min(k + subsize[2] - 1, cubeSize.K - 1))
                                };
                                ranges.Enqueue(range);
                            }
                        }
                    }
                    int  numWorkers = (256 * 1024 * 1024 / 4) / (subsize[0] * subsize[1] * subsize[2]);
                    bool val        = ThreadPool.SetMaxThreads(numWorkers, numWorkers);
                    PetrelLogger.InfoOutputWindow("SetMaxThreads= " + val);
                    _availableWorkers = numWorkers;
                    int numRanges = ranges.Count;
                    ThreadPool.GetMaxThreads(out nwork, out compThreads);
                    PetrelLogger.InfoOutputWindow("nwork= " + nwork + " comp = " + compThreads);
                    int scheduledTasks = 0;
                    int percent;
                    _cancelThread = false;
                    while (ranges.Count > 0)
                    {
                        using (ITransaction trans = DataManager.NewTransaction())
                        {
                            if (progress.IsCanceled)
                            {
                                lock (_cancelThreadLock)
                                {
                                    _cancelThread = true;
                                }
                                outputCube.Delete();
                                break;
                            }
                            Application.DoEvents();
                            while (ranges.Count > 0 && Interlocked.Read(ref _availableWorkers) > 0)
                            {
                                Index3[] range    = ranges.Dequeue();
                                Index3   minIJK   = range[0];
                                Index3   maxIJK   = range[1];
                                var      jobSetup = new JobSetup();
                                jobSetup.min  = range[0];
                                jobSetup.max  = range[1];
                                jobSetup.decn = 0;
                                jobSetup.decm = 0;
                                jobSetup.n    = 0;
                                trans.Lock(outputCube);
                                jobSetup.output = outputCube.GetAsyncSubCubeReadWrite(minIJK, maxIJK);
                                //Using thread pool to run the jobs.
                                Interlocked.Increment(ref _threadCounter);
                                Interlocked.Decrement(ref _availableWorkers);
                                ThreadPool.QueueUserWorkItem(ProcessOneRange, jobSetup);
                                ncreated++;
                                PetrelLogger.InfoOutputWindow("n=" + ncreated);
                                scheduledTasks++;
                            }
                            // **********************************
                            // Wait for the entire batch of threads to finish
                            // before spinning up new threads.
                            // **********************************
                            while (Interlocked.Read(ref _completedThreads) < Interlocked.Read(ref _threadCounter))
                            {
                                percent = (int)((scheduledTasks - (Interlocked.Read(ref _threadCounter) - Interlocked.Read(ref _completedThreads))) * 100f / numRanges);
                                progress.ProgressStatus = percent;
                                if (progress.IsCanceled)
                                {
                                    lock (_cancelThreadLock)
                                    {
                                        _cancelThread = true;
                                    }
                                    outputCube.Delete();
                                    break;
                                }
                                Application.DoEvents();
                                Thread.Sleep(1000);
                                System.GC.Collect();
                            }
                            if (_cancelThread)
                            {
                                break;
                            }
                            trans.Commit();
                        }
                    }
                }
            }
示例#13
0
        public void workingFunction()
        {
            maincomboIndex = 0;
            SeismicRoot    seismicRoot = SeismicRoot.Get(PetrelProject.PrimaryProject);
            SeismicProject proj        = seismicRoot.SeismicProject;


            float[, ,] phi2 = new float[cubeDensity.NumSamplesIJK.I, cubeDensity.NumSamplesIJK.J, cubeDensity.NumSamplesIJK.K];
            float[, ,] S2   = new float[cubeDensity.NumSamplesIJK.I, cubeDensity.NumSamplesIJK.J, cubeDensity.NumSamplesIJK.K];
            float[, ,] C2   = new float[cubeDensity.NumSamplesIJK.I, cubeDensity.NumSamplesIJK.J, cubeDensity.NumSamplesIJK.K];
            float minphi2 = 1.0f;
            float maxphi2 = 0.0f;
            float minC2   = 1.0f;
            float maxC2   = 0.0f;
            float minS2   = 1.0f;
            float maxS2   = 0.0f;

            using (ITransaction txn = DataManager.NewTransaction())
            {
                try
                {
                    using (IProgress i1 = PetrelLogger.NewProgress(1, cubeDensity.NumSamplesIJK.J))
                    {
                        for (int p = 0; p < cubeDensity.NumSamplesIJK.I; p++)
                        {
                            for (int q = 0; q < cubeDensity.NumSamplesIJK.J; q++)
                            {
                                ITrace trace1 = cubeDensity.GetTrace(p, q);
                                ITrace trace2 = cubeSonic.GetTrace(p, q);
                                //ITrace tracePor = PHI_CUBE.GetTrace(p, q);
                                //ITrace traceSw = SW_CUBE.GetTrace(p, q);
                                //ITrace traceVSh = VSHALE_CUBE.GetTrace(p, q);
                                for (int k = 0; k < trace1.Length; k++)
                                {
                                    double sample1 = trace1[k];
                                    double sample2 = trace2[k];
                                    float  rho     = (float)sample1;
                                    float  Vinv    = (float)(1.0 / sample2);
                                    float  ac_imp  = rho * Vinv;
                                    float  error1  = 100e30f;

                                    for (float phi = (float)minPor; phi <= (float)(maxPor + 0.1); phi += 0.1f)
                                    {
                                        for (float S = (float)minWater; S <= (float)(maxWater + 0.1); S += 0.1f)
                                        {
                                            for (float C = (float)minClay; C <= (float)(maxClay + 0.1); C += 0.1f)
                                            {
                                                double error = dfunc(ac_imp, rho, Vinv, C, S, phi);
                                                if (error1 > (float)error)
                                                {
                                                    C2[p, q, k]   = C;
                                                    S2[p, q, k]   = S;
                                                    phi2[p, q, k] = phi;
                                                    error1        = (float)error;
                                                }
                                            }
                                        }
                                    }
                                    updateVals(ac_imp, rho, Vinv, ref C2[p, q, k], ref S2[p, q, k], ref phi2[p, q, k]);
                                    if (phi2[p, q, k] < minphi2)
                                    {
                                        minphi2 = phi2[p, q, k];
                                    }
                                    if (phi2[p, q, k] > maxphi2)
                                    {
                                        maxphi2 = phi2[p, q, k];
                                    }
                                    if (C2[p, q, k] < minC2)
                                    {
                                        minC2 = C2[p, q, k];
                                    }
                                    if (C2[p, q, k] > maxC2)
                                    {
                                        maxC2 = C2[p, q, k];
                                    }
                                    if (S2[p, q, k] < minS2)
                                    {
                                        minS2 = S2[p, q, k];
                                    }
                                    if (S2[p, q, k] > maxS2)
                                    {
                                        maxS2 = S2[p, q, k];
                                    }
                                }
                            }
                            i1.ProgressStatus = p + 1;
                        }
                    }
                    txn.Lock(proj);
                    txn.Lock(scol);
                    Index3       size      = new Index3(cubeDensity.NumSamplesIJK.I, cubeDensity.NumSamplesIJK.J, cubeDensity.NumSamplesIJK.K);
                    IndexDouble3 tempindex = new IndexDouble3(0, 0, 0);
                    Point3       origin    = cubeDensity.PositionAtIndex(tempindex);

                    double d1, d2, d3;

                    d1 = cubeDensity.PositionAtIndex(new IndexDouble3(1, 0, 0)).X - origin.X;
                    d2 = cubeDensity.PositionAtIndex(new IndexDouble3(1, 0, 0)).Y - origin.Y;
                    d3 = cubeDensity.PositionAtIndex(new IndexDouble3(1, 0, 0)).Z - origin.Z;
                    Vector3 iVec = new Vector3(d1, d2, d3);

                    d1 = cubeDensity.PositionAtIndex(new IndexDouble3(0, 1, 0)).X - origin.X;
                    d2 = cubeDensity.PositionAtIndex(new IndexDouble3(0, 1, 0)).Y - origin.Y;
                    d3 = cubeDensity.PositionAtIndex(new IndexDouble3(0, 1, 0)).Z - origin.Z;
                    Vector3 jVec = new Vector3(d1, d2, d3);

                    d1 = cubeDensity.PositionAtIndex(new IndexDouble3(0, 0, 1)).X - origin.X;
                    d2 = cubeDensity.PositionAtIndex(new IndexDouble3(0, 0, 1)).Y - origin.Y;
                    d3 = cubeDensity.PositionAtIndex(new IndexDouble3(0, 0, 1)).Z - origin.Z;
                    Vector3 kVec = new Vector3(d1, d2, d3);


                    /*double inlineI = (cubeDensity.Lattice.Single.SpacingI) * Math.Sin(cubeDensity.Lattice.Single.RotationJ);
                     * double inlineJ = (cubeDensity.Lattice.Single.SpacingI) * Math.Cos(cubeDensity.Lattice.Single.RotationJ);
                     * double crosslineI = (cubeDensity.Lattice.Single.SpacingJ) * Math.Sin(cubeDensity.Lattice.Single.RotationJ);
                     * double crosslineJ = (cubeDensity.Lattice.Single.SpacingJ) * -Math.Cos(cubeDensity.Lattice.Single.RotationJ);
                     * Vector3 iSpacing = new Vector3(inlineJ, inlineI, 0.0);
                     * Vector3 jSpacing = new Vector3(crosslineI, crosslineJ, 0.0);
                     * Vector3 kSpacing = new Vector3(0.0, 0.0, 3.048);
                     */
                    if (scol.CanCreateSeismicCube(size, origin, iVec, jVec, kVec))
                    {
                        Type   dataType              = typeof(float);
                        Domain vDomain               = cubeDensity.Domain;
                        IPropertyVersionService pvs  = PetrelSystem.PropertyVersionService;
                        ILogTemplate            glob = pvs.FindTemplateByMnemonics("Seismic");
                        PropertyVersion         pv   = pvs.FindOrCreate(glob);
                        //PropertyVersion pv = cubeDensity.PropertyVersion;
                        Range1 <double> r1 = new Range1 <double>(minphi2, maxphi2);
                        Range1 <double> r2 = new Range1 <double>(minS2, maxS2);
                        Range1 <double> r3 = new Range1 <double>(minC2, maxC2);
                        PetrelLogger.InfoOutputWindow("OUTPUT TEMPLATE UNDER PROCESS");
                        try
                        {
                            PHI_CUBE    = scol.CreateSeismicCube(size, origin, iVec, jVec, kVec, dataType, vDomain, pv, r1);
                            SW_CUBE     = scol.CreateSeismicCube(size, origin, iVec, jVec, kVec, dataType, vDomain, pv, r2);
                            VSHALE_CUBE = scol.CreateSeismicCube(size, origin, iVec, jVec, kVec, dataType, vDomain, pv, r3);
                        }
                        catch (System.InvalidOperationException e)
                        {
                            PetrelLogger.ErrorBox(e.Message);
                        }
                        catch (System.ArgumentNullException e)
                        {
                            PetrelLogger.InfoOutputWindow(e.Message);
                        }
                    }

                    PHI_CUBE.Name    = porCube;
                    SW_CUBE.Name     = waterCube;
                    VSHALE_CUBE.Name = clayCube;

                    if (PHI_CUBE.IsWritable)
                    {
                        using (ITransaction txn1 = DataManager.NewTransaction())
                        {
                            PetrelLogger.InfoOutputWindow("Writing Data in the Porosity cube");
                            Index3   start = new Index3(0, 0, 0);
                            Index3   end   = new Index3(cubeDensity.NumSamplesIJK.I - 1, cubeDensity.NumSamplesIJK.J - 1, cubeDensity.NumSamplesIJK.K - 1);
                            ISubCube to    = cubeDensity.GetSubCube(start, end);
                            to.CopyFrom(phi2);
                            txn1.Commit();
                        }
                    }
                    if (SW_CUBE.IsWritable)
                    {
                        using (ITransaction txn1 = DataManager.NewTransaction())
                        {
                            PetrelLogger.InfoOutputWindow("Writing Data in the Water Saturation cube");
                            Index3   start = new Index3(0, 0, 0);
                            Index3   end   = new Index3(cubeDensity.NumSamplesIJK.I - 1, cubeDensity.NumSamplesIJK.J - 1, cubeDensity.NumSamplesIJK.K - 1);
                            ISubCube to    = cubeDensity.GetSubCube(start, end);
                            to.CopyFrom(S2);
                            txn1.Commit();
                        }
                    }
                    if (VSHALE_CUBE.IsWritable)
                    {
                        using (ITransaction txn1 = DataManager.NewTransaction())
                        {
                            PetrelLogger.InfoOutputWindow("Writing Data in the Shale Volume cube");
                            Index3   start = new Index3(0, 0, 0);
                            Index3   end   = new Index3(cubeDensity.NumSamplesIJK.I - 1, cubeDensity.NumSamplesIJK.J - 1, cubeDensity.NumSamplesIJK.K - 1);
                            ISubCube to    = cubeDensity.GetSubCube(start, end);
                            to.CopyFrom(C2);
                            txn1.Commit();
                        }
                    }
                    txn.Commit();
                    PetrelLogger.InfoOutputWindow("OUTPUT CUBES' Construction completed");
                }

                catch (ArgumentNullException e)
                {
                    PetrelLogger.ErrorBox("Seismic cube name or propertyVersion can not be blank (null)" + e.Message);
                }
            }
        }
示例#14
0
 public Reservoir(SeismicCube cubeDensity, SeismicCube cubeSonic)
 {
     this.cubeDensity = cubeDensity;
     this.cubeSonic   = cubeSonic;
     this.scol        = cubeDensity.SeismicCollection;
 }
示例#15
0
 public SerializableSeismicCube(SeismicCube cube)
 {
     this.cube = cube;
 }
            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;
            }
示例#17
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;
            }
 private void visual_dropTarget_DragDrop(object sender, DragEventArgs e)
 {
     SeismicCube droppedCube = e.Data.GetData(typeof(SeismicCube)) as SeismicCube;
     if (droppedCube != null)
     {
         visual_textBox.Text = droppedCube.Name;
         visual_cube = droppedCube;
     }
     else
     {
         MessageBox.Show("INVALID CUBE");
     }
 }