pycontrails 0.59.0__cp314-cp314-macosx_10_15_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.

Files changed (123) hide show
  1. pycontrails/__init__.py +70 -0
  2. pycontrails/_version.py +34 -0
  3. pycontrails/core/__init__.py +30 -0
  4. pycontrails/core/aircraft_performance.py +679 -0
  5. pycontrails/core/airports.py +228 -0
  6. pycontrails/core/cache.py +889 -0
  7. pycontrails/core/coordinates.py +174 -0
  8. pycontrails/core/fleet.py +483 -0
  9. pycontrails/core/flight.py +2185 -0
  10. pycontrails/core/flightplan.py +228 -0
  11. pycontrails/core/fuel.py +140 -0
  12. pycontrails/core/interpolation.py +702 -0
  13. pycontrails/core/met.py +2936 -0
  14. pycontrails/core/met_var.py +387 -0
  15. pycontrails/core/models.py +1321 -0
  16. pycontrails/core/polygon.py +549 -0
  17. pycontrails/core/rgi_cython.cpython-314-darwin.so +0 -0
  18. pycontrails/core/vector.py +2249 -0
  19. pycontrails/datalib/__init__.py +12 -0
  20. pycontrails/datalib/_met_utils/metsource.py +746 -0
  21. pycontrails/datalib/ecmwf/__init__.py +73 -0
  22. pycontrails/datalib/ecmwf/arco_era5.py +345 -0
  23. pycontrails/datalib/ecmwf/common.py +114 -0
  24. pycontrails/datalib/ecmwf/era5.py +554 -0
  25. pycontrails/datalib/ecmwf/era5_model_level.py +490 -0
  26. pycontrails/datalib/ecmwf/hres.py +804 -0
  27. pycontrails/datalib/ecmwf/hres_model_level.py +466 -0
  28. pycontrails/datalib/ecmwf/ifs.py +287 -0
  29. pycontrails/datalib/ecmwf/model_levels.py +435 -0
  30. pycontrails/datalib/ecmwf/static/model_level_dataframe_v20240418.csv +139 -0
  31. pycontrails/datalib/ecmwf/variables.py +268 -0
  32. pycontrails/datalib/geo_utils.py +261 -0
  33. pycontrails/datalib/gfs/__init__.py +28 -0
  34. pycontrails/datalib/gfs/gfs.py +656 -0
  35. pycontrails/datalib/gfs/variables.py +104 -0
  36. pycontrails/datalib/goes.py +764 -0
  37. pycontrails/datalib/gruan.py +343 -0
  38. pycontrails/datalib/himawari/__init__.py +27 -0
  39. pycontrails/datalib/himawari/header_struct.py +266 -0
  40. pycontrails/datalib/himawari/himawari.py +671 -0
  41. pycontrails/datalib/landsat.py +589 -0
  42. pycontrails/datalib/leo_utils/__init__.py +5 -0
  43. pycontrails/datalib/leo_utils/correction.py +266 -0
  44. pycontrails/datalib/leo_utils/landsat_metadata.py +300 -0
  45. pycontrails/datalib/leo_utils/search.py +250 -0
  46. pycontrails/datalib/leo_utils/sentinel_metadata.py +748 -0
  47. pycontrails/datalib/leo_utils/static/bq_roi_query.sql +6 -0
  48. pycontrails/datalib/leo_utils/vis.py +59 -0
  49. pycontrails/datalib/sentinel.py +650 -0
  50. pycontrails/datalib/spire/__init__.py +5 -0
  51. pycontrails/datalib/spire/exceptions.py +62 -0
  52. pycontrails/datalib/spire/spire.py +604 -0
  53. pycontrails/ext/bada.py +42 -0
  54. pycontrails/ext/cirium.py +14 -0
  55. pycontrails/ext/empirical_grid.py +140 -0
  56. pycontrails/ext/synthetic_flight.py +431 -0
  57. pycontrails/models/__init__.py +1 -0
  58. pycontrails/models/accf.py +425 -0
  59. pycontrails/models/apcemm/__init__.py +8 -0
  60. pycontrails/models/apcemm/apcemm.py +983 -0
  61. pycontrails/models/apcemm/inputs.py +226 -0
  62. pycontrails/models/apcemm/static/apcemm_yaml_template.yaml +183 -0
  63. pycontrails/models/apcemm/utils.py +437 -0
  64. pycontrails/models/cocip/__init__.py +29 -0
  65. pycontrails/models/cocip/cocip.py +2742 -0
  66. pycontrails/models/cocip/cocip_params.py +305 -0
  67. pycontrails/models/cocip/cocip_uncertainty.py +291 -0
  68. pycontrails/models/cocip/contrail_properties.py +1530 -0
  69. pycontrails/models/cocip/output_formats.py +2270 -0
  70. pycontrails/models/cocip/radiative_forcing.py +1260 -0
  71. pycontrails/models/cocip/radiative_heating.py +520 -0
  72. pycontrails/models/cocip/unterstrasser_wake_vortex.py +508 -0
  73. pycontrails/models/cocip/wake_vortex.py +396 -0
  74. pycontrails/models/cocip/wind_shear.py +120 -0
  75. pycontrails/models/cocipgrid/__init__.py +9 -0
  76. pycontrails/models/cocipgrid/cocip_grid.py +2552 -0
  77. pycontrails/models/cocipgrid/cocip_grid_params.py +138 -0
  78. pycontrails/models/dry_advection.py +602 -0
  79. pycontrails/models/emissions/__init__.py +21 -0
  80. pycontrails/models/emissions/black_carbon.py +599 -0
  81. pycontrails/models/emissions/emissions.py +1353 -0
  82. pycontrails/models/emissions/ffm2.py +336 -0
  83. pycontrails/models/emissions/static/default-engine-uids.csv +239 -0
  84. pycontrails/models/emissions/static/edb-gaseous-v29b-engines.csv +596 -0
  85. pycontrails/models/emissions/static/edb-nvpm-v29b-engines.csv +215 -0
  86. pycontrails/models/extended_k15.py +1327 -0
  87. pycontrails/models/humidity_scaling/__init__.py +37 -0
  88. pycontrails/models/humidity_scaling/humidity_scaling.py +1075 -0
  89. pycontrails/models/humidity_scaling/quantiles/era5-model-level-quantiles.pq +0 -0
  90. pycontrails/models/humidity_scaling/quantiles/era5-pressure-level-quantiles.pq +0 -0
  91. pycontrails/models/issr.py +210 -0
  92. pycontrails/models/pcc.py +326 -0
  93. pycontrails/models/pcr.py +154 -0
  94. pycontrails/models/ps_model/__init__.py +18 -0
  95. pycontrails/models/ps_model/ps_aircraft_params.py +381 -0
  96. pycontrails/models/ps_model/ps_grid.py +701 -0
  97. pycontrails/models/ps_model/ps_model.py +1000 -0
  98. pycontrails/models/ps_model/ps_operational_limits.py +525 -0
  99. pycontrails/models/ps_model/static/ps-aircraft-params-20250328.csv +69 -0
  100. pycontrails/models/ps_model/static/ps-synonym-list-20250328.csv +104 -0
  101. pycontrails/models/sac.py +442 -0
  102. pycontrails/models/tau_cirrus.py +183 -0
  103. pycontrails/physics/__init__.py +1 -0
  104. pycontrails/physics/constants.py +117 -0
  105. pycontrails/physics/geo.py +1138 -0
  106. pycontrails/physics/jet.py +968 -0
  107. pycontrails/physics/static/iata-cargo-load-factors-20250221.csv +74 -0
  108. pycontrails/physics/static/iata-passenger-load-factors-20250221.csv +74 -0
  109. pycontrails/physics/thermo.py +551 -0
  110. pycontrails/physics/units.py +472 -0
  111. pycontrails/py.typed +0 -0
  112. pycontrails/utils/__init__.py +1 -0
  113. pycontrails/utils/dependencies.py +66 -0
  114. pycontrails/utils/iteration.py +13 -0
  115. pycontrails/utils/json.py +187 -0
  116. pycontrails/utils/temp.py +50 -0
  117. pycontrails/utils/types.py +163 -0
  118. pycontrails-0.59.0.dist-info/METADATA +179 -0
  119. pycontrails-0.59.0.dist-info/RECORD +123 -0
  120. pycontrails-0.59.0.dist-info/WHEEL +6 -0
  121. pycontrails-0.59.0.dist-info/licenses/LICENSE +178 -0
  122. pycontrails-0.59.0.dist-info/licenses/NOTICE +43 -0
  123. pycontrails-0.59.0.dist-info/top_level.txt +3 -0
@@ -0,0 +1,387 @@
1
+ """Module containing core met variables."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import dataclasses
6
+
7
+
8
+ @dataclasses.dataclass(frozen=True)
9
+ class MetVariable:
10
+ """Met variable defined using CF, ECMWF, and WMO conventions.
11
+
12
+ When there is a conflict between CF, ECMWF, and WMO conventions,
13
+ CF takes precedence, then WMO, then ECMWF.
14
+
15
+ References
16
+ ----------
17
+ - `CF Standard Names, version 77
18
+ <https://cfconventions.org/Data/cf-standard-names/77/build/cf-standard-name-table.html>`_
19
+ - `ECMWF Parameter Database <https://apps.ecmwf.int/codes/grib/param-db>`_
20
+ - `NCEP Grib v1 Code Table <https://www.nco.ncep.noaa.gov/pmb/docs/on388/table2.html>`_
21
+ - `WMO Codes Registry, Grib Edition 2 <https://codes.wmo.int/_grib2>`_
22
+ - `NCEP Grib v2 Code Table <https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-2.shtml>`_
23
+
24
+ Used for defining support parameters in a grib-like fashion.
25
+ """
26
+
27
+ #: Short variable name.
28
+ #: Chosen for greatest consistency between data sources.
29
+ short_name: str
30
+
31
+ #: CF standard name, if defined.
32
+ #: Otherwise a standard name is chosen for consistency.
33
+ standard_name: str
34
+
35
+ #: Long variable name.
36
+ long_name: str | None = None
37
+
38
+ #: Level type
39
+ #: One of "surface", "isobaricInhPa", "nominalTop"
40
+ level_type: str | None = None
41
+
42
+ #: ECMWF Grib variable id, if defined.
43
+ #: See `ECMWF Parameter Database <https://apps.ecmwf.int/codes/grib/param-db>`_
44
+ ecmwf_id: int | None = None
45
+
46
+ #: WMO Grib v1 variable id, if defined.
47
+ #: See `WMO Codes Registry, Grib Edition 1 <https://codes.wmo.int/_grib1>`_
48
+ #: and `CF Standard Names, version 77 <https://cfconventions.org/Data/cf-standard-names/77/build/cf-standard-name-table.html>`_ # noqa: E501
49
+ grib1_id: int | None = None
50
+
51
+ #: WMO Grib 2 variable id, if defined.
52
+ #: See `WMO Codes Registry, Grib Edition 2 <https://codes.wmo.int/_grib2>`_
53
+ #: Tuple represents (disciple, category, number)
54
+ grib2_id: tuple[int, int, int] | None = None
55
+
56
+ #: Canonical CF units, if defined.
57
+ units: str | None = None
58
+
59
+ #: AMIP identifier, if defined.
60
+ amip: str | None = None
61
+
62
+ #: Description
63
+ description: str | None = None
64
+
65
+ def __post_init__(self) -> None:
66
+ """Validate inputs.
67
+
68
+ Raises
69
+ ------
70
+ ValueError
71
+ If any of the inputs have an unknown :attr:`level_type`.
72
+ """
73
+ level_types = ("surface", "isobaricInPa", "isobaricInhPa", "nominalTop")
74
+ if self.level_type is not None and self.level_type not in level_types:
75
+ raise ValueError(f"`level_type` must be one of {level_types}")
76
+
77
+ @property
78
+ def ecmwf_link(self) -> str | None:
79
+ """Database link in the ECMWF Parameter Database if :attr:`ecmwf_id` is defined.
80
+
81
+ Returns
82
+ -------
83
+ str | None
84
+ Database link in the ECMWF Parameter Database
85
+ """
86
+ return (
87
+ f"https://apps.ecmwf.int/codes/grib/param-db?id={self.ecmwf_id}"
88
+ if self.ecmwf_id
89
+ else None
90
+ )
91
+
92
+ @property
93
+ def attrs(self) -> dict[str, str]:
94
+ """Return a dictionary of met variable attributes.
95
+
96
+ Compatible with xr.Dataset or xr.DataArray attrs.
97
+
98
+ Returns
99
+ -------
100
+ dict[str, str]
101
+ Dictionary with MetVariable attributes.
102
+ """
103
+
104
+ # return only these keys if they are not None
105
+ keys = ("short_name", "standard_name", "long_name", "units")
106
+ return {k: v for k in keys if (v := getattr(self, k, None)) is not None}
107
+
108
+
109
+ # ----
110
+ # Dimensions
111
+ # ----
112
+
113
+
114
+ AirPressure = MetVariable(
115
+ short_name="p",
116
+ standard_name="air_pressure",
117
+ long_name="Air pressure",
118
+ grib1_id=1,
119
+ ecmwf_id=54,
120
+ units="Pa",
121
+ amip="plev",
122
+ description=(
123
+ "Air pressure is the force per unit area which would be "
124
+ "exerted when the moving gas molecules of which the air is "
125
+ "composed strike a theoretical surface of any orientation."
126
+ ),
127
+ )
128
+
129
+ Altitude = MetVariable(
130
+ short_name="alt",
131
+ standard_name="altitude",
132
+ long_name="Altitude",
133
+ grib1_id=8,
134
+ units="m",
135
+ amip="ta",
136
+ description=(
137
+ "Altitude is the (geometric) height above the geoid, which is the "
138
+ "reference geopotential surface. The geoid is similar to mean sea level."
139
+ ),
140
+ )
141
+
142
+
143
+ # ----
144
+ # Pressure level variables
145
+ # ----
146
+
147
+
148
+ AirTemperature = MetVariable(
149
+ short_name="t",
150
+ standard_name="air_temperature",
151
+ long_name="Air Temperature",
152
+ units="K",
153
+ level_type="isobaricInhPa",
154
+ grib1_id=11,
155
+ ecmwf_id=130,
156
+ grib2_id=(0, 0, 0),
157
+ amip="ta",
158
+ description=(
159
+ "Air temperature is the bulk temperature of the air, not the surface (skin) temperature."
160
+ ),
161
+ )
162
+
163
+ SpecificHumidity = MetVariable(
164
+ short_name="q",
165
+ standard_name="specific_humidity",
166
+ long_name="Specific Humidity",
167
+ units="kg kg**-1",
168
+ level_type="isobaricInhPa",
169
+ grib1_id=51,
170
+ ecmwf_id=133,
171
+ grib2_id=(0, 1, 0),
172
+ amip="hus",
173
+ description=(
174
+ "Specific means per unit mass. Specific humidity is the mass "
175
+ "fraction of water vapor in (moist) air."
176
+ ),
177
+ )
178
+
179
+ RelativeHumidity = MetVariable(
180
+ short_name="r",
181
+ standard_name="relative_humidity",
182
+ long_name="Relative Humidity",
183
+ units="1",
184
+ level_type="isobaricInhPa",
185
+ grib1_id=52,
186
+ ecmwf_id=157,
187
+ grib2_id=(0, 1, 1),
188
+ amip="hur",
189
+ description=(
190
+ "This parameter is the water vapour pressure as a percentage of "
191
+ "the value at which the air becomes saturated liquid."
192
+ ),
193
+ )
194
+
195
+ Geopotential = MetVariable(
196
+ short_name="z",
197
+ standard_name="geopotential",
198
+ long_name="Geopotential",
199
+ units="m**2 s**-2",
200
+ level_type="isobaricInhPa",
201
+ grib1_id=6,
202
+ ecmwf_id=129,
203
+ grib2_id=(0, 3, 4),
204
+ description=(
205
+ "Geopotential is the sum of the specific gravitational potential energy "
206
+ "relative to the geoid and the specific centripetal potential energy."
207
+ ),
208
+ )
209
+
210
+ GeopotentialHeight = MetVariable(
211
+ short_name="gh",
212
+ standard_name="geopotential_height",
213
+ long_name="Geopotential Height",
214
+ units="m",
215
+ level_type="isobaricInhPa",
216
+ grib1_id=7,
217
+ ecmwf_id=156,
218
+ grib2_id=(0, 3, 5),
219
+ amip="zg",
220
+ description=(
221
+ "Geopotential is the sum of the specific gravitational potential energy "
222
+ "relative to the geoid and the specific centripetal potential energy. "
223
+ "Geopotential height is the geopotential divided by the standard "
224
+ "acceleration due to gravity. It is numerically similar to the altitude "
225
+ "(or geometric height) and not to the quantity with standard name height, "
226
+ "which is relative to the surface."
227
+ ),
228
+ )
229
+
230
+ EastwardWind = MetVariable(
231
+ short_name="u",
232
+ long_name="Eastward Wind",
233
+ standard_name="eastward_wind",
234
+ level_type="isobaricInhPa",
235
+ units="m s**-1",
236
+ grib1_id=33,
237
+ ecmwf_id=131,
238
+ grib2_id=(0, 2, 2),
239
+ amip="ua",
240
+ description=(
241
+ '"Eastward" indicates a vector component which is positive '
242
+ "when directed eastward (negative westward). Wind is defined "
243
+ "as a two-dimensional (horizontal) air velocity vector, with no vertical component."
244
+ ),
245
+ )
246
+
247
+ NorthwardWind = MetVariable(
248
+ short_name="v",
249
+ standard_name="northward_wind",
250
+ long_name="Northward Wind",
251
+ units="m s**-1",
252
+ level_type="isobaricInhPa",
253
+ grib1_id=34,
254
+ ecmwf_id=132,
255
+ grib2_id=(0, 2, 3),
256
+ amip="va",
257
+ description=(
258
+ '"Northward" indicates a vector component which is positive when '
259
+ "directed northward (negative southward). Wind is defined as a "
260
+ "two-dimensional (horizontal) air velocity vector, with no vertical component."
261
+ ),
262
+ )
263
+
264
+ VerticalVelocity = MetVariable(
265
+ short_name="w",
266
+ standard_name="lagrangian_tendency_of_air_pressure",
267
+ long_name="Vertical Velocity (omega)",
268
+ units="Pa s**-1",
269
+ level_type="isobaricInhPa",
270
+ grib1_id=39,
271
+ ecmwf_id=135,
272
+ grib2_id=(0, 2, 8),
273
+ amip="wap",
274
+ description=(
275
+ 'The Lagrangian tendency of air pressure, often called "omega", plays '
276
+ "the role of the upward component of air velocity when air pressure "
277
+ "is being used as the vertical coordinate. If the vertical air velocity "
278
+ "is upwards, it is negative when expressed as a tendency of air pressure; "
279
+ "downwards is positive. Air pressure is the force per unit area which "
280
+ "would be exerted when the moving gas molecules of which the air is "
281
+ "composed strike a theoretical surface of any orientation."
282
+ ),
283
+ )
284
+
285
+ MassFractionOfCloudLiquidWaterInAir = MetVariable(
286
+ short_name="clw",
287
+ standard_name="mass_fraction_of_cloud_liquid_water_in_air",
288
+ long_name="Mass fraction of cloud liquid water in air",
289
+ units="kg kg**-1",
290
+ level_type="isobaricInhPa",
291
+ amip="clw",
292
+ description=("The mass fraction of cloud liquid water in moist air."),
293
+ )
294
+
295
+ MassFractionOfCloudIceInAir = MetVariable(
296
+ short_name="cli",
297
+ standard_name="mass_fraction_of_cloud_ice_in_air",
298
+ long_name="Mass fraction of cloud ice in air",
299
+ units="kg kg**-1",
300
+ level_type="isobaricInhPa",
301
+ amip="cli",
302
+ description=("The mass fraction of cloud ice in moist air."),
303
+ )
304
+
305
+ CloudAreaFractionInAtmosphereLayer = MetVariable(
306
+ short_name="cl",
307
+ standard_name="cloud_area_fraction_in_atmosphere_layer",
308
+ long_name="Cloud area fraction in atmosphere layer",
309
+ units="[0 - 1]",
310
+ level_type="isobaricInhPa",
311
+ description=("The fraction of the horizontal area of a grid cell that contains cloud."),
312
+ )
313
+
314
+
315
+ # ----
316
+ # Single level variables
317
+ # ----
318
+
319
+
320
+ SurfacePressure = MetVariable(
321
+ short_name="sp",
322
+ standard_name="surface_air_pressure",
323
+ long_name="Surface air pressure",
324
+ level_type="surface",
325
+ grib1_id=1,
326
+ ecmwf_id=134,
327
+ grib2_id=(0, 3, 0),
328
+ units="Pa",
329
+ amip="ps",
330
+ description=(
331
+ "This parameter is the pressure (force per unit area) of the atmosphere "
332
+ "on the surface of land, sea and in-land water. It is a measure of the "
333
+ "weight of all the air in a column vertically above the area of the "
334
+ "Earth's surface represented at a fixed point."
335
+ ),
336
+ )
337
+
338
+ TOANetDownwardShortwaveFlux = MetVariable(
339
+ short_name="rst",
340
+ standard_name="toa_net_downward_shortwave_flux",
341
+ long_name="TOA net downward shortwave flux",
342
+ units="W m**-2",
343
+ level_type="nominalTop",
344
+ amip="rst",
345
+ description=(
346
+ '"shortwave" means shortwave radiation. "toa" means top of atmosphere. '
347
+ '"Downward" indicates a vector component which is positive when directed '
348
+ "downward (negative upward). Net downward radiation is the difference "
349
+ "between radiation from above (downwelling) and radiation from below (upwelling). "
350
+ "In accordance with common usage in geophysical disciplines, "
351
+ '"flux" implies per unit area, called "flux density" in physics.'
352
+ ),
353
+ )
354
+
355
+ TOAOutgoingLongwaveFlux = MetVariable(
356
+ short_name="rlut",
357
+ standard_name="toa_outgoing_longwave_flux",
358
+ long_name="TOA outgoing longwave_flux",
359
+ units="W m**-2",
360
+ level_type="nominalTop",
361
+ amip="rlut",
362
+ description=(
363
+ '"longwave" means longwave radiation. "toa" means top of atmosphere. '
364
+ "The TOA outgoing longwave flux is the upwelling thermal radiative flux, "
365
+ 'often called the "outgoing longwave radiation" or "OLR". '
366
+ "In accordance with common usage in geophysical disciplines, "
367
+ '"flux" implies per unit area, called "flux density" in physics.'
368
+ ),
369
+ )
370
+
371
+ PRESSURE_LEVEL_VARIABLES = [
372
+ AirTemperature,
373
+ SpecificHumidity,
374
+ RelativeHumidity,
375
+ Geopotential,
376
+ GeopotentialHeight,
377
+ EastwardWind,
378
+ NorthwardWind,
379
+ VerticalVelocity,
380
+ MassFractionOfCloudLiquidWaterInAir,
381
+ MassFractionOfCloudIceInAir,
382
+ CloudAreaFractionInAtmosphereLayer,
383
+ ]
384
+
385
+ SINGLE_LEVEL_VARIABLES = [SurfacePressure, TOANetDownwardShortwaveFlux, TOAOutgoingLongwaveFlux]
386
+
387
+ MET_VARIABLES = PRESSURE_LEVEL_VARIABLES + SINGLE_LEVEL_VARIABLES