Пример #1
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);
                }
            }
        }
Пример #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            PetrelLogger.InfoOutputWindow("Generating array for edited cube");
            float[, ,] newVal = new float[scube.NumSamplesIJK.I, scube.NumSamplesIJK.J, scube.NumSamplesIJK.K];
            double min_newVal = 10e+16;
            double max_newVal = 10e-16;

            using (IProgress i1 = PetrelLogger.NewProgress(1, scube.NumSamplesIJK.I))
            {
                for (int ii = 0; ii < scube.NumSamplesIJK.I; ii++)
                {
                    for (int jj = 0; jj < scube.NumSamplesIJK.J; jj++)
                    {
                        for (int kk = 0; kk < scube.NumSamplesIJK.K; kk++)
                        {
                            newVal[ii, jj, kk] = (float)sr.Function(ii, jj, kk, vals[ii, jj, kk]);
                            if (newVal[ii, jj, kk] < min_newVal)
                            {
                                min_newVal = (double)newVal[ii, jj, kk];
                            }
                            if (newVal[ii, jj, kk] > max_newVal)
                            {
                                max_newVal = (double)newVal[ii, jj, kk];
                            }
                        }
                    }
                    i1.ProgressStatus = ii + 1;
                }
            }
            using (ITransaction txn = DataManager.NewTransaction())
            {
                try
                {
                    txn.Lock(scube.SeismicCollection);
                    Index3       size      = new Index3(scube.NumSamplesIJK.I, scube.NumSamplesIJK.J, scube.NumSamplesIJK.K);
                    IndexDouble3 tempindex = new IndexDouble3(0, 0, 0);
                    Point3       origin    = scube.PositionAtIndex(tempindex);

                    double d1, d2, d3;

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

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

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

                    if (scube.SeismicCollection.CanCreateSeismicCube(size, origin, iVec, jVec, kVec))
                    {
                        Type   dataType              = typeof(float);
                        Domain vDomain               = scube.Domain;
                        IPropertyVersionService pvs  = PetrelSystem.PropertyVersionService;
                        ILogTemplate            glob = pvs.FindTemplateByMnemonics("Seismic");
                        PropertyVersion         pv   = pvs.FindOrCreate(glob);
                        Range1 <double>         r    = new Range1 <double>(min_newVal, max_newVal);
                        PetrelLogger.InfoOutputWindow("OUTPUT TEMPLATE UNDER PROCESS");
                        try
                        {
                            newCube = scube.SeismicCollection.CreateSeismicCube(size, origin, iVec, jVec, kVec, dataType, vDomain, pv, r);
                            PetrelLogger.InfoOutputWindow("OUTPUT CUBE  TEMPLATE Construction completed");
                        }
                        catch (System.InvalidOperationException e1)
                        {
                            PetrelLogger.ErrorBox(e1.Message);
                        }
                        catch (System.ArgumentNullException e1)
                        {
                            PetrelLogger.InfoOutputWindow(e1.Message);
                        }
                    }
                    newCube.Name = cubename.Text;
                    if (newCube.IsWritable)
                    {
                        txn.Lock(newCube);
                        PetrelLogger.InfoOutputWindow("Writing Data in the new cube");
                        Index3   start = new Index3(0, 0, 0);
                        Index3   end   = new Index3(newCube.NumSamplesIJK.I - 1, newCube.NumSamplesIJK.J - 1, newCube.NumSamplesIJK.K - 1);
                        ISubCube to    = newCube.GetSubCube(start, end);
                        to.CopyFrom(newVal);
                        txn.Commit();
                    }
                }
                catch (ArgumentNullException e2)
                {
                    PetrelLogger.ErrorBox("Seismic cube name or propertyVersion can not be blank (null)" + e2.Message);
                }
            }
        }