Skip to content

Commit 92c683e

Browse files
committed
Squashed commit of the following:
commit 30fcb0362d06ceedf46abeee729b9398d5d186b4 Author: Michael Hirsch, Ph.D <[email protected]> Date: Mon Aug 13 18:50:14 2018 -0400 allow user to specify wavelength step (short, long, step) commit 4f0b26421207acaa2d09fcd61d357a765a124532 Author: Michael Hirsch, Ph.D <[email protected]> Date: Mon Aug 13 18:07:30 2018 -0400 cleanup commit c45c10e76206efade9c0e03543a73aa06601e113 Author: Michael Hirsch, Ph.D <[email protected]> Date: Mon Aug 13 18:03:57 2018 -0400 modularize
1 parent be68ef9 commit 92c683e

24 files changed

+355
-299
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ script:
2828

2929
after_success:
3030
- if [[ $TRAVIS_PYTHON_VERSION == 3.6* ]]; then
31-
pytest --cov;
31+
pytest --cov --cov-config=setup.cfg;
3232
coveralls;
3333
fi
3434

CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ endif()
2222

2323

2424
# --- assert lib
25-
add_library(assert assert.f90)
25+
add_library(assert src/assert.f90)
2626
target_compile_options(assert PRIVATE ${FFLAGS})
2727

2828
set(okcomp GNU Intel)
2929
if(CMAKE_Fortran_COMPILER_ID IN_LIST okcomp)
30-
target_sources(assert PRIVATE error2008.f90)
30+
target_sources(assert PRIVATE src/error2008.f90)
3131
else() # non-Fortran 2008 compilers
32-
target_sources(assert PRIVATE error2003.f90)
32+
target_sources(assert PRIVATE src/error2003.f90)
3333
endif()
3434
# ---
35-
add_executable(testlowtran reference/lowtran_driver.f90 lowtran7.f)
35+
add_executable(testlowtran reference/lowtran_driver.f90 src/lowtran7.f)
3636
target_link_libraries(testlowtran PRIVATE assert)
3737
target_compile_options(testlowtran PRIVATE ${FFLAGS})
3838

HorizontalTransmittance.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,17 @@ def main():
1515
p.add_argument('-z', '--obsalt', help='altitude of bother observers on horizontal path [km]', type=float, default=0.3)
1616
p.add_argument('-r', '--range_km', help='range between observers on horizontal path [km]', type=float, default=1.0)
1717
p.add_argument('-a', '--zenang', help='zenith angle [deg] can be single value or list of values', type=float, default=0.)
18-
p.add_argument('-w', '--wavelen', help='wavelength range nm (start,stop)', type=float, nargs=2, default=(200, 30000))
18+
p.add_argument('-s', '--short', help='shortest wavelength nm ', type=float, default=200)
19+
p.add_argument('-l', '--long', help='longest wavelength nm ', type=float, default=30000)
20+
p.add_argument('-step', help='wavelength step size cm^-1', type=float, default=20)
1921
P = p.parse_args()
2022

2123
c1 = {'zmdl': P.obsalt,
2224
'h1': P.obsalt,
2325
'range_km': P.range_km,
24-
'wlnmlim': P.wavelen,
26+
'wlshort': P.short,
27+
'wllong': P.long,
28+
'wlstep': P.step,
2529
}
2630

2731
TR = lowtran.horiztrans(c1).squeeze()

README.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@
99

1010
# Lowtran in Python
1111

12-
LOWTRAN7 atmospheric absorption extinction model. Updated by Michael
13-
Hirsch to be platform independent and easily accessible from Python.
12+
LOWTRAN7 atmospheric absorption extinction model.
13+
Updated by Michael Hirsch to be platform independent and easily accessible from Python.
1414

15-
The main LOWTRAN program has been made accessible from Python by using
16-
direct memory transfers instead of the cumbersome and error-prone
17-
process of writing/reading text files. xarray.Dataset high-performance
18-
N-D array data is passed out, with all appropriate metadata.
15+
The main LOWTRAN program has been made accessible from Python by using direct memory transfers instead of the cumbersome and error-prone process of writing/reading text files.
16+
`xarray.Dataset` high-performance, simple N-D array data is passed out, with appropriate metadata.
1917

2018

2119
## Gallery
@@ -26,7 +24,9 @@ See below for how to make these examples.
2624

2725
## Install
2826

29-
1. You need a Fortran compiler. If you don't have one, here is how to install Gfortran:
27+
1. A Fortran compiler such as `gfortran` is needed.
28+
We use `f2py` (part of `numpy`) to seamlessly use the Fortran Lowtran library from Python.
29+
If you don't have one, here is how to install Gfortran:
3030

3131
* Linux: `apt install gfortran`
3232
* Mac: `brew install gcc`
@@ -78,21 +78,25 @@ Right now a lot of configuration features aren't implemented, please request tho
7878
### Fortran (optional)
7979

8080
This is not necessary for normal users:
81+
```sh
82+
cd bin
83+
cmake ..
84+
cmake --build .
85+
ctest -V
86+
```
8187

82-
cd bin
83-
cmake ..
84-
make
85-
make test
86-
87-
should generate [this text output](https://gist.github.com/drhirsch/89ef2060d8f15b0a60914d13a61e33ab).
88+
should generate
89+
[this text output](https://gist.github.com/drhirsch/89ef2060d8f15b0a60914d13a61e33ab).
8890

8991
### Windows f2py
9092

9193
(this is handled automatically by `setup.py`, noted here for debugging)
9294

93-
Yes, even though you're [using a 64-bit compiler](https://scivision.co/f2py-running-fortran-code-in-python-on-windows/):
94-
95-
f2py --compiler=mingw32 -m lowtran7 -c lowtran7.f
95+
Yes, even though you're
96+
[using a 64-bit compiler](https://scivision.co/f2py-running-fortran-code-in-python-on-windows/):
97+
```sh
98+
f2py --compiler=mingw32 -m lowtran7 -c lowtran7.f
99+
```
96100

97101
Tested on Windows with
98102
[MinGW](https://sourceforge.net/projects/mingw-w64/).

ScatterRadiance.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from matplotlib.pyplot import show
1616
try:
1717
import seaborn as sns
18-
sns.set_context('talk', font_scale=1.5)
18+
sns.set_context('talk')
1919
except ImportError:
2020
pass
2121
from argparse import ArgumentParser
@@ -27,7 +27,9 @@ def main():
2727
p = ArgumentParser(description='Lowtran 7 interface')
2828
p.add_argument('-z', '--obsalt', help='altitude of observer [km]', type=float, default=0.)
2929
p.add_argument('-a', '--zenang', help='Observer zenith angle [deg] ', nargs='+', type=float, default=[0., 60, 80])
30-
p.add_argument('-w', '--wavelen', help='wavelength range nm (start,stop)', type=float, nargs=2, default=(300, 1000))
30+
p.add_argument('-s', '--short', help='shortest wavelength nm ', type=float, default=400)
31+
p.add_argument('-l', '--long', help='longest wavelength nm ', type=float, default=700)
32+
p.add_argument('-step', help='wavelength step size cm^-1', type=float, default=20)
3133
p.add_argument('-o', '--outfn', help='NetCDF4 file to write')
3234
p.add_argument('--model', help='0-6, see Card1 "model" reference. 5=subarctic winter', type=int, default=5)
3335

@@ -36,7 +38,9 @@ def main():
3638
c1 = {'model': P.model,
3739
'h1': P.obsalt, # of observer
3840
'angle': P.zenang, # of observer
39-
'wlnmlim': P.wavelen,
41+
'wlshort': P.short,
42+
'wllong': P.long,
43+
'wlstep': P.step,
4044
}
4145
# %%
4246
TR = lowtran.scatter(c1)

SolarIrradiance.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@ def main():
1414
p = ArgumentParser(description='Lowtran 7 interface')
1515
p.add_argument('-z', '--obsalt', help='altitude of observer [km]', type=float, default=0.)
1616
p.add_argument('-a', '--zenang', help='zenith angle [deg] of sun or moon', nargs='+', type=float, default=[0, 60, 80])
17-
p.add_argument('-w', '--wavelen', help='wavelength range nm (start,stop)', type=float, nargs=2, default=(200, 25000))
17+
p.add_argument('-s', '--short', help='shortest wavelength nm ', type=float, default=200)
18+
p.add_argument('-l', '--long', help='longest wavelength nm ', type=float, default=30000)
19+
p.add_argument('-step', help='wavelength step size cm^-1', type=float, default=20)
1820
p.add_argument('--model', help='0-6, see Card1 "model" reference. 5=subarctic winter', type=int, default=5)
1921
P = p.parse_args()
2022

2123
c1 = {'model': P.model,
2224
'h1': P.obsalt,
2325
'angle': P.zenang, # zenith angle of sun or moon
24-
'wlnmlim': P.wavelen,
26+
'wlshort': P.short,
27+
'wllong': P.long,
28+
'wlstep': P.step,
2529
}
2630

2731
irr = lowtran.irradiance(c1)

ThermalRadiance.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ def main():
2323
p = ArgumentParser(description='Lowtran 7 interface')
2424
p.add_argument('-z', '--obsalt', help='altitude of observer [km]', type=float, default=0.)
2525
p.add_argument('-a', '--zenang', help='Observer zenith angle [deg] ', nargs='+', type=float, default=[0., 60, 80])
26-
p.add_argument('-w', '--wavelen', help='wavelength range nm (start,stop)', type=float, nargs=2, default=(200, 30000))
26+
p.add_argument('-s', '--short', help='shortest wavelength nm ', type=float, default=200)
27+
p.add_argument('-l', '--long', help='longest wavelength nm ', type=float, default=30000)
28+
p.add_argument('-step', help='wavelength step size cm^-1', type=float, default=20)
2729
p.add_argument('-o', '--outfn', help='HDF5 file to write')
2830
p.add_argument('--model', help='0-6, see Card1 "model" reference. 5=subarctic winter', type=int, default=5)
2931

@@ -32,7 +34,9 @@ def main():
3234
c1 = {'model': P.model,
3335
'h1': P.obsalt, # of observer
3436
'angle': P.zenang, # of observer
35-
'wlnmlim': P.wavelen,
37+
'wlshort': P.short,
38+
'wllong': P.long,
39+
'wlstep': P.step,
3640
}
3741

3842
TR = lowtran.radiance(c1)

TransmittanceGround2Space.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@ def main():
99
p = ArgumentParser(description='Lowtran 7 interface')
1010
p.add_argument('-z', '--obsalt', help='altitude of observer [km]', type=float, default=0.)
1111
p.add_argument('-a', '--zenang', help='observer zenith angle [deg]', type=float, nargs='+', default=[0, 60, 80])
12-
p.add_argument('-w', '--wavelen', help='wavelength range nm (start,stop)', type=float, nargs=2, default=(200, 30000))
12+
p.add_argument('-s', '--short', help='shortest wavelength nm ', type=float, default=200)
13+
p.add_argument('-l', '--long', help='longest wavelength cm^-1 ', type=float, default=30000)
14+
p.add_argument('-step', help='wavelength step size cm^-1', type=float, default=20)
1315
p.add_argument('--model', help='0-6, see Card1 "model" reference. 5=subarctic winter', type=int, default=5)
1416
P = p.parse_args()
1517

1618
c1 = {'model': P.model,
1719
'h1': P.obsalt,
1820
'angle': P.zenang,
19-
'wlnmlim': P.wavelen,
21+
'wlshort': P.short,
22+
'wllong': P.long,
23+
'wlstep': P.step,
2024
}
2125

2226
TR = lowtran.transmittance(c1)

UserDataHorizontalRadiance.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,19 @@ def main():
1414
p.add_argument(
1515
'ptfn', help='csv file with time,relative humidity [%],ambient temperature [K], total pressure (millibar)', nargs='?')
1616
p.add_argument('-z', '--obsalt', help='altitude of observer [km]', type=float, default=0.05)
17-
p.add_argument('-w', '--wavelen', help='wavelength range nm (start,stop)', type=float, nargs=2, default=(200, 30000))
17+
p.add_argument('-s', '--short', help='shortest wavelength nm ', type=float, default=200)
18+
p.add_argument('-l', '--long', help='longest wavelength nm ', type=float, default=30000)
19+
p.add_argument('-step', help='wavelength step size cm^-1', type=float, default=20)
1820
p.add_argument('-o', '--outfn', help='HDF5 file to write')
1921
P = p.parse_args()
2022

2123
# %% low-level Lowtran configuration for this scenario, don't change
2224
c1 = {'range_km': P.obsalt,
2325
'zmdl': P.obsalt,
2426
'h1': P.obsalt,
25-
'wlnmlim': P.wavelen,
27+
'wlshort': P.short,
28+
'wllong': P.long,
29+
'wlstep': P.step,
2630
}
2731

2832
TR = lowtran.horizrad(P.ptfn, P.outfn, c1)

UserHorizontalTransmittance.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,17 @@ def main():
1818
p.add_argument('-z', '--obsalt', help='altitude of bother observers on horizontal path [km]', type=float, default=0.3)
1919
p.add_argument('-r', '--range_km', help='range between observers on horizontal path [km]', type=float, default=1.0)
2020
p.add_argument('-a', '--zenang', help='zenith angle [deg] can be single value or list of values', type=float, default=0.)
21-
p.add_argument('-w', '--wavelen', help='wavelength range nm (start,stop)', type=float, nargs=2, default=(200, 30000))
21+
p.add_argument('-s', '--short', help='shortest wavelength nm ', type=float, default=200)
22+
p.add_argument('-l', '--long', help='longest wavelength nm ', type=float, default=30000)
23+
p.add_argument('-step', help='wavelength step size cm^-1', type=float, default=20)
2224
P = p.parse_args()
2325

2426
c1 = {'zmdl': P.obsalt,
2527
'h1': P.obsalt,
2628
'range_km': P.range_km,
27-
'wlnmlim': P.wavelen,
29+
'wlshort': P.short,
30+
'wllong': P.long,
31+
'wlstep': P.step,
2832
}
2933

3034
atmos = {'p': 949., 't': 283.8, 'wmol': [93.96, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]}

0 commit comments

Comments
 (0)