Git Product home page Git Product logo

lowtran's Introduction

Lowtran in Python

Zenodo DOI Actions Status PyPi Download stats

LOWTRAN7 atmospheric absorption extinction model. Updated to be platform independent and easily accessible from Python and Matlab.

The main LOWTRAN program is accessible from Python by using direct memory transfers instead of the cumbersome and error-prone process of writing/reading text files. xarray.Dataset high-performance, simple N-D array data is passed out, with appropriate metadata.

Gallery

See below for how to make these examples.

Lowtran7 absorption

Install

Lowtran requires a Fortran compiler and CMake. We use f2py (part of numpy) to seamlessly use Fortran libraries from Python by special compilation of the Fortran library with auto-generated shim code. For Python 3.12, make sure to install setuptools using pip, i.e., pip install setuptools and make sure meson is available on the system.

If a Fortran compiler is not already installed, install Gfortran:

  • Linux: apt install gfortran
  • Mac: brew install gcc
  • Windows: Windows Subsystem for Linux

Install Python Lowtran code

pip install -e .

Examples

In these examples, optionally write to HDF5 with the -o option.

We present Python examples of:

  • ground-to-space transmittance: TransmittanceGround2Space.py

    Lowtran Transmission

  • sun-to-observer scattered radiance (why the sky is blue): ScatterRadiance.py

    Lowtran Scatter Radiance

  • sun-to-observer irradiance: SolarIrradiance.py

    Lowtran Solar Irradiance

  • observer-to-observer solar single-scattering solar radiance (up-going) with custom Pressure, Temperature and partial pressure for 12 species: UserDataHorizontalRadiance.py Lowtran Solar Irradiance

  • observer-to-observer transmittance with custom Pressure, Temperature and partial pressure for 12 species: UserDataHorizontalTransmittance.py

  • observer-to-observer transmittance: HorizontalTransmittance.py

    Lowtran Horizontal Path transmittance

Matlab

Matlab users can seamlessly access Python modules, as demonstrated in RunLowtran.m.

Here's what's you'll need:

  1. Setup Python ↔ Matlab interface.

  2. Install Lowtran in Python as at the top of this Readme.

  3. From Matlab, verify everything is working by:

    runtests('lowtran')

Notes

LOWTRAN7 User manual Refer to this to understand what parameters are set to default. Currently I don't have any aerosols enabled for example, though it's possible to add them into the code.

Right now a lot of configuration features aren't implemented, please request those you want.

Reference

  • Original 1994 Lowtran7 Code
  • LOWFIL program in reference/lowtran7.10.f was not connected as we had previously implemented a filter function directly in Python.
  • LOWSCAN spectral sampling (scanning) program in reference/lowtran7.13.f was not connected as we had no need for coarser spectral resolution.

lowtran's People

Contributors

jkrimmer avatar scivision avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lowtran's Issues

pip install error

@scivision
I'm still having trouble getting this to install, but now with a new error message:
Any ideas?

$ pip install -e .
Obtaining file:///C:/Projects/lowtran-master
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Preparing wheel metadata: started
Preparing wheel metadata: finished with status 'done'
Requirement already satisfied: xarray in c:\anaconda3\lib\site-packages (from lowtran==2.4.1) (0.12.3)
Requirement already satisfied: python-dateutil in c:\anaconda3\lib\site-packages (from lowtran==2.4.1) (2.6.1)
Requirement already satisfied: numpy>=1.16 in c:\anaconda3\lib\site-packages (from lowtran==2.4.1) (1.17.0)
Requirement already satisfied: pandas>=0.19.2 in c:\anaconda3\lib\site-packages (from xarray->lowtran==2.4.1) (0.24.1)
Requirement already satisfied: six>=1.5 in c:\anaconda3\lib\site-packages (from python-dateutil->lowtran==2.4.1) (1.11.0)
Requirement already satisfied: pytz>=2011k in c:\anaconda3\lib\site-packages (from pandas>=0.19.2->xarray->lowtran==2.4.1) (2017.3)
Installing collected packages: lowtran
Running setup.py develop for lowtran
ERROR: Command errored out with exit status 1:
command: 'c:\anaconda3\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Projects\lowtran-master\setup.py'"'"'; file='"'"'C:\ Projects\lowtran-master\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(c ompile(code, file, '"'"'exec'"'"'))' develop --no-deps
cwd: C:\Projects\lowtran-master
Complete output (67 lines):
running develop
running build_scripts
copying and adjusting HorizontalTransmittance.py -> build\scripts.win-amd64-3.6
copying and adjusting ThermalRadiance.py -> build\scripts.win-amd64-3.6
copying and adjusting UserHorizontalTransmittance.py -> build\scripts.win-amd64-3.6
copying and adjusting ScatterRadiance.py -> build\scripts.win-amd64-3.6
copying and adjusting TransmittanceGround2Space.py -> build\scripts.win-amd64-3.6
copying and adjusting Wavelength2LowtranWavenumber.py -> build\scripts.win-amd64-3.6
copying and adjusting SolarIrradiance.py -> build\scripts.win-amd64-3.6
copying and adjusting UserDataHorizontalRadiance.py -> build\scripts.win-amd64-3.6
running egg_info
running build_src
build_src
building extension "lowtran7" sources
f2py options: ['--quiet']
adding 'build\src.win-amd64-3.6\build\src.win-amd64-3.6\fortranobject.c' to sources.
adding 'build\src.win-amd64-3.6\build\src.win-amd64-3.6' to include_dirs.
adding 'build\src.win-amd64-3.6\lowtran7-f2pywrappers.f' to sources.
build_src: building npy-pkg config files
writing lowtran.egg-info\PKG-INFO
writing dependency_links to lowtran.egg-info\dependency_links.txt
writing entry points to lowtran.egg-info\entry_points.txt
writing requirements to lowtran.egg-info\requires.txt
writing top-level names to lowtran.egg-info\top_level.txt
reading manifest file 'lowtran.egg-info\SOURCES.txt'
writing manifest file 'lowtran.egg-info\SOURCES.txt'
running build_ext
Looking for python36.dll
Building import library (arch=AMD64): "c:\anaconda3\libs\libpython36.a" (from c:\anaconda3\python36.dll)
objdump.exe: c:\anaconda3\python36.dll: File format not recognized
Traceback (most recent call last):
File "", line 1, in
File "C:\Projects\lowtran-master\setup.py", line 11, in
setup(ext_modules=ext)
File "C:\Users\ad006850\AppData\Local\Temp\pip-build-env-p40yuiio\overlay\Lib\site-packages\numpy\distutils\core.py", line 171, in setup
return old_setup(**new_attr)
File "C:\Users\ad006850\AppData\Local\Temp\pip-build-env-p40yuiio\overlay\Lib\site-packages\setuptools_init_.py", line 145, in setup
return distutils.core.setup(**attrs)
File "c:\anaconda3\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "c:\anaconda3\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "c:\anaconda3\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Users\ad006850\AppData\Local\Temp\pip-build-env-p40yuiio\overlay\Lib\site-packages\setuptools\command\develop.py", line 38, in run
self.install_for_development()
File "C:\Users\ad006850\AppData\Local\Temp\pip-build-env-p40yuiio\overlay\Lib\site-packages\numpy\distutils\command\develop.py", line 17, in install_for_d evelopment
old_develop.install_for_development(self)
File "C:\Users\ad006850\AppData\Local\Temp\pip-build-env-p40yuiio\overlay\Lib\site-packages\setuptools\command\develop.py", line 140, in install_for_devel opment
self.run_command('build_ext')
File "c:\anaconda3\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "c:\anaconda3\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Users\ad006850\AppData\Local\Temp\pip-build-env-p40yuiio\overlay\Lib\site-packages\numpy\distutils\command\build_ext.py", line 116, in run
force=self.force)
File "C:\Users\ad006850\AppData\Local\Temp\pip-build-env-p40yuiio\overlay\Lib\site-packages\numpy\distutils\ccompiler.py", line 765, in new_compiler
compiler = klass(None, dry_run, force)
File "C:\Users\ad006850\AppData\Local\Temp\pip-build-env-p40yuiio\overlay\Lib\site-packages\numpy\distutils\mingw32ccompiler.py", line 103, in init
build_import_library()
File "C:\Users\ad006850\AppData\Local\Temp\pip-build-env-p40yuiio\overlay\Lib\site-packages\numpy\distutils\mingw32ccompiler.py", line 415, in build_impor t_library
return _build_import_library_amd64()
File "C:\Users\ad006850\AppData\Local\Temp\pip-build-env-p40yuiio\overlay\Lib\site-packages\numpy\distutils\mingw32ccompiler.py", line 471, in _build_impo rt_library_amd64
generate_def(dll_file, def_file)
File "C:\Users\ad006850\AppData\Local\Temp\pip-build-env-p40yuiio\overlay\Lib\site-packages\numpy\distutils\mingw32ccompiler.py", line 301, in generate_de f
raise ValueError("Symbol table not found")
ValueError: Symbol table not found
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\anaconda3\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Projects\lowtran-master\ setup.py'"'"'; file='"'"'C:\Projects\lowtran-master\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'" ', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' develop --no-deps Check the logs for full command output.

Documentation: Details for horizontal path

Hello,
this more a request for help on the documentation. I studied the original "LOWTRAN7 User Manual" that is conveniently linked on the main page, but I'm none the wiser...
I would like to calculate a horizontal path transmittance, so I use the file UserDataHorizontalTransmittance.py as a good starting point.
In there, the LOWTRAN variables range_km, zmdl & h1 are assigned the value of obsalt (observer altitude), but this shows up as "path length 0.05km" in the plot. I checked the manual an on PDF page 40 it says:
ZMDL = Altitude of layer boundary (km)
P = Pressure of layer boundary
T = Temperature of layer boundary

So now I'm at a complete loss on how to achieve a simple calculation like this:
initial altitude (H1) = 300 meter above see level
final altitude (seems like this is called H2) = 300 meter above see level
path length = 1000 meter

I would be very happy, if you could shed some light on this!

Setting wavelength interval

Currently, when running a function from Lowtran many times within a python file, it takes a substantial amount of time to get results. To speed this process up, within my installed copy of Lowtran, I have manually manipulated the wavenumber sampling interval (called wlcminvstep) within the wavelength conversion function nm2lt7. It seems to me that there is currently no way to alter the sampling interval from calling functions within Lowtran.

It would be very helpful to allow users to input their own sampling interval along with the wavelength starting and stopping points, as the current low resolution may be too fine for certain uses, especially if multiple calls to the Lowtran functions need to be executed within a python script.

internal compiler error: segmentation fault

@scivision Hi, I've successfully installed Fortran compilers on Windows 10 and tested that it works. But when I run the command "pip install -e ." from the lowtran folder, I get this segmentation fault error! Have you encountered this before? Any ideas?

Found executable C:\cygwin64\bin\gfortran.exe
Using built-in specs.
COLLECT_GCC=/usr/bin/gfortran
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/lto-wrapper.exe
Target: x86_64-pc-cygwin
Configured with: /cygdrive/i/szsz/tmpp/gcc/gcc-7.4.0-1.x86_64/src/gcc-7.4.0/configure --srcdir=/cygdrive/i/szsz/tmpp/gcc/gcc-7.4.0-1.x86_64/src/gcc-7.4  .0 --prefix=/usr --exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc --docdir=/usr/share/doc/gcc --htmldir=/usr/share/doc/gcc/html -C --build=x86_64-  pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin --without-libiconv-prefix --without-libintl-prefix --libexecdir=/usr/lib --enable-shared --enab  le-shared-libgcc --enable-static --enable-version-specific-runtime-libs --enable-bootstrap --enable-__cxa_atexit --with-dwarf2 --with-tune=generic --enable  -languages=ada,c,c++,fortran,lto,objc,obj-c++ --enable-graphite --enable-threads=posix --enable-libatomic --enable-libcilkrts --enable-libgomp --enable-lib  itm --enable-libquadmath --enable-libquadmath-support --disable-libssp --enable-libada --disable-symvers --with-gnu-ld --with-gnu-as --with-cloog-include=/  usr/include/cloog-isl --without-libiconv-prefix --without-libintl-prefix --with-system-zlib --enable-linker-build-id --with-default-libstdcxx-abi=gcc4-comp  atible --enable-libstdcxx-filesystem-ts
Thread model: posix
gcc version 7.4.0 (GCC)
customize Gnu95FCompiler
Using built-in specs.
COLLECT_GCC=/usr/bin/gfortran
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/lto-wrapper.exe
Target: x86_64-pc-cygwin
Configured with: /cygdrive/i/szsz/tmpp/gcc/gcc-7.4.0-1.x86_64/src/gcc-7.4.0/configure --srcdir=/cygdrive/i/szsz/tmpp/gcc/gcc-7.4.0-1.x86_64/src/gcc-7.4  .0 --prefix=/usr --exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc --docdir=/usr/share/doc/gcc --htmldir=/usr/share/doc/gcc/html -C --build=x86_64-  pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin --without-libiconv-prefix --without-libintl-prefix --libexecdir=/usr/lib --enable-shared --enab  le-shared-libgcc --enable-static --enable-version-specific-runtime-libs --enable-bootstrap --enable-__cxa_atexit --with-dwarf2 --with-tune=generic --enable  -languages=ada,c,c++,fortran,lto,objc,obj-c++ --enable-graphite --enable-threads=posix --enable-libatomic --enable-libcilkrts --enable-libgomp --enable-lib  itm --enable-libquadmath --enable-libquadmath-support --disable-libssp --enable-libada --disable-symvers --with-gnu-ld --with-gnu-as --with-cloog-include=/  usr/include/cloog-isl --without-libiconv-prefix --without-libintl-prefix --with-system-zlib --enable-linker-build-id --with-default-libstdcxx-abi=gcc4-comp  atible --enable-libstdcxx-filesystem-ts
Thread model: posix
gcc version 7.4.0 (GCC)
customize Gnu95FCompiler using build_ext
building 'lowtran7' extension
compiling C sources
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ib  uild\src.win-amd64-3.6\build\src.win-amd64-3.6 -IC:\Users\ad006850\AppData\Local\Temp\pip-build-env-w9xs3_x1\overlay\Lib\site-packages\numpy\core\include -  Ic:\anaconda3\include -Ic:\anaconda3\include -Ic:\anaconda3\include -Ic:\anaconda3\include -IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools  \VC\Tools\MSVC\14.16.27023\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17  763.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um -IC:\Progr  am Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt /Tcbuild\src.win-amd64-3.6  \lowtran7module.c /Fobuild\temp.win-amd64-3.6\Release\build\src.win-amd64-3.6\lowtran7module.obj
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ib  uild\src.win-amd64-3.6\build\src.win-amd64-3.6 -IC:\Users\ad006850\AppData\Local\Temp\pip-build-env-w9xs3_x1\overlay\Lib\site-packages\numpy\core\include -  Ic:\anaconda3\include -Ic:\anaconda3\include -Ic:\anaconda3\include -Ic:\anaconda3\include -IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools  \VC\Tools\MSVC\14.16.27023\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17  763.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um -IC:\Progr  am Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt /Tcbuild\src.win-amd64-3.6  \build\src.win-amd64-3.6\fortranobject.c /Fobuild\temp.win-amd64-3.6\Release\build\src.win-amd64-3.6\build\src.win-amd64-3.6\fortranobject.obj
compiling Fortran sources
Fortran f77 compiler: C:\cygwin64\bin\gfortran.exe -Wall -g -ffixed-form -fno-second-underscore -O3 -funroll-loops
Fortran f90 compiler: C:\cygwin64\bin\gfortran.exe -Wall -g -fno-second-underscore -O3 -funroll-loops
Fortran fix compiler: C:\cygwin64\bin\gfortran.exe -Wall -g -ffixed-form -fno-second-underscore -Wall -g -fno-second-underscore -O3 -funroll-loops
compile options: '-Ibuild\src.win-amd64-3.6\build\src.win-amd64-3.6 -IC:\Users\ad006850\AppData\Local\Temp\pip-build-env-w9xs3_x1\overlay\Lib\site-pack  ages\numpy\core\include -Ic:\anaconda3\include -Ic:\anaconda3\include -Ic:\anaconda3\include -Ic:\anaconda3\include -c'
extra f77 options: '-w'
gfortran.exe:f77: src/lowtran7.f
extra f77 options: '-w'
gfortran.exe:f77: build\src.win-amd64-3.6\lowtran7-f2pywrappers.f
build\src.win-amd64-3.6\lowtran7-f2pywrappers.f:227:0:

       subroutine f2pyinit_BLNK_(setupfunc)

internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
src/lowtran7.f:5285:0:

       SUBROUTINE TRANS(IPH,ISOURC,IDAY,ANGLEM,nwl,TXPy,VPy,ALAMPy,

internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
error: Command "C:\cygwin64\bin\gfortran.exe -Wall -g -ffixed-form -fno-second-underscore -O3 -funroll-loops -Ibuild\src.win-amd64-3.6\build\src.win-am  d64-3.6 -IC:\Users\ad006850\AppData\Local\Temp\pip-build-env-w9xs3_x1\overlay\Lib\site-packages\numpy\core\include -Ic:\anaconda3\include -Ic:\anaconda3\in  clude -Ic:\anaconda3\include -Ic:\anaconda3\include -c -c build\src.win-amd64-3.6\lowtran7-f2pywrappers.f -o build\temp.win-amd64-3.6\Release\build\src.win  -amd64-3.6\lowtran7-f2pywrappers.o -w" failed with exit status 1
----------------------------------------

ERROR: Command errored out with exit status 1: 'c:\anaconda3\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Projects\lowtran-mas ter\setup.py'"'"'; file='"'"'C:\Projects\lowtran-master\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"' "'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' develop --no-deps Check the logs for full command output.

Aerosols support

Hello! I'm using this project for my work. It works great.
But there is no aerosols options support at this time.
Please add support for the aerosols options, e.g. IHAZE, ISEASN, ICLD, VIS.

Atmospheric Transmittance

HI, I have a query. I am currently working with LANDSAT8 band 10 (10.6µm - 11.2µm) image to calculate the Land Surface temperature(LST). The Algorithm I used for LST, require the Atmospheric transmittance. Can i use the LOWTRAN to measure the Atmospheric transmittance? I new to the programming and doesn't have much experience. Would you please help me how to use Atmospheric Transmittance function and what input should I give for parameters? I have two test sites One from Germany and one from Pakistan and both have different climates.

Thank you

DLL load failed

I installed lowtran the way you proposed. However, once I tried to run one of the test scripts, 'import lowtran7' from base.py always raised the error 'DLL load failed'.
Checking the dependencies of lowtran7..pyd in Anaconda3/lib/site-packages with dependency walker revealed that python37.dll and also liblowtran7.dll could not be found. After copying python37.dll from Anaconda3/ and liblowtran7*.dll from Anaconda3/lib/site-packages/lowtran7/.libs/ in the same folder as lowtran7.*.pyd, everything worked fine. Don't know what caused the problem.
I am running anaconda/python 3.7 on Windows 10.

Nonsensical units for wavelength

I'm using the example posted here, and it occurred to me that --short, --long, and -step arguments are nonsensical. In the example, the short wavelength is listed in nanometers, but the longest wavelength is in cm^-1; similarly, the wavelength step is also cm^-1. But cm^-1 is wavenumber, so it makes a big difference what the units are. The x-axis title on the output plot is Wavelength [nm], so which is it? Wavelength (nm)? or Wavenumber (cm^-1)?

p = ArgumentParser(description="Lowtran 7 interface")
p.add_argument("-z", "--obsalt", help="altitude of observer [km]", type=float, default=0.0)
p.add_argument(
    "-a",
    "--zenang",
    help="observer zenith angle [deg]",
    type=float,
    nargs="+",
    default=[0, 60, 80],
)
p.add_argument("-s", "--short", help="shortest wavelength nm ", type=float, default=1000)
p.add_argument("-l", "--long", help="longest wavelength cm^-1 ", type=float, default=1500)
p.add_argument("-step", help="wavelength step size cm^-1", type=float, default=20)
p.add_argument(
    "--model",
    help='0-6, see Card1 "model" reference. 5=subarctic winter',
    type=int,
    default=2,
)
P = p.parse_args()

c1 = {
    "model": P.model,
    "h1": P.obsalt,
    "angle": P.zenang,
    "wlshort": P.short,
    "wllong": P.long,
    "wlstep": P.step,
}

TR = lowtran.transmittance(c1)

transmission(TR, c1)

show()

lowtran7.cp39-win_amd64.pyd missing

After succesfully installing lowtran, I was unable to run the test scripts due to a missing module:

ModuleNotFoundError: **\lowtran-main\src\lowtran\lowtran7.cp39-win_amd64.pyd

What could be the cause of this module being missing?

Thank you.

Can't run example code

Dear all,
I got through the setup on windows 7 x64.
I'm using Anaconda 3.5.10
I succeeded in compiling the fortran code with minGW-x86_64 7.2.0 release-posix-seh-rt_v5-rev0
But when I try to start any of the examples, I get this error


Traceback (most recent call last):
  File "TransmittanceGround2Space.py", line 25, in <module>
    TR = lowtran.loopangle(c1)
  File "C:\lowtran-2.2\lowtran\__init__.py", line 84, in loopangle
    TR.loc[a, ...] = T
  File "C:\Anaconda3\lib\site-packages\xarray\core\dataarray.py", line 112, in __setitem__
    self.data_array[pos_indexers] = value
  File "C:\Anaconda3\lib\site-packages\xarray\core\dataarray.py", line 484, in __setitem__
    assert_coordinate_consistent(value, obj.coords.variables)
  File "C:\Anaconda3\lib\site-packages\xarray\core\coordinates.py", line 325, in assert_coordinate_consistent
    .format(k, obj[k], coords[k]))
IndexError: dimension coordinate 'wavelength_nm' conflicts between indexed and indexing objects:
<xarray.DataArray 'wavelength_nm' (wavelength_nm: 9935)>
array([30303.03   , 29850.746  , 29411.764  , ...,   200.04001,   200.02   ,
         200.     ], dtype=float32)
Coordinates:
  * wavelength_nm  (wavelength_nm) float32 30303.03 29850.746 29411.764 ...
vs.
<xarray.IndexVariable 'wavelength_nm' (wavelength_nm: 9935)>
array([30000.      , 29556.650246, 29126.213592, ...,   200.02667 ,
         200.006667,   199.986668])

DLL Error on Windows Python 3.9

It looks like I'm not the first one with DLL issues on Windows. I was able to solve this one, so passing along for others or potential inclusion in a future version.

Windows 10, CPython 3.9 (Vanilla)

Steps to reproduce:

# add my mingw with gfortran to path
$Env:PATH += ";C:\msys64\mingw64\bin"
# activate my venv
.\venv\scripts\activate
# install lowtran
pip install git+https://github.com/space-physics/lowtran.git

In Python:

import lowtran
ImportError: you must compile the Fortran code first. f2py -m lowtran7 -c src/lowtran7.f  DLL load failed while importing lowtran7: The specified module could not be found.
import lowtran7
ImportError: DLL load failed while importing lowtran7: The specified module could not be found.

After some digging, I found that "the specified module" is the .DLL in site-packages/lowtran7/.libs.
It seems this is a known problem on Windows, see for example this discussion:
https://bugs.python.org/issue32516

See also this discussion of how DLL loading paths have changed on Windows.
https://docs.python.org/3/library/os.html#os.add_dll_directory

I found that adding this code to base.py before the lowtran7 import was able to solve the problem. (It could alternatively be added to __init__.py directly.)

import os
import sys

if os.name == 'nt':
    # code inspired by scipy._distributor_init.py for loading DLLs on Windows
    libs_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'lowtran7', '.libs'))
    if os.path.isdir(libs_path):
        # add the folder for Python 3.8 and above
        if sys.version_info.major == 3 and sys.version_info.minor >= 8:
            os.add_dll_directory(libs_path)

(I was inspired by scipy._distributor_init which solves a similar problem).

DemoLowtran.py fails in Python 2.7

Great package!
The demo script fails on Python 2.7 because the exist_ok parameter for os.makedirs() is not supported. The demo runs smoothly when I replace

    makedirs('out',exist_ok=True)

with

    makedirs('out')

how to get Atmospheric correction image

I tried to use lowtran model to get atmospherically-correct satellite images ,such as Landsat / sentinel-2A .
ARCSI could be used to get atmospherically-correct images results , and a scene image used about 8 minute ,which is too slow.
So, I look forward to trying lowtran for the same purpose, but I don't know how to use lowtran and have no tutorials.
Can anyone help me or show me the procedures.

AttributeError: module 'lowtran7' has no attribute 'lwtrn7'

Hello,

I am running your code in Pycharm (Python 3.9) and was able to successfully compile the fortran file via MinGW (64 bit Windows 10). Afterwards, PyCharm was able to find and install the package "lowtran" within the PyCharm environment.

However, the following error message occurs on all example programs (e.g., ScatterRadiance.py):

Traceback (most recent call last):
File "C:\Users\Johannes.Pseiner\Documents\PycharmProjects\pythonProject\lowtran-master\lowtran-master\HorizontalTransmittance.py", line 30, in
TR = lowtran.horiztrans(c1).squeeze()
File "C:\Users\Johannes.Pseiner\Documents\PycharmProjects\pythonProject\lowtran-master\lowtran-master\lowtran_init_.py", line 222, in horiztrans
return golowtran(c1)
File "C:\Users\Johannes.Pseiner\Documents\PycharmProjects\pythonProject\lowtran-master\lowtran-master\lowtran_init
.py", line 106, in _golowtran
Tx,V,Alam,trace,unif,suma,irrad,sumvv = lowtran7.lwtrn7(
AttributeError: module 'lowtran7' has no attribute 'lwtrn7'

It seems, that the function lwtrn7 is not defined in "init.py". What seems to be the issue here?

Thank you very much in advance!

Requested Features:

Kelly of SAIC requests Object to Sensor configuration, instead of the Sensor-Sun configuration I have first setup the code with.

My program does not write TAPE files, it directly injects into the Fortran variables. In particular, I didn't like how LOWTRAN7 read TAPE5, it was really easy to screw up on the number of whitespaces used and get an unexpected result.

I think we need to think how a Pythonic interface to Lowtran should look. We could hack on this specific case Kelly requests, I'm fine with that too. I am not out to recreate a GUI like MODTRAN, but am fine with that.

object-sensor scheme, given:
object position ECI
sensor position ECI
date and time
geography map for land sea level

The program computes the lat-lon-alt object & sensor positions, position of sun, moon, the season, land influence, etc.
The most general case possible. Aerosols, stratospherics, weather, etc. are user inputs.

Then writes TAPE5, runs the exe, extracts data, calculates info, draws graphs of:
transmission
radiance
absorption coefficients
plots

Ah, something like PCModWin:

http://www.ontar.com/Software/ProductDetails.aspx?item=PcModWin

Install directions for systems with python 2 & 3

Hello,
Thank you for providing this code. I have just a comment that might help future users who wish to use the code if they try to follow your install directions and have both python 2.7 (default) and python 3.6+ installed (common on many current distros).

Ensure they install via their distro package system


and install lowtran with
<pip3 install -e .>

X-axis in plot not reading from T.wavelength_nm?

Using the example posted here, I'm trying to find the spectral transmission for a well-known RF regime; let's say 1 GHz- 1.5 GHz. In wavelength, these convert to 299792458 and 199861639 nm, respectively.

Adding these wavelengths, the code becomes:

p = ArgumentParser(description="Lowtran 7 interface")
p.add_argument("-z", "--obsalt", help="altitude of observer [km]", type=float, default=0.0)
p.add_argument(
    "-a",
    "--zenang",
    help="observer zenith angle [deg]",
    type=float,
    nargs="+",
    default=[0, 60, 80],
)
p.add_argument("-s", "--short", help="shortest wavelength nm ", type=float, default=199861639)
p.add_argument("-l", "--long", help="longest wavelength cm^-1 ", type=float, default=299792458)
p.add_argument("-step", help="wavelength step size cm^-1", type=float, default=20)
p.add_argument(
    "--model",
    help='0-6, see Card1 "model" reference. 5=subarctic winter',
    type=int,
    default=2,
)
P = p.parse_args()

c1 = {
    "model": P.model,
    "h1": P.obsalt,
    "angle": P.zenang,
    "wlshort": P.short,
    "wllong": P.long,
    "wlstep": P.step,
}

TR = lowtran.transmittance(c1)

transmission(TR, c1)

show()

But when I run the code, I get the following plot:

Screenshot 2023-07-06 at 8 38 37 AM

Notice that the wavelength range (see question from #28 ) is 199,861,639 - 299792458nm, but the X-axis on the plot only shows a range of 0e6 - 10e6, or 0 - 10,000,000 nm -- a factor of 20 shorter than the shortest wavelength specified in the code. How can I make sense of the output data if I cannot trust the plot? How do I interpret the output?

Further inspection suggests that 10e6 nm is the longest wavelength that can be plotted, even though LOWTRAN 7 is programmed to work from 0 - 50,000 cm^-1, or 200 - Infinity nm. Furthermore, extracting the plotting wavelengths reveals the limitation as well:

>> TR.wavelength_nm.values
array([9999998.,       0.], dtype=float32)

Why is this artificially limited?

Units for gas values in UserHorizontalTransmission

In the user defined files the value given for the water content of the atmosphere is 93.96. I have been unable to determine what unit this is given in. Line 1145 of lowtran7.f indicates that this is in mb, however this value is too large to be mb or any of the other units defined for use in the Lowtran manual. Could you please clarify what the unit for this quantity is?

"make tests" fails

Hello,
this is just for Information: make test Fails on test 2/2:
Windows 7 x64
Anaconda3-5.1.0-Windows-x86_64
minGW-x86_64 7.2.0 release-posix-seh-rt_v5-rev0

Start testing: Mar 21 08:12 
----------------------------------------------------------
1/2 Testing: Fortran
1/2 Test: Fortran
Command: "C:/lowtran-2.3.0/bin/testlowtran.exe"
Directory: C:/lowtran-2.3.0/bin
"Fortran" start time: Mar 21 08:12 
Output:
----------------------------------------------------------
 wavelength [nm]   transmission
 1200.5             0.93435
 1132.5             0.65318
 1071.8             0.98058
 1017.3             0.98812
  968.1             0.92235
  923.4             0.92811
  882.6             0.98330
  845.3             0.97735
  811.0             0.96312
  779.4             0.97634
  750.2             0.96870
  723.1             0.92408
  697.8             0.94324
  674.3             0.94429
  652.3             0.92014
  631.7             0.90509
  612.4             0.89919
  594.2             0.87836
  577.0             0.88087
  560.9             0.88017
  545.6             0.87844
  531.1             0.87282
  517.3             0.86874
  504.3             0.85890
  491.9             0.85194
  480.1             0.83937
  468.8             0.82782
  458.1             0.81281
  447.8             0.79745
  438.0             0.78082
  428.6             0.76341
  419.6             0.74488
  411.0             0.72542
  402.7             0.70520
  394.8             0.68423
  387.1             0.66257
  379.8             0.64025
  372.7             0.61733
  365.9             0.59386
  359.3             0.56974
  353.0             0.54538
  346.9             0.52038
  340.9             0.49240
  335.2             0.46669
  329.7             0.43371
  324.4             0.38330
  319.2             0.32915
  314.2             0.22525
  309.3             0.12645
  304.6             0.04700
  300.0             0.00850
<end of output>
Test time =   0.09 sec
----------------------------------------------------------
Test Passed.
"Fortran" end time: Mar 21 08:12 
"Fortran" time elapsed: 00:00:00
----------------------------------------------------------

2/2 Testing: Python
2/2 Test: Python
Command: "C:/anaconda3/Scripts/pytest.exe" "-v"
Directory: C:/lowtran-2.3.0
"Python" start time: Mar 21 08:12 
Output:
----------------------------------------------------------
============================= test session starts =============================
platform win32 -- Python 3.6.4, pytest-3.4.2, py-1.5.2, pluggy-0.6.0 -- C:\Utils\anaconda3\python.exe
cachedir: .pytest_cache
rootdir: C:\Utils\lowtran-2.3.0, inifile:
plugins: remotedata-0.2.0, openfiles-0.2.0, doctestplus-0.1.2, arraydiff-0.2
collecting ... collected 5 items

tests/test_all.py::test_fortran FAILED                                   [ 20%]
tests/test_all.py::test_scatter FAILED                                   [ 40%]
tests/test_all.py::test_irradiance FAILED                                [ 60%]
tests/test_all.py::test_radiance FAILED                                  [ 80%]
tests/test_all.py::test_transmittance FAILED                             [100%]

================================== FAILURES ===================================
________________________________ test_fortran _________________________________

    def test_fortran():
    
        c1={'h1':0.,'angle':0,'wlnmlim':(500,900),'model':5,'itype':3,'iemsct':0,'im':0,
            'iseasn':0,'ird1':0,'range_km':0,'zmdl':0,'p':0,'t':0,
            'wmol':[0]*12}
    
>       TR = lowtran._golowtran(c1)
E       AttributeError: module 'lowtran' has no attribute '_golowtran'

tests\test_all.py:12: AttributeError
________________________________ test_scatter _________________________________

    def test_scatter():
        vlim = (400,700)
        angles = 60
    
        c1={'model':5,
            'h1': 0, # of observer
            'angle': angles, # of observer
            'wlnmlim': vlim,
            }
    # %%
>       TR = lowtran.scatter(c1)
E       AttributeError: module 'lowtran' has no attribute 'scatter'

tests\test_all.py:29: AttributeError
_______________________________ test_irradiance _______________________________

    def test_irradiance():
        vlim = (200,25000)
        angles = 60
    
        c1={'model':5,
            'h1': 0, # of observer
            'angle': angles, # of observer
            'wlnmlim': vlim,
            }
    # %%
>       TR = lowtran.irradiance(c1)
E       AttributeError: module 'lowtran' has no attribute 'irradiance'

tests\test_all.py:47: AttributeError
________________________________ test_radiance ________________________________

    def test_radiance():
        vlim = (200,25000)
        angles = 60
    
        c1={'model':5,
            'h1': 0, # of observer
            'angle': angles, # of observer
            'wlnmlim': vlim,
            }
    # %%
>       TR = lowtran.radiance(c1)
E       AttributeError: module 'lowtran' has no attribute 'radiance'

tests\test_all.py:66: AttributeError
_____________________________ test_transmittance ______________________________

    def test_transmittance():
        vlim = (200,30000)
        angles = 60
    
        c1={'model':5,
            'h1': 0, # of observer
            'angle': angles, # of observer
            'wlnmlim': vlim,
            }
    # %%
>       TR = lowtran.transmittance(c1)
E       AttributeError: module 'lowtran' has no attribute 'transmittance'

tests\test_all.py:84: AttributeError
========================== 5 failed in 1.51 seconds ===========================
<end of output>
Test time =   3.96 sec
----------------------------------------------------------
Test Failed.
"Python" end time: Mar 21 08:12 
"Python" time elapsed: 00:00:03
----------------------------------------------------------

End testing: Mar 21 08:12 

Import custom atmospheric profile

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?

Request for inputting/modifying trace gas profiles

I want to start using LOWTRAN in my research and I was wondering how I can use this package to input and vary SO2 profiles (or any other trace gas) and compute thermal infrared spectra at TOA. Is this currently possible with this package?

Thanks!

Implementing additional features

There seems to be an obvious correlation between some features (ex. model in the Python lowtran code and "Model" in the original LOWTRAN documentation), and a NON-obvious correlation between others. For instance, consider the following example (found here):

p = ArgumentParser(description="Lowtran 7 interface")
# 1: Tropical,        2: Midlatitude Summer,  3: Midlatitude Winter
# 4: Subarctic Summer 5: Subarctic Winter:    6: 1976 US Standard
p.add_argument("--model", type=int, default=2)
p.add_argument("-z", "--obsalt", help="Observer altitude [km]", type=float, default=0.0)
p.add_argument("-a", "--zenang", help="Observer zenith angle [deg]", type=float, nargs="+", default=[35])
p.add_argument("-s", "--short", help="Shortest wavelength [nm]", type=float, default=200)
p.add_argument("-l", "--long", help="Longest wavelength [cm^-1]", type=float, default=30000)
p.add_argument("-step", help="Wavelength step size [cm^-1]", type=float, default=20)
P = p.parse_args()

c1 = {
    "model": P.model,
    "h1": P.obsalt,
    "angle": P.zenang,
    "wlshort": P.short,
    "wllong": P.long,
    "wlstep": P.step,
}

How do I implement:

  • Scattering type (IMULT parameter, Card 1)
  • Cloud type (ICLD parameter, Card 2)
  • Aerosol attenuation (IHAZE parameter, Card 2)

These would be phenomenal to be able to control!

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.