Sandrose is a Python library to aid in the analysis of aeolian sand transport using wind data. It simplifies the calculation of Resulant Drift Potential and Direction, and provides access to simple polar bar plots for quick visualization.
Sandrose is available on PyPI: (eventually)
Via pip
:
$ pip install sandrose
Via poetry
:
$ poetry add sandrose
Or, install from GitHub (requires git):
$ pip install "git+https://github.com/acbuie/sandrose.git#egg=sandrose"
$ poetry add git+https://github.com/acbuie/sandrose.git#egg=sandrose
As always, it's recommended to install within a python virtual environment.
Sandrose supplies several useful functions for drift potential calculations. These are in the sandrose.dp.calc
and sandrose.dp.dp_sum
modules.
Functions for calculating per-record drift potential and the resultant drift potential and direction can be found in the sandrose.dp.calc
module. See Fryberg and Dean, 1979 for more.
drift_potential()
: Calculate the per-record drift potential.time_perc()
: Calculate t used in drift potential calculations. It is the time the wind blew expressed as a ratio of the total time of all measurements.rdp_rdd()
: Calculate the resultant drift potential and resultant drift direction.
There are currently 5 different methods to sum per-record drift potentials, and can be found in the sandrose.dp.dp_sum
module.
sum_monthly()
: Sum all drift potential values, while binning montly and directionally (into 16 compass directions).sum_seasonally()
: Sum dp values, binning seasonally (meteorological) and directionally.sum_yearly()
: Sum dp values, binning yearly and directionally.sum_all()
: Sum dp values without time binning, but with directional binning.sum_dp()
: Sum dp values without time binning or directional binning. Useful for finding RDP/DP ratio.
import pandas as pd
from sandrose import dp
# data has datetime col "date", wind col "vals", and direction col "str_dir"
t = dp.calc.time_perc(pd.Timedelta(10, unit="m"), data["date"])
data["dp"] = dp.calc.drift_potential(data["vals"], t)
all_dp = dp.dp_sum.sum_dp(data["dp"])
# Bin dp only via compass direction
grouped = dp.dp_sum.sum_all(
data["date"],
data["dp"],
data["str_dir"],
)
dp_all = dp.calc.rdp_rdd(grouped, all_dp)
print(dp_all)
fancy image output
from sandrose import conversions
These functions are supplied as a means to normalize wind data recorded at varying elevations.
wind_data = pd.Series([5.0, 8.0, 10.0, 6.0, 9.0])
# Adjust records from 10.0m velocities to 80.0m velocities
conversions.wind_log_law(wind_data, z_rec=10.0, z_ref=80.0)
conversions.wind_power_law(wind_data, z_rec=10.0, z_ref=80.0)
fancy image output
The default (and currently only supported) binning method places each drift potential calculation into one of the 16 carindal compass directions. Should your data only supply numerical degree direction, conversions.degree_to_cardinal
will convert the data into the required format.
# Supports angles over 360°, as well as 0° or 360° for North
angles = pd.Series([360, 100, 90, 220, 0, 300, 400])
conversions.degree_to_cardinal(angles)
fancy image output
sandrose.dp.calc_time_percentage()
calculates the total time range of all records by constructing a pd.Timedelta
object from the most recent record and the oldest record. This assumes the dataframe column passed contains np.datetime64
(or other valid datetime) data types.
Some useful pandas functions related to datetimes:
-
pd.to_datetime()
: Converts a pandas Series intonp.datetime64
datatype. Read more here. See here for datetime formating options. -
DataFrame.sort_values()
: Not unique to datetimes, but can be used to sort the data via datetime. Read more here.
Coming soon!
This work is licensed under the GNU GPLv3 license.
See here.