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 identifierpitName- Name of the pitdate- Date of observationcomment- General commentscaamlVersion- Version of CAAML schema useduser- User informationlocation- Location informationweatherConditions- Weather conditions
Example:
ID = snowpit.coreInfo.pitID
User Info (snowpit.coreInfo.user)
operationID- ID of the operationoperationName- Name of the operationprofessional- Boolean indicating if user is professionaluserID- User identifierusername- SnowPilot username of the user
Example:
operationID = snowpit.coreInfo.user.operationID
Location Info (snowpit.coreInfo.location)
latitude- Decimal degreeslongitude- Decimal degreeselevation- [value, units]aspect- Slope aspectslopeAngle- [value, units]country- Country nameregion- Region namepitNearAvalanche- BooleanpitNearAvalancheLocation- Location description if near avalanche
Example:
lat = snowpit.coreInfo.location.latitude
Weather Conditions (snowpit.coreInfo.weatherConditions)
skyCond- Sky conditions codeskyCond_Desc- Sky conditions descriptionprecipTI- Precipitation type and intensity codeprecipTI_Desc- Precipitation descriptionairTempPres- [temperature, units]windSpeed- Wind speed codewindSpeed_Desc- Wind speed descriptionwindDir- Wind direction
Example:
skyCond = snowpit.coreInfo.weatherConditions.skyCond
2. Snow Profile (snowpit.snowProfile)
Contains layer data and measurements:
Profile Info
measurementDirection- Direction of measurementsprofileDepth- [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 codehardnessTop- Top of layer hardnesshardnessBottom- Bottom of layer hardnesswetness- Wetness codewetness_Desc- Wetness descriptionlayerOfConcern- Boolean
Example:
depthTop_layer1 = snowpit.snowProfile.layers[0].depthTop
Grain Info (layer.grainFormPrimary or layer.grainFormSecondary)
grainForm- Grain form codegrainSizeAvg- [size, units]grainSizeMax- [size, units]basicGrainClass_code- Basic grain type codebasicGrainClass_name- Basic grain type namesubGrainClass_code- Detailed grain type codesubGrainClass_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 TestCT- Compression TestRBlock- Rutschblock TestPST- 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 codepropogation- BooleannumTaps- Number of tapscomment- 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 codetestScore- Test result codecomment- 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 codereleaseType- Release type codetestScore- Test result codecomment- 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 resultcutLength- [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 crackingwhumpfNoCracking- Presence of whumpf without crackingcrackingNoWhumpf- Presence of cracking without whumpfwhumpfNearPit- Whumpf location relative to pitwhumpfDepthWeakLayer- Depth of weak layerwhumpfTriggeredRemoteAva- If whumpf triggered remote avalanchewhumpfSize- 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
- SnowPilot.org - Source of snow pit data
- Source Code for SnowPilot
- CAAML Schema Documentation - CAAML data format specification
- Snowpack Repository - Tools built by Ron Simenhois to read and compare SNOWPACK.pro files and SnowPilot CAAML.xml files
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file snowpylot-1.0.10.tar.gz.
File metadata
- Download URL: snowpylot-1.0.10.tar.gz
- Upload date:
- Size: 20.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ae11109d52f5b68c535612e0d0987f1ab08026d06774bfce7bb7a4f512d4958
|
|
| MD5 |
ec83605fdd04ed3295e3e0a131eed4c3
|
|
| BLAKE2b-256 |
d40ca8caf4f44c63e42153e72b7271feddc0383875fa109e22cb8a37f6965aa5
|
File details
Details for the file snowpylot-1.0.10-py3-none-any.whl.
File metadata
- Download URL: snowpylot-1.0.10-py3-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6537cfb004cda87aadc783d59a0a4305cc18967e5bbb3ce7ad478ceaa48e06c3
|
|
| MD5 |
46d910c6c87683464fb1f0844a45b190
|
|
| BLAKE2b-256 |
204dfb53867d166ea0f5876c040935eceb982e374801ff51bb24c4813acd5a6b
|