Utilities to use the International Standard Atmosphere. It uses the International Standard Atmosphere up to the tropopause (11 km by definition) and then extends up to the 500 km using the ARDC Model Atmosphere.
height_in, pressure_in: units of height and pressure, respectively. Possible values are "km", "m" for height and "hPa" and "Pa" for pressure. Alternatively, it can be a numeric constant that multiplied to convert the unit to meters and Pascals respectively. (E.g. if height is in feet, use height_in = 0.3048.)
n: desired number of breaks.
...: extra arguments passed to scales::breaks_extended .
name, breaks, labels, guide: arguments passed to ggplot2::sec_axis()
Details
sa_pressure(), sa_height(), sa_temperature() return, respectively, pressure (in pascals), height (in meters) and temperature (in Kelvin).
sa_height_trans() and sa_pressure_trans() are two transformation functions to be used as the trans argument in ggplot2 scales (e.g. scale_y_continuous(trans = "sa_height").
sa_height_axis() and sa_pressure_axis() return a secondary axis that transforms to height or pressure respectively to be used as ggplot2 secondary axis (e.g. scale_y_continuous(sec.axis = sa_height_axis())).
For convenience, and unlike the "primitive" functions, both the transformation functions and the axis functions input and output in hectopascals and kilometres by default.
Examples
height <- seq(0,100*1000, by =1*200)# Temperature profile that defines the standard atmosphere (in degrees Celsius)plot(sa_temperature(height)-273.15, height, type ="l")# Pressure profileplot(sa_pressure(height), height, type ="l")# Use with ggplot2library(ggplot2)data <- data.frame(height = height/1000,# height in kilometers pressure = sa_pressure(height)/100)# pressures in hectopascals# With the sa_*_axis functions, you can label the approximate height# when using isobaric coordinates#'ggplot(data, aes(height, pressure))+ geom_path()+ scale_y_continuous(sec.axis = sa_height_axis("height"))# Or the approximate pressure when using physical heightggplot(data, aes(pressure, height))+ geom_path()+ scale_y_continuous(sec.axis = sa_pressure_axis("level"))# When working with isobaric coordinates,using a linear scale exagerates# the thickness of the lower levelsggplot(temperature[lat ==0], aes(lon, lev))+ geom_contour_fill(aes(z = air))+ scale_y_reverse()# Using the standard atmospehre height transormation, the result# is an approximate linear scale in heightggplot(temperature[lat ==0], aes(lon, lev))+ geom_contour_fill(aes(z = air))+ scale_y_continuous(trans ="sa_height", expand = c(0,0))# The result is very similar to using a reverse log transform, which is the# current behaviour of scale_y_level(). This transformation slightly# overextends the higher levels.ggplot(temperature[lat ==0], aes(lon, lev))+ geom_contour_fill(aes(z = air))+ scale_y_level()