quick-pp 0.2.3__py3-none-any.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.
- quick_pp/__init__.py +0 -0
- quick_pp/api/__init__.py +0 -0
- quick_pp/api/exceptions.py +61 -0
- quick_pp/api/fastapi_mlflow/__init__.py +1 -0
- quick_pp/api/fastapi_mlflow/_mlflow_types.py +59 -0
- quick_pp/api/fastapi_mlflow/applications.py +72 -0
- quick_pp/api/fastapi_mlflow/exceptions.py +22 -0
- quick_pp/api/fastapi_mlflow/predictors.py +96 -0
- quick_pp/api/main.py +90 -0
- quick_pp/api/mlflow_model_deployment.py +99 -0
- quick_pp/api/qpp_assistant.py +160 -0
- quick_pp/api/router.py +18 -0
- quick_pp/api/schemas/lithology_hc_correction.py +39 -0
- quick_pp/api/schemas/lithology_ssc.py +37 -0
- quick_pp/api/schemas/lithology_vsh_gr.py +25 -0
- quick_pp/api/schemas/permeability_choo.py +25 -0
- quick_pp/api/schemas/permeability_others.py +24 -0
- quick_pp/api/schemas/porosity.py +22 -0
- quick_pp/api/schemas/ressum.py +29 -0
- quick_pp/api/schemas/saturation_archie.py +25 -0
- quick_pp/api/schemas/saturation_b.py +24 -0
- quick_pp/api/schemas/saturation_qv.py +26 -0
- quick_pp/api/schemas/saturation_rw.py +24 -0
- quick_pp/api/schemas/saturation_temp_grad.py +24 -0
- quick_pp/api/schemas/saturation_waxman_smits.py +28 -0
- quick_pp/api/services/las_handler.py +136 -0
- quick_pp/api/services/lithology.py +278 -0
- quick_pp/api/services/permeability.py +252 -0
- quick_pp/api/services/porosity.py +151 -0
- quick_pp/api/services/reservoir_summary.py +78 -0
- quick_pp/api/services/saturation.py +359 -0
- quick_pp/api/static/favicon.ico +0 -0
- quick_pp/api/static/logo.png +0 -0
- quick_pp/cli.py +118 -0
- quick_pp/config.py +94 -0
- quick_pp/core_calibration.py +394 -0
- quick_pp/fluid_type.py +128 -0
- quick_pp/geomechanics.py +195 -0
- quick_pp/las_handler.py +327 -0
- quick_pp/lithology/__init__.py +80 -0
- quick_pp/lithology/carbonate.py +166 -0
- quick_pp/lithology/multi_mineral.py +151 -0
- quick_pp/lithology/sand_shale.py +79 -0
- quick_pp/lithology/sand_silt_clay.py +131 -0
- quick_pp/logger.py +19 -0
- quick_pp/modelling/__init__.py +0 -0
- quick_pp/modelling/config.py +72 -0
- quick_pp/modelling/mock_data/mock_data.parquet +0 -0
- quick_pp/modelling/predict_pipeline.py +126 -0
- quick_pp/modelling/train_pipeline.py +220 -0
- quick_pp/modelling/utils.py +111 -0
- quick_pp/objects.py +177 -0
- quick_pp/permeability.py +151 -0
- quick_pp/plotter/__init__.py +0 -0
- quick_pp/plotter/plotter.py +315 -0
- quick_pp/plotter/well_log.py +187 -0
- quick_pp/plotter/well_log_config.py +409 -0
- quick_pp/porosity.py +341 -0
- quick_pp/qaqc.py +436 -0
- quick_pp/ressum.py +326 -0
- quick_pp/rock_type.py +499 -0
- quick_pp/saturation.py +455 -0
- quick_pp/utils.py +328 -0
- quick_pp-0.2.3.dist-info/METADATA +103 -0
- quick_pp-0.2.3.dist-info/RECORD +69 -0
- quick_pp-0.2.3.dist-info/WHEEL +4 -0
- quick_pp-0.2.3.dist-info/entry_points.txt +2 -0
- quick_pp-0.2.3.dist-info/licenses/AUTHORS.rst +13 -0
- quick_pp-0.2.3.dist-info/licenses/LICENSE +22 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Schemas for hydrocarbon correction lithology input.
|
|
3
|
+
"""
|
|
4
|
+
from pydantic import BaseModel, Field
|
|
5
|
+
from typing import List, Optional, Tuple
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class HCCorrectionData(BaseModel):
|
|
9
|
+
gr: float = Field(..., description="Gamma Ray value (API units)")
|
|
10
|
+
nphi: float = Field(..., description="Neutron porosity (fraction)")
|
|
11
|
+
rhob: float = Field(..., description="Bulk density (g/cm^3)")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class LithologyHCCorrectionInput(BaseModel):
|
|
15
|
+
dry_sand_point: Tuple[Optional[float], Optional[float]] = Field(
|
|
16
|
+
(-0.02, 2.65), description="Dry sand point (nphi, rhob)")
|
|
17
|
+
dry_silt_point: Tuple[Optional[float], Optional[float]] = Field(
|
|
18
|
+
(0, 2.68), description="Dry silt point (nphi, rhob)")
|
|
19
|
+
dry_clay_point: Tuple[Optional[float], Optional[float]] = Field(
|
|
20
|
+
(0.33, 2.7), description="Dry clay point (nphi, rhob)")
|
|
21
|
+
fluid_point: Tuple[Optional[float], Optional[float]] = Field(
|
|
22
|
+
(1.0, 1.0), description="Fluid point (nphi, rhob)")
|
|
23
|
+
wet_clay_point: Tuple[Optional[float], Optional[float]] = Field(
|
|
24
|
+
(0, 0), description="Wet clay point (nphi, rhob)")
|
|
25
|
+
method: str = Field('ssc', description="Method for lithology calculation")
|
|
26
|
+
silt_line_angle: float = Field(117, description="Silt line angle (degrees)")
|
|
27
|
+
corr_angle: float = Field(50, description="Correction angle (degrees)")
|
|
28
|
+
data: List[HCCorrectionData] = Field([
|
|
29
|
+
HCCorrectionData(gr=117.893, nphi=0.285, rhob=2.486),
|
|
30
|
+
HCCorrectionData(gr=116.065, nphi=0.245, rhob=2.441),
|
|
31
|
+
HCCorrectionData(gr=122.852, nphi=0.306, rhob=2.484),
|
|
32
|
+
HCCorrectionData(gr=126.424, nphi=0.357, rhob=2.536),
|
|
33
|
+
HCCorrectionData(gr=111.248, nphi=0.295, rhob=2.498),
|
|
34
|
+
HCCorrectionData(gr=112.464, nphi=0.278, rhob=2.531),
|
|
35
|
+
HCCorrectionData(gr=128.918, nphi=0.388, rhob=2.093),
|
|
36
|
+
HCCorrectionData(gr=60.707, nphi=0.067, rhob=2.073),
|
|
37
|
+
HCCorrectionData(gr=125.888, nphi=0.327, rhob=2.448),
|
|
38
|
+
HCCorrectionData(gr=119.909, nphi=0.313, rhob=2.55),
|
|
39
|
+
], description="List of data points for lithology calculation")
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Schemas for sand-silt-clay lithology input.
|
|
3
|
+
"""
|
|
4
|
+
from pydantic import BaseModel, Field
|
|
5
|
+
from typing import List, Optional, Tuple
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class SSCData(BaseModel):
|
|
9
|
+
nphi: float = Field(..., description="Neutron porosity (fraction)")
|
|
10
|
+
rhob: float = Field(..., description="Bulk density (g/cm^3)")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class LithologySSCInput(BaseModel):
|
|
14
|
+
dry_sand_point: Tuple[Optional[float], Optional[float]] = Field(
|
|
15
|
+
(-0.02, 2.65), description="Dry sand point (nphi, rhob)")
|
|
16
|
+
dry_silt_point: Tuple[Optional[float], Optional[float]] = Field(
|
|
17
|
+
(0, 2.68), description="Dry silt point (nphi, rhob)")
|
|
18
|
+
dry_clay_point: Tuple[Optional[float], Optional[float]] = Field(
|
|
19
|
+
(0.33, 2.7), description="Dry clay point (nphi, rhob)")
|
|
20
|
+
fluid_point: Tuple[Optional[float], Optional[float]] = Field(
|
|
21
|
+
(1.0, 1.0), description="Fluid point (nphi, rhob)")
|
|
22
|
+
wet_clay_point: Tuple[Optional[float], Optional[float]] = Field(
|
|
23
|
+
(0, 0), description="Wet clay point (nphi, rhob)")
|
|
24
|
+
method: str = Field('ssc', description="Method for lithology calculation")
|
|
25
|
+
silt_line_angle: float = Field(117, description="Silt line angle (degrees)")
|
|
26
|
+
data: List[SSCData] = Field([
|
|
27
|
+
SSCData(nphi=0.365, rhob=2.48),
|
|
28
|
+
SSCData(nphi=0.17, rhob=2.304),
|
|
29
|
+
SSCData(nphi=0.31, rhob=2.39),
|
|
30
|
+
SSCData(nphi=0.45, rhob=1.85),
|
|
31
|
+
SSCData(nphi=0.244, rhob=2.513),
|
|
32
|
+
SSCData(nphi=0.207, rhob=2.454),
|
|
33
|
+
SSCData(nphi=0.323, rhob=2.438),
|
|
34
|
+
SSCData(nphi=0.097, rhob=2.177),
|
|
35
|
+
SSCData(nphi=0.353, rhob=2.5),
|
|
36
|
+
SSCData(nphi=0.208, rhob=2.487),
|
|
37
|
+
], description="List of data points for lithology calculation")
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Schemas for Vshale from GR log input.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from pydantic import BaseModel, Field
|
|
6
|
+
from typing import List
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class GRData(BaseModel):
|
|
10
|
+
gr: float = Field(..., description="Gamma Ray value (API units)")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class LithologyVshGRInput(BaseModel):
|
|
14
|
+
data: List[GRData] = Field([
|
|
15
|
+
GRData(gr=121.54),
|
|
16
|
+
GRData(gr=120.133),
|
|
17
|
+
GRData(gr=117.059),
|
|
18
|
+
GRData(gr=124.022),
|
|
19
|
+
GRData(gr=125.076),
|
|
20
|
+
GRData(gr=86.06),
|
|
21
|
+
GRData(gr=130.02),
|
|
22
|
+
GRData(gr=131.419),
|
|
23
|
+
GRData(gr=103.284),
|
|
24
|
+
GRData(gr=102.317),
|
|
25
|
+
], description="List of gamma ray values (API units)")
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from typing import List
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Data(BaseModel):
|
|
6
|
+
"""Input record for Choo permeability estimation."""
|
|
7
|
+
vcld: float = Field(..., description="Volume of clay (fraction)")
|
|
8
|
+
vsilt: float = Field(..., description="Volume of silt (fraction)")
|
|
9
|
+
phit: float = Field(..., description="Total porosity (fraction)")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class InputData(BaseModel):
|
|
13
|
+
"""Input data wrapper for Choo permeability endpoint."""
|
|
14
|
+
data: List[Data] = Field([
|
|
15
|
+
Data(vcld=0.662, vsilt=0.264, phit=0.102),
|
|
16
|
+
Data(vcld=0.618, vsilt=0.22, phit=0.147),
|
|
17
|
+
Data(vcld=0.301, vsilt=0.187, phit=0.21),
|
|
18
|
+
Data(vcld=0.684, vsilt=0.226, phit=0.098),
|
|
19
|
+
Data(vcld=0.663, vsilt=0.259, phit=0.113),
|
|
20
|
+
Data(vcld=0.553, vsilt=0.228, phit=0.258),
|
|
21
|
+
Data(vcld=0.725, vsilt=0.129, phit=0.145),
|
|
22
|
+
Data(vcld=0.806, vsilt=0.103, phit=0.108),
|
|
23
|
+
Data(vcld=0.021, vsilt=0.013, phit=0.273),
|
|
24
|
+
Data(vcld=0.052, vsilt=0.032, phit=0.448)
|
|
25
|
+
], description="List of input data for Choo permeability estimation.")
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from typing import List
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Data(BaseModel):
|
|
6
|
+
"""Input record for permeability estimation (other models)."""
|
|
7
|
+
phit: float = Field(..., description="Total porosity (fraction)")
|
|
8
|
+
swirr: float = Field(..., description="Irreducible water saturation (fraction)")
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class InputData(BaseModel):
|
|
12
|
+
"""Input data wrapper for permeability endpoints (other models)."""
|
|
13
|
+
data: List[Data] = Field([
|
|
14
|
+
Data(phit=0.328, swirr=0.003),
|
|
15
|
+
Data(phit=0.114, swirr=0.016),
|
|
16
|
+
Data(phit=0.111, swirr=0.03),
|
|
17
|
+
Data(phit=0.278, swirr=0.006),
|
|
18
|
+
Data(phit=0.245, swirr=0.013),
|
|
19
|
+
Data(phit=0.116, swirr=0.018),
|
|
20
|
+
Data(phit=0.131, swirr=0.016),
|
|
21
|
+
Data(phit=0.109, swirr=0.042),
|
|
22
|
+
Data(phit=0.2, swirr=0.023),
|
|
23
|
+
Data(phit=0.143, swirr=0.01)
|
|
24
|
+
], description="List of input data for permeability estimation using other models.")
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from typing import List, Tuple, Optional
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Data(BaseModel):
|
|
6
|
+
nphi: float = Field(..., description="Neutron porosity (fraction)")
|
|
7
|
+
rhob: float = Field(..., description="Bulk density (g/cm^3)")
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class InputData(BaseModel):
|
|
11
|
+
dry_sand_point: Tuple[float, float] = Field((-0.02, 2.65), description="Dry sand point (nphi, rhob)")
|
|
12
|
+
dry_silt_point: Tuple[float, float] = Field((0.1, 2.68), description="Dry silt point (nphi, rhob)")
|
|
13
|
+
dry_clay_point: Tuple[float, float] = Field((0.27, 2.7), description="Dry clay point (nphi, rhob)")
|
|
14
|
+
fluid_point: Tuple[float, float] = Field((1.0, 1.0), description="Fluid point (nphi, rhob)")
|
|
15
|
+
wet_clay_point: Optional[Tuple[float, float]] = Field((0, 0), description="Wet clay point (nphi, rhob)")
|
|
16
|
+
method: str = Field('ssc', description="Method for lithology calculation")
|
|
17
|
+
silt_line_angle: float = Field(117, description="Silt line angle (degrees)")
|
|
18
|
+
data: List[Data] = Field([
|
|
19
|
+
Data(nphi=0.3, rhob=1.85),
|
|
20
|
+
Data(nphi=0.35, rhob=1.95),
|
|
21
|
+
Data(nphi=0.34, rhob=1.9),
|
|
22
|
+
], description="List of data points for lithology calculation")
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from typing import List
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Data(BaseModel):
|
|
6
|
+
"""Schema for a single reservoir data point."""
|
|
7
|
+
depth: float = Field(..., description="Depth of the sample")
|
|
8
|
+
vcld: float = Field(..., description="Volume of clay")
|
|
9
|
+
phit: float = Field(..., description="Total porosity")
|
|
10
|
+
swt: float = Field(..., description="Water saturation")
|
|
11
|
+
perm: float = Field(..., description="Permeability")
|
|
12
|
+
zones: str = Field(..., description="Zone identifier")
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class InputData(BaseModel):
|
|
16
|
+
"""Input schema for reservoir summary, including cut-offs and data list."""
|
|
17
|
+
cut_offs: dict = Field(dict(VSHALE=0.3, PHIT=0.1, SWT=0.75), description="Cut-off values for reservoir properties")
|
|
18
|
+
data: List[Data] = Field([
|
|
19
|
+
Data(depth=3898.24, vcld=0.702, phit=0.095, swt=1.0, perm=0, zones='A'),
|
|
20
|
+
Data(depth=3954.932, vcld=0.671, phit=0.108, swt=1.0, perm=0, zones='A'),
|
|
21
|
+
Data(depth=3804.056, vcld=0.698, phit=0.121, swt=1.0, perm=0, zones='A'),
|
|
22
|
+
Data(depth=3742.639, vcld=0.663, phit=0.149, swt=1.0, perm=0, zones='B'),
|
|
23
|
+
Data(depth=3641.75, vcld=0.635, phit=0.121, swt=1.0, perm=0, zones='B'),
|
|
24
|
+
Data(depth=3919.423, vcld=0.036, phit=0.483, swt=0.281, perm=0, zones='B'),
|
|
25
|
+
Data(depth=4014.368, vcld=0.352, phit=0.178, swt=0.801, perm=0, zones='B'),
|
|
26
|
+
Data(depth=3919.88, vcld=0.036, phit=0.483, swt=0.248, perm=0, zones='C'),
|
|
27
|
+
Data(depth=3864.712, vcld=0.007, phit=0.255, swt=0.343, perm=0, zones='C'),
|
|
28
|
+
Data(depth=4062.527, vcld=0.638, phit=0.188, swt=1.0, perm=0, zones='C')
|
|
29
|
+
], description="List of reservoir data points")
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from typing import List
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Data(BaseModel):
|
|
6
|
+
"""Archie saturation input data for a single sample."""
|
|
7
|
+
rt: float = Field(..., description="True resistivity (ohm-m)")
|
|
8
|
+
rw: float = Field(..., description="Water resistivity (ohm-m)")
|
|
9
|
+
phit: float = Field(..., description="Total porosity (fraction)")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class InputData(BaseModel):
|
|
13
|
+
"""Archie saturation input data for a batch of samples."""
|
|
14
|
+
data: List[Data] = Field([
|
|
15
|
+
Data(rt=1.834, rw=0.343, phit=0.141),
|
|
16
|
+
Data(rt=1.955, rw=0.343, phit=0.152),
|
|
17
|
+
Data(rt=2.833, rw=0.335, phit=0.198),
|
|
18
|
+
Data(rt=3.469, rw=0.334, phit=0.192),
|
|
19
|
+
Data(rt=3.788, rw=0.337, phit=0.108),
|
|
20
|
+
Data(rt=8.11, rw=0.332, phit=0.191),
|
|
21
|
+
Data(rt=2.315, rw=0.338, phit=0.167),
|
|
22
|
+
Data(rt=1.827, rw=0.343, phit=0.151),
|
|
23
|
+
Data(rt=2.654, rw=0.336, phit=0.115),
|
|
24
|
+
Data(rt=3.628, rw=0.334, phit=0.198)
|
|
25
|
+
], description="List of input data for Archie saturation calculation.")
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from typing import List
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Data(BaseModel):
|
|
6
|
+
"""Saturation B input data for a single sample."""
|
|
7
|
+
temp_grad: float = Field(..., description="Temperature gradient (C/km or F/100ft)")
|
|
8
|
+
rw: float = Field(..., description="Water resistivity (ohm-m)")
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class InputData(BaseModel):
|
|
12
|
+
"""Saturation B input data for a batch of samples."""
|
|
13
|
+
data: List[Data] = Field([
|
|
14
|
+
Data(temp_grad=44.92, rw=0.34),
|
|
15
|
+
Data(temp_grad=46.08, rw=0.34),
|
|
16
|
+
Data(temp_grad=45.38, rw=0.34),
|
|
17
|
+
Data(temp_grad=46.49, rw=0.33),
|
|
18
|
+
Data(temp_grad=46.0, rw=0.34),
|
|
19
|
+
Data(temp_grad=45.31, rw=0.34),
|
|
20
|
+
Data(temp_grad=45.32, rw=0.34),
|
|
21
|
+
Data(temp_grad=46.18, rw=0.34),
|
|
22
|
+
Data(temp_grad=46.21, rw=0.33),
|
|
23
|
+
Data(temp_grad=46.61, rw=0.33)
|
|
24
|
+
], description="List of input data for multiple samples.")
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from typing import List
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Data(BaseModel):
|
|
6
|
+
"""Qv input data for a single sample."""
|
|
7
|
+
vcld: float = Field(..., description="Volume of clay (fraction)")
|
|
8
|
+
phit: float = Field(..., description="Total porosity (fraction)")
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class InputData(BaseModel):
|
|
12
|
+
"""Qv input data for a batch of samples, with clay properties."""
|
|
13
|
+
rho_clay: float = Field(2.65, description="Density of clay (g/cm^3)")
|
|
14
|
+
cec_clay: float = Field(.062, description="Cation exchange capacity of clay (meq/g)")
|
|
15
|
+
data: List[Data] = Field([
|
|
16
|
+
Data(vcld=0.322, phit=0.204),
|
|
17
|
+
Data(vcld=0.608, phit=0.192),
|
|
18
|
+
Data(vcld=0.622, phit=0.144),
|
|
19
|
+
Data(vcld=0.768, phit=0.102),
|
|
20
|
+
Data(vcld=0.174, phit=0.208),
|
|
21
|
+
Data(vcld=0.018, phit=0.271),
|
|
22
|
+
Data(vcld=0.688, phit=0.125),
|
|
23
|
+
Data(vcld=0.493, phit=0.248),
|
|
24
|
+
Data(vcld=0.781, phit=0.126),
|
|
25
|
+
Data(vcld=0.731, phit=0.115)
|
|
26
|
+
], description="List of input data for multiple samples.")
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from typing import List
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Data(BaseModel):
|
|
6
|
+
"""Rw input data for a single sample."""
|
|
7
|
+
temp_grad: float = Field(..., description="Temperature gradient (C/km or F/100ft)")
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class InputData(BaseModel):
|
|
11
|
+
"""Rw input data for a batch of samples, with water salinity."""
|
|
12
|
+
water_salinity: float = Field(30000, description="Water salinity (ppm)")
|
|
13
|
+
data: List[Data] = Field([
|
|
14
|
+
Data(temp_grad=134.46224999999998),
|
|
15
|
+
Data(temp_grad=134.46625),
|
|
16
|
+
Data(temp_grad=134.47),
|
|
17
|
+
Data(temp_grad=134.47375),
|
|
18
|
+
Data(temp_grad=134.47750000000002),
|
|
19
|
+
Data(temp_grad=134.48149999999998),
|
|
20
|
+
Data(temp_grad=134.48525),
|
|
21
|
+
Data(temp_grad=134.48900000000003),
|
|
22
|
+
Data(temp_grad=134.49275),
|
|
23
|
+
Data(temp_grad=134.49649999999997)
|
|
24
|
+
], description="List of temperature gradients (C/km or F/100ft)")
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from typing import List
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Data(BaseModel):
|
|
6
|
+
"""Temperature gradient input data for a single sample."""
|
|
7
|
+
tvdss: float = Field(..., description="True vertical depth subsea (meters or feet)")
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class InputData(BaseModel):
|
|
11
|
+
"""Temperature gradient input data for a batch of samples, with measurement system."""
|
|
12
|
+
meas_system: str = Field('metric', description="Measurement system: 'metric' or 'imperial'")
|
|
13
|
+
data: List[Data] = Field([
|
|
14
|
+
Data(tvdss=4098.49),
|
|
15
|
+
Data(tvdss=4098.65),
|
|
16
|
+
Data(tvdss=4098.8),
|
|
17
|
+
Data(tvdss=4098.95),
|
|
18
|
+
Data(tvdss=4099.1),
|
|
19
|
+
Data(tvdss=4099.26),
|
|
20
|
+
Data(tvdss=4099.41),
|
|
21
|
+
Data(tvdss=4099.56),
|
|
22
|
+
Data(tvdss=4099.71),
|
|
23
|
+
Data(tvdss=4099.86)
|
|
24
|
+
], description="List of true vertical depths.")
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from typing import List
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Data(BaseModel):
|
|
6
|
+
"""Waxman-Smits input data for a single sample."""
|
|
7
|
+
rt: float = Field(..., description="True resistivity (ohm-m)")
|
|
8
|
+
rw: float = Field(..., description="Water resistivity (ohm-m)")
|
|
9
|
+
phit: float = Field(..., description="Total porosity (fraction)")
|
|
10
|
+
qv: float = Field(..., description="Cation exchange capacity per unit pore volume")
|
|
11
|
+
b: float = Field(..., description="Equivalent conductance parameter")
|
|
12
|
+
m: float = Field(..., description="Cementation exponent")
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class InputData(BaseModel):
|
|
16
|
+
"""Waxman-Smits input data for a batch of samples."""
|
|
17
|
+
data: List[Data] = Field([
|
|
18
|
+
Data(rt=1.834, rw=0.342, phit=0.148, qv=1.197, b=5.479, m=2),
|
|
19
|
+
Data(rt=2.123, rw=0.338, phit=0.122, qv=1.545, b=5.541, m=2),
|
|
20
|
+
Data(rt=12.366, rw=0.334, phit=0.459, qv=0.063, b=5.628, m=2),
|
|
21
|
+
Data(rt=2.414, rw=0.336, phit=0.107, qv=1.573, b=5.596, m=2),
|
|
22
|
+
Data(rt=3.213, rw=0.336, phit=0.12, qv=1.353, b=5.579, m=2),
|
|
23
|
+
Data(rt=3.248, rw=0.342, phit=0.229, qv=0.34, b=5.477, m=2),
|
|
24
|
+
Data(rt=1.687, rw=0.339, phit=0.133, qv=1.244, b=5.53, m=2),
|
|
25
|
+
Data(rt=2.172, rw=0.344, phit=0.125, qv=1.518, b=5.439, m=2),
|
|
26
|
+
Data(rt=1.924, rw=0.333, phit=0.39, qv=.0714, b=.6434e-3, m=2),
|
|
27
|
+
Data(rt=1.82, rw=0.341, phit=0.152, qv=1.175, b=5.494, m=2)
|
|
28
|
+
], description="List of input data for multiple samples.")
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
from fastapi import APIRouter, File, UploadFile, HTTPException
|
|
2
|
+
from typing import List
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
import os
|
|
5
|
+
import shutil
|
|
6
|
+
from hashlib import sha256
|
|
7
|
+
|
|
8
|
+
from quick_pp.las_handler import read_las_file_welly
|
|
9
|
+
|
|
10
|
+
router = APIRouter(prefix="/las_handler", tags=["File Handler"])
|
|
11
|
+
|
|
12
|
+
# Allowed file extensions
|
|
13
|
+
ALLOWED_EXTENSIONS = {".LAS", ".las"}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def validate_file_extension(filename: str):
|
|
17
|
+
_, ext = os.path.splitext(filename)
|
|
18
|
+
if ext.lower() not in ALLOWED_EXTENSIONS:
|
|
19
|
+
raise HTTPException(
|
|
20
|
+
status_code=400,
|
|
21
|
+
detail=f"Invalid file extension. Allowed extensions: {', '.join(ALLOWED_EXTENSIONS)}"
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def save_upload_file(upload_file: UploadFile, destination: Path) -> str:
|
|
26
|
+
try:
|
|
27
|
+
with destination.open("wb") as buffer:
|
|
28
|
+
shutil.copyfileobj(upload_file.file, buffer)
|
|
29
|
+
finally:
|
|
30
|
+
upload_file.file.close()
|
|
31
|
+
return destination.name
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def unique_id(upload_file: UploadFile) -> str:
|
|
35
|
+
# Read the file content and hash it directly
|
|
36
|
+
file_bytes = upload_file.file.read()
|
|
37
|
+
upload_file.file.seek(0) # Reset file pointer after reading
|
|
38
|
+
return sha256(file_bytes).hexdigest()[:8]
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def read_las_file(input_path: Path, destination: Path):
|
|
42
|
+
try:
|
|
43
|
+
with open(input_path, "rb") as f:
|
|
44
|
+
df, _ = read_las_file_welly(f)
|
|
45
|
+
df.to_parquet(destination, index=False)
|
|
46
|
+
return {'message': f"File {destination.name} processed successfully"}
|
|
47
|
+
except Exception as e:
|
|
48
|
+
raise HTTPException(status_code=500, detail=f"Error reading LAS file: {str(e)}")
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@router.post(
|
|
52
|
+
"",
|
|
53
|
+
summary="Process LAS Files",
|
|
54
|
+
description=(
|
|
55
|
+
"""
|
|
56
|
+
Processes uploaded LAS files by saving them and converting to Parquet format.
|
|
57
|
+
|
|
58
|
+
Input:
|
|
59
|
+
- files: List of LAS files uploaded as multipart/form-data. Each file must have a .las or .LAS extension.
|
|
60
|
+
|
|
61
|
+
Request:
|
|
62
|
+
- Content-Type: multipart/form-data
|
|
63
|
+
- Field: files (required) — one or more LAS files to be processed.
|
|
64
|
+
|
|
65
|
+
Example (using curl):
|
|
66
|
+
curl -X POST "<host>/las_handler" -F "files=@/path/to/file1.las" -F "files=@/path/to/file2.las"
|
|
67
|
+
|
|
68
|
+
Workflow:
|
|
69
|
+
- For each file:
|
|
70
|
+
1. Validate file extension (.las or .LAS).
|
|
71
|
+
2. Generate a unique file name using a hash of the file content and the original filename.
|
|
72
|
+
3. Save the raw LAS file to 'uploads/las/'.
|
|
73
|
+
4. Convert the LAS file to Parquet and save to 'uploads/parquet/'.
|
|
74
|
+
5. Raise HTTP 500 error if something goes wrong.
|
|
75
|
+
6. Ensure the uploaded file is closed after processing.
|
|
76
|
+
|
|
77
|
+
Returns:
|
|
78
|
+
- message: Success message listing the original filenames processed.
|
|
79
|
+
- file_paths: List of output Parquet file paths (relative to the server).
|
|
80
|
+
|
|
81
|
+
Raises:
|
|
82
|
+
- HTTPException 400: If file extension is invalid.
|
|
83
|
+
- HTTPException 500: On any processing error.
|
|
84
|
+
"""
|
|
85
|
+
),
|
|
86
|
+
operation_id="process_las_file_to_parquet",
|
|
87
|
+
)
|
|
88
|
+
async def process_las_file(files: List[UploadFile] = File(...)):
|
|
89
|
+
"""
|
|
90
|
+
Asynchronously processes a list of uploaded LAS files by saving the raw files and converting them to Parquet.
|
|
91
|
+
Args:
|
|
92
|
+
files (List[UploadFile]): Uploaded LAS files, provided by FastAPI using File(...).
|
|
93
|
+
Workflow:
|
|
94
|
+
- For each file:
|
|
95
|
+
1. Generate a unique file name using `unique_id(file)` and the original filename.
|
|
96
|
+
2. Save the raw LAS file to 'uploads/las/'.
|
|
97
|
+
3. Convert the LAS file to Parquet and save to 'uploads/parquet/'.
|
|
98
|
+
4. Raise HTTP 500 error if something goes wrong.
|
|
99
|
+
5. Ensure the uploaded file is closed after processing.
|
|
100
|
+
Returns:
|
|
101
|
+
dict: Success message and list of uploaded filenames.
|
|
102
|
+
Raises:
|
|
103
|
+
HTTPException: On error, raises HTTP 500 with a generic message.
|
|
104
|
+
Notes:
|
|
105
|
+
- Uses helper functions: `unique_id(file)`, `save_upload_file(file, path)`, and
|
|
106
|
+
`read_las_file(input_path, output_path)`.
|
|
107
|
+
- Designed as a FastAPI endpoint handler.
|
|
108
|
+
"""
|
|
109
|
+
processed_file_paths = []
|
|
110
|
+
for file in files:
|
|
111
|
+
try:
|
|
112
|
+
# Validate file extension
|
|
113
|
+
validate_file_extension(str(file.filename))
|
|
114
|
+
|
|
115
|
+
# Save the raw LAS file
|
|
116
|
+
file_name = f"{unique_id(file)}-{file.filename}"
|
|
117
|
+
raw_file_path = Path(f"uploads/las/{file_name}")
|
|
118
|
+
raw_file_path.parent.mkdir(parents=True, exist_ok=True)
|
|
119
|
+
save_upload_file(file, raw_file_path)
|
|
120
|
+
|
|
121
|
+
# Process and save the LAS file
|
|
122
|
+
file_name = file_name.split(".")[0]
|
|
123
|
+
processed_file_path = Path(f"uploads/parquet/{file_name}.parquet")
|
|
124
|
+
processed_file_path.parent.mkdir(parents=True, exist_ok=True)
|
|
125
|
+
read_las_file(raw_file_path, processed_file_path)
|
|
126
|
+
processed_file_paths.append(processed_file_path)
|
|
127
|
+
|
|
128
|
+
except Exception:
|
|
129
|
+
raise HTTPException(status_code=500, detail='Something went wrong')
|
|
130
|
+
finally:
|
|
131
|
+
file.file.close()
|
|
132
|
+
|
|
133
|
+
return {
|
|
134
|
+
"message": f"Successfuly converted the LAS files to parquet: {[file.filename for file in files]}",
|
|
135
|
+
"file_paths": processed_file_paths,
|
|
136
|
+
}
|