Skip to main content
Glama

get_atmosphere_profile

Calculate atmospheric pressure, temperature, and density at specified altitudes using International Standard Atmosphere models for flight planning and aerospace analysis.

Instructions

Get atmospheric properties (pressure, temperature, density) at specified altitudes using ISA model.

Args: altitudes_m: List of altitudes in meters model_type: Atmospheric model type ('ISA' for standard, 'enhanced' for extended)

Returns: Formatted string with atmospheric profile data

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
altitudes_mYes
model_typeNoISA

Implementation Reference

  • The main handler function registered as MCP tool. It calls the core implementation, formats the output as a readable table with JSON, and handles errors.
    def get_atmosphere_profile(
        altitudes_m: list[float], model_type: Literal["ISA", "enhanced"] = "ISA"
    ) -> str:
        """Get atmospheric properties (pressure, temperature, density) at specified altitudes using ISA model.
    
        Args:
            altitudes_m: List of altitudes in meters
            model_type: Atmospheric model type ('ISA' for standard, 'enhanced' for extended)
    
        Returns:
            Formatted string with atmospheric profile data
        """
        try:
            from ..integrations.atmosphere import get_atmosphere_profile as _get_profile
    
            profile = _get_profile(altitudes_m, model_type)
    
            # Format response
            result_lines = [f"Atmospheric Profile ({model_type})", "=" * 50]
            result_lines.append(
                f"{'Alt (m)':>8} {'Press (Pa)':>12} {'Temp (K)':>9} {'Density':>10} {'Sound (m/s)':>12}"
            )
            result_lines.append("-" * 60)
    
            for point in profile:
                result_lines.append(
                    f"{point.altitude_m:8.0f} {point.pressure_pa:12.1f} {point.temperature_k:9.2f} "
                    f"{point.density_kg_m3:10.6f} {point.speed_of_sound_mps:12.1f}"
                )
    
            # Add JSON data for programmatic use
            json_data = json.dumps([p.model_dump() for p in profile], indent=2)
            result_lines.extend(["", "JSON Data:", json_data])
    
            return "\n".join(result_lines)
    
        except ImportError:
            return "Atmospheric modeling not available - install with: pip install ambiance"
        except Exception as e:
            logger.error(f"Atmosphere profile error: {str(e)}", exc_info=True)
            return f"Atmosphere profile error: {str(e)}"
  • Registration of the get_atmosphere_profile tool using FastMCP's mcp.tool().
    # Atmospheric tools
    mcp.tool(get_atmosphere_profile)
    mcp.tool(wind_model_simple)
  • Pydantic BaseModel defining the structure of each atmosphere data point returned by the core function.
    class AtmospherePoint(BaseModel):
        """Single atmosphere condition point."""
    
        altitude_m: float = Field(..., description="Geometric altitude in meters")
        pressure_pa: float = Field(..., description="Static pressure in Pascals")
        temperature_k: float = Field(..., description="Temperature in Kelvin")
        density_kg_m3: float = Field(..., description="Air density in kg/m³")
        speed_of_sound_mps: float = Field(..., description="Speed of sound in m/s")
        viscosity_pa_s: float | None = Field(None, description="Dynamic viscosity in Pa·s")
  • Core implementation that performs the actual atmosphere calculations using the 'ambiance' library or a manual ISA model fallback.
    def get_atmosphere_profile(
        altitudes_m: list[float], model_type: str = "ISA"
    ) -> list[AtmospherePoint]:
        """
        Get atmospheric properties at specified altitudes.
    
        Args:
            altitudes_m: List of geometric altitudes in meters (0-81020m when using ambiance, 0-86000m for manual ISA)
            model_type: Atmosphere model ("ISA", "COESA") - currently only ISA supported
    
        Returns:
            List of AtmospherePoint objects with pressure, temperature, density, etc.
        """
        if model_type not in ["ISA", "COESA"]:
            raise ValueError(f"Unknown model type: {model_type}. Use 'ISA' or 'COESA'")
    
        results = []
    
        for altitude in altitudes_m:
            # Use appropriate limits based on availability of ambiance library
            max_altitude = 81020 if AMBIANCE_AVAILABLE else 86000
            if altitude < 0 or altitude > max_altitude:
                range_str = f"0-{max_altitude}m"
                raise ValueError(f"Altitude {altitude}m out of ISA range ({range_str})")
    
            if AMBIANCE_AVAILABLE and model_type == "ISA":
                # Use ambiance library if available
                atm = ambiance.Atmosphere(altitude)
                point = AtmospherePoint(
                    altitude_m=altitude,
                    pressure_pa=float(atm.pressure),
                    temperature_k=float(atm.temperature),
                    density_kg_m3=float(atm.density),
                    speed_of_sound_mps=float(atm.speed_of_sound),
                    viscosity_pa_s=(
                        float(atm.dynamic_viscosity)
                        if hasattr(atm, "dynamic_viscosity")
                        else None
                    ),
                )
            else:
                # Fall back to manual calculation
                pressure, temperature, density = _isa_manual(altitude)
                speed_of_sound = math.sqrt(GAMMA * R_SPECIFIC * temperature)
    
                point = AtmospherePoint(
                    altitude_m=altitude,
                    pressure_pa=pressure,
                    temperature_k=temperature,
                    density_kg_m3=density,
                    speed_of_sound_mps=speed_of_sound,
                    viscosity_pa_s=None,  # Not calculated in manual mode
                )
    
            results.append(point)
    
        return results
  • Tool schema reference used by agent functions for input parameter descriptions and examples.
    ToolReference(
        name="get_atmosphere_profile",
        description="Calculate atmospheric conditions at various altitudes",
        parameters={
            "altitudes_m": "List[float] - List of altitudes in meters",
            "model_type": "Literal['isa', 'enhanced'] - Atmospheric model type (default 'isa')",
        },
        examples=[
            "get_atmosphere_profile([0, 1000, 5000, 10000])",
            'get_atmosphere_profile([0, 2000, 4000, 6000, 8000, 10000], "enhanced")',
        ],
    ),

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cheesejaguar/aerospace-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server