33个版本
0.11.1 | 2019年8月30日 |
---|---|
0.11.0 | 2019年5月7日 |
0.10.0 | 2019年1月13日 |
0.9.2 | 2018年12月25日 |
0.1.0 | 2017年11月30日 |
#5 in #声学
每月 85 次下载
用于 sounding-validate
55KB
630 代码行
该包整体已弃用,其功能已移至 sounding-analysis 包。迁移的原因是这两个包几乎从未单独使用过,并且在这个包中的更改需要版本号提升,这将需要所有依赖它的包的版本号提升。维护相关包变得非常繁琐。
声学基础库
相关包
表示以压力为垂直坐标的气象声学的库。基本包旨在成为其他包构建的共同基础。这些包可能用于管理数据存储、显示数据或保存和加载文件。
该包的重点是数据表示和使用声学数据构建和使用的通用类型。
示例
use optional::{Optioned, some};
use metfor::{HectoPascal, Celsius, Feet};
use sounding_base::{Sounding, StationInfo};
fn main() {
// Create pressure profile
let pressure_profile: Vec<Optioned<HectoPascal>> =
vec![1000.0, 925.0, 850.0, 700.0, 500.0, 300.0, 250.0, 100.0]
.into_iter()
.map(HectoPascal)
.map(some)
.collect();
// Create a temperature profile
let temperature_profile: Vec<Optioned<Celsius>> =
vec![13.0, 7.0, 5.0, -4.5, -20.6, -44.0, -52.0, -56.5]
.into_iter()
.map(Celsius)
.map(some)
.collect();
// Create some station info
let stn = StationInfo::new_with_values(None, (45.6789, -115.6789), Feet(992.0));
// Create a valid time. This uses a `chrono::NaiveDateTime`, and you should always assume
// that valid times are in UTC.
let vt = chrono::NaiveDate::from_ymd(2018,3,8).and_hms(12,0,0);
// Use the builder pattern to construct a sounding.
let snd = Sounding::new()
.with_station_info(stn)
.with_valid_time(vt)
.with_lead_time(24) // Lead time in hours for forecast soundings.
.with_pressure_profile(pressure_profile)
.with_temperature_profile(temperature_profile)
.with_station_pressure(some(HectoPascal(1013.25)))
.with_sfc_temperature(some(Celsius(15.0)));
// Top down and bottom up iterators are provided. If surface data is available, it is
// inserted into the profile.
let mut iter = snd.top_down();
let mut data_row = iter.next().unwrap();
assert_eq!(data_row.pressure, some(HectoPascal(100.0)));
assert_eq!(data_row.temperature, some(Celsius(-56.5)));
data_row = iter.next().unwrap();
assert_eq!(data_row.pressure, some(HectoPascal(250.0)));
assert_eq!(data_row.temperature, some(Celsius(-52.0)));
data_row = iter.next().unwrap();
assert_eq!(data_row.pressure, some(HectoPascal(300.0)));
assert_eq!(data_row.temperature, some(Celsius(-44.0)));
data_row = iter.next().unwrap();
assert_eq!(data_row.pressure, some(HectoPascal(500.0)));
assert_eq!(data_row.temperature, some(Celsius(-20.6)));
data_row = iter.next().unwrap();
assert_eq!(data_row.pressure, some(HectoPascal(700.0)));
assert_eq!(data_row.temperature, some(Celsius(-4.5)));
data_row = iter.next().unwrap();
assert_eq!(data_row.pressure, some(HectoPascal(850.0)));
assert_eq!(data_row.temperature, some(Celsius(5.0)));
data_row = iter.next().unwrap();
assert_eq!(data_row.pressure, some(HectoPascal(925.0)));
assert_eq!(data_row.temperature, some(Celsius(7.0)));
data_row = iter.next().unwrap();
assert_eq!(data_row.pressure, some(HectoPascal(1000.0)));
assert_eq!(data_row.temperature, some(Celsius(13.0)));
// THIS ONE IS THE SURFACE DATA!
data_row = iter.next().unwrap();
assert_eq!(data_row.pressure, some(HectoPascal(1013.25)));
assert_eq!(data_row.temperature, some(Celsius(15.0)));
assert_eq!(iter.next(), None);
// Profiles and surface values can also be accessed via getter methods. Read the docs!
}
你可能在示例中看到了很多 optional::Optioned
。基本上,任何东西都可能缺失,缺失值在高层大气声学中很常见。例如,在高层大气中,露点或湿度通常缺失(如果不完全不准确)。
依赖关系
~3MB
~21K SLoC