- Fix bug in
PSGrid
in which themet
data was assumed to be already loaded into memory. This caused errors when runningPSGrid
with aMetDataset
source. - Fix bug (#86) in which
Cocip.eval
loses thesource
fuel type. Instead of instantiating a newFlight
orFleet
instance with the default fuel type, theCocip._bundle_results
method now overwrites theself.source.data
attribute with the bundled predictions.
Implement a Poll-Schumann (PSGrid
) theoretical aircraft performance over a grid.
- Move the
pycontrails.models.aircraft_performance
module topycontrails.core.aircraft_performance
. - Rename
PSModel
->PSFlight
.
- Use the instance
fuel
attribute in theFleet.to_flight_list
method. Previously, the defaultJetA
fuel was always used. - Ensure the
Fleet.fuel
attribute is inferred from the underlying sequence of flights in theFleet.from_seq
method.
- Implement the
PSGrid
model. For a given aircraft type and position, this model computes optimal aircraft performance at cruise conditions. In particular, this model can be used to estimate fuel flow, engine efficiency, and aircraft mass at cruise. In particular, thePSGrid
model can now be used in conjunction withCocipGrid
to simulate contrail formation over a grid. - Refactor the
Emissions
model so thatEmissions.eval
runs withsource: GeoVectorDataset
. Previously, theeval
method required aFlight
instance for thesource
parameter. This change allows theEmissions
model to run more seamlessly as a sub-model of a gridded model (ie,CocipGrid
), - No longer require
pycontrails-bada
to import or run theCocipGrid
model. Instead, theCocipGridParams.aircraft_performance
parameter can be set to anyAircraftPerformanceGrid
instance. This allows theCocipGrid
model to run with any aircraft performance model that implements theAircraftPerformanceGrid
interface. - Add experimental
EmpiricalAircraftPerformanceGrid
model. - Add convenience
GeoVectorDataset.T_isa
method to compute the ISA temperature at each point.
- Add optional
climb_descend_at_end
parameter to theFlight.resample_and_fill
method. If True, the climb or descent will be placed at the end of each segment rather than the start. - Define
AircraftPerformanceGridParams
,AircraftPerformanceGrid
, andAircraftPerformanceGridData
abstract interfaces for gridded aircraft performance models. - Add
set_attr
parameter toModels.get_source_param
. - Better handle
source
,source.attrs
, andparams
customizations inCocipGrid
. - Include additional classes and functions in the
pycontrails.models.emissions
module. - Hardcode the paths to the static data files used in the
Emissions
andPSFlight
models. Previously these were configurable by model parameters. - Add
altitude_ft
parameter to theGeoVectorDataset
constructor. Warn if at least two ofaltitude_ft
,altitude
, andlevel
are provided. - Allow instantiation of
Model
instances withparams: ModelParams
. Previously, theparams
parameter was required to be adict
. The current implementation checks that theparams
parameter is either adict
or has typedefault_params
on theModel
class.
Support "dry advection" simulation.
- Add new
DryAdvection
model to simulate sediment-free advection of an aircraft's exhaust plume. This model is experimental and may change in future releases. By default, the current implementation simulates plume geometry as a cylinder with an elliptical cross section (the same geometry assumed in CoCiP). Wind shear perturbs the ellipse azimuth, width, and depth over the plume evolution. TheDryAdvection
model may also be used to simulate advection without wind-shear effects by setting the model parametersazimuth
,width
, anddepth
to None. - Add new Dry Advection example notebook highlighting the new
DryAdvection
model and comparing it to theCocip
model. - Add optional
fill_value
parameter toVectorDataset.sum
.
- (#80) Fix unit error in
wake_vortex.turbulent_kinetic_energy_dissipation_rate
. This fix affects the estimate of wake vortex max downward displacement and slightly changesCocip
predictions. - Change the implementation of
Flight.resample_and_fill
so that lat-lon interpolation is linear in time. Previously, the timestamp associated to a waypoint was floored according to the resampling frequency without updating the position accordingly. This caused errors in segment calculations (e.g., true airspeed).
- Add optional
keep_original_index
parameter to theFlight.resample_and_fill
method. IfTrue
, the time original index is preserved in the output in addition to the new time index obtained by resampling. - Improve docstrings in
wake_vortex
module - Rename
wake_vortex
functions to removeget_
prefix at the start of each function name. - Add pytest command line parameter
--regenerate-results
to regenerate static test fixture results. Automate in make recipemake pytest-regenerate-results
. - Update handling of
GeoVectorDataset.required_keys
theGeoVectorDataset
constructor. Add class variableGeoVectorDataset.vertical_keys
for handing the vertical dimension. - Rename
CocipParam.max_contrail_depth
->CocipParam.max_depth
. - Add
units.dt_to_seconds
function to convertnp.timedelta64
tofloat
seconds. - Rename
thermo.p_dz
->thermo.pressure_dz
.
Add experimental support for simulating radiative effects due to contrail-contrail overlap.
- Support simulating contrail contrail overlap when running the
Cocip
model with aFleet
source. Thecontrail_contrail_overlapping
anddz_overlap_m
parameters govern the overlap calculation. This mode of calculation is still experimental and may change in future releases. - Rewrite the
pycontrails.models.cocip.output
modules into a singlepycontrails.cocip.output_formats
module. The new module supports flight waypoint summary statistics, contrail waypoints summary statistics, gridded outputs, and time-slice outputs. - Add new
GeoVectorDataset.to_lon_lat_grid
method. This method can be thought of as a partial inverse to theMetDataset.to_vector
method. The current implementation is brittle and may be revised in a future release.
- Extend
Models.set_source_met
to allowinterpolation_q_method="cubic-spline"
when working withMetDataset
source (ie, so-called gridded models). Previously aNotImplementedError
was raised. - Ensure the
Flight.copy
implementation works withFleet
instances as well. - Avoid looping over
keys
twice inVectorDataset.broadcast_attrs
. This is a slight performance enhancement. - Fix
Fleet
signature for compatibility withFlight
. - Fix a few hard-coded assumptions in broadcasting aircraft performance and emissions when running
Cocip
with aFleet
source. The previous implementation did not consider the possibility of aircraft performance variables onFlight.data
andFlight.attrs
separately.
- Add optional
raise_error
parameter to theVectorDataset.broadcast_attrs
method. - Update
Fleet
internals.
- Narrow type hints on the ABC
AircraftPerformance
model. TheAircraftPerformance.eval
method requires aFlight
object for thesource
parameter. - In
PSFlight.eval
, explicitly set any aircraft performance data at waypoints with zero true airspeed tonp.nan
. This avoids numpyRuntimeWarning
s without affecting the results. - Fix corner-case in the
polygon.buffer_and_clean
function in which the polygon created by buffering theopencv
contour is not valid. Now a second attempt to buffer the polygon is made with a smaller buffer distance. - Ignore RuntimeError raised in
scipy.optimize.newton
if the maximum number of iterations is reached before convergence. This is a workaround for occasional false positive convergence warnings. The pycontrails use-case may be related to this GitHub issue. - Update the
Models.__init__
warnings whenhumidity_scaling
is not provided. The previous warning provided an outdated code example. - Ensure the
interpolation_q_method
used in a parent model is passed into thehumidity_scaling
child model in theModels.__init__
method. If the twointerpolation_q_method
values are different, a warning is issued. This could be extended to other model parameters in the future.
- Enable
ExponentialBoostLatitudeCorrectionHumidityScaling
humidity scaling for the model parameterinterpolation_q_method="cubic_spline"
. - Add GFS notebook example.
- Remove
ExponentialBoostLatitudeCorrectionHumidityScalingParams
. These parameters are now hard-coded in theExponentialBoostLatitudeCorrectionHumidityScaling
model.
- By default, call
xr.open_mfdataset
withlock=False
in theMetDataSource.open_dataset
method. This helps alleviate adask
threading issue similar to this GitHub issue.
- Support
MetDataset
source in theHistogramMatching
humidity scaling model. Previously onlyGeoVectorDataset
sources were explicitly supported. - Replace
np.gradient
withdask.array.gradient
in thetau_cirrus
module. This ensures that the computation is done lazily for dask-backed arrays. - Round to 6 digits in the
polygon.determine_buffer
function. This avoid unnecessary warnings for rounding errors. - Fix type hint for
opencv-python
4.8.0.74.
- Take more care with
float
andint
types in thecontrail_properties
module. Prefernp.clip
tonp.where
ornp.maximum
for clipping values. - Support
air_temperature
inCocipGrid
verbose formation outputs. - Remove
pytest-timeout
dev dependency.
Support for the Poll-Schumann aircraft performance model.
-
Implement a basic working version of the Poll-Schumann (PS) aircraft performance model. This is experimental and may undergo revision in future releases. The PS Model currently supports the following 53 aircraft types:
- A30B
- A306
- A310
- A313
- A318
- A319
- A320
- A321
- A332
- A333
- A342
- A343
- A345
- A346
- A359
- A388
- B712
- B732
- B733
- B734
- B735
- B736
- B737
- B738
- B739
- B742
- B743
- B744
- B748
- B752
- B753
- B762
- B763
- B764
- B77L
- B772
- B77W
- B773
- B788
- B789
- E135
- E145
- E170
- E195
- MD82
- MD83
- GLF5
- CRJ9
- DC93
- RJ1H
- B722
- A20N
- A21N
The "gridded" version of this model is not yet implemented. This will be added in a future release.
-
Improve the runtime of instantiating the
Emissions
model by a factor of 10-15x. This translates to a time savings of several hundred milliseconds on modern hardware. This improvement is achieved by more efficient parsing of the underlying static data and by deferring the construction of the interpolation artifacts until they are needed. -
Automatically use a default engine type from the aircraft type in the
Emissions
model if anengine_uid
parameter is not included on thesource
. This itself is configurable via theuse_default_engine_uid
parameter on theEmissions
model. The default mappings from aircraft types to engines is included inpycontrails/models/emissions/static/default-engine-uids.csv
.
- Remove the
Aircraft
dataclass fromFlight
instantiation. Any code previously using this should instead directly pass additionalattrs
to theFlight
constructor. - The
load_factor
is now required inAircraftPerformance
models. The globalDEFAULT_LOAD_FACTOR
constant inpycontrails.models.aircraft_performance
provides a reasonable default. This is currently set to 0.7. - Use a
takeoff_mass
parameter inAircraftPerformance
models if provided in thesource.attrs
data. - No longer use a reference mass
ref_mass
inAircraftPerformance
models. This is replaced by thetakeoff_mass
parameter if provided, or calculated from operating empty operating mass, max payload mass, total fuel consumption mass, reserve fuel mass, and the load factor.
- Remove the
fuel
parameter from theEmissions
model. This is inferred directly from thesource
parameter inEmissions.eval
. - Fix edge cases in the
jet.reserve_fuel_requirements
implementation. The previous version would returnnan
for some combinations offuel_flow
andsegment_phase
variables. - Fix a spelling mistake:
units.kelvin_to_celcius
->units.kelvin_to_celsius
.
- Use
ruff
in place ofpydocstyle
for linting docstrings. - Use
ruff
in place ofisort
for sorting imports. - Update the
AircraftPerformance
template based on the patterns used in the newPSFlight
class. This may change again in the future.
Support experimental interpolation against gridded specific humidity. Add new data-driven humidity scaling models.
-
Add new experimental
interpolation_q_method
field to theModelParams
data class. This parameter controls the interpolation methodology when interpolation against gridded specific humidity. The possible values are:None
: Interpolate linearly against specific humidity. This is the default behavior and is the same as the previous behavior."cubic-spline"
: Apply cubic-spline scaling to the interpolation table vertical coordinate before interpolating linearly against specific humidity."log-q-log-p"
: Interpolate in the log-log domain against specific humidity and pressure.
This interpolation parameter is used when calling
pycontrails.core.models.interpolate_met
. It can also be used directly with the new lower-levelpycontrails.core.models.interpolate_gridded_specific_humidity
function. -
Add new experimental
HistogramMatching
humidity scaling model to match RHi values against IAGOS observations. The previousHistogramMatchingWithEckel
scaling is still available when working with ERA5 ensemble members. -
Add new tutorial discussing the new specific humidity interpolation methodology.
- Add an optional
q_method
parameter to thepycontrails.core.models.interpolate_met
function. The default valueNone
agrees with the previous behavior. - Change function signatures in the
cocip.py
module for consistency. Theinterp_kwargs
parameter is now unpacked in thecalc_timestep_meterology
signature. Renamekwargs
tointerp_kwargs
where appropriate. - Remove the
cache_size
parameter inMetDataset.from_zarr
. Previously this parameter allowed the user to wrap the Zarr store in aLRUCacheStore
to improve performance. Changes to Zarr internals have broken this approach. Custom Zarr patterns should now be handled outside ofpycontrails
.
- Recompute and extend quantiles for histogram matching humidity scaling. Quantiles are now available for each combination of
q_method
and the following ERA5 data products: reanalysis and ensemble members 0-9. This data is available as a parquet file and is packaged withpycontrails
. - Fix the precomputed Eckel coefficients. Previous values where computed for different interpolation assumptions and were not correct for the default interpolation method.
- Clip the scaled humidity values computed by the
humidity_scaling.eckel_scaling
function to ensure that they are non-negative. Previously, both relative and specific humidity values arising from Eckel scaling could be negative. - Handle edge case of all NaN values in the
T_critical_sac
function in thesac.py
module. - Avoid extraneous copy when calling
VectorDataset.sum
. - Officially support
numpy
v1.25.0. - Set a
pytest-timeout
limit for tests intests/unit/test_ecmwf.py
to avoid hanging tests. - Add
forecast_step
parameter to theACCF
model.
- Refactor auxillary functions used by
HistogramMatchingWithEckel
to better isolated histogram matching from Eckel scaling. - Refactor
intersect_met
method inpycontrails.core.models
to handle experimentalq_method
parameter. - Include a
q_method
field inModel.interp_kwargs
. - Include precomputed humidity lapse rate values in the new
pycontrails.core.models._load_spline
function. - Move the
humidity_scaling.py
module into its own subdirectory withinpycontrails/models
.
Re-release of v0.42.1.
- Add new
HistogramMatchingWithEckel
experimental humidity scaling model. This is still a work in progress. - Add new
Flight.fit_altitude
method which uses piecewise linear fitting to smooth a flight profile. - Add new
pycontrails.core.flightplan
module for parsing ATC flight plans between string and dictionary representations. - Add new airports and flightplan examples.
- No longer attach empty fields "sdr", "rsr", "olr", "rf_sw", "rf_lw", "rf_net" onto the
source
parameter inCocip.eval
when the flight doesn't generate any persistent contrails. - Remove params
humidity_scaling
,rhi_adj_uncertainty
, andrhi_boost_exponent_uncertainty
fromCocipUncertaintyParams
. - Change the default value for
parallel
from True to False inxr.open_mfdataset
. This can be overridden by setting thexr_kwargs
parameter inERA5.open_metdataset
.
- Fix a unit test (
test_dtypes.py::test_issr_sac_grid_output
) that occasionally hangs. There may be another test intest_ecmwf.py
that suffers from the same issue. - Fix issue encountered in
Cocip.eval
when concatenating contrails with inconsistent values for_out_of_bounds
. This is only relevant when running the model with the experimental parameterinterpolation_use_indices=True
. - Add a
Fleet.max_distance_gap
property. The previous property on theFlight
class was not applicable toFleet
instances. - Fix warning in
Flight
class to correctly suggest adding kwargdrop_duplicated_times
. - Fix an issue in the
VectorDataset
constructor with adata
parameter of typepd.DataFrame
. Previously, time data was rewritten to the underlying DataFrame. This could cause copy-on-write issues if the DataFrame was a view of another DataFrame. This is now avoided.
- When possible, replace type hints
np.ndarray
->np.typing.NDArray[np.float_]
in thecocip
,cocip_params
,cocip_uncertainty
,radiative_forcing
, andwake_vortex
modules. - Slight performance enhancements in the
radiative_forcing
module. - Change the default value of
u_wind
andv_wind
from None to 0 inFlight.segment_true_airspeed
. This makes more sense semantically.
Phase 1 of the Spire datalib, which contains functions to identify unique flight trajectories from the raw Spire ADS-B data.
- Add a
pycontrails.core.airport
module to read and process the global airport database, which can be used to identify the nearest airport to a given coordinate. - Add a
pycontrails.datalib.spire.clean
function to remove and address erroneous waypoints in the raw Spire ADS-B data. - Add a
pycontrails.datalib.spire.filter_altitude
function to remove noise in cruise altitude. - Add a
pycontrails.datalib.spire.identify_flights
function to identify unique flight trajectories from ADS-B messages. - Add a
pycontrails.datalib.spire.validate_trajectory
function to check the validity of the identified trajectories from ADS-B messages. - Add a
FlightPhase
integerEnum
in theflight
module. This includes a newlevel_flight
flight phase.
- Add unit tests providing examples to identify unique flights.
- Rename
flight._dt_waypoints
->flight.segment_duration
. - Move
jet.rate_of_climb_descent
->flight.segment_rocd
. - Move
jet.identify_phase_of_flight
->flight.segment_phase
. - Update
FlightPhase
to be a dictionary enumeration of flight phases. - Add references to
traffic
library.
Improve polygon algorithms.
- Rewrite the
polygon
module to run computation with opencv in place of scikit-image for finding contours. This change improves the algorithm runtime and fixes some previous unstable behavior in finding nested contours. For an introduction to the methodology, see the OpenCV contour tutorial.
- Completely rewrite the
polygon
module. Replace the "main" public functionpolygon.find_contours_to_depth
withpolygon.find_multipolygon
. Replace thepolygon.contour_to_lat_lon
function withpolygon.multipolygon_to_geojson
. Returnshapely
objects when convenient to do so. - Convert continuous data to binary for polygon computation.
- Remove parameters
min_area_to_iterate
anddepth
in theMetDataArray.to_polygon_feature
method. Thedepth
parameter has been replaced by the booleaninteriors
parameter. Add aproperties
parameter for adding properties to thePolygon
andMultiPolygon
features. Themax_area
andepsilon
parameters are now expressed in terms of latitude-longitude degrees.
- Add
opencv-python-headless>=4.5
as an optional "vis" dependency. Some flavor ofopencv
is required for the updated polygon algorithms.
- Use oldest-supported-numpy for building pycontrails wheels. This allows pycontrails to be compatible with environments that use old versions of numpy. The pycontrails v0.40.0 wheels are not compatible with numpy 1.22.
Support scipy 1.10, improve interpolation performance, and fix many windows issues.
- Improve interpolation performance by cythonizing linear interpolation. This extends the approach taken in scipy 1.10. The pycontrails cython routines allow for both float64 and float32 grids via cython fused types (the current scipy implementation assumes float64). In addition, interpolation up to dimension 4 is supported (the scipy implementation supports dimension 1 and 2).
- Officially support scipy 1.10.
- Officially test on windows in the GitHub Actions CI.
- Build custom wheels for python 3.9, 3.10, and 3.11 for the following platforms:
- Linux (x86_64)
- macOS (arm64 and x86_64)
- Windows (x86_64)
- Change
MetDataset
andMetDataArray
conventions: underlying dimension coordinates are automatically promoted to float64. - Change how datetime arrays are converted to floating values for interpolation. The new approach introduces small differences compared with the previous implementation. These differences are significant enough to see relative differences in CoCiP predictions on the order of 1e-4.
- Unit tests no longer raise errors when the
pycontrails-bada
package is not installed. Instead, some tests are skipped. - Fix many numpy casting issues encountered on windows.
- Fix temp file issues encountered on windows.
- Officially support changes in
xarray
2023.04 andpandas
2.0.
- Make the
interpolation
module more aligned with scipy 1.10 enhancements to theRegularGridInterpolator
. In particular, grid coordinates now must be float64. - Use cibuildwheel to build wheels for Linux, macOS (arm64 and x86_64), and Windows on release in Github Actions. Allow this workflow to be triggered manually to test the release process without actually publishing to PyPI.
- Simplify interpolation with pre-computed indices (invoked with the model parameter
interpolation_use_indices
) via aRGIArtifacts
interface. - Overhaul much of the interpolation module to improve performance.
- Slight performance enhancements to the
met
module.
- Add
geo.azimuth
andgeo.segment_azimuth
functions to calculate the azimuth between coordinates. Azimuth is the angle between coordinates relative to true north on the interval[0, 360)
.
- Fix edge case in polygon algorithm by utilizing the
fully_connected
parameter inmeasure.find_contours
. This update leads to slight changes in interior contours in some cases. - Fix hard-coded POSIX path in
conftest.py
for windows compatibility. - Address
PermissionError
raised byshutil.copy
when the destination file is open in another thread. The copy is skipped and a warning is logged. - Fix some unit tests in
test_vector.py
andtest_ecmwf.py
for windows compatibility. There are still a few tests that fail on windows (unrelated to changes in this release) that will be fixed in v0.40.0. - Allow
cachestore=None
to skip caching inERA5
,HRES
, andGFS
interfaces. Previously a defaultDiskCacheStore
was created even whencachestore=None
. By default, caching is still enabled.
- Clean up
geo
module docstrings. - Add Wikipedia reference for Azimuth.
- Convert
MetBase._load
to from a class method to a function.
- Fix
docs/examples/CoCiP.ipynb
example demonstrating aircraft performance integration - Fix unit test caused by breaking change in pyproj 3.5.0
- Add additional Zenodo metadata
- Execute notebook examples in Docs Action
- Add additional Zenodo metadata
- Add Doc / Notebook test Action to run notebook test (
make nb-test
) and doctests (make doctest
) on pull requests. - Update Docs Action to use python 3.11.
- Update links in the README.
- Update the release guide to include a checklist of steps to follow when cutting a release.
- Fix links in documentation website.
- Deploy build to PyPI (in addition to Test PyPI) on release.
- Use setuptools_scm to manage the
pycontrails
version.
- Add Apache-2 LICENSE and NOTICE files (#21)
- Add CONTRIBUTING document
- Update documentation website py.contrails.org.
Includes
install
anddevelop
guides, update citations and many other small improvements (#19). - Initiate the Github Discussion forum (#22).
- Fix erroneous docstrings in
emissions.py
(#25)
- Add Github action to push to
pypi
on tag (#3) - Replace
flake8
withruff
linter - Add
nb-clean
to pre-commit hooks for example notebooks - Add
doc8
rst linter and pre-commit hook
- Change default value of
epsilon
parameter in methodMetDataArray.to_polygon_feature
from 0.15 to 0.0. - Change the polygon simplification algorithm. The new implementation uses
shapely.buffer
and doesn't try to preserve the topology of the simplified polygon. This change may result in slightly different polygon geometries.
- Add
depth
parameter toMetDataArray.to_polygon_feature
to control the depth of the contour searching. - Add experimental
convex_hull
parameter toMetDataArray.to_polygon_feature
to control whether to take the convex hull of each contour. - Warn if
iso_value
is not specified inMetDataArray.to_polygon_feature
.
- Consolidate three redundant implementations of standardizing variables into a single
met.standardize_variables
. - Ensure simplified polygons returned by
MetDataArray.to_polygon_feature
are disjoint. While non-disjoint polygons don't violate the GeoJSON spec, they can cause problems in some applications.
- Add citations for ISA calculations
- Abstract functionality to convert a Dataset or DataArray to longitude coordinates
[-180, 180)
intocore.met.shift_longitude
. Add tests for method. - Add auto-formatting checks to CI testing
ACCF integration updates
- Fixes ability to evaluate ACCF model over a
MetDataset
grid by passing in tuple of (dims, data) when assigning data - Fixes minor issues with ACCF configuration and allows more configuration options
- Updates example ACCF notebook with example of how to set configuration options when evaluating ACCFs over a grid
- Include "rhi" and "iwc" variables in
CocipGrid
verbose outputs.
- Update CoCiP unit test static results for breaking changes in tau cirrus calculation. The relative difference in pinned energy forcing values is less than 0.001%.
- Fix geopotential height gradient calculation in the
tau_cirrus
module. When calculating finite differences along the vertical axis, the tau cirrus model previously divided the top and bottom differences by 2. To numerically approximate the derivative at the top and bottom levels, these differences should have actually been divided by 1. The calculation now usesnp.gradient
to calculate the derivative along the vertical axis, which handles this correctly. - Make tau cirrus calculation slightly more performant.
- Include a warning in the suspect
IFS._calc_geopotential
implementation.
- Remove
_deprecated.tau_cirrus_alt
. This function is now the defaulttau_cirrus
calculation. The originaltau_cirrus
calculation is still available in the_deprecated
module. - Run
flake8
over test modules.