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.core_info.pit_id}")
print(f"Date: {snowpit.core_info.date}")
print(f"Location: {snowpit.core_info.location.latitude}, {snowpit.core_info.location.longitude}")
# Access snow profile data
print(f"HS: {snowpit.snow_profile.hs}")
# Access layer information
for i, layer in enumerate(snowpit.snow_profile.layers):
print(f"Layer {i+1}: Depth {layer.depth_top}, Thickness {layer.thickness}")
print(f" Grain form: {layer.grain_form_primary.grain_form}")
print(f" Hardness: {layer.hardness}")
# Access ECT test results
for ect in snowpit.stability_tests.ECT:
print(f"ECT at depth {ect.depth_top}: Score {ect.test_score}")
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.core_info)
Basic information about the snow pit:
pit_id- Unique identifierpit_name- Name of the pitdate- Date of observationcomment- General commentscaaml_version- Version of CAAML schema useduser- User informationlocation- Location informationweather_conditions- Weather conditions
Example:
ID = snowpit.core_info.pit_id
User Info (snowpit.core_info.user)
operation_id- ID of the operationoperation_name- Name of the operationprofessional- Boolean indicating if user is professionaluser_id- User identifierusername- SnowPilot username of the user
Example:
operationID = snowpit.core_info.user.operation_id
Location Info (snowpit.core_info.location)
latitude- Decimal degreeslongitude- Decimal degreeselevation- [value, units]aspect- Slope aspectslope_angle- [value, units]country- Country nameregion- Region namepit_near_avalanche- Booleanpit_near_avalanche_location- Location description if near avalanche
Example:
lat = snowpit.core_info.location.latitude
Weather Conditions (snowpit.core_info.weather_conditions)
sky_cond- Sky conditions codesky_cond_desc- Sky conditions descriptionprecip_ti- Precipitation type and intensity codeprecip_ti_desc- Precipitation descriptionair_temp_pres- [temperature, units]wind_speed- Wind speed codewind_speed_desc- Wind speed descriptionwind_dir- Wind direction
Example:
skyCond = snowpit.core_info.weather_conditions.sky_cond
2. Snow Profile (snowpit.snow_profile)
Contains layer data and measurements:
Profile Info
measurement_direction- Direction of measurementsprofile_depth- [depth, units]hs- Total snow height [value, units]
Example:
measDir = snowpit.snow_profile.measurement_direction
Layers (snowpit.snow_profile.layers)
Example:
layers_list = snowpit.snow_profile.layers
List of Layer objects, each containing:
depth_top- [depth, units]thickness- [thickness, units]hardness- Hand hardness codehardness_top- Top of layer hardnesshardness_bottom- Bottom of layer hardnesswetness- Wetness codewetness_desc- Wetness descriptionlayer_of_concern- Booleangrain_form_primary- grain form object representing primary grain formgrain_form_secondary- grain form object representing secondary grain form
Example:
depthTop_layer1 = snowpit.snow_profile.layers[0].depth_top
Grain Info (layer.grain_form_primary or layer.grain_form_secondary)
grain_form- Grain form codegrain_size_avg- [size, units]grain_size_max- [size, units]basic_grain_class_code- Basic grain type codebasic_grain_class_name- Basic grain type namesub_grain_class_code- Detailed grain type codesub_grain_class_name- Detailed grain type name
Example:
primaryGrainForm_layer1 = snowpit.snow_profile.layers[0].grain_form_primary.grain_form
Temperature Profile (snowpit.snow_profile.temp_profile)
List of temperature observations, each containing:
depth- [depth, units]snow_temp- [temperature, units]
Example:
depth_obs1 = snowpit.snow_profile.temp_profile[0].depth
Density Profile (snowpit.snow_profile.density_profile)
List of density observation, each containing:
depth_top- [depth, units]thickness- [thickness, units]density- [density, units]
Example:
depthTop_obs1 = snowpit.snow_profile.density_profile[0].depth_top
3. Stability Tests (snowpit.stability_tests)
Contains lists of different stability test results:
ECT- Extended Column TestCT- Compression TestRBlock- Rutschblock TestPST- Propagation Saw Test
Example:
ECTs_list = snowpit.stability_tests.ECT
Extended Column Test (snowpit.stability_tests.ECT) is a list of ExtColumnTest objects
Each containing:
depth_top- [depth, units]test_score- Test result codepropagation- Booleannum_taps- Number of tapscomment- Test comments
Example:
ECT1_depthTop = snowpit.stability_tests.ECT[0].depth_top
Compression Test (snowpit.stability_tests.CT) is a list of ComprTest objects
Each containing:
depth_top- [depth, units]fracture_character- Fracture character codetest_score- Test result codecomment- Test comments
Example:
CT1_depthTop = snowpit.stability_tests.CT[0].depth_top
Rutschblock Test (snowpit.stability_tests.RBlock) is a list of RBlockTest objects
Each containing:
depth_top- [depth, units]fracture_character- Fracture character coderelease_type- Release type codetest_score- Test result codecomment- Test comments
Example:
RBlock1_depthTop = snowpit.stability_tests.RBlock[0].depth_top
Propagation Saw Test (snowpit.stability_tests.PST) is a list of PropSawTest objects
Each containing:
depth_top- [depth, units]fracture_prop- Propagation resultcut_length- [length, units]column_length- [length, units]comment- Test comments
Example:
PST1_depthTop = snowpit.stability_tests.PST[0].depth_top
4. Whumpf Data (snowpit.whumpf_data)
Custom SnowPilot data about collapsing weak layers:
whumpf_cracking- Presence of whumpf with crackingwhumpf_no_cracking- Presence of whumpf without crackingcracking_no_whumpf- Presence of cracking without whumpfwhumpf_near_pit- Whumpf location relative to pitwhumpf_depth_weak_layer- Depth of weak layerwhumpf_triggered_remote_ava- If whumpf triggered remote avalanchewhumpf_size- Size of the whumpf
Example:
whumpfCracking = snowpit.whumpf_data.whumpf_cracking
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.core_info.pit_id,
"Date": pit.core_info.date,
"Location": f"{pit.core_info.location.latitude}, {pit.core_info.location.longitude}",
"HS": pit.snow_profile.hs,
"LayerCount": len(pit.snow_profile.layers),
"ECTCount": len(pit.stability_tests.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.stability_tests.ECT:
print(f"ECT at depth {ect.depth_top}: Score {ect.test_score}")
print(f" Propagation: {ect.propagation}")
print(f" Number of taps: {ect.num_taps}")
print(f" Comment: {ect.comment}")
# Find layers of concern
for layer in pit.snow_profile.layers:
if layer.layer_of_concern:
print(f"Layer of concern at depth {layer.depth_top}")
print(f" Grain form: {layer.grain_form_primary.grain_form}")
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.1.1.tar.gz.
File metadata
- Download URL: snowpylot-1.1.1.tar.gz
- Upload date:
- Size: 22.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d53832150d65deebddd092d80079aa6d0f1c130d369253ddff1fed99f839e87c
|
|
| MD5 |
5e906fcfae2b7a3fe57e74a05dc7ea8c
|
|
| BLAKE2b-256 |
12b3cad56fa4f8280aba5060972a9880d766d56f4c4ab35b0487065cd34eca8d
|
File details
Details for the file snowpylot-1.1.1-py3-none-any.whl.
File metadata
- Download URL: snowpylot-1.1.1-py3-none-any.whl
- Upload date:
- Size: 18.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e01d91df267d38b632193de093230ce1953a7f12aa336dfbcf325eacc0f7e7c0
|
|
| MD5 |
04b4a7053772629c9ec1afdbc28aa9f0
|
|
| BLAKE2b-256 |
0201781b1b5a61963f82e5a54da5119c7bf6c2c00c5ba80f38a95eb19ac2b299
|