Coder Social home page Coder Social logo

danielkoll / pyrads-shortwave Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 4.0 12.42 MB

A line-by-line radiation code for planetary atmospheres. Now with shortwave radiative transfer.

License: MIT License

Fortran 85.47% Python 13.73% Makefile 0.40% Batchfile 0.40%
longwave-radiation line-by-line radiative-transfer radiation atmosphere python olr planetary-atmospheres surface-temperature shortwave-radiation planetary-albedo albedo

pyrads-shortwave's Introduction

PyRADS

PyRADS is the Python line-by-line RADiation model for planetary atmosphereS. PyRADS is a radiation code that can provide line-by-line spectral resolution, yet is written in Python and so is flexible enough to be useful in teaching.

For Earth-like atmospheres, PyRADS currently uses HITRAN 2016 line lists (http://hitran.org/) and the MTCKD continuum model (http://rtweb.aer.com/continuum_frame.html).

This version of PyRADS tackles shortwave calculations using the DISORT radiative solver.

References:

(1) Koll & Cronin, 2018, https://doi.org/10.1073/pnas.1809868115.

(2) Koll & Cronin, 2019, https://arxiv.org/abs/1907.13169.

(3) Stamnes et al, 1988, Applied Optics.

Installation

  1. Download to your own computer.

  2. Manually compile the MTCKD model:

  • cd $PyRADS/DATA/MT_CKD_continuum/cntnm.H2O_N2/build
  • (on a Mac) make -f make_cntnm osxGNUdbl
  • (on a Mac if you are using gfortran installed with conda) make -f make_cntnm osxGNUCONDAdbl
  1. Manually install the pyDISORT wrapper, which solves the radiative transfer equations with scattering (=in the shortwave). Steps marked with (x) use conda to create a separate environment, and are optional.
  • (x) conda create --clone base --name base_w_pyDISORT

  • (x) source activate base_w_pyDISORT

  • cd $PyRADS/pyDISORT-master

  • python setup.py install

    To test whether pyDISORT was successfully installed:

  • cd $PyRADS/pyDISORT-master/test

  • python test_disort.py

  • python test_Rayleigh.py

    If the installation failed, the test scripts will return "ImportError: No module named disort". If the installation worked, the test scripts will print a large slew of output. If using a separate conda environment, later remember to load that environment with 'source activate' before running pyDISORT or importing pyRADS.

  1. Run test scripts

To compute outgoing longwave radiation (OLR) in W/m2 for a given surface temperature:

  • cd $PyRADS/Test01.olr
  • python compute_olr_h2o.py

To compute OLRs for a set of surface temperatures and save the resulting output to txt:

  • cd $PyRADS/Test02.runaway
  • python compute_olr_h2o.01.100RH.py

To compute SW fluxes in W/m2 for a given surface temperature (here, 300 K) over a limited part of the solar spectrum (here, 1000-2000 cm-1) at some resolution (here, 1 cm-1; see note below) and save the resulting output to txt file in the same directory ("."):

  • cd $PyRADS/Test03.sw
  • python compute_sw_h2o.py 1000. 2000. 1. 300. .

To stitch together the SW fluxes across the entire solar spectrum (takes a while even at low spectral res; see note below):

  • cd $PyRADS/Test04.sw_full_spectrum
  • python compute_sw_h2o.py 1000. 10000. 1. 300. .
  • python compute_sw_h2o.py 10000. 20000. 1. 300. .
  • python compute_sw_h2o.py 20000. 30000. 1. 300. .
  • python compute_sw_h2o.py 30000. 90000. 10. 300. .
  • python merge_spectrum.py

NOTE: computing opacities + running pyDISORT over the entire solar spectrum becomes computationally very costly. It is much faster to split the spectral calculations up over many spectral chunks, distribute those over parallel processors, and them combine the spectral resolved calculations at the end. Use Merge_Spectral_Output.py to combine discrete chunks of the spectrum.

NOTE: spectral resolution should reflect the available data. E.g., HITRAN2016 doesn't contain H2O lines beyond ~25000 cm-1, so there is no need to retain high spectral resolution in the UV.

NOTE: resolution in test scripts was chosen for relative speed, not accuracy. For research-grade output and model intercomparisons, vertical and spectral resolution need to be increased. For some reference values, see Methods in Koll & Cronin (2018) and Koll & Cronin (2019).

Requirements

Python 2 or 3 with numpy and scipy.

For the MTCKD continuum model: gmake and gfortran.

For the pyDISORT radiation solver: see https://github.com/chanGimeno/pyDISORT.

Acknowledgements

PyRADS makes use of HITRAN 2016 line lists (http://hitran.org/), AER's MTCKD continuum model (http://rtweb.aer.com/continuum_frame.html), and the PyTran script published by Ray Pierrehumbert as part of the courseware for "Principles of Planetary Climates" (https://geosci.uchicago.edu/~rtp1/PrinciplesPlanetaryClimate/). Brian Rose (http://www.atmos.albany.edu/facstaff/brose/) has helped improve the code. The SW version of PyRADS uses DISORT, developed by Stamnes et al, and the pyDISORT wrapper, developed by chanGimeno (https://github.com/chanGimeno/pyDISORT).

pyrads-shortwave's People

Contributors

brian-rose avatar danielkoll avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pyrads-shortwave's Issues

Python 3 compatibility?

Have all components been fully-verified to be working for Python 3? I run into many issues trying to build PyRADS in Python 3.6.5 on Ubuntu, specifically the DISORT wrapper, such as Python 2 print statements in installation scripts, and upon converting a number of files with 2to3, get the following error:

Traceback (most recent call last):
  File "test_disort.py", line 9, in <module>
    import disort
  File "/home/USER/anaconda3/lib/python3.6/site-packages/disort/__init__.py", line 9, in <module>
    from . import _disort
ImportError: /home/USER/anaconda3/lib/python3.6/site-packages/disort/_disort.so: invalid ELF header

Any ideas, slash additional info on compatibility?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.