xtgeo 4.6.0__cp39-cp39-win_amd64.whl → 4.7.0__cp39-cp39-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of xtgeo might be problematic. Click here for more details.

cxtgeo.py CHANGED
@@ -538,9 +538,6 @@ def grd3d_get_all_corners(nx, ny, nz, swig_np_dbl_in_v1, swig_np_dbl_in_v2, swig
538
538
  def grd3d_well_ijk(nx, ny, nz, swig_np_dbl_in_v1, swig_np_dbl_in_v2, swig_np_int_in_v1, swig_np_dbl_in_v3, swig_np_int_in_v2, nval, p_utme_v, p_utmn_v, p_tvds_v, ivector, jvector, kvector, iflag):
539
539
  return _cxtgeo.grd3d_well_ijk(nx, ny, nz, swig_np_dbl_in_v1, swig_np_dbl_in_v2, swig_np_int_in_v1, swig_np_dbl_in_v3, swig_np_int_in_v2, nval, p_utme_v, p_utmn_v, p_tvds_v, ivector, jvector, kvector, iflag)
540
540
 
541
- def grdcp3d_from_cube(ncol, nrow, nlay, swig_np_dbl_inplaceflat_v1, swig_np_flt_inplaceflat_v1, swig_np_int_inplaceflat_v1, xori, yori, zori, xinc, yinc, zinc, rotation, yflip, option):
542
- return _cxtgeo.grdcp3d_from_cube(ncol, nrow, nlay, swig_np_dbl_inplaceflat_v1, swig_np_flt_inplaceflat_v1, swig_np_int_inplaceflat_v1, xori, yori, zori, xinc, yinc, zinc, rotation, yflip, option)
543
-
544
541
  def grd3cp3d_xtgformat1to2_geom(ncol, nrow, nlay, swig_np_dbl_inplaceflat_v1, swig_np_dbl_inplaceflat_v2, swig_np_dbl_inplaceflat_v3, swig_np_flt_inplaceflat_v1, swig_np_int_inplaceflat_v1, swig_np_int_inplaceflat_v2):
545
542
  return _cxtgeo.grd3cp3d_xtgformat1to2_geom(ncol, nrow, nlay, swig_np_dbl_inplaceflat_v1, swig_np_dbl_inplaceflat_v2, swig_np_dbl_inplaceflat_v3, swig_np_flt_inplaceflat_v1, swig_np_int_inplaceflat_v1, swig_np_int_inplaceflat_v2)
546
543
 
@@ -559,9 +556,6 @@ def grdcp3d_get_vtk_esg_geometry_data(ncol, nrow, nlay, swig_np_dbl_inplaceflat_
559
556
  def grdcp3d_get_vtk_grid_arrays(ncol, nrow, nlay, swig_np_dbl_inplaceflat_v1, swig_np_flt_inplaceflat_v1, swig_np_dbl_aout_v1, swig_np_dbl_aout_v2, swig_np_dbl_aout_v3):
560
557
  return _cxtgeo.grdcp3d_get_vtk_grid_arrays(ncol, nrow, nlay, swig_np_dbl_inplaceflat_v1, swig_np_flt_inplaceflat_v1, swig_np_dbl_aout_v1, swig_np_dbl_aout_v2, swig_np_dbl_aout_v3)
561
558
 
562
- def grdcp3d_conv_grid_roxapi(ncol, nrow, nlay, swig_np_dbl_inplaceflat_v1, swig_np_flt_inplaceflat_v1, swig_np_dbl_aout_v1, swig_np_dbl_aout_v2, swig_np_dbl_aout_v3):
563
- return _cxtgeo.grdcp3d_conv_grid_roxapi(ncol, nrow, nlay, swig_np_dbl_inplaceflat_v1, swig_np_flt_inplaceflat_v1, swig_np_dbl_aout_v1, swig_np_dbl_aout_v2, swig_np_dbl_aout_v3)
564
-
565
559
  def grdcp3d_quality_indicators(ncol, nrow, nlay, swig_np_dbl_inplaceflat_v1, swig_np_flt_inplaceflat_v1, swig_np_int_inplaceflat_v1, swig_np_flt_inplaceflat_v2):
566
560
  return _cxtgeo.grdcp3d_quality_indicators(ncol, nrow, nlay, swig_np_dbl_inplaceflat_v1, swig_np_flt_inplaceflat_v1, swig_np_int_inplaceflat_v1, swig_np_flt_inplaceflat_v2)
567
561
 
cxtgeoPYTHON_wrap.c CHANGED
@@ -18687,160 +18687,6 @@ fail:
18687
18687
  }
18688
18688
 
18689
18689
 
18690
- SWIGINTERN PyObject *_wrap_grdcp3d_from_cube(PyObject *self, PyObject *args) {
18691
- PyObject *resultobj = 0;
18692
- int arg1 ;
18693
- int arg2 ;
18694
- int arg3 ;
18695
- double *arg4 = (double *) 0 ;
18696
- long arg5 ;
18697
- float *arg6 = (float *) 0 ;
18698
- long arg7 ;
18699
- int *arg8 = (int *) 0 ;
18700
- long arg9 ;
18701
- double arg10 ;
18702
- double arg11 ;
18703
- double arg12 ;
18704
- double arg13 ;
18705
- double arg14 ;
18706
- double arg15 ;
18707
- double arg16 ;
18708
- int arg17 ;
18709
- int arg18 ;
18710
- int val1 ;
18711
- int ecode1 = 0 ;
18712
- int val2 ;
18713
- int ecode2 = 0 ;
18714
- int val3 ;
18715
- int ecode3 = 0 ;
18716
- PyArrayObject *array4 = NULL ;
18717
- int i4 = 1 ;
18718
- PyArrayObject *array6 = NULL ;
18719
- int i6 = 1 ;
18720
- PyArrayObject *array8 = NULL ;
18721
- int i8 = 1 ;
18722
- double val10 ;
18723
- int ecode10 = 0 ;
18724
- double val11 ;
18725
- int ecode11 = 0 ;
18726
- double val12 ;
18727
- int ecode12 = 0 ;
18728
- double val13 ;
18729
- int ecode13 = 0 ;
18730
- double val14 ;
18731
- int ecode14 = 0 ;
18732
- double val15 ;
18733
- int ecode15 = 0 ;
18734
- double val16 ;
18735
- int ecode16 = 0 ;
18736
- int val17 ;
18737
- int ecode17 = 0 ;
18738
- int val18 ;
18739
- int ecode18 = 0 ;
18740
- PyObject *swig_obj[15] ;
18741
-
18742
- (void)self;
18743
- if (!SWIG_Python_UnpackTuple(args, "grdcp3d_from_cube", 15, 15, swig_obj)) SWIG_fail;
18744
- ecode1 = SWIG_AsVal_int(swig_obj[0], &val1);
18745
- if (!SWIG_IsOK(ecode1)) {
18746
- SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "grdcp3d_from_cube" "', argument " "1"" of type '" "int""'");
18747
- }
18748
- arg1 = (int)(val1);
18749
- ecode2 = SWIG_AsVal_int(swig_obj[1], &val2);
18750
- if (!SWIG_IsOK(ecode2)) {
18751
- SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "grdcp3d_from_cube" "', argument " "2"" of type '" "int""'");
18752
- }
18753
- arg2 = (int)(val2);
18754
- ecode3 = SWIG_AsVal_int(swig_obj[2], &val3);
18755
- if (!SWIG_IsOK(ecode3)) {
18756
- SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "grdcp3d_from_cube" "', argument " "3"" of type '" "int""'");
18757
- }
18758
- arg3 = (int)(val3);
18759
- {
18760
- array4 = obj_to_array_no_conversion(swig_obj[3], NPY_DOUBLE);
18761
- if (!array4 || !require_c_or_f_contiguous(array4)
18762
- || !require_native(array4)) SWIG_fail;
18763
- arg4 = (double*) array_data(array4);
18764
- arg5 = 1;
18765
- for (i4=0; i4 < array_numdims(array4); ++i4) arg5 *= array_size(array4,i4);
18766
- }
18767
- {
18768
- array6 = obj_to_array_no_conversion(swig_obj[4], NPY_FLOAT);
18769
- if (!array6 || !require_c_or_f_contiguous(array6)
18770
- || !require_native(array6)) SWIG_fail;
18771
- arg6 = (float*) array_data(array6);
18772
- arg7 = 1;
18773
- for (i6=0; i6 < array_numdims(array6); ++i6) arg7 *= array_size(array6,i6);
18774
- }
18775
- {
18776
- array8 = obj_to_array_no_conversion(swig_obj[5], NPY_INT);
18777
- if (!array8 || !require_c_or_f_contiguous(array8)
18778
- || !require_native(array8)) SWIG_fail;
18779
- arg8 = (int*) array_data(array8);
18780
- arg9 = 1;
18781
- for (i8=0; i8 < array_numdims(array8); ++i8) arg9 *= array_size(array8,i8);
18782
- }
18783
- ecode10 = SWIG_AsVal_double(swig_obj[6], &val10);
18784
- if (!SWIG_IsOK(ecode10)) {
18785
- SWIG_exception_fail(SWIG_ArgError(ecode10), "in method '" "grdcp3d_from_cube" "', argument " "10"" of type '" "double""'");
18786
- }
18787
- arg10 = (double)(val10);
18788
- ecode11 = SWIG_AsVal_double(swig_obj[7], &val11);
18789
- if (!SWIG_IsOK(ecode11)) {
18790
- SWIG_exception_fail(SWIG_ArgError(ecode11), "in method '" "grdcp3d_from_cube" "', argument " "11"" of type '" "double""'");
18791
- }
18792
- arg11 = (double)(val11);
18793
- ecode12 = SWIG_AsVal_double(swig_obj[8], &val12);
18794
- if (!SWIG_IsOK(ecode12)) {
18795
- SWIG_exception_fail(SWIG_ArgError(ecode12), "in method '" "grdcp3d_from_cube" "', argument " "12"" of type '" "double""'");
18796
- }
18797
- arg12 = (double)(val12);
18798
- ecode13 = SWIG_AsVal_double(swig_obj[9], &val13);
18799
- if (!SWIG_IsOK(ecode13)) {
18800
- SWIG_exception_fail(SWIG_ArgError(ecode13), "in method '" "grdcp3d_from_cube" "', argument " "13"" of type '" "double""'");
18801
- }
18802
- arg13 = (double)(val13);
18803
- ecode14 = SWIG_AsVal_double(swig_obj[10], &val14);
18804
- if (!SWIG_IsOK(ecode14)) {
18805
- SWIG_exception_fail(SWIG_ArgError(ecode14), "in method '" "grdcp3d_from_cube" "', argument " "14"" of type '" "double""'");
18806
- }
18807
- arg14 = (double)(val14);
18808
- ecode15 = SWIG_AsVal_double(swig_obj[11], &val15);
18809
- if (!SWIG_IsOK(ecode15)) {
18810
- SWIG_exception_fail(SWIG_ArgError(ecode15), "in method '" "grdcp3d_from_cube" "', argument " "15"" of type '" "double""'");
18811
- }
18812
- arg15 = (double)(val15);
18813
- ecode16 = SWIG_AsVal_double(swig_obj[12], &val16);
18814
- if (!SWIG_IsOK(ecode16)) {
18815
- SWIG_exception_fail(SWIG_ArgError(ecode16), "in method '" "grdcp3d_from_cube" "', argument " "16"" of type '" "double""'");
18816
- }
18817
- arg16 = (double)(val16);
18818
- ecode17 = SWIG_AsVal_int(swig_obj[13], &val17);
18819
- if (!SWIG_IsOK(ecode17)) {
18820
- SWIG_exception_fail(SWIG_ArgError(ecode17), "in method '" "grdcp3d_from_cube" "', argument " "17"" of type '" "int""'");
18821
- }
18822
- arg17 = (int)(val17);
18823
- ecode18 = SWIG_AsVal_int(swig_obj[14], &val18);
18824
- if (!SWIG_IsOK(ecode18)) {
18825
- SWIG_exception_fail(SWIG_ArgError(ecode18), "in method '" "grdcp3d_from_cube" "', argument " "18"" of type '" "int""'");
18826
- }
18827
- arg18 = (int)(val18);
18828
- {
18829
- char *err;
18830
- clear_exception();
18831
- grdcp3d_from_cube(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15,arg16,arg17,arg18);
18832
- if ((err = check_exception())) {
18833
- PyErr_SetString(PY_XTGeoCLibError, err);
18834
- return NULL;
18835
- }
18836
- }
18837
- resultobj = SWIG_Py_Void();
18838
- return resultobj;
18839
- fail:
18840
- return NULL;
18841
- }
18842
-
18843
-
18844
18690
  SWIGINTERN PyObject *_wrap_grd3cp3d_xtgformat1to2_geom(PyObject *self, PyObject *args) {
18845
18691
  PyObject *resultobj = 0;
18846
18692
  long arg1 ;
@@ -19490,143 +19336,6 @@ fail:
19490
19336
  }
19491
19337
 
19492
19338
 
19493
- SWIGINTERN PyObject *_wrap_grdcp3d_conv_grid_roxapi(PyObject *self, PyObject *args) {
19494
- PyObject *resultobj = 0;
19495
- long arg1 ;
19496
- long arg2 ;
19497
- long arg3 ;
19498
- double *arg4 = (double *) 0 ;
19499
- long arg5 ;
19500
- float *arg6 = (float *) 0 ;
19501
- long arg7 ;
19502
- double *arg8 = (double *) 0 ;
19503
- long arg9 ;
19504
- double *arg10 = (double *) 0 ;
19505
- long arg11 ;
19506
- double *arg12 = (double *) 0 ;
19507
- long arg13 ;
19508
- long val1 ;
19509
- int ecode1 = 0 ;
19510
- long val2 ;
19511
- int ecode2 = 0 ;
19512
- long val3 ;
19513
- int ecode3 = 0 ;
19514
- PyArrayObject *array4 = NULL ;
19515
- int i4 = 1 ;
19516
- PyArrayObject *array6 = NULL ;
19517
- int i6 = 1 ;
19518
- PyObject *array8 = NULL ;
19519
- PyObject *array10 = NULL ;
19520
- PyObject *array12 = NULL ;
19521
- PyObject *swig_obj[8] ;
19522
- int result;
19523
-
19524
- (void)self;
19525
- if (!SWIG_Python_UnpackTuple(args, "grdcp3d_conv_grid_roxapi", 8, 8, swig_obj)) SWIG_fail;
19526
- ecode1 = SWIG_AsVal_long(swig_obj[0], &val1);
19527
- if (!SWIG_IsOK(ecode1)) {
19528
- SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "grdcp3d_conv_grid_roxapi" "', argument " "1"" of type '" "long""'");
19529
- }
19530
- arg1 = (long)(val1);
19531
- ecode2 = SWIG_AsVal_long(swig_obj[1], &val2);
19532
- if (!SWIG_IsOK(ecode2)) {
19533
- SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "grdcp3d_conv_grid_roxapi" "', argument " "2"" of type '" "long""'");
19534
- }
19535
- arg2 = (long)(val2);
19536
- ecode3 = SWIG_AsVal_long(swig_obj[2], &val3);
19537
- if (!SWIG_IsOK(ecode3)) {
19538
- SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "grdcp3d_conv_grid_roxapi" "', argument " "3"" of type '" "long""'");
19539
- }
19540
- arg3 = (long)(val3);
19541
- {
19542
- array4 = obj_to_array_no_conversion(swig_obj[3], NPY_DOUBLE);
19543
- if (!array4 || !require_c_or_f_contiguous(array4)
19544
- || !require_native(array4)) SWIG_fail;
19545
- arg4 = (double*) array_data(array4);
19546
- arg5 = 1;
19547
- for (i4=0; i4 < array_numdims(array4); ++i4) arg5 *= array_size(array4,i4);
19548
- }
19549
- {
19550
- array6 = obj_to_array_no_conversion(swig_obj[4], NPY_FLOAT);
19551
- if (!array6 || !require_c_or_f_contiguous(array6)
19552
- || !require_native(array6)) SWIG_fail;
19553
- arg6 = (float*) array_data(array6);
19554
- arg7 = 1;
19555
- for (i6=0; i6 < array_numdims(array6); ++i6) arg7 *= array_size(array6,i6);
19556
- }
19557
- {
19558
- npy_intp dims[1];
19559
- if (!PyInt_Check(swig_obj[5]))
19560
- {
19561
- const char* typestring = pytype_string(swig_obj[5]);
19562
- PyErr_Format(PyExc_TypeError,
19563
- "Int dimension expected. '%s' given.",
19564
- typestring);
19565
- SWIG_fail;
19566
- }
19567
- arg9 = (long) PyInt_AsLong(swig_obj[5]);
19568
- dims[0] = (npy_intp) arg9;
19569
- array8 = PyArray_SimpleNew(1, dims, NPY_DOUBLE);
19570
- if (!array8) SWIG_fail;
19571
- arg8 = (double*) array_data(array8);
19572
- }
19573
- {
19574
- npy_intp dims[1];
19575
- if (!PyInt_Check(swig_obj[6]))
19576
- {
19577
- const char* typestring = pytype_string(swig_obj[6]);
19578
- PyErr_Format(PyExc_TypeError,
19579
- "Int dimension expected. '%s' given.",
19580
- typestring);
19581
- SWIG_fail;
19582
- }
19583
- arg11 = (long) PyInt_AsLong(swig_obj[6]);
19584
- dims[0] = (npy_intp) arg11;
19585
- array10 = PyArray_SimpleNew(1, dims, NPY_DOUBLE);
19586
- if (!array10) SWIG_fail;
19587
- arg10 = (double*) array_data(array10);
19588
- }
19589
- {
19590
- npy_intp dims[1];
19591
- if (!PyInt_Check(swig_obj[7]))
19592
- {
19593
- const char* typestring = pytype_string(swig_obj[7]);
19594
- PyErr_Format(PyExc_TypeError,
19595
- "Int dimension expected. '%s' given.",
19596
- typestring);
19597
- SWIG_fail;
19598
- }
19599
- arg13 = (long) PyInt_AsLong(swig_obj[7]);
19600
- dims[0] = (npy_intp) arg13;
19601
- array12 = PyArray_SimpleNew(1, dims, NPY_DOUBLE);
19602
- if (!array12) SWIG_fail;
19603
- arg12 = (double*) array_data(array12);
19604
- }
19605
- {
19606
- char *err;
19607
- clear_exception();
19608
- result = (int)grdcp3d_conv_grid_roxapi(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13);
19609
- if ((err = check_exception())) {
19610
- PyErr_SetString(PY_XTGeoCLibError, err);
19611
- return NULL;
19612
- }
19613
- }
19614
- resultobj = SWIG_From_int((int)(result));
19615
- {
19616
- resultobj = SWIG_Python_AppendOutput(resultobj,(PyObject*)array8);
19617
- }
19618
- {
19619
- resultobj = SWIG_Python_AppendOutput(resultobj,(PyObject*)array10);
19620
- }
19621
- {
19622
- resultobj = SWIG_Python_AppendOutput(resultobj,(PyObject*)array12);
19623
- }
19624
- return resultobj;
19625
- fail:
19626
- return NULL;
19627
- }
19628
-
19629
-
19630
19339
  SWIGINTERN PyObject *_wrap_grdcp3d_quality_indicators(PyObject *self, PyObject *args) {
19631
19340
  PyObject *resultobj = 0;
19632
19341
  long arg1 ;
@@ -20627,14 +20336,12 @@ static PyMethodDef SwigMethods[] = {
20627
20336
  { "grd3d_zminmax", _wrap_grd3d_zminmax, METH_VARARGS, NULL},
20628
20337
  { "grd3d_get_all_corners", _wrap_grd3d_get_all_corners, METH_VARARGS, NULL},
20629
20338
  { "grd3d_well_ijk", _wrap_grd3d_well_ijk, METH_VARARGS, NULL},
20630
- { "grdcp3d_from_cube", _wrap_grdcp3d_from_cube, METH_VARARGS, NULL},
20631
20339
  { "grd3cp3d_xtgformat1to2_geom", _wrap_grd3cp3d_xtgformat1to2_geom, METH_VARARGS, NULL},
20632
20340
  { "grd3cp3d_xtgformat2to1_geom", _wrap_grd3cp3d_xtgformat2to1_geom, METH_VARARGS, NULL},
20633
20341
  { "grdcp3d_process_edges", _wrap_grdcp3d_process_edges, METH_VARARGS, NULL},
20634
20342
  { "grdcp3d_corners", _wrap_grdcp3d_corners, METH_VARARGS, NULL},
20635
20343
  { "grdcp3d_get_vtk_esg_geometry_data", _wrap_grdcp3d_get_vtk_esg_geometry_data, METH_VARARGS, NULL},
20636
20344
  { "grdcp3d_get_vtk_grid_arrays", _wrap_grdcp3d_get_vtk_grid_arrays, METH_VARARGS, NULL},
20637
- { "grdcp3d_conv_grid_roxapi", _wrap_grdcp3d_conv_grid_roxapi, METH_VARARGS, NULL},
20638
20345
  { "grdcp3d_quality_indicators", _wrap_grdcp3d_quality_indicators, METH_VARARGS, NULL},
20639
20346
  { "well_geometrics", _wrap_well_geometrics, METH_VARARGS, NULL},
20640
20347
  { "well_trunc_parallel", _wrap_well_trunc_parallel, METH_VARARGS, NULL},
xtgeo/__init__.py CHANGED
@@ -142,6 +142,7 @@ from xtgeo.grid3d.grid import (
142
142
  grid_from_cube,
143
143
  grid_from_file,
144
144
  grid_from_roxar,
145
+ grid_from_surfaces,
145
146
  )
146
147
  from xtgeo.xyz.polygons import (
147
148
  polygons_from_file,
@@ -210,6 +211,7 @@ __all__ = [
210
211
  "grid_from_cube",
211
212
  "grid_from_file",
212
213
  "grid_from_roxar",
214
+ "grid_from_surfaces",
213
215
  "grid_properties",
214
216
  "grid_properties",
215
217
  "grid_property",
Binary file
Binary file
xtgeo/common/_xyz_enum.py CHANGED
@@ -14,6 +14,7 @@ class _AttrName(ExtendedEnum):
14
14
  XNAME = "X_UTME"
15
15
  YNAME = "Y_UTMN"
16
16
  ZNAME = "Z_TVDSS"
17
+ PNAME = "POLY_ID"
17
18
  M_MD_NAME = "M_MDEPTH"
18
19
  Q_MD_NAME = "Q_MDEPTH"
19
20
  M_AZI_NAME = "M_AZI"
@@ -24,6 +25,12 @@ class _AttrName(ExtendedEnum):
24
25
  J_INDEX = "J_INDEX"
25
26
  K_INDEX = "K_INDEX"
26
27
  R_HLEN_NAME = "R_HLEN"
28
+ HNAME = "H_CUMLEN"
29
+ DHNAME = "H_DELTALEN"
30
+ TNAME = "T_CUMLEN"
31
+ DTNAME = "T_DELTALEN"
32
+ WELLNAME = "WELLNAME"
33
+ TRAJECTORY = "TRAJECTORY"
27
34
 
28
35
 
29
36
  @unique
@@ -38,6 +45,6 @@ class _AttrType(ExtendedEnum):
38
45
  class _XYZType(ExtendedEnum):
39
46
  """Enumerate type of context"""
40
47
 
41
- POINTS = 1
42
- POLYGONS = 2 # ie. same here as PolyLines
43
- WELL = 3
48
+ POINTS = "POINTS"
49
+ POLYGONS = "POLYGONS"
50
+ WELL = "WELL"
xtgeo/common/version.py CHANGED
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '4.6.0'
21
- __version_tuple__ = version_tuple = (4, 6, 0)
20
+ __version__ = version = '4.7.0'
21
+ __version_tuple__ = version_tuple = (4, 7, 0)
@@ -144,5 +144,5 @@ class InteHead:
144
144
  return (
145
145
  None
146
146
  if value is None
147
- else TypeOfGrid.alternate_code(cast(Literal[0, 1, 2, 3], value))
147
+ else TypeOfGrid.alternate_code(cast("Literal[0, 1, 2, 3]", value))
148
148
  )
@@ -90,7 +90,7 @@ def remainder_saturations(saturations):
90
90
  rest = sum(saturations.values())
91
91
  if len(saturations) == 2 or np.allclose(rest, 1.0):
92
92
  missing = set(sat_keys).difference(set(saturations.keys()))
93
- return {m: 1.0 - rest for m in missing}
93
+ return dict.fromkeys(missing, 1.0 - rest)
94
94
  return {}
95
95
 
96
96
 
@@ -16,6 +16,7 @@ from xtgeo import _cxtgeo
16
16
  from xtgeo.common.calc import find_flip
17
17
  from xtgeo.common.constants import UNDEF_INT, UNDEF_LIMIT
18
18
  from xtgeo.common.log import null_logger
19
+ from xtgeo.common.types import Dimensions
19
20
  from xtgeo.grid3d.grid_properties import GridProperties
20
21
  from xtgeo.xyz.polygons import Polygons
21
22
 
@@ -24,10 +25,10 @@ from ._grid3d_fence import _update_tmpvars
24
25
  from .grid_property import GridProperty
25
26
 
26
27
  if TYPE_CHECKING:
27
- from xtgeo.common.types import Dimensions
28
28
  from xtgeo.grid3d import Grid
29
29
  from xtgeo.grid3d.types import METRIC
30
30
  from xtgeo.surface.regular_surface import RegularSurface
31
+ from xtgeo.surface.surfaces import Surfaces
31
32
  from xtgeo.xyz.points import Points
32
33
 
33
34
  logger = null_logger(__name__)
@@ -42,6 +43,9 @@ def create_box(
42
43
  flip: Literal[1, -1],
43
44
  ) -> dict[str, np.ndarray]:
44
45
  """Create a shoebox grid from cubi'sh spec, xtgformat=2."""
46
+
47
+ from xtgeo.cube.cube1 import Cube
48
+
45
49
  ncol, nrow, nlay = dimension
46
50
  nncol = ncol + 1
47
51
  nnrow = nrow + 1
@@ -51,33 +55,100 @@ def create_box(
51
55
  zcornsv = np.zeros((nncol, nnrow, nnlay, 4), dtype=np.float32)
52
56
  actnumsv = np.zeros((ncol, nrow, nlay), dtype=np.int32)
53
57
 
54
- option = 0 if not oricenter else 1
55
-
56
- _cxtgeo.grdcp3d_from_cube(
57
- ncol,
58
- nrow,
59
- nlay,
60
- coordsv,
61
- zcornsv,
62
- actnumsv,
63
- origin[0],
64
- origin[1],
65
- origin[2],
66
- increment[0],
67
- increment[1],
68
- increment[2],
69
- rotation,
70
- flip,
71
- option,
58
+ cube = Cube(
59
+ ncol=ncol,
60
+ nrow=nrow,
61
+ nlay=nlay,
62
+ xinc=increment[0],
63
+ yinc=increment[1],
64
+ zinc=increment[2],
65
+ xori=origin[0],
66
+ yori=origin[1],
67
+ zori=origin[2],
68
+ rotation=rotation,
72
69
  )
73
70
 
71
+ cubecpp = _internal.cube.Cube(cube)
72
+ coordsv, zcornsv, actnumsv = _internal.grid3d.create_grid_from_cube(
73
+ cubecpp, oricenter, flip
74
+ )
74
75
  return {
75
76
  "coordsv": coordsv,
76
77
  "zcornsv": zcornsv,
77
- "actnumsv": actnumsv,
78
+ "actnumsv": actnumsv.astype(np.int32),
78
79
  }
79
80
 
80
81
 
82
+ def create_grid_from_surfaces(
83
+ srfs: Surfaces,
84
+ ij_dimension: tuple[int, int] | None = None,
85
+ ij_origin: tuple[float, float] | None = None,
86
+ ij_increment: tuple[float, float] | None = None,
87
+ rotation: float | None = None,
88
+ tolerance: float = _internal.numerics.TOLERANCE,
89
+ ) -> Grid:
90
+ """Use a stack of surfaces to create a nonfaulted grid.
91
+
92
+ Technically, a shoebox grid is made first, then the layers are adjusted to follow
93
+ surfaces.
94
+ """
95
+ from xtgeo.grid3d.grid import create_box_grid
96
+
97
+ n_surfaces = len(srfs.surfaces)
98
+
99
+ # ensure that surfaces are consistent
100
+ if not srfs.is_depth_consistent():
101
+ raise ValueError(
102
+ "Surfaces are not depth consistent, they must not cross is depth"
103
+ )
104
+ top = srfs.surfaces[0]
105
+ base = srfs.surfaces[-1]
106
+
107
+ zinc = (base.values.mean() - top.values.mean()) / (n_surfaces - 1)
108
+ kdim: int = n_surfaces - 1
109
+ zori = top.values.mean()
110
+ ncol: int = top.ncol - 1 # since surface are nodes while grid is cell centered
111
+ nrow: int = top.nrow - 1
112
+
113
+ if ij_dimension: # mypy needs this:
114
+ dimension = Dimensions(int(ij_dimension[0]), int(ij_dimension[1]), kdim)
115
+ else:
116
+ dimension = Dimensions(ncol, nrow, kdim)
117
+
118
+ increment = (*ij_increment, zinc) if ij_increment else (top.xinc, top.yinc, zinc)
119
+ origin = (*ij_origin, zori) if ij_origin else (top.xori, top.yori, zori)
120
+ rotation = rotation if rotation is not None else top.rotation
121
+
122
+ grd = create_box_grid(
123
+ dimension=dimension,
124
+ origin=origin,
125
+ increment=increment,
126
+ rotation=rotation,
127
+ oricenter=False,
128
+ flip=1,
129
+ )
130
+
131
+ # now adjust the grid to surfaces
132
+ surf_list = []
133
+ for surf in srfs.surfaces:
134
+ cpp_surf = _internal.regsurf.RegularSurface(surf)
135
+ surf_list.append(cpp_surf)
136
+
137
+ grd_cpp = _internal.grid3d.Grid(grd)
138
+ new_zcorns, new_actnum = grd_cpp.adjust_boxgrid_layers_from_regsurfs(
139
+ surf_list, tolerance
140
+ )
141
+
142
+ grd._zcornsv = new_zcorns
143
+ grd._actnumsv = new_actnum
144
+
145
+ # set the subgrid index (zones)
146
+ subgrids = {f"zone_{i + 1}": 1 for i in range(n_surfaces - 1)}
147
+ grd.set_subgrids(subgrids)
148
+
149
+ return grd
150
+
151
+
81
152
  method_factory = {
82
153
  "euclid": _cxtgeo.euclid_length,
83
154
  "horizontal": _cxtgeo.horizontal_length,
@@ -1185,7 +1256,7 @@ def reduce_to_one_layer(self: Grid) -> None:
1185
1256
 
1186
1257
  def translate_coordinates(
1187
1258
  self: Grid,
1188
- translate: tuple[int, int, int] = (0, 0, 0),
1259
+ translate: tuple[float, float, float] = (0.0, 0.0, 0.0),
1189
1260
  flip: tuple[int, int, int] = (1, 1, 1),
1190
1261
  ) -> None:
1191
1262
  """Translate grid coordinates."""