pycontrails 0.58.0__cp314-cp314-macosx_10_13_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pycontrails might be problematic. Click here for more details.
- pycontrails/__init__.py +70 -0
- pycontrails/_version.py +34 -0
- pycontrails/core/__init__.py +30 -0
- pycontrails/core/aircraft_performance.py +679 -0
- pycontrails/core/airports.py +228 -0
- pycontrails/core/cache.py +889 -0
- pycontrails/core/coordinates.py +174 -0
- pycontrails/core/fleet.py +483 -0
- pycontrails/core/flight.py +2185 -0
- pycontrails/core/flightplan.py +228 -0
- pycontrails/core/fuel.py +140 -0
- pycontrails/core/interpolation.py +702 -0
- pycontrails/core/met.py +2931 -0
- pycontrails/core/met_var.py +387 -0
- pycontrails/core/models.py +1321 -0
- pycontrails/core/polygon.py +549 -0
- pycontrails/core/rgi_cython.cpython-314-darwin.so +0 -0
- pycontrails/core/vector.py +2249 -0
- pycontrails/datalib/__init__.py +12 -0
- pycontrails/datalib/_met_utils/metsource.py +746 -0
- pycontrails/datalib/ecmwf/__init__.py +73 -0
- pycontrails/datalib/ecmwf/arco_era5.py +345 -0
- pycontrails/datalib/ecmwf/common.py +114 -0
- pycontrails/datalib/ecmwf/era5.py +554 -0
- pycontrails/datalib/ecmwf/era5_model_level.py +490 -0
- pycontrails/datalib/ecmwf/hres.py +804 -0
- pycontrails/datalib/ecmwf/hres_model_level.py +466 -0
- pycontrails/datalib/ecmwf/ifs.py +287 -0
- pycontrails/datalib/ecmwf/model_levels.py +435 -0
- pycontrails/datalib/ecmwf/static/model_level_dataframe_v20240418.csv +139 -0
- pycontrails/datalib/ecmwf/variables.py +268 -0
- pycontrails/datalib/geo_utils.py +261 -0
- pycontrails/datalib/gfs/__init__.py +28 -0
- pycontrails/datalib/gfs/gfs.py +656 -0
- pycontrails/datalib/gfs/variables.py +104 -0
- pycontrails/datalib/goes.py +757 -0
- pycontrails/datalib/himawari/__init__.py +27 -0
- pycontrails/datalib/himawari/header_struct.py +266 -0
- pycontrails/datalib/himawari/himawari.py +667 -0
- pycontrails/datalib/landsat.py +589 -0
- pycontrails/datalib/leo_utils/__init__.py +5 -0
- pycontrails/datalib/leo_utils/correction.py +266 -0
- pycontrails/datalib/leo_utils/landsat_metadata.py +300 -0
- pycontrails/datalib/leo_utils/search.py +250 -0
- pycontrails/datalib/leo_utils/sentinel_metadata.py +748 -0
- pycontrails/datalib/leo_utils/static/bq_roi_query.sql +6 -0
- pycontrails/datalib/leo_utils/vis.py +59 -0
- pycontrails/datalib/sentinel.py +650 -0
- pycontrails/datalib/spire/__init__.py +5 -0
- pycontrails/datalib/spire/exceptions.py +62 -0
- pycontrails/datalib/spire/spire.py +604 -0
- pycontrails/ext/bada.py +42 -0
- pycontrails/ext/cirium.py +14 -0
- pycontrails/ext/empirical_grid.py +140 -0
- pycontrails/ext/synthetic_flight.py +431 -0
- pycontrails/models/__init__.py +1 -0
- pycontrails/models/accf.py +425 -0
- pycontrails/models/apcemm/__init__.py +8 -0
- pycontrails/models/apcemm/apcemm.py +983 -0
- pycontrails/models/apcemm/inputs.py +226 -0
- pycontrails/models/apcemm/static/apcemm_yaml_template.yaml +183 -0
- pycontrails/models/apcemm/utils.py +437 -0
- pycontrails/models/cocip/__init__.py +29 -0
- pycontrails/models/cocip/cocip.py +2742 -0
- pycontrails/models/cocip/cocip_params.py +305 -0
- pycontrails/models/cocip/cocip_uncertainty.py +291 -0
- pycontrails/models/cocip/contrail_properties.py +1530 -0
- pycontrails/models/cocip/output_formats.py +2270 -0
- pycontrails/models/cocip/radiative_forcing.py +1260 -0
- pycontrails/models/cocip/radiative_heating.py +520 -0
- pycontrails/models/cocip/unterstrasser_wake_vortex.py +508 -0
- pycontrails/models/cocip/wake_vortex.py +396 -0
- pycontrails/models/cocip/wind_shear.py +120 -0
- pycontrails/models/cocipgrid/__init__.py +9 -0
- pycontrails/models/cocipgrid/cocip_grid.py +2552 -0
- pycontrails/models/cocipgrid/cocip_grid_params.py +138 -0
- pycontrails/models/dry_advection.py +602 -0
- pycontrails/models/emissions/__init__.py +21 -0
- pycontrails/models/emissions/black_carbon.py +599 -0
- pycontrails/models/emissions/emissions.py +1353 -0
- pycontrails/models/emissions/ffm2.py +336 -0
- pycontrails/models/emissions/static/default-engine-uids.csv +239 -0
- pycontrails/models/emissions/static/edb-gaseous-v29b-engines.csv +596 -0
- pycontrails/models/emissions/static/edb-nvpm-v29b-engines.csv +215 -0
- pycontrails/models/extended_k15.py +1327 -0
- pycontrails/models/humidity_scaling/__init__.py +37 -0
- pycontrails/models/humidity_scaling/humidity_scaling.py +1075 -0
- pycontrails/models/humidity_scaling/quantiles/era5-model-level-quantiles.pq +0 -0
- pycontrails/models/humidity_scaling/quantiles/era5-pressure-level-quantiles.pq +0 -0
- pycontrails/models/issr.py +210 -0
- pycontrails/models/pcc.py +326 -0
- pycontrails/models/pcr.py +154 -0
- pycontrails/models/ps_model/__init__.py +18 -0
- pycontrails/models/ps_model/ps_aircraft_params.py +381 -0
- pycontrails/models/ps_model/ps_grid.py +701 -0
- pycontrails/models/ps_model/ps_model.py +1000 -0
- pycontrails/models/ps_model/ps_operational_limits.py +525 -0
- pycontrails/models/ps_model/static/ps-aircraft-params-20250328.csv +69 -0
- pycontrails/models/ps_model/static/ps-synonym-list-20250328.csv +104 -0
- pycontrails/models/sac.py +442 -0
- pycontrails/models/tau_cirrus.py +183 -0
- pycontrails/physics/__init__.py +1 -0
- pycontrails/physics/constants.py +117 -0
- pycontrails/physics/geo.py +1138 -0
- pycontrails/physics/jet.py +968 -0
- pycontrails/physics/static/iata-cargo-load-factors-20250221.csv +74 -0
- pycontrails/physics/static/iata-passenger-load-factors-20250221.csv +74 -0
- pycontrails/physics/thermo.py +551 -0
- pycontrails/physics/units.py +472 -0
- pycontrails/py.typed +0 -0
- pycontrails/utils/__init__.py +1 -0
- pycontrails/utils/dependencies.py +66 -0
- pycontrails/utils/iteration.py +13 -0
- pycontrails/utils/json.py +187 -0
- pycontrails/utils/temp.py +50 -0
- pycontrails/utils/types.py +163 -0
- pycontrails-0.58.0.dist-info/METADATA +180 -0
- pycontrails-0.58.0.dist-info/RECORD +122 -0
- pycontrails-0.58.0.dist-info/WHEEL +6 -0
- pycontrails-0.58.0.dist-info/licenses/LICENSE +178 -0
- pycontrails-0.58.0.dist-info/licenses/NOTICE +43 -0
- pycontrails-0.58.0.dist-info/top_level.txt +3 -0
|
@@ -0,0 +1,1530 @@
|
|
|
1
|
+
"""Contrail Property Calculations."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
from typing import Any, overload
|
|
7
|
+
|
|
8
|
+
import numpy as np
|
|
9
|
+
import numpy.typing as npt
|
|
10
|
+
|
|
11
|
+
from pycontrails.models.cocip import radiative_heating
|
|
12
|
+
from pycontrails.physics import constants, thermo, units
|
|
13
|
+
|
|
14
|
+
logger = logging.getLogger(__name__)
|
|
15
|
+
|
|
16
|
+
####################
|
|
17
|
+
# Initial Contrail Properties
|
|
18
|
+
####################
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def initial_iwc(
|
|
22
|
+
air_temperature: npt.NDArray[np.floating],
|
|
23
|
+
specific_humidity: npt.NDArray[np.floating],
|
|
24
|
+
air_pressure: npt.NDArray[np.floating],
|
|
25
|
+
fuel_dist: npt.NDArray[np.floating],
|
|
26
|
+
width: npt.NDArray[np.floating],
|
|
27
|
+
depth: npt.NDArray[np.floating],
|
|
28
|
+
ei_h2o: float,
|
|
29
|
+
) -> npt.NDArray[np.floating]:
|
|
30
|
+
r"""
|
|
31
|
+
Estimate the initial contrail ice water content (iwc) before the wake vortex phase.
|
|
32
|
+
|
|
33
|
+
Note that the ice water content is replaced by zero if it is negative (dry air),
|
|
34
|
+
and this will end the contrail life-cycle in subsequent steps.
|
|
35
|
+
|
|
36
|
+
Parameters
|
|
37
|
+
----------
|
|
38
|
+
air_temperature : npt.NDArray[np.floating]
|
|
39
|
+
ambient temperature for each waypoint, [:math:`K`]
|
|
40
|
+
specific_humidity : npt.NDArray[np.floating]
|
|
41
|
+
ambient specific humidity for each waypoint, [:math:`kg_{H_{2}O}/kg_{air}`]
|
|
42
|
+
air_pressure : npt.NDArray[np.floating]
|
|
43
|
+
initial pressure altitude at each waypoint, before the wake vortex phase, [:math:`Pa`]
|
|
44
|
+
fuel_dist : npt.NDArray[np.floating]
|
|
45
|
+
fuel consumption of the flight segment per distance traveled, [:math:`kg m^{-1}`]
|
|
46
|
+
width : npt.NDArray[np.floating]
|
|
47
|
+
initial contrail width, [:math:`m`]
|
|
48
|
+
depth : npt.NDArray[np.floating]
|
|
49
|
+
initial contrail depth, [:math:`m`]
|
|
50
|
+
ei_h2o : float
|
|
51
|
+
water vapor emissions index of fuel, [:math:`kg_{H_{2}O} \ kg_{fuel}^{-1}`]
|
|
52
|
+
|
|
53
|
+
Returns
|
|
54
|
+
-------
|
|
55
|
+
npt.NDArray[np.floating]
|
|
56
|
+
Initial contrail ice water content (iwc) at the original waypoint
|
|
57
|
+
before the wake vortex phase, [:math:`kg_{H_{2}O}/kg_{air}`].
|
|
58
|
+
Returns zero if iwc is is negative (dry air).
|
|
59
|
+
"""
|
|
60
|
+
q_sat = thermo.q_sat_ice(air_temperature, air_pressure)
|
|
61
|
+
q_exhaust_ = q_exhaust(air_temperature, air_pressure, fuel_dist, width, depth, ei_h2o)
|
|
62
|
+
return np.maximum(q_exhaust_ + specific_humidity - q_sat, 0.0)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def q_exhaust(
|
|
66
|
+
air_temperature: npt.NDArray[np.floating],
|
|
67
|
+
air_pressure: npt.NDArray[np.floating],
|
|
68
|
+
fuel_dist: npt.NDArray[np.floating],
|
|
69
|
+
width: npt.NDArray[np.floating],
|
|
70
|
+
depth: npt.NDArray[np.floating],
|
|
71
|
+
ei_h2o: float,
|
|
72
|
+
) -> npt.NDArray[np.floating]:
|
|
73
|
+
r"""
|
|
74
|
+
Calculate the specific humidity released by water vapor from aircraft emissions.
|
|
75
|
+
|
|
76
|
+
Parameters
|
|
77
|
+
----------
|
|
78
|
+
air_temperature : npt.NDArray[np.floating]
|
|
79
|
+
ambient temperature for each waypoint, [:math:`K`]
|
|
80
|
+
air_pressure : npt.NDArray[np.floating]
|
|
81
|
+
initial pressure altitude at each waypoint, before the wake vortex phase, [:math:`Pa`]
|
|
82
|
+
fuel_dist : npt.NDArray[np.floating]
|
|
83
|
+
fuel consumption of the flight segment per distance travelled, [:math:`kg m^{-1}`]
|
|
84
|
+
width : npt.NDArray[np.floating]
|
|
85
|
+
initial contrail width, [:math:`m`]
|
|
86
|
+
depth : npt.NDArray[np.floating]
|
|
87
|
+
initial contrail depth, [:math:`m`]
|
|
88
|
+
ei_h2o : float
|
|
89
|
+
water vapor emissions index of fuel, [:math:`kg_{H_{2}O} \ kg_{fuel}^{-1}`]
|
|
90
|
+
|
|
91
|
+
Returns
|
|
92
|
+
-------
|
|
93
|
+
npt.NDArray[np.floating]
|
|
94
|
+
Humidity released by water vapour from aircraft emissions, [:math:`kg_{H_{2}O}/kg_{air}`]
|
|
95
|
+
"""
|
|
96
|
+
rho_air = thermo.rho_d(air_temperature, air_pressure)
|
|
97
|
+
return (ei_h2o * fuel_dist) / ((np.pi / 4.0) * width * depth * rho_air)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def iwc_adiabatic_heating(
|
|
101
|
+
air_temperature: npt.NDArray[np.floating],
|
|
102
|
+
air_pressure: npt.NDArray[np.floating],
|
|
103
|
+
air_pressure_1: npt.NDArray[np.floating],
|
|
104
|
+
) -> npt.NDArray[np.floating]:
|
|
105
|
+
"""
|
|
106
|
+
Calculate the change in ice water content due to adiabatic heating from the wake vortex phase.
|
|
107
|
+
|
|
108
|
+
Parameters
|
|
109
|
+
----------
|
|
110
|
+
air_temperature : npt.NDArray[np.floating]
|
|
111
|
+
ambient temperature for each waypoint, [:math:`K`]
|
|
112
|
+
air_pressure : npt.NDArray[np.floating]
|
|
113
|
+
initial pressure altitude at each waypoint, before the wake vortex phase, [:math:`Pa`]
|
|
114
|
+
air_pressure_1 : npt.NDArray[np.floating]
|
|
115
|
+
pressure altitude at each waypoint, after the wake vortex phase, [:math:`Pa`]
|
|
116
|
+
|
|
117
|
+
Returns
|
|
118
|
+
-------
|
|
119
|
+
npt.NDArray[np.floating]
|
|
120
|
+
Change in ice water content due to adiabatic heating from the wake
|
|
121
|
+
vortex phase, [:math:`kg_{H_{2}O}/kg_{air}`]
|
|
122
|
+
"""
|
|
123
|
+
p_ice = thermo.e_sat_ice(air_temperature)
|
|
124
|
+
air_temperature_1 = temperature_adiabatic_heating(air_temperature, air_pressure, air_pressure_1)
|
|
125
|
+
p_ice_1 = thermo.e_sat_ice(air_temperature_1)
|
|
126
|
+
|
|
127
|
+
out = (constants.R_d / constants.R_v) * ((p_ice_1 / air_pressure_1) - (p_ice / air_pressure))
|
|
128
|
+
out.clip(min=0.0, out=out)
|
|
129
|
+
return out
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def temperature_adiabatic_heating(
|
|
133
|
+
air_temperature: npt.NDArray[np.floating],
|
|
134
|
+
air_pressure: npt.NDArray[np.floating],
|
|
135
|
+
air_pressure_1: npt.NDArray[np.floating],
|
|
136
|
+
) -> npt.NDArray[np.floating]:
|
|
137
|
+
"""Calculate the ambient air temperature for each waypoint after the wake vortex phase.
|
|
138
|
+
|
|
139
|
+
This calculation accounts for adiabatic heating.
|
|
140
|
+
|
|
141
|
+
Parameters
|
|
142
|
+
----------
|
|
143
|
+
air_temperature : npt.NDArray[np.floating]
|
|
144
|
+
ambient temperature for each waypoint, [:math:`K`]
|
|
145
|
+
air_pressure : npt.NDArray[np.floating]
|
|
146
|
+
initial pressure altitude at each waypoint, before the wake vortex phase, [:math:`Pa`]
|
|
147
|
+
air_pressure_1 : npt.NDArray[np.floating]
|
|
148
|
+
pressure altitude at each waypoint, after the wake vortex phase, [:math:`Pa`]
|
|
149
|
+
|
|
150
|
+
Returns
|
|
151
|
+
-------
|
|
152
|
+
npt.NDArray[np.floating]
|
|
153
|
+
ambient air temperature after the wake vortex phase, [:math:`K`]
|
|
154
|
+
|
|
155
|
+
Notes
|
|
156
|
+
-----
|
|
157
|
+
Level 1, see Figure 1 of :cite:`schumannContrailCirrusPrediction2012`
|
|
158
|
+
|
|
159
|
+
References
|
|
160
|
+
----------
|
|
161
|
+
- :cite:`schumannContrailCirrusPrediction2012`
|
|
162
|
+
"""
|
|
163
|
+
exponent = (constants.gamma - 1.0) / constants.gamma
|
|
164
|
+
return air_temperature * (air_pressure_1 / air_pressure) ** exponent
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def iwc_post_wake_vortex(
|
|
168
|
+
iwc: npt.NDArray[np.floating], iwc_ad: npt.NDArray[np.floating]
|
|
169
|
+
) -> npt.NDArray[np.floating]:
|
|
170
|
+
"""
|
|
171
|
+
Calculate the ice water content after the wake vortex phase (``iwc_1``).
|
|
172
|
+
|
|
173
|
+
``iwc_1`` is calculated by subtracting the initial iwc before the wake vortex phase (``iwc``)
|
|
174
|
+
by the change in iwc from adiabatic heating experienced during the wake vortex phase.
|
|
175
|
+
|
|
176
|
+
Note that the iwc is replaced by zero if it is negative (dry air),
|
|
177
|
+
and this will end the contrail lifecycle in subsequent steps.
|
|
178
|
+
|
|
179
|
+
Parameters
|
|
180
|
+
----------
|
|
181
|
+
iwc : npt.NDArray[np.floating]
|
|
182
|
+
initial ice water content at each waypoint before the wake vortex
|
|
183
|
+
phase, [:math:`kg_{H_{2}O}/kg_{air}`]
|
|
184
|
+
iwc_ad : npt.NDArray[np.floating]
|
|
185
|
+
change in iwc from adiabatic heating during the wake vortex
|
|
186
|
+
phase, [:math:`kg_{H_{2}O}/kg_{air}`]
|
|
187
|
+
|
|
188
|
+
Returns
|
|
189
|
+
-------
|
|
190
|
+
npt.NDArray[np.floating]
|
|
191
|
+
ice water content after the wake vortex phase, ``iwc_1``, [:math:`kg_{H_{2}O}/kg_{air}`]
|
|
192
|
+
|
|
193
|
+
Notes
|
|
194
|
+
-----
|
|
195
|
+
Level 1, see Figure 1 of :cite:`schumannContrailCirrusPrediction2012`
|
|
196
|
+
|
|
197
|
+
References
|
|
198
|
+
----------
|
|
199
|
+
- :cite:`schumannContrailCirrusPrediction2012`
|
|
200
|
+
"""
|
|
201
|
+
return np.maximum(iwc - iwc_ad, 0.0)
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def initial_ice_particle_number(
|
|
205
|
+
aei: npt.NDArray[np.floating],
|
|
206
|
+
fuel_dist: npt.NDArray[np.floating],
|
|
207
|
+
min_aei: float | None,
|
|
208
|
+
) -> npt.NDArray[np.floating]:
|
|
209
|
+
"""Calculate the initial number of ice particles per distance after the wake vortex phase.
|
|
210
|
+
|
|
211
|
+
The initial number of ice particle per distance is calculated from the activated apparent
|
|
212
|
+
emissions index ``aei`` and fuel burn per distance ``fuel_dist``.
|
|
213
|
+
Note that a lower bound for ``aei`` is set at ``1e13`` :math:`kg^{-1}` to account
|
|
214
|
+
for the activation of ambient aerosol particles and organic volatile particles.
|
|
215
|
+
|
|
216
|
+
.. versionchanged:: 0.55
|
|
217
|
+
|
|
218
|
+
The signature of this function has changed. The parameter ``aei`` is now
|
|
219
|
+
expected to be the previous ``npvm_ei_n`` multiplied by the activation
|
|
220
|
+
fraction ``f_activation``.
|
|
221
|
+
|
|
222
|
+
Parameters
|
|
223
|
+
----------
|
|
224
|
+
aei : npt.NDArray[np.floating]
|
|
225
|
+
Apparent contrail emissions index, [:math:`kg^{-1}`]
|
|
226
|
+
fuel_dist : npt.NDArray[np.floating]
|
|
227
|
+
Fuel consumption of the flight segment per distance traveled, [:math:`kg m^{-1}`]
|
|
228
|
+
min_aei : float | None
|
|
229
|
+
Lower bound for ``aei`` to account for ambient aerosol particles for
|
|
230
|
+
newer engines [:math:`kg^{-1}`]. If None, no clipping is applied.
|
|
231
|
+
|
|
232
|
+
Returns
|
|
233
|
+
-------
|
|
234
|
+
npt.NDArray[np.floating]
|
|
235
|
+
The initial number of ice particles per distance before the wake vortex
|
|
236
|
+
phase, [:math:`# m^{-1}`]
|
|
237
|
+
"""
|
|
238
|
+
if min_aei is not None:
|
|
239
|
+
aei = np.clip(aei, min=min_aei) # type: ignore[call-overload]
|
|
240
|
+
return fuel_dist * aei
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def ice_particle_activation_rate(
|
|
244
|
+
air_temperature: npt.NDArray[np.floating], T_crit_sac: npt.NDArray[np.floating]
|
|
245
|
+
) -> npt.NDArray[np.floating]:
|
|
246
|
+
"""
|
|
247
|
+
Calculate the activation rate of black carbon particles to contrail ice crystals.
|
|
248
|
+
|
|
249
|
+
The activation rate is calculated as a function of the difference between
|
|
250
|
+
the ambient temperature and the Schmidt-Appleman threshold temperature ``T_crit_sac``.
|
|
251
|
+
|
|
252
|
+
Parameters
|
|
253
|
+
----------
|
|
254
|
+
air_temperature : npt.NDArray[np.floating]
|
|
255
|
+
ambient temperature at each waypoint before wake_wortex, [:math:`K`]
|
|
256
|
+
T_crit_sac : npt.NDArray[np.floating]
|
|
257
|
+
estimated Schmidt-Appleman temperature threshold for contrail formation, [:math:`K`]
|
|
258
|
+
|
|
259
|
+
Returns
|
|
260
|
+
-------
|
|
261
|
+
npt.NDArray[np.floating]
|
|
262
|
+
Proportion of black carbon particles that activates to contrail ice parties.
|
|
263
|
+
|
|
264
|
+
Notes
|
|
265
|
+
-----
|
|
266
|
+
The equation is not published but based on the raw data
|
|
267
|
+
from :cite:`brauerAirborneMeasurementsContrail2021`.
|
|
268
|
+
|
|
269
|
+
References
|
|
270
|
+
----------
|
|
271
|
+
- :cite:`brauerAirborneMeasurementsContrail2021`
|
|
272
|
+
"""
|
|
273
|
+
d_temp = air_temperature - T_crit_sac
|
|
274
|
+
d_temp.clip(None, 0.0, out=d_temp)
|
|
275
|
+
|
|
276
|
+
# NOTE: It seems somewhat unnecessary to do this additional "rounding down"
|
|
277
|
+
# of d_temp for values below -5. As d_temp near -5, the activation rate approaches
|
|
278
|
+
# 1. This additional rounding injects a small jump discontinuity into the activation rate that
|
|
279
|
+
# likely does not match reality. I suggest removing the line below. This will change
|
|
280
|
+
# model outputs roughly at 0.001 - 0.1%.
|
|
281
|
+
d_temp[d_temp < -5.0] = -np.inf
|
|
282
|
+
return -0.661 * np.exp(d_temp) + 1.0
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
def ice_particle_survival_fraction(
|
|
286
|
+
iwc: npt.NDArray[np.floating], iwc_1: npt.NDArray[np.floating]
|
|
287
|
+
) -> npt.NDArray[np.floating]:
|
|
288
|
+
"""
|
|
289
|
+
Estimate the fraction of contrail ice particle number that survive the wake vortex phase.
|
|
290
|
+
|
|
291
|
+
CoCiP assumes that this fraction is proportional to the change in ice water content
|
|
292
|
+
(``iwc_1 - iwc``) before and after the wake vortex phase.
|
|
293
|
+
|
|
294
|
+
Parameters
|
|
295
|
+
----------
|
|
296
|
+
iwc : npt.NDArray[np.floating]
|
|
297
|
+
initial ice water content at each waypoint before the wake vortex
|
|
298
|
+
phase, [:math:`kg_{H_{2}O}/kg_{air}`]
|
|
299
|
+
iwc_1 : npt.NDArray[np.floating]
|
|
300
|
+
ice water content after the wake vortex phase, [:math:`kg_{H_{2}O}/kg_{air}`]
|
|
301
|
+
|
|
302
|
+
Returns
|
|
303
|
+
-------
|
|
304
|
+
npt.NDArray[np.floating]
|
|
305
|
+
Fraction of contrail ice particle number that survive the wake vortex phase.
|
|
306
|
+
"""
|
|
307
|
+
f_surv = np.empty_like(iwc)
|
|
308
|
+
is_positive = (iwc > 0.0) & (iwc_1 > 0.0)
|
|
309
|
+
|
|
310
|
+
ratio = iwc_1[is_positive] / iwc[is_positive]
|
|
311
|
+
ratio.clip(None, 1.0, out=ratio)
|
|
312
|
+
|
|
313
|
+
f_surv[is_positive] = ratio
|
|
314
|
+
f_surv[~is_positive] = 0.5
|
|
315
|
+
|
|
316
|
+
return f_surv
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
def initial_persistent(
|
|
320
|
+
iwc_1: npt.NDArray[np.floating], rhi_1: npt.NDArray[np.floating]
|
|
321
|
+
) -> npt.NDArray[np.floating]:
|
|
322
|
+
"""
|
|
323
|
+
Determine if waypoints have persistent contrails.
|
|
324
|
+
|
|
325
|
+
Conditions for persistent initial_contrails:
|
|
326
|
+
|
|
327
|
+
1. ice water content at level 1: ``1e-12 < iwc < 1e10``
|
|
328
|
+
2. rhi at level 1: ``0 < rhi < 1e10``
|
|
329
|
+
|
|
330
|
+
.. versionchanged:: 0.25.1
|
|
331
|
+
Returned array now has floating dtype. This is consistent with other filtering
|
|
332
|
+
steps in the CoCiP model (ie, ``sac``).
|
|
333
|
+
|
|
334
|
+
Parameters
|
|
335
|
+
----------
|
|
336
|
+
iwc_1 : npt.NDArray[np.floating]
|
|
337
|
+
ice water content after the wake vortex phase, [:math:`kg_{H_{2}O}/kg_{air}`]
|
|
338
|
+
rhi_1 : npt.NDArray[np.floating]
|
|
339
|
+
relative humidity with respect to ice after the wake vortex phase
|
|
340
|
+
|
|
341
|
+
Returns
|
|
342
|
+
-------
|
|
343
|
+
npt.NDArray[np.floating]
|
|
344
|
+
Mask of waypoints with persistent contrails. Waypoints with persistent contrails
|
|
345
|
+
will have value 1.
|
|
346
|
+
|
|
347
|
+
Notes
|
|
348
|
+
-----
|
|
349
|
+
The RHi at level 1 does not need to be above 100% if the iwc > 0 kg/kg. If iwc > 0
|
|
350
|
+
and RHi < 100%, the contrail lifetime will not end immediately as the ice particles
|
|
351
|
+
will gradually evaporate with the rate depending on the background RHi.
|
|
352
|
+
"""
|
|
353
|
+
out = (iwc_1 > 1e-12) & (iwc_1 < 1e10) & (rhi_1 > 0.0) & (rhi_1 < 1e10)
|
|
354
|
+
dtype = np.result_type(iwc_1, rhi_1)
|
|
355
|
+
return out.astype(dtype)
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
def contrail_persistent(
|
|
359
|
+
latitude: npt.NDArray[np.floating],
|
|
360
|
+
altitude: npt.NDArray[np.floating],
|
|
361
|
+
segment_length: npt.NDArray[np.floating],
|
|
362
|
+
age: npt.NDArray[np.timedelta64],
|
|
363
|
+
tau_contrail: npt.NDArray[np.floating],
|
|
364
|
+
n_ice_per_m3: npt.NDArray[np.floating],
|
|
365
|
+
params: dict[str, Any],
|
|
366
|
+
) -> npt.NDArray[np.bool_]:
|
|
367
|
+
r"""
|
|
368
|
+
Determine surviving contrail segments after time integration step.
|
|
369
|
+
|
|
370
|
+
A contrail waypoint reaches its end of life if any of the following conditions hold:
|
|
371
|
+
|
|
372
|
+
1. Contrail age exceeds ``max_age``
|
|
373
|
+
2. Contrail optical depth lies outside of interval ``[min_tau, max_tau]``
|
|
374
|
+
3. Ice number density lies outside of interval ``[min_n_ice_per_m3, max_n_ice_per_m3]``
|
|
375
|
+
4. Altitude lies outside of the interval ``[min_altitude_m, max_altitude_m]``
|
|
376
|
+
5. Segment length exceeds ``max_seg_length_m``
|
|
377
|
+
6. Latitude values are within 1 degree of the north or south pole
|
|
378
|
+
|
|
379
|
+
This function warns if all values in the ``tau_contrail`` array are nan.
|
|
380
|
+
|
|
381
|
+
.. versionchanged:: 0.25.10
|
|
382
|
+
|
|
383
|
+
Extreme values of ``latitude`` (ie, close to the north or south pole) now
|
|
384
|
+
create an end of life condition. This check helps address issues related to
|
|
385
|
+
divergence in the polar regions. (With large enough integration time delta,
|
|
386
|
+
it is still possible for post-advection latitude values to lie outside of
|
|
387
|
+
[-90, 90], but this is no longer possible with typical parameters and wind
|
|
388
|
+
speeds.)
|
|
389
|
+
|
|
390
|
+
Parameters
|
|
391
|
+
----------
|
|
392
|
+
latitude : npt.NDArray[np.floating]
|
|
393
|
+
Contrail latitude, [:math:`\deg`]
|
|
394
|
+
altitude : npt.NDArray[np.floating]
|
|
395
|
+
Contrail altitude, [:math:`m`]
|
|
396
|
+
segment_length : npt.NDArray[np.floating]
|
|
397
|
+
Contrail segment length, [:math:`m`]
|
|
398
|
+
age : npt.NDArray[np.timedelta64]
|
|
399
|
+
Contrail age
|
|
400
|
+
tau_contrail : npt.NDArray[np.floating]
|
|
401
|
+
Contrail optical depth
|
|
402
|
+
n_ice_per_m3 : npt.NDArray[np.floating]
|
|
403
|
+
Contrail ice particle number per volume of air, [:math:`# m^{-3}`]
|
|
404
|
+
params : dict[str, Any]
|
|
405
|
+
Dictionary of :class:`CocipParams` parameters determining the
|
|
406
|
+
conditions for end of contrail life.
|
|
407
|
+
|
|
408
|
+
Returns
|
|
409
|
+
-------
|
|
410
|
+
npt.NDArray[np.bool_]
|
|
411
|
+
Boolean array indicating surviving contrails. Persisting contrails
|
|
412
|
+
will be marked as True.
|
|
413
|
+
"""
|
|
414
|
+
status_1 = _within_range(age, max=params["max_age"])
|
|
415
|
+
status_2 = _within_range(tau_contrail, max=params["max_tau"], min=params["min_tau"])
|
|
416
|
+
status_3 = _within_range(
|
|
417
|
+
n_ice_per_m3, max=params["max_n_ice_per_m3"], min=params["min_n_ice_per_m3"]
|
|
418
|
+
)
|
|
419
|
+
status_4 = _within_range(altitude, max=params["max_altitude_m"], min=params["min_altitude_m"])
|
|
420
|
+
status_5 = _within_range(segment_length, max=params["max_seg_length_m"])
|
|
421
|
+
status_6 = _within_range(latitude, max=89.0, min=-89.0)
|
|
422
|
+
|
|
423
|
+
logger.debug(
|
|
424
|
+
"Survival stats. age: %s, tau: %s, ice: %s, altitude: %s, segment: %s, latitude: %s",
|
|
425
|
+
np.sum(status_1),
|
|
426
|
+
np.sum(status_2),
|
|
427
|
+
np.sum(status_3),
|
|
428
|
+
np.sum(status_4),
|
|
429
|
+
np.sum(status_5),
|
|
430
|
+
np.sum(status_6),
|
|
431
|
+
)
|
|
432
|
+
return status_1 & status_2 & status_3 & status_4 & status_5 & status_6
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
@overload
|
|
436
|
+
def _within_range(
|
|
437
|
+
val: npt.NDArray[np.floating],
|
|
438
|
+
max: float | None = None,
|
|
439
|
+
min: float | None = None,
|
|
440
|
+
) -> npt.NDArray[np.bool_]: ...
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
@overload
|
|
444
|
+
def _within_range(
|
|
445
|
+
val: npt.NDArray[np.timedelta64],
|
|
446
|
+
max: np.timedelta64 | None = None,
|
|
447
|
+
min: np.timedelta64 | None = None,
|
|
448
|
+
) -> npt.NDArray[np.bool_]: ...
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
def _within_range(
|
|
452
|
+
val: np.ndarray,
|
|
453
|
+
max: float | np.timedelta64 | None = None,
|
|
454
|
+
min: float | np.timedelta64 | None = None,
|
|
455
|
+
) -> npt.NDArray[np.bool_]:
|
|
456
|
+
"""
|
|
457
|
+
Check if the input values (val) are each within the specified range.
|
|
458
|
+
|
|
459
|
+
If both ``max`` and ``min`` are None, a literal constant True is returned.
|
|
460
|
+
|
|
461
|
+
Parameters
|
|
462
|
+
----------
|
|
463
|
+
val : np.ndarray
|
|
464
|
+
value of selected contrail property
|
|
465
|
+
max : float | np.timedelta64 | None, optional
|
|
466
|
+
Upper bound. If None, no upper bound is imposed. None by default.
|
|
467
|
+
min : float | np.timedelta64 | None, optional
|
|
468
|
+
Lower bound. If None, no lower bound is imposed. None by default.
|
|
469
|
+
|
|
470
|
+
Returns
|
|
471
|
+
-------
|
|
472
|
+
npt.NDArray[np.bool_]
|
|
473
|
+
Mask of waypoints. Waypoints with values within the specified range will be marked as true.
|
|
474
|
+
"""
|
|
475
|
+
cond: npt.NDArray[np.bool_] = True # type: ignore[assignment]
|
|
476
|
+
if min is not None:
|
|
477
|
+
cond &= val >= min
|
|
478
|
+
if max is not None:
|
|
479
|
+
cond &= val <= max
|
|
480
|
+
return cond
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
####################
|
|
484
|
+
# Contrail Properties
|
|
485
|
+
####################
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
def contrail_edges(
|
|
489
|
+
lon: npt.NDArray[np.floating],
|
|
490
|
+
lat: npt.NDArray[np.floating],
|
|
491
|
+
sin_a: npt.NDArray[np.floating],
|
|
492
|
+
cos_a: npt.NDArray[np.floating],
|
|
493
|
+
width: npt.NDArray[np.floating],
|
|
494
|
+
) -> tuple[
|
|
495
|
+
npt.NDArray[np.floating],
|
|
496
|
+
npt.NDArray[np.floating],
|
|
497
|
+
npt.NDArray[np.floating],
|
|
498
|
+
npt.NDArray[np.floating],
|
|
499
|
+
]:
|
|
500
|
+
"""
|
|
501
|
+
Calculate the longitude and latitude of the contrail edges to account for contrail spreading.
|
|
502
|
+
|
|
503
|
+
(lon_edge_l, lat_edge_l) x---------------------
|
|
504
|
+
|
|
505
|
+
(Contrail midpoint: lon, lat) X===================== ->
|
|
506
|
+
|
|
507
|
+
(lon_edge_r, lat_edge_r) x---------------------
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
Parameters
|
|
511
|
+
----------
|
|
512
|
+
lon : npt.NDArray[np.floating]
|
|
513
|
+
longitude of contrail waypoint, degrees
|
|
514
|
+
lat : npt.NDArray[np.floating]
|
|
515
|
+
latitude of contrail waypoint, degrees
|
|
516
|
+
sin_a : npt.NDArray[np.floating]
|
|
517
|
+
sin(a), where a is the angle between the plume and the longitudinal axis
|
|
518
|
+
cos_a : npt.NDArray[np.floating]
|
|
519
|
+
cos(a), where a is the angle between the plume and the longitudinal axis
|
|
520
|
+
width : npt.NDArray[np.floating]
|
|
521
|
+
contrail width at each waypoint, [:math:`m`]
|
|
522
|
+
|
|
523
|
+
Returns
|
|
524
|
+
-------
|
|
525
|
+
tuple[npt.NDArray[np.floating], npt.NDArray[np.floating], npt.NDArray[np.floating], npt.NDArray[np.floating]]
|
|
526
|
+
(lon_edge_l, lat_edge_l, lon_edge_r, lat_edge_r), longitudes and latitudes
|
|
527
|
+
at the left and right edges of the contrail, degrees
|
|
528
|
+
""" # noqa: E501
|
|
529
|
+
dlon = units.m_to_longitude_distance(width * sin_a * 0.5, lat)
|
|
530
|
+
dlat = units.m_to_latitude_distance(width * cos_a * 0.5)
|
|
531
|
+
|
|
532
|
+
lon_edge_l = lon - dlon
|
|
533
|
+
lat_edge_l = lat + dlat
|
|
534
|
+
lon_edge_r = lon + dlon
|
|
535
|
+
lat_edge_r = lat - dlat
|
|
536
|
+
|
|
537
|
+
return lon_edge_l, lat_edge_l, lon_edge_r, lat_edge_r
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
def contrail_vertices(
|
|
541
|
+
lon: npt.NDArray[np.floating],
|
|
542
|
+
lat: npt.NDArray[np.floating],
|
|
543
|
+
sin_a: npt.NDArray[np.floating],
|
|
544
|
+
cos_a: npt.NDArray[np.floating],
|
|
545
|
+
width: npt.NDArray[np.floating],
|
|
546
|
+
segment_length: npt.NDArray[np.floating],
|
|
547
|
+
) -> tuple[
|
|
548
|
+
npt.NDArray[np.floating],
|
|
549
|
+
npt.NDArray[np.floating],
|
|
550
|
+
npt.NDArray[np.floating],
|
|
551
|
+
npt.NDArray[np.floating],
|
|
552
|
+
npt.NDArray[np.floating],
|
|
553
|
+
npt.NDArray[np.floating],
|
|
554
|
+
npt.NDArray[np.floating],
|
|
555
|
+
npt.NDArray[np.floating],
|
|
556
|
+
]:
|
|
557
|
+
"""
|
|
558
|
+
Calculate the longitude and latitude of the contrail vertices.
|
|
559
|
+
|
|
560
|
+
This is equivalent to running :meth:`contrail_edges` at each contrail waypoint
|
|
561
|
+
and associating the next continuous waypoint with the previous.
|
|
562
|
+
This method is helpful when you want to treat each contrail waypoint independently.
|
|
563
|
+
|
|
564
|
+
(lon_1, lat_1) x--------------------x (lon_4, lat_4)
|
|
565
|
+
|
|
566
|
+
(Contrail waypoint: lon, lat) X==================== ->
|
|
567
|
+
|
|
568
|
+
(lon_2, lat_2) x--------------------x (lon_3, lat_3)
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
Parameters
|
|
572
|
+
----------
|
|
573
|
+
lon : npt.NDArray[np.floating]
|
|
574
|
+
longitude of contrail waypoint, degrees
|
|
575
|
+
lat : npt.NDArray[np.floating]
|
|
576
|
+
latitude of contrail waypoint, degrees
|
|
577
|
+
sin_a : npt.NDArray[np.floating]
|
|
578
|
+
sin(a), where a is the angle between the plume and the longitudinal axis
|
|
579
|
+
cos_a : npt.NDArray[np.floating]
|
|
580
|
+
cos(a), where a is the angle between the plume and the longitudinal axis
|
|
581
|
+
width : npt.NDArray[np.floating]
|
|
582
|
+
contrail width at each waypoint, [:math:`m`]
|
|
583
|
+
segment_length : npt.NDArray[np.floating]
|
|
584
|
+
contrail length at each waypoint, [:math:`m`]
|
|
585
|
+
|
|
586
|
+
Returns
|
|
587
|
+
-------
|
|
588
|
+
tuple
|
|
589
|
+
(lon_1, lat_1, lon_2, lat_2, lon_3, lat_3, lon_4, lat_4) degrees
|
|
590
|
+
"""
|
|
591
|
+
dlon_width = units.m_to_longitude_distance(width * sin_a * 0.5, lat)
|
|
592
|
+
dlat_width = units.m_to_latitude_distance(width * cos_a * 0.5)
|
|
593
|
+
|
|
594
|
+
# using "lat" as mean here is a little inaccurate, but its a close approx
|
|
595
|
+
dlon_length = units.m_to_longitude_distance(segment_length * cos_a, lat)
|
|
596
|
+
dlat_length = units.m_to_latitude_distance(segment_length * sin_a)
|
|
597
|
+
|
|
598
|
+
lon_1 = lon - dlon_width
|
|
599
|
+
lon_2 = lon + dlon_width
|
|
600
|
+
lon_3 = lon + dlon_width + dlon_length
|
|
601
|
+
lon_4 = lon - dlon_width + dlon_length
|
|
602
|
+
|
|
603
|
+
lat_1 = lat + dlat_width
|
|
604
|
+
lat_2 = lat - dlat_width
|
|
605
|
+
lat_3 = lat - dlat_width + dlat_length
|
|
606
|
+
lat_4 = lat + dlat_width + dlat_length
|
|
607
|
+
|
|
608
|
+
return lon_1, lat_1, lon_2, lat_2, lon_3, lat_3, lon_4, lat_4
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
def plume_effective_cross_sectional_area(
|
|
612
|
+
width: npt.NDArray[np.floating],
|
|
613
|
+
depth: npt.NDArray[np.floating],
|
|
614
|
+
sigma_yz: npt.NDArray[np.floating] | float,
|
|
615
|
+
) -> npt.NDArray[np.floating]:
|
|
616
|
+
"""
|
|
617
|
+
Calculate the effective cross-sectional area of the contrail plume (``area_eff``).
|
|
618
|
+
|
|
619
|
+
``sigma_yy``, ``sigma_zz`` and ``sigma_yz`` are the parameters governing the
|
|
620
|
+
contrail plume's temporal evolution.
|
|
621
|
+
|
|
622
|
+
Parameters
|
|
623
|
+
----------
|
|
624
|
+
width : npt.NDArray[np.floating]
|
|
625
|
+
contrail width at each waypoint, [:math:`m`]
|
|
626
|
+
depth : npt.NDArray[np.floating]
|
|
627
|
+
contrail depth at each waypoint, [:math:`m`]
|
|
628
|
+
sigma_yz : npt.NDArray[np.floating] | float
|
|
629
|
+
temporal evolution of the contrail plume parameters
|
|
630
|
+
|
|
631
|
+
Returns
|
|
632
|
+
-------
|
|
633
|
+
npt.NDArray[np.floating]
|
|
634
|
+
effective cross-sectional area of the contrail plume, [:math:`m^{2}`]
|
|
635
|
+
"""
|
|
636
|
+
sigma_yy = 0.125 * (width**2)
|
|
637
|
+
sigma_zz = 0.125 * (depth**2)
|
|
638
|
+
return new_effective_area_from_sigma(sigma_yy, sigma_zz, sigma_yz)
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
def plume_effective_depth(
|
|
642
|
+
width: npt.NDArray[np.floating], area_eff: npt.NDArray[np.floating]
|
|
643
|
+
) -> npt.NDArray[np.floating]:
|
|
644
|
+
"""
|
|
645
|
+
Calculate the effective depth of the contrail plume (``depth_eff``).
|
|
646
|
+
|
|
647
|
+
``depth_eff`` is calculated from the effective cross-sectional area (``area_eff``)
|
|
648
|
+
and the contrail width.
|
|
649
|
+
|
|
650
|
+
Parameters
|
|
651
|
+
----------
|
|
652
|
+
width : npt.NDArray[np.floating]
|
|
653
|
+
contrail width at each waypoint, [:math:`m`]
|
|
654
|
+
area_eff : npt.NDArray[np.floating]
|
|
655
|
+
effective cross-sectional area of the contrail plume, [:math:`m^{2}`]
|
|
656
|
+
|
|
657
|
+
Returns
|
|
658
|
+
-------
|
|
659
|
+
npt.NDArray[np.floating]
|
|
660
|
+
effective depth of the contrail plume, [:math:`m`]
|
|
661
|
+
"""
|
|
662
|
+
return area_eff / width
|
|
663
|
+
|
|
664
|
+
|
|
665
|
+
def plume_mass_per_distance(
|
|
666
|
+
area_eff: npt.NDArray[np.floating], rho_air: npt.NDArray[np.floating]
|
|
667
|
+
) -> npt.NDArray[np.floating]:
|
|
668
|
+
"""
|
|
669
|
+
Calculate the contrail plume mass per unit length.
|
|
670
|
+
|
|
671
|
+
Parameters
|
|
672
|
+
----------
|
|
673
|
+
area_eff : npt.NDArray[np.floating]
|
|
674
|
+
effective cross-sectional area of the contrail plume, [:math:`m^{2}`]
|
|
675
|
+
rho_air : npt.NDArray[np.floating]
|
|
676
|
+
density of air for each waypoint, [:math:`kg m^{-3}`]
|
|
677
|
+
|
|
678
|
+
Returns
|
|
679
|
+
-------
|
|
680
|
+
npt.NDArray[np.floating]
|
|
681
|
+
contrail plume mass per unit length, [:math:`kg m^{-1}`]
|
|
682
|
+
"""
|
|
683
|
+
return area_eff * rho_air
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
def ice_particle_number_per_volume_of_plume(
|
|
687
|
+
n_ice_per_m: npt.NDArray[np.floating], area_eff: npt.NDArray[np.floating]
|
|
688
|
+
) -> npt.NDArray[np.floating]:
|
|
689
|
+
"""
|
|
690
|
+
Calculate the number of contrail ice particles per volume of plume (``n_ice_per_vol``).
|
|
691
|
+
|
|
692
|
+
Parameters
|
|
693
|
+
----------
|
|
694
|
+
n_ice_per_m : npt.NDArray[np.floating]
|
|
695
|
+
number of ice particles per distance at time t, [:math:`m^{-1}`]
|
|
696
|
+
area_eff : npt.NDArray[np.floating]
|
|
697
|
+
effective cross-sectional area of the contrail plume, [:math:`m^{2}`]
|
|
698
|
+
|
|
699
|
+
Returns
|
|
700
|
+
-------
|
|
701
|
+
npt.NDArray[np.floating]
|
|
702
|
+
number of ice particles per volume of contrail plume at time t, [:math:`# m^{-3}`]
|
|
703
|
+
"""
|
|
704
|
+
return n_ice_per_m / area_eff
|
|
705
|
+
|
|
706
|
+
|
|
707
|
+
def ice_particle_number_per_mass_of_air(
|
|
708
|
+
n_ice_per_vol: npt.NDArray[np.floating], rho_air: npt.NDArray[np.floating]
|
|
709
|
+
) -> npt.NDArray[np.floating]:
|
|
710
|
+
"""
|
|
711
|
+
Calculate the number of contrail ice particles per mass of air.
|
|
712
|
+
|
|
713
|
+
Parameters
|
|
714
|
+
----------
|
|
715
|
+
n_ice_per_vol : npt.NDArray[np.floating]
|
|
716
|
+
number of ice particles per volume of contrail plume at time t, [:math:`# m^{-3}`]
|
|
717
|
+
rho_air : npt.NDArray[np.floating]
|
|
718
|
+
density of air for each waypoint, [:math:`kg m^{-3}`]
|
|
719
|
+
|
|
720
|
+
Returns
|
|
721
|
+
-------
|
|
722
|
+
npt.NDArray[np.floating]
|
|
723
|
+
number of ice particles per mass of air at time t, [:math:`# kg^{-1}`]
|
|
724
|
+
"""
|
|
725
|
+
return n_ice_per_vol / rho_air
|
|
726
|
+
|
|
727
|
+
|
|
728
|
+
def ice_particle_volume_mean_radius(
|
|
729
|
+
iwc: npt.NDArray[np.floating], n_ice_per_kg_air: npt.NDArray[np.floating]
|
|
730
|
+
) -> npt.NDArray[np.floating]:
|
|
731
|
+
"""
|
|
732
|
+
Calculate the ice particle volume mean radius.
|
|
733
|
+
|
|
734
|
+
Parameters
|
|
735
|
+
----------
|
|
736
|
+
iwc : npt.NDArray[np.floating]
|
|
737
|
+
contrail ice water content, i.e., contrail ice mass per
|
|
738
|
+
kg of air, [:math:`kg_{H_{2}O}/kg_{air}`]
|
|
739
|
+
|
|
740
|
+
n_ice_per_kg_air : npt.NDArray[np.floating]
|
|
741
|
+
number of ice particles per mass of air, [:math:`# kg^{-1}`]
|
|
742
|
+
|
|
743
|
+
Returns
|
|
744
|
+
-------
|
|
745
|
+
npt.NDArray[np.floating]
|
|
746
|
+
ice particle volume mean radius, [:math:`m`]
|
|
747
|
+
|
|
748
|
+
Notes
|
|
749
|
+
-----
|
|
750
|
+
``r_ice_vol`` is the mean radius of a sphere that has the same volume as the
|
|
751
|
+
contrail ice particle.
|
|
752
|
+
|
|
753
|
+
``r_ice_vol`` calculated by dividing the total volume of contrail
|
|
754
|
+
ice particle per kg of air (``total_ice_volume``, :math:`m**3/kg-air`) with the
|
|
755
|
+
number of contrail ice particles per kg of air (``n_ice_per_kg_air``, :math:`#/kg-air`).
|
|
756
|
+
"""
|
|
757
|
+
total_ice_volume = iwc / constants.rho_ice
|
|
758
|
+
r_ice_vol = ((3 / (4.0 * np.pi)) * (total_ice_volume / n_ice_per_kg_air)) ** (1 / 3)
|
|
759
|
+
zero_negative_values = iwc <= 0.0
|
|
760
|
+
r_ice_vol[zero_negative_values] = iwc[zero_negative_values]
|
|
761
|
+
r_ice_vol.clip(min=1e-10, out=r_ice_vol)
|
|
762
|
+
return r_ice_vol
|
|
763
|
+
|
|
764
|
+
|
|
765
|
+
def ice_particle_terminal_fall_speed(
|
|
766
|
+
air_pressure: npt.NDArray[np.floating],
|
|
767
|
+
air_temperature: npt.NDArray[np.floating],
|
|
768
|
+
r_ice_vol: npt.NDArray[np.floating],
|
|
769
|
+
) -> npt.NDArray[np.floating]:
|
|
770
|
+
"""
|
|
771
|
+
Calculate the terminal fall speed of contrail ice particles.
|
|
772
|
+
|
|
773
|
+
``v_t`` is calculated based on a parametric model
|
|
774
|
+
from :cite:`spichtingerModellingCirrusClouds2009`, using inputs of pressure
|
|
775
|
+
level, ambient temperature and the ice particle volume mean radius. See
|
|
776
|
+
Table 2 for the model parameters.
|
|
777
|
+
|
|
778
|
+
Parameters
|
|
779
|
+
----------
|
|
780
|
+
air_pressure : npt.NDArray[np.floating]
|
|
781
|
+
Pressure altitude at each waypoint, [:math:`Pa`]
|
|
782
|
+
air_temperature : npt.NDArray[np.floating]
|
|
783
|
+
Ambient temperature for each waypoint, [:math:`K`]
|
|
784
|
+
r_ice_vol : npt.NDArray[np.floating]
|
|
785
|
+
Ice particle volume mean radius, [:math:`m`]
|
|
786
|
+
|
|
787
|
+
Returns
|
|
788
|
+
-------
|
|
789
|
+
npt.NDArray[np.floating]
|
|
790
|
+
Terminal fall speed of contrail ice particles, [:math:`m s^{-1}`]
|
|
791
|
+
|
|
792
|
+
References
|
|
793
|
+
----------
|
|
794
|
+
- :cite:`spichtingerModellingCirrusClouds2009`
|
|
795
|
+
"""
|
|
796
|
+
ipm = ice_particle_mass(r_ice_vol)
|
|
797
|
+
|
|
798
|
+
alpha = np.full_like(r_ice_vol, np.nan)
|
|
799
|
+
|
|
800
|
+
# For ice particle mass >= 4.264e-8 kg
|
|
801
|
+
particle_mass = ipm >= 4.264e-8
|
|
802
|
+
alpha[particle_mass] = 8.80 * ipm[particle_mass] ** 0.096
|
|
803
|
+
|
|
804
|
+
# For ice particle mass in [2.166e-9 kg, 4.264e-8 kg)
|
|
805
|
+
particle_mass = (ipm < 4.264e-8) & (ipm >= 2.166e-9)
|
|
806
|
+
alpha[particle_mass] = 329.8 * ipm[particle_mass] ** 0.31
|
|
807
|
+
|
|
808
|
+
# For ice particle mass in [2.146e-13 kg, 2.166e-9 kg)
|
|
809
|
+
particle_mass = (ipm < 2.166e-9) & (ipm >= 2.146e-13)
|
|
810
|
+
alpha[particle_mass] = 63292.4 * ipm[particle_mass] ** 0.57
|
|
811
|
+
|
|
812
|
+
# For ice particle mass < 2.146e-13 kg
|
|
813
|
+
particle_mass = ipm < 2.146e-13
|
|
814
|
+
alpha[particle_mass] = 735.4 * ipm[particle_mass] ** 0.42
|
|
815
|
+
|
|
816
|
+
return alpha * (30000.0 / air_pressure) ** 0.178 * (233.0 / air_temperature) ** 0.394
|
|
817
|
+
|
|
818
|
+
|
|
819
|
+
def ice_particle_mass(r_ice_vol: npt.NDArray[np.floating]) -> npt.NDArray[np.floating]:
|
|
820
|
+
"""
|
|
821
|
+
Calculate the contrail ice particle mass.
|
|
822
|
+
|
|
823
|
+
It is calculated by multiplying the mean ice particle volume with the density of ice
|
|
824
|
+
|
|
825
|
+
Parameters
|
|
826
|
+
----------
|
|
827
|
+
r_ice_vol : npt.NDArray[np.floating]
|
|
828
|
+
Ice particle volume mean radius, [:math:`m`]
|
|
829
|
+
|
|
830
|
+
Returns
|
|
831
|
+
-------
|
|
832
|
+
npt.NDArray[np.floating]
|
|
833
|
+
Mean contrail ice particle mass, [:math:`kg`]
|
|
834
|
+
"""
|
|
835
|
+
return ((4 / 3) * np.pi * r_ice_vol**3) * constants.rho_ice
|
|
836
|
+
|
|
837
|
+
|
|
838
|
+
def horizontal_diffusivity(
|
|
839
|
+
ds_dz: npt.NDArray[np.floating], depth: npt.NDArray[np.floating]
|
|
840
|
+
) -> npt.NDArray[np.floating]:
|
|
841
|
+
"""
|
|
842
|
+
Calculate contrail horizontal diffusivity.
|
|
843
|
+
|
|
844
|
+
Parameters
|
|
845
|
+
----------
|
|
846
|
+
ds_dz : npt.NDArray[np.floating]
|
|
847
|
+
Total wind shear (eastward and northward winds) with respect
|
|
848
|
+
to altitude (``dz``), [:math:`m s^{-1} / Pa`]
|
|
849
|
+
depth : npt.NDArray[np.floating]
|
|
850
|
+
Contrail depth at each waypoint, [:math:`m`]
|
|
851
|
+
|
|
852
|
+
Returns
|
|
853
|
+
-------
|
|
854
|
+
npt.NDArray[np.floating]
|
|
855
|
+
horizontal diffusivity, [:math:`m^{2} s^{-1}`]
|
|
856
|
+
|
|
857
|
+
References
|
|
858
|
+
----------
|
|
859
|
+
- :cite:`schumannContrailCirrusPrediction2012`
|
|
860
|
+
|
|
861
|
+
Notes
|
|
862
|
+
-----
|
|
863
|
+
Accounts for the turbulence-induced diffusive contrail spreading in
|
|
864
|
+
the horizontal direction.
|
|
865
|
+
"""
|
|
866
|
+
return 0.1 * ds_dz * depth**2
|
|
867
|
+
|
|
868
|
+
|
|
869
|
+
def vertical_diffusivity(
|
|
870
|
+
air_pressure: npt.NDArray[np.floating],
|
|
871
|
+
air_temperature: npt.NDArray[np.floating],
|
|
872
|
+
dT_dz: npt.NDArray[np.floating],
|
|
873
|
+
depth_eff: npt.NDArray[np.floating],
|
|
874
|
+
terminal_fall_speed: npt.NDArray[np.floating] | float,
|
|
875
|
+
sedimentation_impact_factor: npt.NDArray[np.floating] | float,
|
|
876
|
+
eff_heat_rate: npt.NDArray[np.floating] | None,
|
|
877
|
+
) -> npt.NDArray[np.floating]:
|
|
878
|
+
"""
|
|
879
|
+
Calculate contrail vertical diffusivity.
|
|
880
|
+
|
|
881
|
+
Parameters
|
|
882
|
+
----------
|
|
883
|
+
air_pressure : npt.NDArray[np.floating]
|
|
884
|
+
Pressure altitude at each waypoint, [:math:`Pa`]
|
|
885
|
+
air_temperature : npt.NDArray[np.floating]
|
|
886
|
+
Ambient temperature for each waypoint, [:math:`K`]
|
|
887
|
+
dT_dz : npt.NDArray[np.floating]
|
|
888
|
+
Temperature gradient with respect to altitude (dz), [:math:`K m^{-1}`]
|
|
889
|
+
depth_eff : npt.NDArray[np.floating]
|
|
890
|
+
Effective depth of the contrail plume, [:math:`m`]
|
|
891
|
+
terminal_fall_speed : npt.NDArray[np.floating] | float
|
|
892
|
+
Terminal fall speed of contrail ice particles, [:math:`m s^{-1}`]
|
|
893
|
+
sedimentation_impact_factor : npt.NDArray[np.floating] | float
|
|
894
|
+
Enhancement parameter denoted by `f_T` in eq. (35) Schumann (2012).
|
|
895
|
+
eff_heat_rate: npt.NDArray[np.floating] | None
|
|
896
|
+
Effective heating rate, i.e., rate of which the contrail plume
|
|
897
|
+
is heated, [:math:`K s^{-1}`]. If None is passed, the radiative
|
|
898
|
+
heating effects on contrail cirrus properties are not included.
|
|
899
|
+
|
|
900
|
+
Returns
|
|
901
|
+
-------
|
|
902
|
+
npt.NDArray[np.floating]
|
|
903
|
+
vertical diffusivity, [:math:`m^{2} s^{-1}`]
|
|
904
|
+
|
|
905
|
+
References
|
|
906
|
+
----------
|
|
907
|
+
- :cite:`schumannContrailCirrusPrediction2012`
|
|
908
|
+
- :cite:`schumannAviationinducedCirrusRadiation2013`
|
|
909
|
+
|
|
910
|
+
Notes
|
|
911
|
+
-----
|
|
912
|
+
Accounts for the turbulence-induced diffusive contrail spreading in the vertical direction.
|
|
913
|
+
See eq. (35) of :cite:`schumannContrailCirrusPrediction2012`.
|
|
914
|
+
|
|
915
|
+
The first term in Eq. (35) of :cite:`schumannContrailCirrusPrediction2012` is
|
|
916
|
+
(c_V * w'_N^2 / N_BV, where c_V = 0.2 and w'_N^2 = 0.1) is different
|
|
917
|
+
than outlined below. Here, a constant of 0.01 is used when radiative
|
|
918
|
+
heating effects are not activated. This update comes from
|
|
919
|
+
:cite:`schumannAviationinducedCirrusRadiation2013`
|
|
920
|
+
, which found that the original formulation estimated thinner
|
|
921
|
+
contrails relative to satellite observations. The vertical diffusivity
|
|
922
|
+
was enlarged so that the simulated contrails are more consistent with observations.
|
|
923
|
+
"""
|
|
924
|
+
n_bv = thermo.brunt_vaisala_frequency(air_pressure, air_temperature, dT_dz)
|
|
925
|
+
n_bv.clip(min=0.001, out=n_bv)
|
|
926
|
+
|
|
927
|
+
cvs: npt.NDArray[np.floating] | float
|
|
928
|
+
if eff_heat_rate is not None:
|
|
929
|
+
cvs = radiative_heating.convective_velocity_scale(depth_eff, eff_heat_rate, air_temperature)
|
|
930
|
+
cvs.clip(min=0.01, out=cvs)
|
|
931
|
+
else:
|
|
932
|
+
cvs = 0.01
|
|
933
|
+
|
|
934
|
+
return cvs / n_bv + sedimentation_impact_factor * terminal_fall_speed * depth_eff
|
|
935
|
+
|
|
936
|
+
|
|
937
|
+
####################
|
|
938
|
+
# Ice particle losses
|
|
939
|
+
####################
|
|
940
|
+
|
|
941
|
+
|
|
942
|
+
def particle_losses_aggregation(
|
|
943
|
+
r_ice_vol: npt.NDArray[np.floating],
|
|
944
|
+
terminal_fall_speed: npt.NDArray[np.floating],
|
|
945
|
+
area_eff: npt.NDArray[np.floating],
|
|
946
|
+
agg_efficiency: float = 1.0,
|
|
947
|
+
) -> npt.NDArray[np.floating]:
|
|
948
|
+
"""
|
|
949
|
+
Calculate the rate of contrail ice particle losses due to sedimentation-induced aggregation.
|
|
950
|
+
|
|
951
|
+
Parameters
|
|
952
|
+
----------
|
|
953
|
+
r_ice_vol : npt.NDArray[np.floating]
|
|
954
|
+
Ice particle volume mean radius, [:math:`m`]
|
|
955
|
+
terminal_fall_speed : npt.NDArray[np.floating]
|
|
956
|
+
Terminal fall speed of contrail ice particles, [:math:`m s^{-1}`]
|
|
957
|
+
area_eff : npt.NDArray[np.floating]
|
|
958
|
+
Effective cross-sectional area of the contrail plume, [:math:`m^{2}`]
|
|
959
|
+
agg_efficiency : float, optional
|
|
960
|
+
Aggregation efficiency
|
|
961
|
+
|
|
962
|
+
Returns
|
|
963
|
+
-------
|
|
964
|
+
npt.NDArray[np.floating]
|
|
965
|
+
Rate of contrail ice particle losses due to sedimentation-induced
|
|
966
|
+
aggregation, [:math:`# s^{-1}`]
|
|
967
|
+
|
|
968
|
+
Notes
|
|
969
|
+
-----
|
|
970
|
+
The aggregation efficiency (``agg_efficiency = 1``) was calibrated based on
|
|
971
|
+
the observed lifetime and optical properties from the Contrail Library (COLI)
|
|
972
|
+
database (:cite:`schumannPropertiesIndividualContrails2017`).
|
|
973
|
+
|
|
974
|
+
References
|
|
975
|
+
----------
|
|
976
|
+
- :cite:`schumannPropertiesIndividualContrails2017`
|
|
977
|
+
"""
|
|
978
|
+
return (8.0 * agg_efficiency * np.pi * r_ice_vol**2 * terminal_fall_speed) / area_eff
|
|
979
|
+
|
|
980
|
+
|
|
981
|
+
def particle_losses_turbulence(
|
|
982
|
+
width: npt.NDArray[np.floating],
|
|
983
|
+
depth: npt.NDArray[np.floating],
|
|
984
|
+
depth_eff: npt.NDArray[np.floating],
|
|
985
|
+
diffuse_h: npt.NDArray[np.floating],
|
|
986
|
+
diffuse_v: npt.NDArray[np.floating],
|
|
987
|
+
turb_efficiency: float = 0.1,
|
|
988
|
+
) -> npt.NDArray[np.floating]:
|
|
989
|
+
"""
|
|
990
|
+
Calculate the rate of contrail ice particle losses due to plume-internal turbulence.
|
|
991
|
+
|
|
992
|
+
Parameters
|
|
993
|
+
----------
|
|
994
|
+
width : npt.NDArray[np.floating]
|
|
995
|
+
Contrail width at each waypoint, [:math:`m`]
|
|
996
|
+
depth : npt.NDArray[np.floating]
|
|
997
|
+
Contrail depth at each waypoint, [:math:`m`]
|
|
998
|
+
depth_eff : npt.NDArray[np.floating]
|
|
999
|
+
Effective depth of the contrail plume, [:math:`m`]
|
|
1000
|
+
diffuse_h : npt.NDArray[np.floating]
|
|
1001
|
+
Horizontal diffusivity, [:math:`m^{2} s^{-1}`]
|
|
1002
|
+
diffuse_v : npt.NDArray[np.floating]
|
|
1003
|
+
Vertical diffusivity, [:math:`m^{2} s^{-1}`]
|
|
1004
|
+
turb_efficiency : float, optional
|
|
1005
|
+
Turbulence sublimation efficiency
|
|
1006
|
+
|
|
1007
|
+
Returns
|
|
1008
|
+
-------
|
|
1009
|
+
npt.NDArray[np.floating]
|
|
1010
|
+
Rate of contrail ice particle losses due to plume-internal turbulence, [:math:`# s^{-1}`]
|
|
1011
|
+
|
|
1012
|
+
Notes
|
|
1013
|
+
-----
|
|
1014
|
+
The turbulence sublimation efficiency (``turb_efficiency = 0.1``) was calibrated
|
|
1015
|
+
based on the observed lifetime and optical properties from the Contrail Library (COLI)
|
|
1016
|
+
database (:cite:`schumannPropertiesIndividualContrails2017`).
|
|
1017
|
+
|
|
1018
|
+
References
|
|
1019
|
+
----------
|
|
1020
|
+
- :cite:`schumannPropertiesIndividualContrails2017`
|
|
1021
|
+
"""
|
|
1022
|
+
inner_term = (diffuse_h / (np.maximum(width, depth)) ** 2) + (diffuse_v / depth_eff**2)
|
|
1023
|
+
return turb_efficiency * np.abs(inner_term)
|
|
1024
|
+
|
|
1025
|
+
|
|
1026
|
+
####################
|
|
1027
|
+
# Optical properties
|
|
1028
|
+
####################
|
|
1029
|
+
|
|
1030
|
+
|
|
1031
|
+
def contrail_optical_depth(
|
|
1032
|
+
r_ice_vol: npt.NDArray[np.floating],
|
|
1033
|
+
n_ice_per_m: npt.NDArray[np.floating],
|
|
1034
|
+
width: npt.NDArray[np.floating],
|
|
1035
|
+
) -> npt.NDArray[np.floating]:
|
|
1036
|
+
"""
|
|
1037
|
+
Calculate the contrail optical depth for each waypoint.
|
|
1038
|
+
|
|
1039
|
+
Parameters
|
|
1040
|
+
----------
|
|
1041
|
+
r_ice_vol : npt.NDArray[np.floating]
|
|
1042
|
+
ice particle volume mean radius, [:math:`m`]
|
|
1043
|
+
n_ice_per_m : npt.NDArray[np.floating]
|
|
1044
|
+
Number of contrail ice particles per distance, [:math:`m^{-1}`]
|
|
1045
|
+
width : npt.NDArray[np.floating]
|
|
1046
|
+
Contrail width, [:math:`m`]
|
|
1047
|
+
|
|
1048
|
+
Returns
|
|
1049
|
+
-------
|
|
1050
|
+
npt.NDArray[np.floating]
|
|
1051
|
+
Contrail optical depth
|
|
1052
|
+
"""
|
|
1053
|
+
q_ext = scattering_extinction_efficiency(r_ice_vol)
|
|
1054
|
+
tau_contrail = constants.c_r * np.pi * r_ice_vol**2 * (n_ice_per_m / width) * q_ext
|
|
1055
|
+
|
|
1056
|
+
bool_small = r_ice_vol <= 1e-9
|
|
1057
|
+
tau_contrail[bool_small] = 0.0
|
|
1058
|
+
tau_contrail.clip(min=0.0, out=tau_contrail)
|
|
1059
|
+
return tau_contrail
|
|
1060
|
+
|
|
1061
|
+
|
|
1062
|
+
def scattering_extinction_efficiency(
|
|
1063
|
+
r_ice_vol: npt.NDArray[np.floating],
|
|
1064
|
+
) -> npt.NDArray[np.floating]:
|
|
1065
|
+
"""
|
|
1066
|
+
Calculate the scattering extinction efficiency (``q_ext``) based on Mie-theory.
|
|
1067
|
+
|
|
1068
|
+
Parameters
|
|
1069
|
+
----------
|
|
1070
|
+
r_ice_vol : npt.NDArray[np.floating]
|
|
1071
|
+
ice particle volume mean radius, [:math:`m`]
|
|
1072
|
+
|
|
1073
|
+
Returns
|
|
1074
|
+
-------
|
|
1075
|
+
npt.NDArray[np.floating]
|
|
1076
|
+
scattering extinction efficiency
|
|
1077
|
+
|
|
1078
|
+
References
|
|
1079
|
+
----------
|
|
1080
|
+
- https://en.wikipedia.org/wiki/Mie_scattering
|
|
1081
|
+
"""
|
|
1082
|
+
phase_delay = light_wave_phase_delay(r_ice_vol)
|
|
1083
|
+
return 2.0 - (4.0 / phase_delay) * (
|
|
1084
|
+
np.sin(phase_delay) - ((1.0 - np.cos(phase_delay)) / phase_delay)
|
|
1085
|
+
)
|
|
1086
|
+
|
|
1087
|
+
|
|
1088
|
+
def light_wave_phase_delay(r_ice_vol: npt.NDArray[np.floating]) -> npt.NDArray[np.floating]:
|
|
1089
|
+
"""
|
|
1090
|
+
Calculate the phase delay of the light wave passing through the contrail ice particle.
|
|
1091
|
+
|
|
1092
|
+
Parameters
|
|
1093
|
+
----------
|
|
1094
|
+
r_ice_vol : npt.NDArray[np.floating]
|
|
1095
|
+
ice particle volume mean radius, [:math:`m`]
|
|
1096
|
+
|
|
1097
|
+
Returns
|
|
1098
|
+
-------
|
|
1099
|
+
npt.NDArray[np.floating]
|
|
1100
|
+
phase delay of the light wave passing through the contrail ice particle
|
|
1101
|
+
|
|
1102
|
+
References
|
|
1103
|
+
----------
|
|
1104
|
+
- https://en.wikipedia.org/wiki/Mie_scattering
|
|
1105
|
+
"""
|
|
1106
|
+
phase_delay = (4.0 * np.pi * (constants.mu_ice - 1.0) / constants.lambda_light) * r_ice_vol
|
|
1107
|
+
phase_delay.clip(min=None, max=100.0, out=phase_delay)
|
|
1108
|
+
return phase_delay
|
|
1109
|
+
|
|
1110
|
+
|
|
1111
|
+
#######################################################
|
|
1112
|
+
# Contrail evolution: second-order Runge Kutta scheme
|
|
1113
|
+
#######################################################
|
|
1114
|
+
# Notation "t1" implies properties at the start of the time step (before the time integration step)
|
|
1115
|
+
# Notation "t2" implies properties at the end of the time step (after the time integration step)
|
|
1116
|
+
|
|
1117
|
+
|
|
1118
|
+
def segment_length_ratio(
|
|
1119
|
+
seg_length_t1: npt.NDArray[np.floating],
|
|
1120
|
+
seg_length_t2: npt.NDArray[np.floating],
|
|
1121
|
+
) -> npt.NDArray[np.floating]:
|
|
1122
|
+
"""Calculate the ratio of contrail segment length pre-advection to post-advection.
|
|
1123
|
+
|
|
1124
|
+
Parameters
|
|
1125
|
+
----------
|
|
1126
|
+
seg_length_t1 : npt.NDArray[np.floating]
|
|
1127
|
+
Segment length of contrail waypoint at the start of the time step, [:math:`m`]
|
|
1128
|
+
seg_length_t2 : npt.NDArray[np.floating]
|
|
1129
|
+
Segment length of contrail waypoint after time step and advection, [:math:`m`]
|
|
1130
|
+
|
|
1131
|
+
Returns
|
|
1132
|
+
-------
|
|
1133
|
+
npt.NDArray[np.floating]
|
|
1134
|
+
Ratio of segment length before advection to segment length after advection.
|
|
1135
|
+
|
|
1136
|
+
Notes
|
|
1137
|
+
-----
|
|
1138
|
+
This implementation differs from the original fortran implementation.
|
|
1139
|
+
Instead of taking a geometric mean between
|
|
1140
|
+
the previous and following segments, a simple ratio is computed.
|
|
1141
|
+
|
|
1142
|
+
For terminal waypoints along a flight trajectory, the associated segment length is 0. In this
|
|
1143
|
+
case, the segment ratio is set to 1 (the naive ratio 0 / 0 is undefined). According to CoCiP
|
|
1144
|
+
conventions, terminus waypoints are "discontinuous" within the flight trajectory, and will not
|
|
1145
|
+
contribute to contrail calculations.
|
|
1146
|
+
|
|
1147
|
+
More broadly, any undefined (nan values, or division by 0) segment ratio is set to 1.
|
|
1148
|
+
This convention ensures that the contrail calculations are not affected by undefined
|
|
1149
|
+
segment-based properties.
|
|
1150
|
+
|
|
1151
|
+
Presently, the output of this function is only used by :func:`plume_temporal_evolution`
|
|
1152
|
+
and :func:`new_ice_particle_number` as a scaling term.
|
|
1153
|
+
|
|
1154
|
+
A `seg_ratio` value of 1 is the same as not applying any scaling in these two functions.
|
|
1155
|
+
"""
|
|
1156
|
+
is_defined = (seg_length_t2 > 0.0) & np.isfinite(seg_length_t1)
|
|
1157
|
+
default_value = np.ones_like(seg_length_t1)
|
|
1158
|
+
return np.divide(seg_length_t1, seg_length_t2, out=default_value, where=is_defined)
|
|
1159
|
+
|
|
1160
|
+
|
|
1161
|
+
def plume_temporal_evolution(
|
|
1162
|
+
width_t1: npt.NDArray[np.floating],
|
|
1163
|
+
depth_t1: npt.NDArray[np.floating],
|
|
1164
|
+
sigma_yz_t1: npt.NDArray[np.floating],
|
|
1165
|
+
dsn_dz_t1: npt.NDArray[np.floating],
|
|
1166
|
+
diffuse_h_t1: npt.NDArray[np.floating],
|
|
1167
|
+
diffuse_v_t1: npt.NDArray[np.floating],
|
|
1168
|
+
seg_ratio: npt.NDArray[np.floating] | float,
|
|
1169
|
+
dt: npt.NDArray[np.timedelta64] | np.timedelta64,
|
|
1170
|
+
max_depth: float | None,
|
|
1171
|
+
) -> tuple[npt.NDArray[np.floating], npt.NDArray[np.floating], npt.NDArray[np.floating]]:
|
|
1172
|
+
"""
|
|
1173
|
+
Calculate the temporal evolution of the contrail plume parameters.
|
|
1174
|
+
|
|
1175
|
+
Refer to equation (6) of Schumann (2012). See also equations (29), (30), and (31).
|
|
1176
|
+
|
|
1177
|
+
Parameters
|
|
1178
|
+
----------
|
|
1179
|
+
width_t1 : npt.NDArray[np.floating]
|
|
1180
|
+
contrail width at the start of the time step, [:math:`m`]
|
|
1181
|
+
depth_t1 : npt.NDArray[np.floating]
|
|
1182
|
+
contrail depth at the start of the time step, [:math:`m`]
|
|
1183
|
+
sigma_yz_t1 : npt.NDArray[np.floating]
|
|
1184
|
+
sigma_yz governs the contrail plume's temporal evolution at the start of the time step
|
|
1185
|
+
dsn_dz_t1 : npt.NDArray[np.floating]
|
|
1186
|
+
vertical gradient of the horizontal velocity (wind shear) normal to the contrail axis
|
|
1187
|
+
at the start of the time step, [:math:`m s^{-1} / Pa`]::
|
|
1188
|
+
|
|
1189
|
+
X-----------------------X X
|
|
1190
|
+
^ |
|
|
1191
|
+
| (dsn_dz) | <-- (dsn_dz)
|
|
1192
|
+
| |
|
|
1193
|
+
X
|
|
1194
|
+
diffuse_h_t1 : npt.NDArray[np.floating]
|
|
1195
|
+
horizontal diffusivity at the start of the time step, [:math:`m^{2} s^{-1}`]
|
|
1196
|
+
diffuse_v_t1 : npt.NDArray[np.floating]
|
|
1197
|
+
vertical diffusivity at the start of the time step, [:math:`m^{2} s^{-1}`]
|
|
1198
|
+
seg_ratio : npt.NDArray[np.floating] | float
|
|
1199
|
+
Segment length ratio before and after it is advected to the new location.
|
|
1200
|
+
See :func:`segment_length_ratio`.
|
|
1201
|
+
dt : npt.NDArray[np.timedelta64] | np.timedelta64
|
|
1202
|
+
integrate contrails with time steps of dt, [:math:`s`]
|
|
1203
|
+
max_depth: float | None
|
|
1204
|
+
Constrain maximum plume depth to prevent unrealistic values, [:math:`m`].
|
|
1205
|
+
If None is passed, the maximum plume depth is not constrained.
|
|
1206
|
+
|
|
1207
|
+
Returns
|
|
1208
|
+
-------
|
|
1209
|
+
sigma_yy_t2 : npt.NDArray[np.floating]
|
|
1210
|
+
The ``yy`` component of convariance matrix, [:math:`m^{2}`]
|
|
1211
|
+
sigma_zz_t2 : npt.NDArray[np.floating]
|
|
1212
|
+
The ``zz`` component of convariance matrix, [:math:`m^{2}`]
|
|
1213
|
+
sigma_yz_t2 : npt.NDArray[np.floating]
|
|
1214
|
+
The ``yz`` component of convariance matrix, [:math:`m^{2}`]
|
|
1215
|
+
"""
|
|
1216
|
+
# Convert dt to seconds value and use dtype of other variables
|
|
1217
|
+
dtype = np.result_type(width_t1, depth_t1, sigma_yz_t1, dsn_dz_t1, diffuse_h_t1, diffuse_v_t1)
|
|
1218
|
+
dt_s = units.dt_to_seconds(dt, dtype)
|
|
1219
|
+
|
|
1220
|
+
sigma_yy = 0.125 * width_t1**2
|
|
1221
|
+
sigma_zz = 0.125 * depth_t1**2
|
|
1222
|
+
|
|
1223
|
+
# Convert from max_depth to an upper bound for diffuse_v_t1
|
|
1224
|
+
# All three terms involve the diffuse_v_t1 variable, so we need to
|
|
1225
|
+
# calculate the max value for diffuse_v_t1 and apply it to all three terms.
|
|
1226
|
+
# If we don't do this, we violate the some mathematical constraints of the
|
|
1227
|
+
# covariance matrix (positive definite). In particular, for downstream
|
|
1228
|
+
# calculations, we required that
|
|
1229
|
+
# sigma_yy_t2 * sigma_zz_t2 - sigma_yz_t2**2 >= 0
|
|
1230
|
+
if max_depth is not None:
|
|
1231
|
+
max_sigma_zz = 0.125 * max_depth**2
|
|
1232
|
+
max_diffuse_v = (max_sigma_zz - sigma_zz) / (2.0 * dt_s)
|
|
1233
|
+
diffuse_v_t1 = np.minimum(diffuse_v_t1, max_diffuse_v)
|
|
1234
|
+
|
|
1235
|
+
# Avoid some redundant calculations
|
|
1236
|
+
dsn_dz_t1_2 = dsn_dz_t1**2
|
|
1237
|
+
dt_s_2 = dt_s**2
|
|
1238
|
+
dt_s_3 = dt_s * dt_s_2
|
|
1239
|
+
|
|
1240
|
+
# Calculate the return arrays
|
|
1241
|
+
sigma_yy_t2 = (
|
|
1242
|
+
((2 / 3) * dsn_dz_t1_2 * diffuse_v_t1 * dt_s_3)
|
|
1243
|
+
+ (dsn_dz_t1_2 * sigma_zz * dt_s_2)
|
|
1244
|
+
+ (2.0 * (diffuse_h_t1 + dsn_dz_t1 * sigma_yz_t1) * dt_s)
|
|
1245
|
+
+ sigma_yy
|
|
1246
|
+
) * (seg_ratio**2)
|
|
1247
|
+
|
|
1248
|
+
sigma_zz_t2 = (2.0 * diffuse_v_t1 * dt_s) + sigma_zz
|
|
1249
|
+
|
|
1250
|
+
sigma_yz_t2 = (
|
|
1251
|
+
(dsn_dz_t1 * diffuse_v_t1 * dt_s_2) + (dsn_dz_t1 * sigma_zz * dt_s) + sigma_yz_t1
|
|
1252
|
+
) * seg_ratio
|
|
1253
|
+
|
|
1254
|
+
return sigma_yy_t2, sigma_zz_t2, sigma_yz_t2
|
|
1255
|
+
|
|
1256
|
+
|
|
1257
|
+
def new_contrail_dimensions(
|
|
1258
|
+
sigma_yy_t2: npt.NDArray[np.floating],
|
|
1259
|
+
sigma_zz_t2: npt.NDArray[np.floating],
|
|
1260
|
+
) -> tuple[npt.NDArray[np.floating], npt.NDArray[np.floating]]:
|
|
1261
|
+
"""
|
|
1262
|
+
Calculate the new contrail width and depth.
|
|
1263
|
+
|
|
1264
|
+
Parameters
|
|
1265
|
+
----------
|
|
1266
|
+
sigma_yy_t2 : npt.NDArray[np.floating]
|
|
1267
|
+
element yy, covariance matrix of the Gaussian concentration
|
|
1268
|
+
field, Eq. (6) of Schumann (2012)
|
|
1269
|
+
sigma_zz_t2 : npt.NDArray[np.floating]
|
|
1270
|
+
element zz, covariance matrix of the Gaussian concentration
|
|
1271
|
+
field, Eq. (6) of Schumann (2012)
|
|
1272
|
+
|
|
1273
|
+
Returns
|
|
1274
|
+
-------
|
|
1275
|
+
width_t2 : npt.NDArray[np.floating]
|
|
1276
|
+
Contrail width at the end of the time step, [:math:`m`]
|
|
1277
|
+
depth_t2 : npt.NDArray[np.floating]
|
|
1278
|
+
Contrail depth at the end of the time step, [:math:`m`]
|
|
1279
|
+
"""
|
|
1280
|
+
width_t2 = (8 * sigma_yy_t2) ** 0.5
|
|
1281
|
+
depth_t2 = (8 * sigma_zz_t2) ** 0.5
|
|
1282
|
+
return width_t2, depth_t2
|
|
1283
|
+
|
|
1284
|
+
|
|
1285
|
+
def new_effective_area_from_sigma(
|
|
1286
|
+
sigma_yy: npt.NDArray[np.floating],
|
|
1287
|
+
sigma_zz: npt.NDArray[np.floating],
|
|
1288
|
+
sigma_yz: npt.NDArray[np.floating] | float,
|
|
1289
|
+
) -> npt.NDArray[np.floating]:
|
|
1290
|
+
"""
|
|
1291
|
+
Calculate effective cross-sectional area of contrail plume (``area_eff``) from sigma parameters.
|
|
1292
|
+
|
|
1293
|
+
This method calculates the same output as :func`plume_effective_cross_sectional_area`, but
|
|
1294
|
+
calculated with different input parameters.
|
|
1295
|
+
|
|
1296
|
+
Parameters
|
|
1297
|
+
----------
|
|
1298
|
+
sigma_yy : npt.NDArray[np.floating]
|
|
1299
|
+
element yy, covariance matrix of the Gaussian concentration
|
|
1300
|
+
field, Eq. (6) of Schumann (2012)
|
|
1301
|
+
sigma_zz : npt.NDArray[np.floating]
|
|
1302
|
+
element zz, covariance matrix of the Gaussian concentration
|
|
1303
|
+
field, Eq. (6) of Schumann (2012)
|
|
1304
|
+
sigma_yz : npt.NDArray[np.floating] | float
|
|
1305
|
+
element yz, covariance matrix of the Gaussian concentration
|
|
1306
|
+
field, Eq. (6) of Schumann (2012)
|
|
1307
|
+
|
|
1308
|
+
Returns
|
|
1309
|
+
-------
|
|
1310
|
+
npt.NDArray[np.floating]
|
|
1311
|
+
Effective cross-sectional area of the contrail plume (area_eff)
|
|
1312
|
+
"""
|
|
1313
|
+
det_sigma = sigma_yy * sigma_zz - sigma_yz**2
|
|
1314
|
+
return 2.0 * np.pi * det_sigma**0.5
|
|
1315
|
+
|
|
1316
|
+
|
|
1317
|
+
def new_ice_water_content(
|
|
1318
|
+
iwc_t1: npt.NDArray[np.floating],
|
|
1319
|
+
q_t1: npt.NDArray[np.floating],
|
|
1320
|
+
q_t2: npt.NDArray[np.floating],
|
|
1321
|
+
q_sat_t1: npt.NDArray[np.floating],
|
|
1322
|
+
q_sat_t2: npt.NDArray[np.floating],
|
|
1323
|
+
mass_plume_t1: npt.NDArray[np.floating],
|
|
1324
|
+
mass_plume_t2: npt.NDArray[np.floating],
|
|
1325
|
+
) -> npt.NDArray[np.floating]:
|
|
1326
|
+
"""
|
|
1327
|
+
Calculate the new contrail ice water content after the time integration step (``iwc_t2``).
|
|
1328
|
+
|
|
1329
|
+
Parameters
|
|
1330
|
+
----------
|
|
1331
|
+
iwc_t1 : npt.NDArray[np.floating]
|
|
1332
|
+
contrail ice water content, i.e., contrail ice mass per kg of air,
|
|
1333
|
+
at the start of the time step, [:math:`kg_{H_{2}O}/kg_{air}`]
|
|
1334
|
+
q_t1 : npt.NDArray[np.floating]
|
|
1335
|
+
specific humidity for each waypoint at the start of the
|
|
1336
|
+
time step, [:math:`kg_{H_{2}O}/kg_{air}`]
|
|
1337
|
+
q_t2 : npt.NDArray[np.floating]
|
|
1338
|
+
specific humidity for each waypoint at the end of the
|
|
1339
|
+
time step, [:math:`kg_{H_{2}O}/kg_{air}`]
|
|
1340
|
+
q_sat_t1 : npt.NDArray[np.floating]
|
|
1341
|
+
saturation humidity for each waypoint at the start of the
|
|
1342
|
+
time step, [:math:`kg_{H_{2}O}/kg_{air}`]
|
|
1343
|
+
q_sat_t2 : npt.NDArray[np.floating]
|
|
1344
|
+
saturation humidity for each waypoint at the end of the
|
|
1345
|
+
time step, [:math:`kg_{H_{2}O}/kg_{air}`]
|
|
1346
|
+
mass_plume_t1 : npt.NDArray[np.floating]
|
|
1347
|
+
contrail plume mass per unit length at the start of the
|
|
1348
|
+
time step, [:math:`kg_{air} m^{-1}`]
|
|
1349
|
+
mass_plume_t2 : npt.NDArray[np.floating]
|
|
1350
|
+
contrail plume mass per unit length at the end of the
|
|
1351
|
+
time step, [:math:`kg_{air} m^{-1}`]
|
|
1352
|
+
|
|
1353
|
+
Returns
|
|
1354
|
+
-------
|
|
1355
|
+
npt.NDArray[np.floating]
|
|
1356
|
+
Contrail ice water content at the end of the time step, [:math:`kg_{ice} kg_{air}^{-1}`]
|
|
1357
|
+
|
|
1358
|
+
Notes
|
|
1359
|
+
-----
|
|
1360
|
+
(1) The ice water content is fully conservative.
|
|
1361
|
+
(2) ``mass_h2o_t2``: the total H2O mass (ice + vapour) per unit of
|
|
1362
|
+
contrail plume [Units of kg-H2O/m]
|
|
1363
|
+
(3) ``q_sat`` is used to calculate mass_h2o because air inside the
|
|
1364
|
+
contrail is assumed to be ice saturated.
|
|
1365
|
+
(4) ``(mass_plume_t2 - mass_plume) * q_mean``: contrail absorbs
|
|
1366
|
+
(releases) H2O from (to) surrounding air.
|
|
1367
|
+
(5) ``iwc_t2 = mass_h2o_t2 / mass_plume_t2 - q_sat_t2``: H2O in the
|
|
1368
|
+
gas phase is removed (``- q_sat_t2``).
|
|
1369
|
+
"""
|
|
1370
|
+
q_mean = 0.5 * (q_t1 + q_t2)
|
|
1371
|
+
mass_h2o_t1 = mass_plume_t1 * (iwc_t1 + q_sat_t1)
|
|
1372
|
+
mass_h2o_t2 = mass_h2o_t1 + (mass_plume_t2 - mass_plume_t1) * q_mean
|
|
1373
|
+
iwc_t2 = (mass_h2o_t2 / mass_plume_t2) - q_sat_t2
|
|
1374
|
+
iwc_t2.clip(min=0.0, out=iwc_t2)
|
|
1375
|
+
return iwc_t2
|
|
1376
|
+
|
|
1377
|
+
|
|
1378
|
+
def new_ice_particle_number(
|
|
1379
|
+
n_ice_per_m_t1: npt.NDArray[np.floating],
|
|
1380
|
+
dn_dt_agg: npt.NDArray[np.floating],
|
|
1381
|
+
dn_dt_turb: npt.NDArray[np.floating],
|
|
1382
|
+
seg_ratio: npt.NDArray[np.floating] | float,
|
|
1383
|
+
dt: npt.NDArray[np.timedelta64] | np.timedelta64,
|
|
1384
|
+
) -> npt.NDArray[np.floating]:
|
|
1385
|
+
"""Calculate the number of ice particles per distance at the end of the time step.
|
|
1386
|
+
|
|
1387
|
+
Parameters
|
|
1388
|
+
----------
|
|
1389
|
+
n_ice_per_m_t1 : npt.NDArray[np.floating]
|
|
1390
|
+
number of contrail ice particles per distance at the start of
|
|
1391
|
+
the time step, [:math:`m^{-1}`]
|
|
1392
|
+
dn_dt_agg : npt.NDArray[np.floating]
|
|
1393
|
+
rate of ice particle losses due to sedimentation-induced aggregation, [:math:`# s^{-1}`]
|
|
1394
|
+
dn_dt_turb : npt.NDArray[np.floating]
|
|
1395
|
+
rate of contrail ice particle losses due to plume-internal turbulence, [:math:`# s^{-1}`]
|
|
1396
|
+
seg_ratio : npt.NDArray[np.floating] | float
|
|
1397
|
+
Segment length ratio before and after it is advected to the new location.
|
|
1398
|
+
dt : npt.NDArray[np.timedelta64] | np.timedelta64
|
|
1399
|
+
integrate contrails with time steps of dt, [:math:`s`]
|
|
1400
|
+
|
|
1401
|
+
Returns
|
|
1402
|
+
-------
|
|
1403
|
+
npt.NDArray[np.floating]
|
|
1404
|
+
number of ice particles per distance at the end of the time step, [:math:`m^{-1}`]
|
|
1405
|
+
"""
|
|
1406
|
+
# Convert dt to seconds value and use dtype of other variables
|
|
1407
|
+
dtype = np.result_type(n_ice_per_m_t1, dn_dt_agg, dn_dt_turb, seg_ratio)
|
|
1408
|
+
dt_s = units.dt_to_seconds(dt, dtype)
|
|
1409
|
+
|
|
1410
|
+
n_ice_per_m_t1 = np.maximum(n_ice_per_m_t1, 0.0)
|
|
1411
|
+
|
|
1412
|
+
exp_term = np.where(dn_dt_turb * dt_s < 80.0, np.exp(-dn_dt_turb * dt_s), 0.0)
|
|
1413
|
+
|
|
1414
|
+
numerator = dn_dt_turb * n_ice_per_m_t1 * exp_term
|
|
1415
|
+
denominator = dn_dt_turb + (dn_dt_agg * n_ice_per_m_t1 * (1 - exp_term))
|
|
1416
|
+
n_ice_per_m_t2 = (numerator / denominator) * seg_ratio
|
|
1417
|
+
|
|
1418
|
+
small_loss = (dn_dt_turb * dt_s) < 1e-5 # For small ice particle losses
|
|
1419
|
+
denom = 1 + (dn_dt_agg * dt_s * n_ice_per_m_t1)
|
|
1420
|
+
n_ice_per_m_t2[small_loss] = n_ice_per_m_t1[small_loss] / denom[small_loss]
|
|
1421
|
+
n_ice_per_m_t2.clip(min=0.0, out=n_ice_per_m_t2)
|
|
1422
|
+
return n_ice_per_m_t2
|
|
1423
|
+
|
|
1424
|
+
|
|
1425
|
+
########
|
|
1426
|
+
# Energy Forcing
|
|
1427
|
+
########
|
|
1428
|
+
# TODO: This should be moved closer to the radiative forcing calculations
|
|
1429
|
+
|
|
1430
|
+
|
|
1431
|
+
def energy_forcing(
|
|
1432
|
+
rf_net_t1: npt.NDArray[np.floating],
|
|
1433
|
+
rf_net_t2: npt.NDArray[np.floating],
|
|
1434
|
+
width_t1: npt.NDArray[np.floating],
|
|
1435
|
+
width_t2: npt.NDArray[np.floating],
|
|
1436
|
+
seg_length_t2: npt.NDArray[np.floating] | float,
|
|
1437
|
+
dt: npt.NDArray[np.timedelta64] | np.timedelta64,
|
|
1438
|
+
) -> npt.NDArray[np.floating]:
|
|
1439
|
+
"""Calculate the contrail energy forcing over time step.
|
|
1440
|
+
|
|
1441
|
+
The contrail energy forcing is calculated as the local contrail net
|
|
1442
|
+
radiative forcing (RF', change in energy flux per contrail area) multiplied
|
|
1443
|
+
by its width and integrated over its length and lifetime.
|
|
1444
|
+
|
|
1445
|
+
Parameters
|
|
1446
|
+
----------
|
|
1447
|
+
rf_net_t1 : npt.NDArray[np.floating]
|
|
1448
|
+
local contrail net radiative forcing at the start of the time step, [:math:`W m^{-2}`]
|
|
1449
|
+
rf_net_t2 : npt.NDArray[np.floating]
|
|
1450
|
+
local contrail net radiative forcing at the end of the time step, [:math:`W m^{-2}`]
|
|
1451
|
+
width_t1 : npt.NDArray[np.floating]
|
|
1452
|
+
contrail width at the start of the time step, [:math:`m`]
|
|
1453
|
+
width_t2 : npt.NDArray[np.floating]
|
|
1454
|
+
contrail width at the end of the time step, [:math:`m`]
|
|
1455
|
+
seg_length_t2 : npt.NDArray[np.floating] | float
|
|
1456
|
+
Segment length of contrail waypoint at the end of the time step, [:math:`m`]
|
|
1457
|
+
dt : npt.NDArray[np.timedelta64] | np.timedelta64
|
|
1458
|
+
integrate contrails with time steps of dt, [:math:`s`]
|
|
1459
|
+
|
|
1460
|
+
Returns
|
|
1461
|
+
-------
|
|
1462
|
+
npt.NDArray[np.floating]
|
|
1463
|
+
Contrail energy forcing over time step dt, [:math:`J`].
|
|
1464
|
+
"""
|
|
1465
|
+
rad_flux_per_m = mean_radiative_flux_per_m(rf_net_t1, rf_net_t2, width_t1, width_t2)
|
|
1466
|
+
energy_flux_per_m = mean_energy_flux_per_m(rad_flux_per_m, dt)
|
|
1467
|
+
return energy_flux_per_m * seg_length_t2
|
|
1468
|
+
|
|
1469
|
+
|
|
1470
|
+
def mean_radiative_flux_per_m(
|
|
1471
|
+
rf_net_t1: npt.NDArray[np.floating],
|
|
1472
|
+
rf_net_t2: npt.NDArray[np.floating],
|
|
1473
|
+
width_t1: npt.NDArray[np.floating],
|
|
1474
|
+
width_t2: npt.NDArray[np.floating],
|
|
1475
|
+
) -> npt.NDArray[np.floating]:
|
|
1476
|
+
"""Calculate the mean radiative flux per length of contrail between two time steps.
|
|
1477
|
+
|
|
1478
|
+
Parameters
|
|
1479
|
+
----------
|
|
1480
|
+
rf_net_t1 : npt.NDArray[np.floating]
|
|
1481
|
+
local contrail net radiative forcing at the start of the time step, [:math:`W m^{-2}`]
|
|
1482
|
+
rf_net_t2 : npt.NDArray[np.floating]
|
|
1483
|
+
local contrail net radiative forcing at the end of the time step, [:math:`W m^{-2}`]
|
|
1484
|
+
width_t1 : npt.NDArray[np.floating]
|
|
1485
|
+
contrail width at the start of the time step, [:math:`m`]
|
|
1486
|
+
width_t2 : npt.NDArray[np.floating]
|
|
1487
|
+
contrail width at the end of the time step, [:math:`m`]
|
|
1488
|
+
|
|
1489
|
+
Returns
|
|
1490
|
+
-------
|
|
1491
|
+
npt.NDArray[np.floating]
|
|
1492
|
+
Mean radiative flux between time steps, [:math:`W m^{-1}`]
|
|
1493
|
+
"""
|
|
1494
|
+
rad_flux_per_m_t1 = width_t1 * rf_net_t1
|
|
1495
|
+
rad_flux_per_m_t2 = width_t2 * rf_net_t2
|
|
1496
|
+
return (rad_flux_per_m_t1 + rad_flux_per_m_t2) * 0.5
|
|
1497
|
+
|
|
1498
|
+
|
|
1499
|
+
def mean_energy_flux_per_m(
|
|
1500
|
+
rad_flux_per_m: npt.NDArray[np.floating], dt: npt.NDArray[np.timedelta64] | np.timedelta64
|
|
1501
|
+
) -> npt.NDArray[np.floating]:
|
|
1502
|
+
"""Calculate the mean energy flux per length of contrail on segment following waypoint.
|
|
1503
|
+
|
|
1504
|
+
Parameters
|
|
1505
|
+
----------
|
|
1506
|
+
rad_flux_per_m : npt.NDArray[np.floating]
|
|
1507
|
+
Mean radiative flux between time steps for waypoint, [:math:`W m^{-1}`].
|
|
1508
|
+
See :func:`mean_radiative_flux_per_m`.
|
|
1509
|
+
dt : npt.NDArray[np.timedelta64] | np.timedelta64
|
|
1510
|
+
timedelta of integration timestep for each waypoint.
|
|
1511
|
+
|
|
1512
|
+
Returns
|
|
1513
|
+
-------
|
|
1514
|
+
npt.NDArray[np.floating]
|
|
1515
|
+
Mean energy flux per length of contrail after waypoint, [:math:`J m^{-1}`]
|
|
1516
|
+
|
|
1517
|
+
Notes
|
|
1518
|
+
-----
|
|
1519
|
+
Implementation differs from original fortran in two ways:
|
|
1520
|
+
|
|
1521
|
+
- Discontinuity is no longer set to 0 (this occurs directly in model :class:`Cocip`)
|
|
1522
|
+
- Instead of taking an average of the previous and following segments,
|
|
1523
|
+
energy flux is only calculated for the following segment.
|
|
1524
|
+
|
|
1525
|
+
See Also
|
|
1526
|
+
--------
|
|
1527
|
+
:func:`mean_radiative_flux_per_m`
|
|
1528
|
+
"""
|
|
1529
|
+
dt_s = units.dt_to_seconds(dt, rad_flux_per_m.dtype)
|
|
1530
|
+
return rad_flux_per_m * dt_s
|