space-physics / lowtran

LOWTRAN atmospheric absorption extinction, scatter and irradiance model--in Python and Matlab
MIT License
102 stars 42 forks source link

Import custom atmospheric profile #26

Open chrismolli opened 1 year ago

chrismolli commented 1 year ago

I would like to adapt the implementation to be able to input custom atmospheric profiles for ITYPE=2 slant H1 to H2 calculations. I have seen the part in the documentation regarding custom model input at CARD 2C and following. I am not sure though on how these would translate to the input using the Python interface.

Could you give me a hint how to ingress a custom atmospheric model?

chrismolli commented 1 year ago

I tried it like this, in theory the Fortran interface supports giving multiple values for temperature, pressure and layer altitude. However, it does not finish computing anything.

import lowtran
from lowtran.base import golowtran
import numpy as np 

# custom fake atmosphere
steps = 5
altitudes = (np.arange(steps))/steps*100+10
temps = np.ones(steps)*300
press = np.arange(steps)*200
press = press[::-1]
wmols = np.zeros((12))
wmols = np.array(
    [0.5,0.3,0.1,0,0,0,0,0,0,0,0,0]
)

# setup settings
c1 = {
    # wave length settings
    "wllong": 15000,   # max wavelength
    "wlshort": 8000.0, # min wavelength
    "wlstep" : 20,     # step resolution
    # model type
    "model" :  7, # 7 custom model, 0 custom horizontal, 1-6 standard models
    "itype" :  2, # 2 slant path
    "iemsct" : 1, # 0 transmission only, 1 thermal radiance
    "im" :     1, # 0 use existing model, 1 read in new model
    "iseasn" : 0, # 0 default season, unused
    "ird1" :   1, # 1 read atmospheric densities from wmols
    # atmospheric properties
    "zmdl" : altitudes.tolist(),
    "p" : press.tolist(),
    "t" : temps.tolist(),
    "wmol" : wmols.tolist(),
    # observer settings
    "h1" : 0.0,     # km, starting height
    "h2" : 550.0,   # km, final height
    "angle" : 0,    # zenit angle
    "range_km" : 0, # km, path length
}

TR = golowtran(c1)