Learn R Programming

sarp.snowprofile (version 1.3.2)

snowprofileCaaml: Read a Caaml file into a snowprofile object

Description

Note, that this function only provides a starting point for loading caaml files into R. Currently, caaml files exported from niviz.org, or snowpilot.org should be compatible with this routine. However, this routine only extracts some metadata and some of the most important layer characteristics. While a temperature profile (that is independent from the layers) is extracted, no other variables that can be written into a caaml file are currently being read (such as stability test results, etc).

Usage

snowprofileCaaml(
  caamlFile,
  sourceType = NA,
  readStabilityTests = TRUE,
  validate = TRUE
)

Value

snowprofile object

Arguments

caamlFile

'path/to/file.caaml'

sourceType

choose 'manual', 'modeled', 'vstation', 'aggregate' or 'whiteboard'; while this routine has some functionality built in to detect sourceTypes under certain circumstances, it needs to be provided in most cases.

readStabilityTests

boolean (this is still beta version and can throw errors sometimes)

validate

Should the resulting snowprofile object be validated by validate_snowprofile?

Author

fherla

Details

  • There is still a bug related to non-numeric aspects (e.g., E instead of 90).

  • The snowprofileCsv function provides a lot more flexibility to read in data, if you can choose the format of your underlying data. Don't hesitate to reach out though if your caaml files throw errors and you need help! If you extend this routine, please also reach out and let us know, so we can update this package with your code extensions.

Examples

Run this code

## load example caaml file that ships with package:
caamlFile <- system.file('extdata', 'example.caaml', package = 'sarp.snowprofile')

## read caaml file:
profile <- snowprofileCaaml(caamlFile, sourceType = 'vstation')

## other file with slighlty different xml namespace, structure, etc (including stability test):
caamlFile2 <- system.file('extdata', 'example2.caaml', package = 'sarp.snowprofile')
profile2 <- snowprofileCaaml(caamlFile2, sourceType = 'manual')

Run the code above in your browser using DataLab