-
Notifications
You must be signed in to change notification settings - Fork 186
/
Units.jl
143 lines (103 loc) 路 3.01 KB
/
Units.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
module Units
export Time, second, minute, hour, day, meter, kilometer,
seconds, minutes, hours, days, meters, kilometers,
KiB, MiB, GiB, TiB
#####
##### Convenient definitions
#####
"""
second
A `Float64` constant equal to 1.0. Useful for increasing the clarity of scripts, e.g. `螖t = 1second`.
"""
const second = 1.0
"""
seconds
A `Float64` constant equal to 1.0. Useful for increasing the clarity of scripts, e.g. `螖t = 7seconds`.
"""
const seconds = second
"""
minute
A `Float64` constant equal to 60`seconds`. Useful for increasing the clarity of scripts, e.g. `螖t = 1minute`.
"""
const minute = 60seconds
"""
minutes
A `Float64` constant equal to 60`seconds`. Useful for increasing the clarity of scripts, e.g. `螖t = 15minutes`.
"""
const minutes = minute
"""
hour
A `Float64` constant equal to 60`minutes`. Useful for increasing the clarity of scripts, e.g. `螖t = 1hour`.
"""
const hour = 60minutes
"""
hours
A `Float64` constant equal to 60`minutes`. Useful for increasing the clarity of scripts, e.g. `螖t = 3hours`.
"""
const hours = hour
"""
day
A `Float64` constant equal to 24`hours`. Useful for increasing the clarity of scripts, e.g. `stop_time = 1day`.
"""
const day = 24hours
"""
days
A `Float64` constant equal to 24`hours`. Useful for increasing the clarity of scripts, e.g. `stop_time = 7days`.
"""
const days = day
"""
meter
A `Float64` constant equal to 1.0. Useful for increasing the clarity of scripts, e.g. `Lx = 1meter`.
"""
const meter = 1.0
"""
meters
A `Float64` constant equal to 1.0. Useful for increasing the clarity of scripts, e.g. `Lx = 50meters`.
"""
const meters = meter
"""
kilometer
A `Float64` constant equal to 1000`meters`. Useful for increasing the clarity of scripts, e.g. `Lx = 1kilometer`.
"""
const kilometer = 1000meters
"""
kilometers
A `Float64` constant equal to 1000`meters`. Useful for increasing the clarity of scripts, e.g. `Lx = 5000kilometers`.
"""
const kilometers = kilometer
"""
KiB
A `Float64` constant equal to 1024.0. Useful for increasing the clarity of scripts, e.g. `max_filesize = 250KiB`.
"""
const KiB = 1024.0
"""
MiB
A `Float64` constant equal to 1024`KiB`. Useful for increasing the clarity of scripts, e.g. `max_filesize = 100MiB`.
"""
const MiB = 1024KiB
"""
GiB
A `Float64` constant equal to 1024`MiB`. Useful for increasing the clarity of scripts, e.g. `max_filesize = 50GiB`.
"""
const GiB = 1024MiB
"""
TiB
A `Float64` constant equal to 1024`GiB`. Useful for increasing the clarity of scripts, e.g. `max_filesize = 2TiB`.
"""
const TiB = 1024GiB
"""
Time(t)
Return a time "selector" at the continuous time `t` for linearly interpolating `FieldTimeSeries`.
Examples
=======
```julia
# Interpolate `field_time_series` to `t=0.1`, returning `interpolated::Field`
interpolated = field_time_series[Time(0.1)]
# Interpolate `field_time_series` at `i, j, k` and `t=0.1`
interpolated_ijk = field_time_series[i, j, k, Time(0.1)]
```
"""
struct Time{T}
time :: T
end
end # module