Releases: contrailcirrus/pycontrails
Releases · contrailcirrus/pycontrails
v0.49.3
Features
- Re-organize notebooks in documentation.
- Add new model level tutorial notebook.
- Add new high-level
Flight.clean_and_resample
method. This method parallels theFlight.resample_and_fill
method but performs additional altitude filtering. In essence, this method is a combination ofFlight.filter_altitude
andFlight.resample_and_fill
.
Breaking changes
- Remove
Flight.fit_altitude
method in favor ofFlight.filter_altitude
. The new method now only applies a median filter during cruise flight phase.
Fixes
- Remove opaque warning issued when all tau_contrail values are nan in
Cocip
evolution. - Emit warning in
Cocip.eval
if the advected contrail is blown outside of the domain of the met data. - Remove empty flights in
Fleet.from_seq
. Issue warning if an empty flight is encountered. - Emit warning when
Flight.resample_and_fill
returns an empty flight.
Internals
- Modify test workflow to use Makefile recipes and ensure early failures are detected in CI.
- Pin
black
andruff
versions for consistency between local and CI/CD environments. - Improve development documentation.
- Improve handling of missing credentials in tests (
make nb-test
,make doctest
). - Update time frequency aliases for
pandas
2.2 compatibility. - Update cython annotations for
scipy
1.12 compatibility. - Improve notebook output testing capabilities (
make nb-test
). - Add new convenience Make recipe to execute all notebooks in the docs (
make nb-execute
). - Add new Make recipe to cleanup notebooks (
make nb-clean
). - Add pre-commit hook to check if notebooks are clean.
- Re-organize notebooks in documentation.
- Clean up contributing and develop documentation.
- Automatically parse
np.timedelta64
-like model params inModel.update_params
.
v0.49.2
Features
- Support pandas Copy-on-Write. This can be enabled with
pd.set_option("mode.copy_on_write", True)
or by setting thePANDAS_COPY_ON_WRITE
environment variable.
Fixes
- Ensure the
Flight.fuel
attribute is preserved for theFlight.filter
method. - Ensure the
Fleet.fl_attrs
attribute is preserved for theFleet.filter
method. - Raise
ValueError
whenFlight.sort
orFleet.sort
is called. Both of these subclasses assume a custom sorting order that is enforced in their constructors. - Always correct intermediate thrust coefficients computed in the
PSGrid
model. This correction is already enabled by default in thePSFlight
model. - Include
attr
fields in the ValueError message raised inCocipGrid
when not all aircraft performance variables are present on thesource
parameter. - Allow
mach_number
as a replacement fortrue_airspeed
inCocipGrid
aircraft performance determination.
Internals
- Make
Fuel
and its subclassesJetA
,SAFBlend
, andHydrogenFuel
frozen. - No longer copy
met
whenModels.downselect_met
is called. In some modes of operation, this reduces the memory footprint of the model. - Update codebase for more harmony with PDEP 8 and Copy-on-Write semantics.
- Add
default
parameter to theVectorDataset.get_data_or_attr
method.
v0.49.1
Fixes
- Fix memory bottleneck in
CocipGrid
simulation by avoiding expensive call topd.concat
. - Require
oldest-supported-numpy
for python 3.12. Remove logic fornumpy
1.26.0rc1 in thepyproject.toml
build system.
v0.49.0
This release updates the Poll-Schumann (PS) aircraft performance model to version 2.0. It also includes a number of bug fixes and internal improvements.
Features
- Add convenience
Fleet.resample_and_fill
. - Update the PS model aircraft-engine parameters.
- Improve PS model accuracy in fuel consumption estimates.
- Improve PS model accuracy in overall propulsive efficiency estimates.
- Include additional guardrails in the PS model to constrain the operational limits of different aircraft-engine types, i.e., the maximum permitted Mach number by altitude, maximum available thrust coefficient, maximum lift coefficient, and maximum allowable aircraft mass.
Fixes
- Update polygon algorithm to use
shapely.Polygon
instead ofshapely.LinearRing
for contours with at least 4 vertices. - Fix
Fleet.to_flight_list
to avoid duplicating global attributes on the childFlight
instances. - Add
__slots__
toGeoVectorDataset
,Flight
, andFleet
. The baseVectorDataset
class already uses__slots__
. - Add
Fleet.copy
method. - Improve
Fleet.__init__
implementation. - Ensure
source
parameter is mutated inCocipGrid.eval
when the model parametercopy_source=False
.
v0.48.1
Features
- Generalize
met.shift_longitude()
to translate longitude coordinates onto any domain bounds. - Add
VectorDataset.to_dict()
methods to output Vector data as dictionary. This method enablesFlight.to_dict()
objects to be serialized for input to the Contrails API. - Add
VectorDataset.from_dict()
class method to createVectorDataset
class from dictionary. - Support more time formats, including timezone aware times, in
VectorDataset
creation. All timezone aware `"time"`` coordinates are converted to UTC and stripped of timezone identifier.
Fixes
- Fix issue in the
wake_vortex.max_downward_displacement
function in which float32 dtypes were promoted to float64 dtypes in certain cases. - Ignore empty vectors in
VectorDataset.sum
.
Internals
- Set
frozen=True
on theMetVariable
dataclass. - Test against python 3.12 in the GitHub Actions CI. Use python 3.12 in docs and doctest workflows.
v0.48.0
This release includes a number of breaking changes and new features. If upgrading from a previous version of pycontrails
, please read the changes below carefully. Open an issue if you experience problems.
Breaking changes
- When running
Cocip
and otherpycontrails
models, themet
andrad
parameter must now contain predefined metadata attributesprovider
,dataset
, andproduct
describing the met source. An error will now be raised inCocip
if these attributes are not present. - Deprecate passing arbitrary
kwargs
into theMetDataArray
constructor. - No longer convert accumulated radiation data to average instantaneous data in
ERA5
andHRES
interfaces. This logic is now handled downstream by the model (e.g.,Cocip
). This change allows for more flexibility in therad
data passed into the model and avoids unnecessary computation in theMetDataSource
interfaces. - Add new
MetDataSource.set_met_source_metadata
abstract method. This should be called within the implementing classopen_metdataset
method. - No longer take a finite difference in the time dimension for HRES radiation data. This is now also handled natively in
Cocip
. - No longer convert relative humidity from a percentage to a fraction in
ERA5
andHRES
interfaces. - Require the
HRES
stream
parameter to be one of["oper", "enfo"]
. Require thefield_type
parameter to be one of["fc", "pf", "cf", "an"]
. - Remove the
steps
andstep_offset
properties in theGFSForecast
interface. Now thetimesteps
attribute is the only source of truth for determining AWS S3 keys. Change thefilename
method to take in adatatime
timestep instead of anint
step. No longer assign the first step radiation data to the zeroth step. - Change the return type of
ISSR.eval
,SAC.eval
, andPCR.eval
fromMetDataArray
toMetDataset
. This is more consistent with the return type of otherpycontrails
models and more closely mirrors the behavior of vector models. Set outputattrs
metadata on the globalMetDataset
instead of the individualMetDataArray
in each case.
Features
- Rewrite parts of the
pycontrails.core.datalib
module for higher performance and readability. - Add optional
attrs
andattrs_kwargs
parameters toMetDataset
constructor. This allows the user to customize the attributes on the underlyingxarray.Dataset
object. This update makesMetDataset
more consistent withVectorDataset
. - Add three new properties
provider_attr
,dataset_attr
, andproduct_attr
toMetDataset
. These properties give metadata describing the underlying meterological data source. - Add new
Model.transfer_met_source_attrs
method for more consistent handling of met source metadata on thesource
parameter passed intoModel.eval
. - No longer require
geopotential
data when computingtau_cirrus
. If neithergeopotential
norgeopotential_height
are available, geopotential is approximated from the geometric height. No longer require geopotential on themet
parameter inCocip
orCocipGrid
. - Remove the
Cocip
shift_radiation_time
parameter. This is now inferred directly from therad
metadata. An error is raised if the necessary metadata is not present. - Allow
Cocip
to run with both instantaneous (W m-2
) and accumulated (J m-2
) radiation data. - Allow
Cocip
to run with accumulated ECMWF HRES radiation data.
Fixes
- Correct radiation unit in the
ACCF
wrapper model [#64]. Both instantaneous (W m-2
) and accumulated (J m-2
) radiation data are now supported, and theACCF
wrapper will handle each appropriately. - Avoid unnecessary writing and reading of temporary files in
ERA5.cache_dataset
andHRES.cache_dataset
. - Fix timestep resolution bug in
GFSForecast
. When thegrid
parameter is 0.5 or 1.0, forecasts are only available every 3 hours. Previously, thetimesteps
property would define an hourly timestep.
Internals
- Include
name
parameter inMetDataArray
constructor. - Make the
coordinates.slice_domain
function slightly more performant by explicitly dropping nan values from therequest
parameter. - Round unwieldy floating point numbers in
GeoVectorDataset._display_attrs
. - Remove the
ecmwflibs
package from theecmwf
optional dependencies. - Add NPY to
ruff
rules. - Add convenience
MetDataset.standardize_variables
method. - Remove the
p_settings
attribute on theACCF
interface. This is now constructed internally withinACCF.eval
. Replace theACCF._update_accf_config
method with a_get_accf_config
function.
v0.47.3
Fixes
- Strengthen
correct_fuel_flow
in thePSmodel
to account for descent conditions. - Clip the denominator computed in
pycontrails.physics.jet.equivalent_fuel_flow_rate_at_cruise
. - Ensure the token used within GitHub workflows has the fewest privileges required. Set top-level permissions to
none
in each workflow file. Remove unnecessary permissions previously used in thegoogle-github-actions/auth
action. - Fix bug in
radiative_forcing.effective_tau_contrail
identified in #99. - Fix the unit for
vertical_velocity
ingeo.advect_level
. - Fix bug appearing in
Flight._geodesic_interpolation
in which a single initial large gap was not interpolated with a geodesic path.
Internals
- Add
FlightPhase
to thepycontrails
namespace.
v0.47.2
Features
- New experimental
GOES
interface for downloading and visualizing GOES-16 satellite imagery. - Add new GOES example notebook highlighting the interface.
- Build python 3.12 wheels for Linux, macOS, and Windows on release. This is in addition to the existing python 3.9, 3.10, and 3.11 wheels.
Fixes
- Use the experimental version number parameter
E
inpycontrails.ecmwf.hres.get_forecast_filename
. Update the logic involved in setting the dissemination data stream indicatorS
. - Change the behavior of
_altitude_interpolation
method that is called withinresample_and_fill
. Step climbs are now placed in the middle of long flight segments. Descents continue to occur at the end of segments.
Internals
- Provide consistent
ModuleNotFoundError
messages when optional dependencies are not installed. - Move the
synthetic_flight
module into thepycontrails.ext
namespace.
v0.47.1
Fixes
- 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. - Avoid a memory explosion when running
Cocip
on a large non-dask-backedmet
parameter. Previously thetau_cirrus
computation would be performed in memory over the entiremet
dataset. - Replace
datetime.utcfromtimestamp
(deprecated in python 3.12) withdatetime.fromtimestamp
. - Explicitly support python 3.12 in the
pyproject.toml
build system.
Internals
- Add
compute_tau_cirrus_in_model_init
parameter toCocipParams
. This controls whether to compute the cirrus optical depth inCocip.__init__
orCocip.eval
. When set to"auto"
(the default), thetau_cirrus
is computed inCocip.__init__
if and only if themet
parameter is dask-backed. - Change data requirements for the
EmpiricalGrid
aircraft performance model. - Consolidate
ERA5.cache_dataset
andHRES.cache_dataset
onto commonECMWFAPI.cache_dataset
method. Previously the child implementations were identical. - No longer require the
pyproj
package as a dependency. This is now an optional dependency, and can be installed withpip install pycontrails[pyproj]
.
v0.47.0
Implement a Poll-Schumann (PSGrid
) theoretical aircraft performance model over a grid.
Breaking changes
- Move the
pycontrails.models.aircraft_performance
module topycontrails.core.aircraft_performance
. - Rename
PSModel
->PSFlight
.
Fixes
- 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.
Features
- 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.
Internals
- 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.