validate_gas_gravities
Validate gas gravity consistency and calculate missing values for PVT data quality control and gap filling in petroleum engineering analysis.
Instructions
Validate and impute missing gas gravities.
DATA VALIDATION TOOL - Checks consistency of gas gravities and calculates missing values when one is unknown.
Logic:
If sg_g provided: Calculate sg_sp from sg_g
If sg_sp provided: Calculate sg_g from sg_sp
If both provided: Validate consistency
Use Cases:
QC PVT data before analysis
Fill gaps in incomplete data
Validate separator gas measurements
Returns tuple of (sg_g, sg_sp) with calculated/validated values.
Args: request: Available gas gravities and GORs
Returns: Dictionary with validated/calculated gas gravities
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| request | Yes |
Input Schema (JSON Schema)
Implementation Reference
- The main handler function for the 'validate_gas_gravities' tool. It is decorated with @mcp.tool() and implements the validation logic by calling the external oil.check_sgs function.def validate_gas_gravities(request: CheckGasSGsRequest) -> dict: """Validate and impute missing gas gravities. **DATA VALIDATION TOOL** - Checks consistency of gas gravities and calculates missing values when one is unknown. **Logic:** - If sg_g provided: Calculate sg_sp from sg_g - If sg_sp provided: Calculate sg_g from sg_sp - If both provided: Validate consistency **Use Cases:** - QC PVT data before analysis - Fill gaps in incomplete data - Validate separator gas measurements Returns tuple of (sg_g, sg_sp) with calculated/validated values. Args: request: Available gas gravities and GORs Returns: Dictionary with validated/calculated gas gravities """ sg_g_out, sg_sp_out = oil.check_sgs( sg_g=request.sg_g if request.sg_g is not None else 0, sg_sp=request.sg_sp if request.sg_sp is not None else 0, rst=request.rst, rsp=request.rsp, sg_st=request.sg_st ) return { "sg_g_weighted_average": float(sg_g_out), "sg_sp_separator": float(sg_sp_out), "method": "Weighted average calculation", "units": "dimensionless (air=1)", "inputs": request.model_dump(), "note": "sg_g and sg_sp are now consistent and validated" }
- Pydantic model defining the input schema (CheckGasSGsRequest) used by the validate_gas_gravities tool handler.class CheckGasSGsRequest(BaseModel): """Request model for gas gravity validation/imputation.""" sg_g: Optional[float] = Field(None, description="Weighted average gas SG (optional)") sg_sp: Optional[float] = Field(None, description="Separator gas SG (optional)") rst: float = Field(..., ge=0, description="Stock tank GOR (scf/stb)") rsp: float = Field(..., ge=0, description="Separator GOR (scf/stb)") sg_st: float = Field(..., gt=0, description="Stock tank gas SG")
- src/pyrestoolbox_mcp/server.py:24-24 (registration)Invocation of register_oil_tools(mcp) in the main server setup, which defines and registers the validate_gas_gravities tool along with other oil tools.register_oil_tools(mcp)