Package: climlab
Python package for process-oriented climate modelingAuthorBrian E. J. RoseDepartment of Atmospheric and Environmental SciencesUniversity at Albanybrose@albany.eduAbout climlabclimlabis a flexible engine for process-oriented climate modeling.
It is based on a very general concept of a model as a collection of individual,
interacting processes.climlabdefines a base class calledProcess, which
can contain an arbitrarily complex tree of sub-processes (each also some
sub-class ofProcess). Every climate process (radiative, dynamical,
physical, turbulent, convective, chemical, etc.) can be simulated as a stand-alone
process model given appropriate input, or as a sub-process of a more complex model.
New classes of model can easily be defined and run interactively by putting together an
appropriate collection of sub-processes.Currently,climlabhas out-of-the-box support and documented examples forRadiative and radiative-convective column models, with various radiation schemes:RRTMG (a widely used radiative transfer code)CAM3  (from the NCAR GCM)Grey GasSimplified band-averaged models (4 bands each in longwave and shortwave)Convection schemes:Emanuel moist convection schemeHard convective adjustment (to constant lapse rate or to moist adiabat)1D Advection-Diffusion solversMoist and dry Energy Balance ModelsFlexible insolation including:
- Seasonal and annual-mean models
- Arbitrary orbital parametersBoundary layer scheme including sensible and latent heat fluxesArbitrary combinations of the above, for example:2D latitude-pressure models with radiation, horizontally-varying meridional diffusion, and fixed relative humidityInstallationInstalling pre-built binaries with conda (Mac OSX, Linux, and Windows)By far the simplest and recommended way to installclimlabis usingconda(which is the wonderful package manager that comes withAnaconda Python).You can installclimlaband all its dependencies with:conda install -c conda-forge climlabOr (recommended) addconda-forgeto your conda channels with:conda config --add channels conda-forgeand then simply do:conda install climlabBinaries are available for OSX, Linux, and Windows.Installing from sourceConsult thedocumentationfor detailed instructions.LinksHTML documentation:http://climlab.readthedocs.io/en/latest/intro.htmlIssue tracker:http://github.com/climlab/climlab/issuesSource code:http://github.com/climlab/climlabJOSS meta-paper:https://doi.org/10.21105/joss.00659DependenciesThese are handled automatically if you install withconda.RequiredPython (currently testing on versions 3.8, 3.9, 3.10, 3.11)numpyscipyfuturepooch (for remote data access and caching)xarray (for data handling)climlab will still run on Python 2.7 on some systems but we are no longer supporting thisRecommended for full functionalitynumba >=0.43.1 (used for acceleration of some components)Note that there is a bug in previous numba versions that caused a hanging condition in climlab under Python 3.Documentation and ExamplesFull user manual is availablehere.A rich and up-to-date collection of example usage can be found in Brian Rose’s online textbookThe Climate Laboratory.Source notebooks for thetutorials in the docscan be found in theclimlab/docs/source/courseware/directory of the source repo.These are self-describing, and should run out-of-the-box once the package is installed, e.g:jupyter notebook Insolation.ipynbRelease historyVersion 0.8.2 (released November 2023)New feature: process classclimlab.radiation.InstantInsolation()which correctly interprets longitude, respects local solar time and calculates hour angle.
A utility functionclimlab.solar.insolation.instant_insolation()is also available, with usage mirroring the existingclimlab.solar.insolation.daily_insolation().
Thanks to@HenryDanefor this contribution!This release also includes numerous bug fixes, updates for Python 3.11, and improvements to documentation and CI builds.Version 0.8.1 (released May 2022)A major refactor of the internals: all the Fortran code has been moved into external companion
packagesclimlab-rrtmg,climlab-cam3-radiation, andclimlab-emanuel-convection.
Climlab is now (once again!) a pure Python package.
Builds of these helper packages are available through conda-forge and will be
automatically installed as dependencies by conda / mamba.The climlab source repo also moved tohttps://github.com/climlab/climlabThere should be no breaking changes to the user-facing API.The major motivation for this change was to (vastly) simplify the development
and testing of new-and-improved climlab internals (coming soon).Version 0.7.13 (released February 2022)Maintenance release to support Python 3.10.Theattrdict packagebyBrendan Curran-Johnsonhas been removed from the dependencies since it is broken on Python 3.10 and no longer under development.
A modified version of the MIT-licensed attrdict source is now bundled internally with climlab. There are no changes to climlab’s public API.Version 0.7.12 (released May 2021)New feature: spectral output from RRTMG (accompanied by a new tutorial)Version 0.7.11 (released May 2021)Improvements to data file download and caching (outsourcing this topooch)Version 0.7.10 (released April 2021)Improvements to docs and build.Version 0.7.9 (released December 2020)Bug fixes and doc improvements.Version 0.7.8 (released December 2020)Bug fixes.Version 0.7.7 (released October 2020)Bug fixes.Version 0.7.6 (released January 2020)Bug fixes, Python 3.8 compatibility, improvements to build and docs.Version 0.7.5 (released July 2019)Bug fixes and improvements to continuous integrationVersion 0.7.4 (released June 2019)New flexible solver for 1D advection-diffusion processes on non-uniform grids, along with some bug fixes.Version 0.7.3 (released April 2019)Bug fix and changes to continuous integration for Python 2.7 compatibilityVersion 0.7.2 (released April 2019)Improvements to surface flux processes, a new data management strategy, and improved documentation.Details:climlab.surface.LatentHeatFluxandclimlab.surface.SensibleHeatFluxare now documented, more consistent with the climlab API, and have new optionalresistanceparameters to reduce the fluxes (e.g. for modeling stomatal resistance)climlab.surface.LatentHeatFluxnow produces the diagnosticevaporationin kg/m2/s.climlab.convection.EmanuelConvectionproducesprecipitationin the same units.The previousPRECIPdiagnostic (mm/day) inclimlab.convection.EmanuelConvectionis removed. This is a BREAKING CHANGE.Data files have been removed from the climlab source repository. All data is now accessible remotely. climlab will attempt to download and cache data files upon first use.climlab.convection.ConvectiveAdjustementis now accelerated withnumbaif it is available (optional)Version 0.7.1 (released January 2019)Deeper xarray integration, include one breaking change toclimlab.solar.orbital.OrbitalTable, Python 3.7 compatibility, and minor enhancements.Details:Removedclimlab.utils.attr_dict.AttrDictand replaced with AttrDict package (a new dependency)Addedxarrayinput and output capabilities forclimlab.solar.insolation.daily_insolation()climlab.solar.orbital.OrbitalTableandclimlab.solar.orbital.long.OrbitalTablenow returnxarray.Datasetobjects containing the orbital data.Thelookup_parameter()method was removed in favor of using built-in xarray interpolation.New classclimlab.process.ExternalForcing()for arbitrary externally defined tendencies for state variables.New input optionozone_file=Nonefor radiation components, sets ozone to zero.Tested on Python 3.7. Builds will be available through conda-forge.Version 0.7.0 (released July 2018)New functionality, improveddocumentation, and a few breaking changes to the API.Major new functionality includesconvective adjustment to the moist adiabatandmoist EBMs with diffusion on moist static energy gradients.Details:climlab.convection.ConvectiveAdjustementnow allows non-constant critical lapse rates, stored in input parameteradj_lapse_rate.New switches to implement automatic adjustment todryandmoistadiabats (pseudoadiabat)climlab.EBM()and its daughter classes are significantly reorganized to better respect CLIMLAB principles:Essentially all the computations are done by subprocessesSW radiation is now handled byclimlab.radiation.SimpleAbsorbedShortwaveclassDiffusion and its diagnostics now handled byclimlab.dynamics.MeridionalHeatDiffusionclass.Diffusivity can be altered at any time by the user, e.g. during timesteppingDiffusivity input valueKin classclimlab.dynamics.MeridionalDiffusionis now specified in physical units of m2/s instead of (1/s). This is consistent with its parent classclimlab.dynamics.Diffusion.A new classclimlab.dynamics.MeridionalMoistDiffusionfor the moist EBM (diffusion down moist static energy gradient)Tests that require compiled code are now marked withpytest.mark.compiledfor easy exclusion during local developmentUnder-the-hood changes includeInternal changes to the timestepping; thecompute()method of every subprocess is now called explicitly.compute()now always returns tendency dictionariesVersion 0.6.5 (released April 2018)Some improved documentation, associated with publication of a meta-description paper in JOSS.Version 0.6.4 (released February 2018)Some bug fixes and a newclimlab.couple()method to simplify creating complete models from components.Version 0.6.3 (released February 2018)Under-the-hood improvements to the Fortran builds which enable successful builds on a wider variety of platforms (incluing Windows/Python3).Version 0.6.2 (released February 2018)Introduces the Emanuel moist convection scheme, support for asynchonous coupling, and internal optimzations.Version 0.6.1 (released January 2018)Provides basic integration withxarray(convenience methods for converting climlab objects intoxarray.DataArrayandxarray.Datasetobjects)Version 0.6.0 (released December 2017)Provides full Python 3 compatibility, updated documentation, and minor enhancements and bug fixes.Version 0.5.5 (released early April 2017)Finally provides easy binary distribution withcondaVersion 0.5.2 (released late March 2017)Many under-the-hood improvements to the build procedure,
which should make it much easier to getclimlabinstalled on user machines.
Binary distribution withcondais coming soon!Version 0.5 (released March 2017)Bug fixes and full functionality for the RRTMG radiation module,
an improved common API for all radiation modules, and better documentation.Version 0.4.2 (released January 2017)Introduces the RRTMG radiation scheme,
a much-improved build process for the Fortran extension,
and numerous enhancements and simplifications to the API.Version 0.4 (released October 2016)Includes comprehensive documentation, an automated test suite,
support for latitude-longitude grids, and numerous small enhancements and bug fixes.Version 0.3 (released February 2016)Includes many internal changes and some backwards-incompatible changes
(hopefully simplifications) to the public API.
It also includes the CAM3 radiation module.Version 0.2 (released January 2015)The package and its API was completely redesigned around a truly object-oriented
modeling framework in January 2015.It was used extensively for a graduate-level climate modeling course in Spring 2015:http://www.atmos.albany.edu/facstaff/brose/classes/ATM623_Spring2015/Many more examples are found in the online lecture notes for that course:http://nbviewer.jupyter.org/github/brian-rose/ClimateModeling_courseware/blob/master/index.ipynbVersion 0.1The first versions of the code and notebooks were originally developed in winter / spring 2014
in support of an undergraduate course at the University at Albany.See the original course webpage athttp://www.atmos.albany.edu/facstaff/brose/classes/ENV480_Spring2014/Thedocumentationwas first created by Moritz Kreuzer
(Potsdam Institut for Climate Impact Research) as part of a thesis project in Spring 2016.Contact and Bug ReportsUsers are strongly encouraged to submit bug reports and feature requests on
github athttps://github.com/climlab/climlabLicenseThis code is freely available under the MIT license.
See the accompanying LICENSE file.SupportDevelopment ofclimlabis partially supported by the National Science Foundation under award AGS-1455071 to Brian Rose.Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.