pycontrails 0.53.0__cp313-cp313-macosx_10_13_x86_64.whl → 0.53.1__cp313-cp313-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/_version.py CHANGED
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.53.0'
16
- __version_tuple__ = version_tuple = (0, 53, 0)
15
+ __version__ = version = '0.53.1'
16
+ __version_tuple__ = version_tuple = (0, 53, 1)
@@ -79,12 +79,12 @@ def parse_timesteps(time: TimeInput | None, freq: str | None = "1h") -> list[dat
79
79
  elif len(time) == 1:
80
80
  time = (time[0], time[0])
81
81
  elif len(time) != 2:
82
- msg = f"Input time bounds must have length < 2 and > 0, got {len(time)}"
82
+ msg = f"Input time bounds must have length 1 or 2, got {len(time)}"
83
83
  raise ValueError(msg)
84
84
 
85
85
  # convert all to pandas Timestamp
86
86
  try:
87
- timestamps = [pd.to_datetime(t) for t in time]
87
+ t0, t1 = (pd.to_datetime(t) for t in time)
88
88
  except ValueError as e:
89
89
  msg = (
90
90
  f"Failed to parse time input {time}. "
@@ -93,10 +93,13 @@ def parse_timesteps(time: TimeInput | None, freq: str | None = "1h") -> list[dat
93
93
  raise ValueError(msg) from e
94
94
 
95
95
  if freq is None:
96
- daterange = pd.DatetimeIndex([timestamps[0], timestamps[1]])
96
+ daterange = pd.DatetimeIndex([t0, t1])
97
97
  else:
98
98
  # get date range that encompasses all whole hours
99
- daterange = pd.date_range(timestamps[0].floor(freq), timestamps[1].ceil(freq), freq=freq)
99
+ daterange = pd.date_range(t0.floor(freq), t1.ceil(freq), freq=freq)
100
+ if len(daterange) == 0:
101
+ msg = f"Time range {t0} to {t1} with freq {freq} has no valid time steps."
102
+ raise ValueError(msg)
100
103
 
101
104
  # return list of datetimes
102
105
  return daterange.to_pydatetime().tolist()
@@ -63,7 +63,7 @@ class ECMWFAPI(metsource.MetDataSource):
63
63
  except KeyError as exc:
64
64
  # this snippet shows the missing times for convenience
65
65
  np_timesteps = {np.datetime64(t, "ns") for t in self.timesteps}
66
- missing_times = sorted(np_timesteps.difference(ds["time"].values))
66
+ missing_times = sorted(np_timesteps.difference(ds["time"].values)) # type: ignore[type-var]
67
67
  msg = f"Input dataset is missing time coordinates {[str(t) for t in missing_times]}"
68
68
  raise KeyError(msg) from exc
69
69
 
@@ -80,10 +80,17 @@ class ERA5(ECMWFAPI):
80
80
  Cache data store for staging ECMWF ERA5 files.
81
81
  Defaults to :class:`cache.DiskCacheStore`.
82
82
  If None, cache is turned off.
83
- url : str
84
- Override `cdsapi <https://github.com/ecmwf/cdsapi>`_ url
85
- key : str
86
- Override `cdsapi <https://github.com/ecmwf/cdsapi>`_ key
83
+ url : str | None
84
+ Override the default `cdsapi <https://github.com/ecmwf/cdsapi>`_ url.
85
+ As of August 2024, the url for the `CDS-Beta <https://cds-beta.climate.copernicus.eu>`_
86
+ is "https://cds-beta.climate.copernicus.eu/api", and the url for the legacy server is
87
+ "https://cds.climate.copernicus.eu/api/v2". If None, the url is set
88
+ by the ``CDSAPI_URL`` environment variable. If this is not defined, the
89
+ ``cdsapi`` package will determine the url.
90
+ key : str | None
91
+ Override default `cdsapi <https://github.com/ecmwf/cdsapi>`_ key. If None,
92
+ the key is set by the ``CDSAPI_KEY`` environment variable. If this is not defined,
93
+ the ``cdsapi`` package will determine the key.
87
94
 
88
95
  Notes
89
96
  -----
@@ -522,17 +529,21 @@ class ERA5(ECMWFAPI):
522
529
  xr.Dataset
523
530
  Processed :class:`xr.Dataset`
524
531
  """
525
-
526
532
  if "pycontrails_version" in ds.attrs:
527
533
  LOG.debug("Input dataset processed with pycontrails > 0.29")
528
534
  return ds
529
535
 
530
- # not pre-processed source file from `download` or `paths`
531
-
532
- # for "reanalysis-era5-single-levels" or if self.pressure_levels length == 1,
536
+ # For "reanalysis-era5-single-levels" or if self.pressure_levels length == 1,
533
537
  # then the netcdf file does not contain the dimension "level"
534
538
  if len(self.pressure_levels) == 1:
535
- ds = ds.expand_dims({"level": self.pressure_levels})
539
+ ds = ds.expand_dims(level=self.pressure_levels)
540
+
541
+ # New CDS-Beta gives "valid_time" instead of "time"
542
+ # and "pressure_level" instead of "level"
543
+ if "valid_time" in ds:
544
+ ds = ds.rename(valid_time="time")
545
+ if "pressure_level" in ds:
546
+ ds = ds.rename(pressure_level="level")
536
547
 
537
548
  ds.attrs["pycontrails_version"] = pycontrails.__version__
538
549
  return ds
@@ -54,8 +54,8 @@ ALL_ENSEMBLE_MEMBERS = list(range(10))
54
54
  class ERA5ModelLevel(ECMWFAPI):
55
55
  """Class to support model-level ERA5 data access, download, and organization.
56
56
 
57
- The interface is similar to :class:`pycontrails.datalib.ecmwf.ERA5`, which downloads pressure-level
58
- with much lower vertical resolution.
57
+ The interface is similar to :class:`pycontrails.datalib.ecmwf.ERA5`, which downloads
58
+ pressure-level with much lower vertical resolution.
59
59
 
60
60
  Requires account with
61
61
  `Copernicus Data Portal <https://cds.climate.copernicus.eu/cdsapp#!/home>`_
@@ -114,11 +114,18 @@ class ERA5ModelLevel(ECMWFAPI):
114
114
  cache_grib: bool, optional
115
115
  If True, cache downloaded GRIB files rather than storing them in a temporary file.
116
116
  By default, False.
117
- url : str
118
- Override `cdsapi <https://github.com/ecmwf/cdsapi>`_ url
119
- key : str
120
- Override `cdsapi <https://github.com/ecmwf/cdsapi>`_ key
121
- """ # noqa: E501
117
+ url : str | None
118
+ Override the default `cdsapi <https://github.com/ecmwf/cdsapi>`_ url.
119
+ As of August 2024, the url for the `CDS-Beta <https://cds-beta.climate.copernicus.eu>`_
120
+ is "https://cds-beta.climate.copernicus.eu/api", and the url for the legacy server is
121
+ "https://cds.climate.copernicus.eu/api/v2". If None, the url is set
122
+ by the ``CDSAPI_URL`` environment variable. If this is not defined, the
123
+ ``cdsapi`` package will determine the url.
124
+ key : str | None
125
+ Override default `cdsapi <https://github.com/ecmwf/cdsapi>`_ key. If None,
126
+ the key is set by the ``CDSAPI_KEY`` environment variable. If this is not defined,
127
+ the ``cdsapi`` package will determine the key.
128
+ """
122
129
 
123
130
  __marker = object()
124
131
 
@@ -322,7 +322,7 @@ class CocipGrid(models.Model):
322
322
 
323
323
  if met is None:
324
324
  # idx is the first index at which self.met.variables["time"].to_numpy() >= time_end
325
- idx = np.searchsorted(self.met.indexes["time"].to_numpy(), time_end)
325
+ idx = np.searchsorted(self.met.indexes["time"].to_numpy(), time_end).item()
326
326
  sl = slice(max(0, idx - 1), idx + 1)
327
327
  logger.debug("Select met slice %s", sl)
328
328
  met = MetDataset(self.met.data.isel(time=sl), copy=False)
@@ -331,7 +331,7 @@ class CocipGrid(models.Model):
331
331
  current_times = met.indexes["time"].to_numpy()
332
332
  all_times = self.met.indexes["time"].to_numpy()
333
333
  # idx is the first index at which all_times >= time_end
334
- idx = np.searchsorted(all_times, time_end)
334
+ idx = np.searchsorted(all_times, time_end).item()
335
335
  sl = slice(max(0, idx - 1), idx + 1)
336
336
 
337
337
  # case 1: cannot re-use end of current met as start of new met
@@ -353,7 +353,7 @@ class CocipGrid(models.Model):
353
353
 
354
354
  if rad is None:
355
355
  # idx is the first index at which self.rad.variables["time"].to_numpy() >= time_end
356
- idx = np.searchsorted(self.rad.indexes["time"].to_numpy(), time_end)
356
+ idx = np.searchsorted(self.rad.indexes["time"].to_numpy(), time_end).item()
357
357
  sl = slice(max(0, idx - 1), idx + 1)
358
358
  logger.debug("Select rad slice %s", sl)
359
359
  rad = MetDataset(self.rad.data.isel(time=sl), copy=False)
@@ -362,7 +362,7 @@ class CocipGrid(models.Model):
362
362
  current_times = rad.indexes["time"].to_numpy()
363
363
  all_times = self.rad.indexes["time"].to_numpy()
364
364
  # idx is the first index at which all_times >= time_end
365
- idx = np.searchsorted(all_times, time_end)
365
+ idx = np.searchsorted(all_times, time_end).item()
366
366
  sl = slice(max(0, idx - 1), idx + 1)
367
367
 
368
368
  # case 1: cannot re-use end of current rad as start of new rad
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pycontrails
3
- Version: 0.53.0
3
+ Version: 0.53.1
4
4
  Summary: Python library for modeling aviation climate impacts
5
5
  Author-email: Breakthrough Energy <py@contrails.org>
6
6
  License: Apache-2.0
@@ -1,10 +1,10 @@
1
- pycontrails-0.53.0.dist-info/RECORD,,
2
- pycontrails-0.53.0.dist-info/LICENSE,sha256=gJ-h7SFFD1mCfR6a7HILvEtodDT6Iig8bLXdgqR6ucA,10175
3
- pycontrails-0.53.0.dist-info/WHEEL,sha256=flfwH_YJqoZxjiTo5yqY-63P4sdkbUhrmshSgnd9_BA,111
4
- pycontrails-0.53.0.dist-info/NOTICE,sha256=gKI8DcN1WhiXB2SFRKDogcjONldGubTvBxiOYdC4CXU,1926
5
- pycontrails-0.53.0.dist-info/top_level.txt,sha256=Z8J1R_AiBAyCVjNw6jYLdrA68PrQqTg0t3_Yek_IZ0Q,29
6
- pycontrails-0.53.0.dist-info/METADATA,sha256=KawffeH5dt3zqz-uONsaZA0CW71sETwVoMZlr-o_mbY,9173
7
- pycontrails/_version.py,sha256=HgHkwbsDGIaPCk8iUguKYMfK_2lWI-gqCUMPeRc5ptw,413
1
+ pycontrails-0.53.1.dist-info/RECORD,,
2
+ pycontrails-0.53.1.dist-info/LICENSE,sha256=gJ-h7SFFD1mCfR6a7HILvEtodDT6Iig8bLXdgqR6ucA,10175
3
+ pycontrails-0.53.1.dist-info/WHEEL,sha256=iCS7T4bKVbFdUhCnC5THAFycGpLoJM-dx8PFJVexZLI,111
4
+ pycontrails-0.53.1.dist-info/NOTICE,sha256=gKI8DcN1WhiXB2SFRKDogcjONldGubTvBxiOYdC4CXU,1926
5
+ pycontrails-0.53.1.dist-info/top_level.txt,sha256=Z8J1R_AiBAyCVjNw6jYLdrA68PrQqTg0t3_Yek_IZ0Q,29
6
+ pycontrails-0.53.1.dist-info/METADATA,sha256=zCTO7zFOkvqI0JzbmFthdOuZs7Mdt5vl66qd3z7_x0Q,9173
7
+ pycontrails/_version.py,sha256=vV71ixZB5LSC5mFURNjkJpZgkyEImidyN2Ez0p0YzQk,413
8
8
  pycontrails/__init__.py,sha256=O2T9kXCMhcELcMZz7HEnwiBhh4Gfcj-yG1HtrotOKHQ,2001
9
9
  pycontrails/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  pycontrails/core/vector.py,sha256=v_oO7if8SbNPMRci0TR8hLGSdAZ_fGZOVIT47e4hA58,71541
@@ -16,7 +16,7 @@ pycontrails/core/fuel.py,sha256=kJZ3P1lPm1L6rdPREM55XQ-VfJ_pt35cP4sO2Nnvmjs,4332
16
16
  pycontrails/core/polygon.py,sha256=gosyZBX1XBKD2EcHycIZb7uM-xGs8rCfdpiSZlhc2Hc,18028
17
17
  pycontrails/core/cache.py,sha256=ly2Prq5CUxxc2pClZUXDeH-E8zkj3zZkLoKpdKUCyGs,27984
18
18
  pycontrails/core/__init__.py,sha256=x1z6x8w3sYmEqYcNWyWHuNkS9lPUPbHUoYJZs1K0q98,856
19
- pycontrails/core/rgi_cython.cpython-313-darwin.so,sha256=pHoZt-_lYYIuej-SXxqQ25-lJeSnWlW6jjYqXLZvKh0,308768
19
+ pycontrails/core/rgi_cython.cpython-313-darwin.so,sha256=WJ4AyiGpNlLTkFa09ZrtBJn9hnUqHpILSORgPLPX2pg,308768
20
20
  pycontrails/core/flightplan.py,sha256=UO4vL087d5TZMlU984-FxfotGTxFbqK78w2fLDRiel4,7335
21
21
  pycontrails/core/met.py,sha256=0lGZqGu-_EnulU9Df05xo0I-IYX2MRQXvJ7PgCjU6p0,101342
22
22
  pycontrails/core/aircraft_performance.py,sha256=4KnLj0zK-mk8Oo3As1CXUkQWBQGMeDdrKi5TeOhOmUA,26107
@@ -28,15 +28,15 @@ pycontrails/datalib/landsat.py,sha256=WBOXcVgkoWmEM1jeUnOX1IKBOzzUbHWFU3lL3pJ8rf
28
28
  pycontrails/datalib/spire.py,sha256=66SnMdA8KOS69USjKmqrJmTKPK08Ehih9tnlsCt-AJw,25331
29
29
  pycontrails/datalib/__init__.py,sha256=hW9NWdFPC3y_2vHMteQ7GgQdop3917MkDaf5ZhU2RBY,369
30
30
  pycontrails/datalib/sentinel.py,sha256=Rzsp5Hv6Rh3XVEfvFeofmClId4Eq2KhdYiEhIqFPE3U,17222
31
- pycontrails/datalib/_met_utils/metsource.py,sha256=lNQrNKwyQqXROZ4FqsF8VhRdoLf0nEeOsjMgWGMUyWE,23865
31
+ pycontrails/datalib/_met_utils/metsource.py,sha256=1MLLnMDHlzXgRD-oeuZObgOoY8sGde81hluTm8oILPg,23965
32
32
  pycontrails/datalib/ecmwf/arco_era5.py,sha256=YuoPmPlP9TpZ6qhUPLbb30y3D3dTNDasTLZqP5MAWtw,18624
33
- pycontrails/datalib/ecmwf/era5.py,sha256=ibkOew_-9UU-UdQRgMgX0LlTURMW0-Q3qT4OsvDRUfQ,18228
34
- pycontrails/datalib/ecmwf/era5_model_level.py,sha256=s4PFFwNrRcfXiMQ1Ln7VfCaXrYgviU_SxSqtEU_E2tA,18945
33
+ pycontrails/datalib/ecmwf/era5.py,sha256=MvL8TgC8Wg-Q3pZSGVsvGRNL-HT_ndQT7CRdv2bGK7k,19016
34
+ pycontrails/datalib/ecmwf/era5_model_level.py,sha256=8ewGjs0LU_sySPMCk0B1xcAeMGydDx31AOXao9vrbNE,19519
35
35
  pycontrails/datalib/ecmwf/hres.py,sha256=p_l0ytCEEWGam7G7aVynpLmH4H4LQNeVe0Ay7Tw6fp8,28240
36
36
  pycontrails/datalib/ecmwf/variables.py,sha256=jsyHxQ8YTjLA_28DrKvplFn7pOC4T6SrO4j9d2wpkic,9563
37
37
  pycontrails/datalib/ecmwf/hres_model_level.py,sha256=-xh6BIEvsyddqJjuV7tygV85H5J8k4gCUKjj2kdkJkY,19147
38
38
  pycontrails/datalib/ecmwf/__init__.py,sha256=kwgk9P4RYdLgOYcBLXX5rWz1T_yL7aO8nt2Eb1PB-eE,1455
39
- pycontrails/datalib/ecmwf/common.py,sha256=p6zTQcojmTNF2FYGztxhX7cYEg9d29JH6_v2mrKteW0,3878
39
+ pycontrails/datalib/ecmwf/common.py,sha256=PIkEdYEmlmwxQ7v4TenW_BaHX7mslnmdJW3iZYXb7Kg,3904
40
40
  pycontrails/datalib/ecmwf/model_levels.py,sha256=x83WJtjC6OnHcUsiNgvYIrVX4lY-pkXR-YlvUo9vYis,2712
41
41
  pycontrails/datalib/ecmwf/ifs.py,sha256=2heema398PoEVCfiTZSBawN25PXAa_CpWm_pGLZ1GuY,10662
42
42
  pycontrails/datalib/ecmwf/static/model_level_dataframe_v20240418.csv,sha256=PmvGLRzn6uuCKSwiasSuVcehvvmSaqP7cnLuN6hhCQQ,9788
@@ -100,7 +100,7 @@ pycontrails/models/ps_model/static/ps-synonym-list-20240524.csv,sha256=ksrpQTHkx
100
100
  pycontrails/models/ps_model/static/ps-aircraft-params-20240524.csv,sha256=3eNhSwzut0gon04k2EYKKaXRvQSUlau3yBAbHS0EBao,25784
101
101
  pycontrails/models/cocipgrid/cocip_grid_params.py,sha256=l4vBPrOKCJDz5Y1uMjmOGVyUcSWgfZtFWbjW968OPz8,5875
102
102
  pycontrails/models/cocipgrid/__init__.py,sha256=ar6bF_8Pusbb-myujz_q5ntFylQTNH8yiM8fxP7Zk30,262
103
- pycontrails/models/cocipgrid/cocip_grid.py,sha256=RuKEnhAddGcxKkm1lH6A1b_lC8DsOCI0iw19fKxZnVY,94319
103
+ pycontrails/models/cocipgrid/cocip_grid.py,sha256=B1-f3D62fg3OeLp7xnxANAsneg9JRiiRVMqs-REFaII,94347
104
104
  pycontrails/physics/geo.py,sha256=9ZWIXyEEgrBNqsoeBBlYLTA-8GUTgyc-jgeVgchxXa8,30288
105
105
  pycontrails/physics/units.py,sha256=j-G5AC9eWIvv2MTOq9lUOoOQKFNJJuHzWLanHRji2tE,12272
106
106
  pycontrails/physics/constants.py,sha256=pHQQmccMUwuNnY4hFtm3L8G2rnUQcfJnroyQr8HAVeM,3146
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (72.2.0)
2
+ Generator: setuptools (73.0.1)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp313-cp313-macosx_10_13_x86_64
5
5