Skip to main content

A Python library for working CAAML.XML files from SnowPilot

Project description

SnowPylot

A Python library for working with CAAML.xml files containing snow pit data from SnowPilot.org.

Features

  • Parse CAAML.xml files from SnowPilot.org to access snow pit information including:
    • Core metadata (pit ID, date, location, etc.)
    • Snow profile data (layers, grain types, etc.)
    • Stability test results (ECT, CT, Rutschblock, PST)
    • Density Profile
    • Temperature Profile
    • Whumpf observations

Installation

pip install snowpylot

Or clone the repository:

git clone https://github.com/connellymk/snowpylot.git
cd snowpylot
pip install -e .

Quick Start

from snowpylot import caaml_parser

# Parse a CAAML file
snowpit = caaml_parser("path/to/snowpit.caaml.xml")

# Access basic information
print(f"Pit ID: {snowpit.coreInfo.pitID}")
print(f"Date: {snowpit.coreInfo.date}")
print(f"Location: {snowpit.coreInfo.location.latitude}, {snowpit.coreInfo.location.longitude}")

# Access snow profile data
print(f"HS: {snowpit.snowProfile.hS}")

# Access layer information
for i, layer in enumerate(snowpit.snowProfile.layers):
    print(f"Layer {i+1}: Depth {layer.depthTop}, Thickness {layer.thickness}")
    print(f"  Grain form: {layer.grainFormPrimary.grainForm}")
    print(f"  Hardness: {layer.hardness}")

# Access ECT test results
for ect in snowpit.stabilityTests.ECT:
    print(f"ECT at depth {ect.depthTop}: Score {ect.testScore}")

Documentation

This documentation provides a comprehensive overview of the SnowPit object structure and how to access its various components. The nested structure allows for logical organization of the data while maintaining easy access to all information through dot notation.

For more detailed examples, the demos directory contains Jupyter notebooks demonstrating various use cases.

SnowPit Object Structure

The SnowPit object is the main container for all snow pit data. It consists of four main components:

1. Core Info (snowpit.coreInfo)

Basic information about the snow pit:

  • pitID - Unique identifier
  • pitName - Name of the pit
  • date - Date of observation
  • comment - General comments
  • caamlVersion - Version of CAAML schema used
  • user - User information
  • location - Location information
  • weatherConditions - Weather conditions

Example:

ID = snowpit.coreInfo.pitID

User Info (snowpit.coreInfo.user)

  • operationID - ID of the operation
  • operationName - Name of the operation
  • professional - Boolean indicating if user is professional
  • userID - User identifier
  • username - SnowPilot username of the user

Example:

operationID = snowpit.coreInfo.user.operationID

Location Info (snowpit.coreInfo.location)

  • latitude - Decimal degrees
  • longitude - Decimal degrees
  • elevation - [value, units]
  • aspect - Slope aspect
  • slopeAngle - [value, units]
  • country - Country name
  • region - Region name
  • pitNearAvalanche - Boolean
  • pitNearAvalancheLocation - Location description if near avalanche

Example:

lat = snowpit.coreInfo.location.latitude

Weather Conditions (snowpit.coreInfo.weatherConditions)

  • skyCond - Sky conditions code
  • skyCond_Desc - Sky conditions description
  • precipTI - Precipitation type and intensity code
  • precipTI_Desc - Precipitation description
  • airTempPres - [temperature, units]
  • windSpeed - Wind speed code
  • windSpeed_Desc - Wind speed description
  • windDir - Wind direction

Example:

skyCond = snowpit.coreInfo.weatherConditions.skyCond

2. Snow Profile (snowpit.snowProfile)

Contains layer data and measurements:

Profile Info

  • measurementDirection - Direction of measurements
  • profileDepth - [depth, units]
  • hS - Total snow height [value, units]

Example:

measDir = snowpit.snowProfile.measurementDirection

Layers (snowpit.snowProfile.layers)

Example:

layers_list = snowpit.snowProfile.layers

List of Layer objects, each containing:

  • depthTop - [depth, units]
  • thickness - [thickness, units]
  • hardness - Hand hardness code
  • hardnessTop - Top of layer hardness
  • hardnessBottom - Bottom of layer hardness
  • wetness - Wetness code
  • wetness_Desc - Wetness description
  • layerOfConcern - Boolean
  • grainFormPrimary - grain form object representing primary grain form
  • grainFormSecondary - grain form object representing secondary grain form

Example:

depthTop_layer1 = snowpit.snowProfile.layers[0].depthTop
Grain Info (layer.grainFormPrimary or layer.grainFormSecondary)
  • grainForm - Grain form code
  • grainSizeAvg - [size, units]
  • grainSizeMax - [size, units]
  • basicGrainClass_code - Basic grain type code
  • basicGrainClass_name - Basic grain type name
  • subGrainClass_code - Detailed grain type code
  • subGrainClass_name - Detailed grain type name

Example:

primaryGrainForm_layer1 = snowpit.snowProfile.layers[0].grainFormPrimary.grainForm

Temperature Profile (snowpit.snowProfile.tempProfile)

List of temperature observations, each containing:

  • depth - [depth, units]
  • snowTemp - [temperature, units]

Example:

depth_obs1 = snowpit.snowProfile.tempProfile[0].depth

Density Profile (snowpit.snowProfile.densityProfile)

List of density observation, each containing:

  • depthTop - [depth, units]
  • thickness - [thickness, units]
  • density - [density, units]

Example:

depthTop_obs1 = snowpit.snowProfile.densityProfile[0].depthTop

3. Stability Tests (snowpit.stabilityTests)

Contains lists of different stability test results:

  • ECT - Extended Column Test
  • CT - Compression Test
  • RBlock - Rutschblock Test
  • PST - Propagation Saw Test

Example:

ECTs_list = snowpit.stabilityTests.ECT

Extended Column Test (snowpit.stabilityTests.ECT) is a list of ExtColumnTest objects

Each containing:

  • depthTop - [depth, units]
  • testScore - Test result code
  • propogation - Boolean
  • numTaps - Number of taps
  • comment - Test comments

Example:

ECT1_depthTop = snowpit.stabilityTests.ECT[0].depthTop

Compression Test (snowpit.stabilityTests.CT) is a list of ComprTest objects

Each containing:

  • depthTop - [depth, units]
  • fractureCharacter - Fracture character code
  • testScore - Test result code
  • comment - Test comments

Example:

CT1_depthTop = snowpit.stabilityTests.CT[0].depthTop

Rutschblock Test (snowpit.stabilityTests.RBlock) is a list of RBlockTest objects

Each containing:

  • depthTop - [depth, units]
  • fractureCharacter - Fracture character code
  • releaseType - Release type code
  • testScore - Test result code
  • comment - Test comments

Example:

RBlock1_depthTop = snowpit.stabilityTests.RBlock[0].depthTop

Propagation Saw Test (snowpit.stabilityTests.PST) is a list of PropSawTest objects

Each containing:

  • depthTop - [depth, units]
  • fractureProp - Propagation result
  • cutLength - [length, units]
  • columnLength - [length, units]
  • comment - Test comments

Example:

PST1_depthTop = snowpit.stabilityTests.PST[0].depthTop

4. Whumpf Data (snowpit.whumpfData)

Custom SnowPilot data about collapsing weak layers:

  • whumpfCracking - Presence of whumpf with cracking
  • whumpfNoCracking - Presence of whumpf without cracking
  • crackingNoWhumpf - Presence of cracking without whumpf
  • whumpfNearPit - Whumpf location relative to pit
  • whumpfDepthWeakLayer - Depth of weak layer
  • whumpfTriggeredRemoteAva - If whumpf triggered remote avalanche
  • whumpfSize - Size of the whumpf

Example:

whumpfCracking = snowpit.whumpfData.whumpfCracking

Advanced Usage Examples

Batch Processing Multiple Snow Pits

import os
from snowpylot import caaml_parser

# Process all CAAML files in a directory
folder_path = "path/to/snowpits"
caaml_files = [f for f in os.listdir(folder_path) if f.endswith(".xml")]

results = []
for file in caaml_files:
    file_path = os.path.join(folder_path, file)
    pit = caaml_parser(file_path)

    # Extract data of interest
    result = {
        "PitID": pit.coreInfo.pitID,
        "Date": pit.coreInfo.date,
        "Location": f"{pit.coreInfo.location.latitude}, {pit.coreInfo.location.longitude}",
        "HS": pit.snowProfile.hS,
        "LayerCount": len(pit.snowProfile.layers),
        "ECTCount": len(pit.stabilityTests.ECT)
    }
    results.append(result)

# Convert to pandas DataFrame for analysis
import pandas as pd
df = pd.DataFrame(results)
print(df.head())

Analyzing Stability Test Results

from snowpylot import caaml_parser

pit = caaml_parser("path/to/snowpit.caaml.xml")

# Analyze ECT results
for ect in pit.stabilityTests.ECT:
    print(f"ECT at depth {ect.depthTop}: Score {ect.testScore}")
    print(f"  Propagation: {ect.propogation}")
    print(f"  Number of taps: {ect.numTaps}")
    print(f"  Comment: {ect.comment}")

# Find layers of concern
for layer in pit.snowProfile.layers:
    if layer.layerOfConcern:
        print(f"Layer of concern at depth {layer.depthTop}")
        print(f"  Grain form: {layer.grainFormPrimary.grainForm}")
        print(f"  Hardness: {layer.hardness}")

Resources

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

snowpylot-1.1.0.tar.gz (23.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

snowpylot-1.1.0-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

Details for the file snowpylot-1.1.0.tar.gz.

File metadata

  • Download URL: snowpylot-1.1.0.tar.gz
  • Upload date:
  • Size: 23.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for snowpylot-1.1.0.tar.gz
Algorithm Hash digest
SHA256 e6a7bdeeab399166ec5cf479ceea12d09cfbfd7d81a42de2a73c5515691af607
MD5 525a20abdd9543960c9ecbca69082ee7
BLAKE2b-256 f0935550d1c6b6d98fce702ed4025b2782e162a91190cb7bff4c57db800a28c3

See more details on using hashes here.

File details

Details for the file snowpylot-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: snowpylot-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for snowpylot-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7df3d148c43b4f788e1df705779da8379ec9d1bbefb8242349ffbb81173075c6
MD5 34ae806c222e81b5a53670cb893924fd
BLAKE2b-256 42894da21c241234e369670de41bd0e4b4036b2c5c60dc8e6a8d5bd754a43309

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page