forked from nguy/PyRadarMet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
193 lines (165 loc) · 5.91 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
190
191
192
193
"""PyRadarMet: Python Fundamental Calculations in Radar Meteorology
PyRadarMet is a toolkit that contains a variety of utilities that can be used
to calculate fundamental radar meteorology values:
* Convert between linear reflectivity(Z) and log reflectivity (dBZ)
* Calculate coefficients for attenuation calculations
* Calculate fundamental radar system characteristics
* Calculate Doppler radar characteristics
* Calculate geometrical characterisistics of radar
* Calculate variables from radar output
* Calculate ZDR bias of radar system
"""
import os
import sys
import urllib2
import shutil
#from shutil import copyfile
import tarfile
import time
from setuptools import setup
#- Pull the header into a variable
doclines = __doc__.split("\n")
VERSION = '0.1.3'
#- Set variables for setup
PACKNAME = 'pyradarmet'
PACKAGES = [PACKNAME]
URL = 'https://github.com/nguy/PyRadarMet'
AUTHOR = 'Nick Guy'
EMAIL = "[email protected]"
LICENSE = 'LICENSE.txt'
#DEMDIR = PACKNAME + os.sep.join([os.path.dirname(__file__), 'data'])
package_dirs={'':PACKNAME}
#datafiles = glob.glob(os.path.join(pathout,'*'))
#datafiles = [os.path.join('data',os.path.basename(f)) for f in datafiles]
#package_data = {'pyradarmet':datafiles}
# Check for Pyart package - Avoid conflict with PyPI
try:
import pyart
except ImportError as e:
print("Could not find PyArt Install\n\
Please go to https://github.com/ARM-DOE/pyart for PyArt install")
sys.exit()
# Read the text file with location of where to install
#demfiletxt = open('pyradarmet/demfile_locator.txt', 'r')
#DEMInstall = demfiletxt.readline()
#demfiletxt.close()
# Check for trailing directory "/"
#if DEMInstall[-1] is not '/':
# DEMInstall = DEMInstall + '/'
########
gtopourl="ftp://edcftp.cr.usgs.gov/data/gtopo30/global/"
try:
basefolder = os.environ["GTOPO_DATA"]
print "Topo data will be installed to %s" % os.environ["GTOPO_DATA"]
except KeyError:
basefolder = "./pyradarmet/"
print "GTOPO_DATA environmental variable not set, "\
"using default path in package directory"
archfolder=os.path.join(basefolder, 'gz')
datafolder=os.path.join(basefolder, 'data')
names =["antarcps", "e060n40", "e100n40", "e140n40", "w020n40", "w060n90",
"w100n90", "w140n90", "w180s10", "e020n40", "e060n90", "e100n90",
"e140n90", "w020n90", "w060s10", "w100s10", "w140s10", "w180s60",
"e020n90", "e060s10", "e100s10", "e140s10", "w020s10", "w060s60",
"w120s60", "w180n40", "e020s10", "e060s60", "e120s60", "w000s60",
"w060n40", "w100n40", "w140n40", "w180n90"]
for folder in [archfolder, datafolder]:
print folder
if not os.path.exists(folder):
os.makedirs(folder)
start_time = time.time()
for filename in names:
archfilebase = filename+".tar.gz"
archfile = os.path.join(archfolder, archfilebase)
hdrfilebase = filename+".hdr"
demfilebase = filename+".dem"
if not os.path.exists(archfile):
print("downloading: {0}".format(archfilebase))
ftpfile = urllib2.urlopen(gtopourl+archfilebase)
localfile = open(archfile, "wb")
shutil.copyfileobj(ftpfile, localfile)
localfile.close()
for exfilebase in [hdrfilebase, demfilebase]:
exfile = os.path.join(datafolder,exfilebase)
if not os.path.exists(exfile):
print("extracting: {0} from {1}".format(exfilebase, archfilebase))
tar = tarfile.open(archfile)
tarobj = tar.extractfile(exfilebase.upper())
localfile = open(exfile, "wb")
shutil.copyfileobj(tarobj, localfile)
tarobj.close()
localfile.close()
tar.close()
download_time = time.time() - start_time
print "Total download time: %g seconds"%(download_time)
#print "Removing tar directory: %s" % archfolder
#shutil.rmtree(archfolder)
#########
#- Run setup
if datafolder == './pyradarmet/data/':
setup(
name=PACKNAME,
version=VERSION,
url=URL,
author=AUTHOR,
author_email=EMAIL,
description=doclines[0],
license=LICENSE,
packages=PACKAGES,
package_data={PACKNAME: [datafolder+'*']},
include_package_data=True,
classifiers=["""
Development Status :: 3 - Alpha,
Programming Language :: Python",
Topic :: Scientific/Engineering
Topic :: Scientific/Engineering :: Atmospheric Science
Operating System :: Unix
Operating System :: POSIX :: Linux
Operating System :: MacOS
"""],
long_description = """
A toolkit that contains a variety of utilities that can be used
to calculate fundamental radar meteorology values:
* Convert between linear reflectivity(Z) and log reflectivity (dBZ)
* Calculate coefficients for attenuation calculations
* Calculate fundamental radar system characteristics
* Calculate Doppler radar characteristics
* Calculate geometrical characterisistics of radar
* Calculate variables from radar output
* Calculate ZDR bias of radar system""",
install_requires = ['Numpy >=1.7.2'],
)
else:
print "In EXTERNAL"
setup(
name=PACKNAME,
version=VERSION,
url=URL,
author=AUTHOR,
author_email=EMAIL,
description=doclines[0],
license=LICENSE,
packages=PACKAGES,
classifiers=["""
Development Status :: 3 - Alpha,
Programming Language :: Python",
Topic :: Scientific/Engineering
Topic :: Scientific/Engineering :: Atmospheric Science
Operating System :: Unix
Operating System :: POSIX :: Linux
Operating System :: MacOS
"""],
long_description = """
A toolkit that contains a variety of utilities that can be used
to calculate fundamental radar meteorology values:
* Convert between linear reflectivity(Z) and log reflectivity (dBZ)
* Calculate coefficients for attenuation calculations
* Calculate fundamental radar system characteristics
* Calculate Doppler radar characteristics
* Calculate geometrical characterisistics of radar
* Calculate variables from radar output
* Calculate ZDR bias of radar system""",
install_requires = ['Numpy >=1.7.2'],
)
install_time = time.time() - start_time
print "Total install time: %g seconds"%(install_time)