-
Notifications
You must be signed in to change notification settings - Fork 5
/
setup.py
189 lines (164 loc) · 6.07 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
import setuptools
import os
import subprocess
NAME = "shdom"
EXTENSION_NAME = "pyshdom"
DESCRIPTION = "3D Radiative Transfer Inversion using the SHDOM forward algorithm"
LONG_DESCRIPTION ="""
Pyshdom performs 3D reconstruction of cloud microphysical properties from multi-angle, multi-spectral solar reflected
radiation using a non-linear optimization procedure. The core radiative transfer routines are sourced from the
Fortran SHDOM (Spherical Harmonic Discrete Ordinate Method for 3D Atmospheric Radiative Transfer) code by Frank K. Evans [1].
The python package was created by Aviad Levis [2], Amit Aides (Technion - Israel Institute of Technology) and Jesse Loveridge (University of Illinois).
The inversion algorithms for can be found in the following papers:
- `Levis, Aviad, et al. "Airborne Three-Dimensional Cloud Tomography." Proceedings of the IEEE International Conference on Computer Vision. 2015.`
- `Levis, Aviad, et al. "Multiple-Scattering Microphysical Tomography." Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition. 2017.`
[1] http://nit.colorado.edu/shdom.html
[2] https://www.aviadlevis.com/3d-remote-sensing
"""
MAINTAINER = "Aviad Levis; Jesse Loveridge"
MAINTAINER_EMAIL = "aviad.levis@gmail.com"
URL = "https://github.com/aviadlevis/pyshdom"
LICENSE = "MIT"
VERSION = "3.0.0"
classifiers = ['Development Status :: 3 - Alpha',
'Programming Language :: Python',
'License :: OSI Approved :: MIT License',
'Intended Audience :: Science/Research',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Mathematics',
'Operating System :: OS Independent']
#
# Set this to True for compiling the polarized
# version of the SHDOM algorithm.
#
POLARIZED_SHDOM = False
#
# f2py stuff
#
F2PY_CMD = 'f2py'
F2PY_MODULE_NAME = 'core'
F2PY_SRC_PATH = 'src'
F2PY_SIGN_FILE = '{path}/core.pyf'.format(path=F2PY_SRC_PATH)
F2PY_SHDOM_FILES = ['fftpack.f', 'ocean_brdf.f', 'shdom_nompi.f', 'shdomsub5.f']
if POLARIZED_SHDOM:
F2PY_SHDOM_FILES.extend(['polarized/shdom90.f90',
'polarized/shdomsub1.f',
'polarized/shdomsub2.f',
'polarized/shdomsub3.f',
'polarized/shdomsub4.f',
'polarized/make_mie_table.f90',
'polarized/miewig.f',
'polarized/indexwatice.f'])
else:
F2PY_SHDOM_FILES.extend(['unpolarized/shdom90.f90',
'unpolarized/shdomsub1.f',
'unpolarized/shdomsub2.f',
'unpolarized/shdomsub3.f',
'unpolarized/shdomsub4.f',
'unpolarized/make_mie_table.f90',
'unpolarized/mieindsub.f'])
F2PY_SHDOM_FILES = [
'{path}/{file_name}'.format(path=F2PY_SRC_PATH, file_name=file_name) for file_name in F2PY_SHDOM_FILES
]
F2PY_CORE_API = [
'get_mie_table',
'get_center_wavelen',
'get_refract_index',
'get_nsize',
'get_sizes',
'compute_mie_all_sizes',
'make_multi_size_dist',
'write_mono_table',
'read_mono_table',
'get_poly_table',
'write_poly_table',
'read_poly_table',
'transform_leg_to_phase',
'rayleigh_extinct',
'rayleigh_phase_function',
'start_mpi',
'end_shdom_mpi',
'check_input_parmeters',
'new_grids',
'init_cell_structure',
'transfer_pa_to_grid',
'init_solution',
'solution_iterations',
'make_direct',
'make_direct_derivative',
'render',
'compute_top_radiances',
'fixed_lambertian_boundary',
'variable_lambertian_boundary',
'gradient_normcorr',
'gradient_l2',
'space_carve',
'precompute_phase_check',
'precompute_phase_check_grad'
]
def _run_command(cmd):
proc = subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
out_file = proc.stdout.read()
err_file = proc.stderr.read()
output = out_file + err_file
proc.stdout.close()
proc.stderr.close()
# need this hack to get the exit status
print('running ' + cmd)
out_file = os.popen(cmd)
if out_file.close():
# close returns exit status of command.
return ''
else:
# no errors, out_file.close() returns None.
return output
def createSignatureFile():
"""Create the signature file for the f2py file."""
signature_cmd = "{cmd} -h {sign} --overwrite-signature -m {module} {files} only: {api}".format(
cmd=F2PY_CMD,
sign=F2PY_SIGN_FILE,
module=F2PY_MODULE_NAME,
files=' '.join(F2PY_SHDOM_FILES),
api=' '.join(F2PY_CORE_API)
)
_run_command(signature_cmd)
def configuration(parent_package='',top_path=None):
from numpy.distutils.misc_util import Configuration
config = Configuration(
NAME,
parent_package,
top_path,
version = VERSION,
maintainer = MAINTAINER,
maintainer_email = MAINTAINER_EMAIL,
description = DESCRIPTION,
license = LICENSE,
url = URL,
long_description = LONG_DESCRIPTION
)
config.add_extension(
name=F2PY_MODULE_NAME,
sources=[F2PY_SIGN_FILE] + F2PY_SHDOM_FILES,
f2py_options=[]
)
return config
def multiple_configurations(name):
return lambda parent_package='', top_path=None: configuration(name, parent_package,top_path)
if __name__ == "__main__":
from numpy.distutils.core import setup
createSignatureFile()
setup(
configuration = configuration,
packages = setuptools.find_packages(),
include_package_data = True,
platforms = ["any"],
requires = ["numpy", "scipy"],
tests_require = ['nose',],
test_suite = 'nose.collector',
zip_safe = True,
install_requires=[
'numdifftools',
'tensorboardX'
],
classifiers = classifiers
)