autoplot 0.9.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- autoplot/__init__.py +13 -0
- autoplot/autoplot.py +937 -0
- autoplot-0.9.3.dist-info/LICENSE.txt +11 -0
- autoplot-0.9.3.dist-info/METADATA +59 -0
- autoplot-0.9.3.dist-info/RECORD +7 -0
- autoplot-0.9.3.dist-info/WHEEL +5 -0
- autoplot-0.9.3.dist-info/top_level.txt +1 -0
autoplot/__init__.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Allow "from autoplot import javaaddpath"
|
|
2
|
+
from autoplot.autoplot import javaaddpath
|
|
3
|
+
from autoplot.autoplot import init
|
|
4
|
+
from autoplot.autoplot import start
|
|
5
|
+
from autoplot.autoplot import APDataSet
|
|
6
|
+
from autoplot.autoplot import applot
|
|
7
|
+
from autoplot.autoplot import plot
|
|
8
|
+
from autoplot.autoplot import to_qdataset
|
|
9
|
+
from autoplot.autoplot import to_ndarray
|
|
10
|
+
from autoplot.autoplot import show_completions
|
|
11
|
+
from autoplot.autoplot import getDataSet
|
|
12
|
+
from autoplot.autoplot import formatDataSet
|
|
13
|
+
__version__='0.9.3'
|
autoplot/autoplot.py
ADDED
|
@@ -0,0 +1,937 @@
|
|
|
1
|
+
from __future__ import print_function
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def version():
|
|
5
|
+
return "0.8.1"
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def printNoNewline(s):
|
|
9
|
+
print(s, end=" ")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def init(url="", jdwpPort=-1):
|
|
13
|
+
"""Start up JVM, import JAR at URL.
|
|
14
|
+
com= jpype.JPackage('com')
|
|
15
|
+
can be used to the com package into the Python namespace.
|
|
16
|
+
Example:
|
|
17
|
+
javaaddpath('http://autoplot.org/devel/autoplot.jar')
|
|
18
|
+
if no url is provided, then the default http://autoplot.org/latest/autoplot.jar is used.
|
|
19
|
+
"""
|
|
20
|
+
import jpype
|
|
21
|
+
if not jpype.isJVMStarted():
|
|
22
|
+
javaaddpath(url="", jdwpPort=jdwpPort)
|
|
23
|
+
|
|
24
|
+
def handleShutdown():
|
|
25
|
+
"shutdown hook which shuts down the JVM."
|
|
26
|
+
print("shut down JVM...")
|
|
27
|
+
import jpype
|
|
28
|
+
|
|
29
|
+
System = jpype.JClass("java.lang.System")
|
|
30
|
+
System.exit(-15)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def start(vers="latest", noexit=False):
|
|
34
|
+
"""start up the JVM and launch Autoplot. This also disables Java's system.exit, which also shuts down Python."""
|
|
35
|
+
# javaaddpath(url='https://ci-pw.physics.uiowa.edu/job/autoplot-release-2022/lastSuccessfulBuild/artifact/autoplot/Autoplot/dist/autoplot.jar')
|
|
36
|
+
import re
|
|
37
|
+
|
|
38
|
+
if not re.match("[a-zA-Z_0-9]+", vers):
|
|
39
|
+
raise Exception(
|
|
40
|
+
"version must match [a-zA-Z_0-9]+, (latest, devel, v2023a_8, etc)"
|
|
41
|
+
)
|
|
42
|
+
javaaddpath(url="http://autoplot.org/jnlp/" + vers + "/autoplot.jar")
|
|
43
|
+
|
|
44
|
+
import jpype
|
|
45
|
+
|
|
46
|
+
AppManager = jpype.JClass("org.autoplot.AppManager")
|
|
47
|
+
AppManager.getInstance().setAllowExit(False)
|
|
48
|
+
AutoplotUI = jpype.JClass("org.autoplot.AutoplotUI")
|
|
49
|
+
AutoplotUI.main([])
|
|
50
|
+
if not noexit:
|
|
51
|
+
import atexit
|
|
52
|
+
|
|
53
|
+
atexit.register(handleShutdown)
|
|
54
|
+
# import time
|
|
55
|
+
# time.sleep(5)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def javaaddpath(url="", jdwpPort=-1):
|
|
59
|
+
"""Start up JVM, import JAR at URL.
|
|
60
|
+
com= jpype.JPackage('com')
|
|
61
|
+
can be used to the com package into the Python namespace.
|
|
62
|
+
Example:
|
|
63
|
+
javaaddpath('http://autoplot.org/devel/autoplot.jar')
|
|
64
|
+
if no url is provided, then the default http://autoplot.org/latest/autoplot.jar is used.
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
import os
|
|
68
|
+
import tempfile
|
|
69
|
+
|
|
70
|
+
import jpype
|
|
71
|
+
|
|
72
|
+
# TODO: Use requests package.
|
|
73
|
+
try:
|
|
74
|
+
# For Python 3.0 and later
|
|
75
|
+
from urllib.request import urlopen
|
|
76
|
+
except ImportError:
|
|
77
|
+
# Fall back to Python 2's urllib2
|
|
78
|
+
from urllib2 import urlopen
|
|
79
|
+
|
|
80
|
+
if url == "":
|
|
81
|
+
url = "http://autoplot.org/latest/autoplot.jar"
|
|
82
|
+
|
|
83
|
+
file_name = url.split("/")[-1]
|
|
84
|
+
u = urlopen(url)
|
|
85
|
+
i = u.info()
|
|
86
|
+
file_size = int(i.get("Content-Length"))
|
|
87
|
+
cacheFile = tempfile.gettempdir() + os.sep + file_name
|
|
88
|
+
useCache = False
|
|
89
|
+
if os.path.exists(cacheFile):
|
|
90
|
+
cacheFileSize = os.path.getsize(cacheFile)
|
|
91
|
+
print("cache file size: %d" % cacheFileSize)
|
|
92
|
+
if cacheFileSize == file_size:
|
|
93
|
+
useCache = True
|
|
94
|
+
|
|
95
|
+
if useCache:
|
|
96
|
+
print("Using existing file: %s" % cacheFile)
|
|
97
|
+
|
|
98
|
+
else:
|
|
99
|
+
print("Downloading: %s Bytes: %s" % (file_name, file_size))
|
|
100
|
+
|
|
101
|
+
file_size_dl = 0
|
|
102
|
+
block_sz = 8192
|
|
103
|
+
|
|
104
|
+
f = open(cacheFile, "wb")
|
|
105
|
+
|
|
106
|
+
while True:
|
|
107
|
+
buffer = u.read(block_sz)
|
|
108
|
+
if not buffer:
|
|
109
|
+
break
|
|
110
|
+
|
|
111
|
+
file_size_dl += len(buffer)
|
|
112
|
+
f.write(buffer)
|
|
113
|
+
status = r"%10d [%3.2f%%]" % (
|
|
114
|
+
file_size_dl,
|
|
115
|
+
file_size_dl * 100.0 / file_size,
|
|
116
|
+
)
|
|
117
|
+
status = status + chr(8) * (len(status) + 1)
|
|
118
|
+
status = "\r" + status
|
|
119
|
+
printNoNewline(status) # support Python 2.7 / 3.x
|
|
120
|
+
|
|
121
|
+
print("")
|
|
122
|
+
|
|
123
|
+
f.close()
|
|
124
|
+
|
|
125
|
+
if not jpype.isJVMStarted():
|
|
126
|
+
if jdwpPort > -1:
|
|
127
|
+
print("Java is waiting for debugger at port %d" % jdwpPort)
|
|
128
|
+
jpype.startJVM(
|
|
129
|
+
jpype.getDefaultJVMPath(),
|
|
130
|
+
"-Djava.class.path=" + cacheFile,
|
|
131
|
+
"-Xdebug",
|
|
132
|
+
"-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=%d"
|
|
133
|
+
% jdwpPort,
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
else:
|
|
137
|
+
print("Java is starting")
|
|
138
|
+
jpype.startJVM(
|
|
139
|
+
jpype.getDefaultJVMPath(), "-Djava.class.path=" + cacheFile
|
|
140
|
+
)
|
|
141
|
+
else:
|
|
142
|
+
print("Java is already running.")
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def APDataSet():
|
|
146
|
+
"""create a new container for loading data"""
|
|
147
|
+
import jpype
|
|
148
|
+
|
|
149
|
+
clas = jpype.JClass("org.autoplot.idlsupport.APDataSet")
|
|
150
|
+
return clas()
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def to_ndarray(apds, name=None):
|
|
154
|
+
"""extract the data identified by name to numpy array, using datetime64 for times. If name is empty or not specified, then
|
|
155
|
+
the default dataset is returned."""
|
|
156
|
+
import jpype
|
|
157
|
+
import numpy as np
|
|
158
|
+
|
|
159
|
+
if name == None:
|
|
160
|
+
name = apds.name()
|
|
161
|
+
Units = jpype.JClass("org.das2.datum.Units")
|
|
162
|
+
apds.setPreferredUnits("microseconds since 2000-01-01T00:00")
|
|
163
|
+
u = Units.lookupUnits(apds.propertyAsString(name, "UNITS"))
|
|
164
|
+
if u.isConvertibleTo(Units.us2000):
|
|
165
|
+
g_base = np.datetime64("2000-01-01T00:00:00Z")
|
|
166
|
+
dd = apds.values(name)
|
|
167
|
+
result = np.array(
|
|
168
|
+
[
|
|
169
|
+
g_base + np.timedelta64(int(dd[i] * 1000), "ns")
|
|
170
|
+
for i in range(len(dd))
|
|
171
|
+
]
|
|
172
|
+
)
|
|
173
|
+
else:
|
|
174
|
+
dd = apds.values(name)
|
|
175
|
+
result = np.array(dd)
|
|
176
|
+
return result
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def to_qdataset(X, Y=None, Z=None):
|
|
180
|
+
"""convert the ndarrays or array like objects to Autoplot QDataSet objects.
|
|
181
|
+
datetime64 are handled by converting to QDataSet with Units.us2000"""
|
|
182
|
+
import jpype
|
|
183
|
+
|
|
184
|
+
if not jpype.isJVMStarted():
|
|
185
|
+
raise Exception("Java is not running, use javaaddpath")
|
|
186
|
+
Ops = jpype.JClass("org.das2.qds.ops.Ops")
|
|
187
|
+
QDataSet = jpype.JClass("org.das2.qds.QDataSet")
|
|
188
|
+
Units = jpype.JClass("org.das2.datum.Units")
|
|
189
|
+
import datetime
|
|
190
|
+
|
|
191
|
+
import numpy as np
|
|
192
|
+
|
|
193
|
+
if not X is None and isinstance(X, jpype.JObject):
|
|
194
|
+
if X.getClass().getTypeName() == "org.autoplot.idlsupport.APDataSet":
|
|
195
|
+
X= X.getQDataSet()
|
|
196
|
+
|
|
197
|
+
if not Y is None and isinstance(Y, jpype.JObject):
|
|
198
|
+
if Y.getClass().getTypeName() == "org.autoplot.idlsupport.APDataSet":
|
|
199
|
+
Y = Y.getQDataSet()
|
|
200
|
+
|
|
201
|
+
if not Z is None and isinstance(Z, jpype.JObject):
|
|
202
|
+
if Z.getClass().getTypeName() == "org.autoplot.idlsupport.APDataSet":
|
|
203
|
+
Z = Z.getQDataSet()
|
|
204
|
+
|
|
205
|
+
if Y is None and Z is None:
|
|
206
|
+
if isinstance(X, jpype.JObject):
|
|
207
|
+
xds = X # assume it's a QDataSet already
|
|
208
|
+
else:
|
|
209
|
+
if isinstance(X, list):
|
|
210
|
+
if isinstance(X[0], datetime.datetime):
|
|
211
|
+
X = np.array(X, dtype="datetime64[us]")
|
|
212
|
+
if not hasattr(X, "dtype"):
|
|
213
|
+
X = np.array(X)
|
|
214
|
+
if str(X.dtype).startswith("datetime64") or str(X.dtype).startswith(
|
|
215
|
+
"<M8"
|
|
216
|
+
):
|
|
217
|
+
g_base = np.datetime64("2000-01-01T00:00:00Z")
|
|
218
|
+
X = (X - g_base) / np.timedelta64(1000, "ns")
|
|
219
|
+
xds = Ops.dataset(
|
|
220
|
+
jpype.JArray(jpype.JDouble, X.ndim)(X.tolist())
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
xds.putProperty(QDataSet.UNITS, Units.us2000)
|
|
224
|
+
else:
|
|
225
|
+
xds = Ops.dataset(
|
|
226
|
+
jpype.JArray(jpype.JDouble, X.ndim)(X.tolist())
|
|
227
|
+
)
|
|
228
|
+
if xds.rank() == 2:
|
|
229
|
+
xds = Ops.transpose(xds)
|
|
230
|
+
return xds
|
|
231
|
+
elif Z is None:
|
|
232
|
+
xds = to_qdataset(X)
|
|
233
|
+
yds = to_qdataset(Y)
|
|
234
|
+
return Ops.link(xds, yds)
|
|
235
|
+
else:
|
|
236
|
+
xds = to_qdataset(X)
|
|
237
|
+
yds = to_qdataset(Y)
|
|
238
|
+
zds = to_qdataset(Z)
|
|
239
|
+
return Ops.link(xds, yds, zds)
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
def getDataSet(uri, monitor=None):
|
|
243
|
+
init()
|
|
244
|
+
apds = APDataSet()
|
|
245
|
+
apds.setDataSetURI(uri)
|
|
246
|
+
apds.doGetDataSet(monitor=monitor)
|
|
247
|
+
return apds
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def formatDataSet(ds, path):
|
|
251
|
+
import jpype
|
|
252
|
+
|
|
253
|
+
if not isinstance(path, jpype.JObject):
|
|
254
|
+
print('autoconvert to string!')
|
|
255
|
+
java_string_class = jpype.JClass("java.lang.String")
|
|
256
|
+
path= java_string_class(path)
|
|
257
|
+
print(ds,'before')
|
|
258
|
+
print(type(ds))
|
|
259
|
+
ds = to_qdataset(ds)
|
|
260
|
+
print(ds,'after')
|
|
261
|
+
print(type(ds))
|
|
262
|
+
if not isinstance(path, jpype.JObject):
|
|
263
|
+
print ('not a qdataset...')
|
|
264
|
+
sc = jpype.JClass("org.autoplot.ScriptContext")
|
|
265
|
+
sc.formatDataSet(ds, path)
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
def show_completions(s):
|
|
269
|
+
"print completions for the given URI."
|
|
270
|
+
import jpype
|
|
271
|
+
|
|
272
|
+
sc = jpype.JClass("org.autoplot.ScriptContext")
|
|
273
|
+
xxs = sc.getCompletions(s)
|
|
274
|
+
for x in xxs:
|
|
275
|
+
print(x)
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
def plot(X, Y=None, Z=None):
|
|
279
|
+
"""Plot to a running Autoplot"""
|
|
280
|
+
import jpype
|
|
281
|
+
|
|
282
|
+
if not jpype.isJVMStarted():
|
|
283
|
+
raise Exception("Java is not running, use javaaddpath")
|
|
284
|
+
ds = to_qdataset(X, Y, Z)
|
|
285
|
+
sc = jpype.JClass("org.autoplot.ScriptContext")
|
|
286
|
+
sc.plot(ds)
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
def das2stream(dataStruct, filename, ytags=None, ascii=1, xunits=""):
|
|
290
|
+
"""Write the python data structure to a das2stream"""
|
|
291
|
+
print("writing das2stream to " + filename + " using " + version())
|
|
292
|
+
import time
|
|
293
|
+
|
|
294
|
+
streamHeader = [
|
|
295
|
+
'[00]xxxxxx<stream source="applot.pro" localDate="'
|
|
296
|
+
+ time.asctime()
|
|
297
|
+
+ '">',
|
|
298
|
+
"</stream>",
|
|
299
|
+
]
|
|
300
|
+
contentLength = -10 # don't include the packet tag and content length
|
|
301
|
+
for i in range(len(streamHeader)):
|
|
302
|
+
contentLength += len(streamHeader[i]) + 1
|
|
303
|
+
|
|
304
|
+
x = streamHeader[0]
|
|
305
|
+
x = "[00]" + "%06d" % contentLength + x[10:]
|
|
306
|
+
streamHeader[0] = x
|
|
307
|
+
|
|
308
|
+
if ascii:
|
|
309
|
+
xdatatype = "ascii24"
|
|
310
|
+
else:
|
|
311
|
+
xdatatype = "sun_real8"
|
|
312
|
+
if ascii:
|
|
313
|
+
datatype = "ascii16"
|
|
314
|
+
else:
|
|
315
|
+
datatype = "sun_real8"
|
|
316
|
+
|
|
317
|
+
packetDescriptor = ["[01]xxxxxx<packet>"]
|
|
318
|
+
tags = dataStruct["tags"]
|
|
319
|
+
nt = len(tags)
|
|
320
|
+
packetDescriptor.append(
|
|
321
|
+
' <x type="'
|
|
322
|
+
+ xdatatype
|
|
323
|
+
+ '" name="'
|
|
324
|
+
+ tags[0]
|
|
325
|
+
+ '" units="'
|
|
326
|
+
+ xunits
|
|
327
|
+
+ '" />'
|
|
328
|
+
)
|
|
329
|
+
|
|
330
|
+
totalItems = 1
|
|
331
|
+
|
|
332
|
+
format = ["%24.12f"]
|
|
333
|
+
reclen = 4 + 24 + (nt - 1) * 20
|
|
334
|
+
i = 0
|
|
335
|
+
for tag in tags:
|
|
336
|
+
d = dataStruct[tag]
|
|
337
|
+
if i == 0:
|
|
338
|
+
name = ""
|
|
339
|
+
i = i + 1
|
|
340
|
+
continue
|
|
341
|
+
else:
|
|
342
|
+
name = tags[i] ### stream reader needs a default plane
|
|
343
|
+
if isinstance(d, list):
|
|
344
|
+
rank = 1
|
|
345
|
+
elif hasattr(d, "shape"): # check for numpy
|
|
346
|
+
rank = len(d.shape)
|
|
347
|
+
|
|
348
|
+
if rank == 1:
|
|
349
|
+
packetDescriptor.append(
|
|
350
|
+
' <y type="'
|
|
351
|
+
+ datatype
|
|
352
|
+
+ '" name="'
|
|
353
|
+
+ name
|
|
354
|
+
+ '" units="" idlname="'
|
|
355
|
+
+ tags[i]
|
|
356
|
+
+ '" />'
|
|
357
|
+
)
|
|
358
|
+
|
|
359
|
+
if i < nt - 1:
|
|
360
|
+
format.append("%16.4e")
|
|
361
|
+
else:
|
|
362
|
+
format.append("%15.3e")
|
|
363
|
+
totalItems = totalItems + 1
|
|
364
|
+
else:
|
|
365
|
+
if ytags == None:
|
|
366
|
+
ytags = range(s[2])
|
|
367
|
+
sytags = ",".join(["%f" % n for n in ytags])
|
|
368
|
+
nitems = len(ytags)
|
|
369
|
+
packetDescriptor.append(
|
|
370
|
+
' <yscan type="'
|
|
371
|
+
+ datatype
|
|
372
|
+
+ '" name="'
|
|
373
|
+
+ name
|
|
374
|
+
+ '" units="" nitems="'
|
|
375
|
+
+ str(nitems)
|
|
376
|
+
+ '" yTags="'
|
|
377
|
+
+ sytags
|
|
378
|
+
+ '"'
|
|
379
|
+
+ " />"
|
|
380
|
+
)
|
|
381
|
+
|
|
382
|
+
for i in range(1, nitems):
|
|
383
|
+
format.append("%16.4e")
|
|
384
|
+
if i < nt - 1:
|
|
385
|
+
format.append("%16.4e")
|
|
386
|
+
else:
|
|
387
|
+
format.append("%15.4e")
|
|
388
|
+
totalItems += nitems
|
|
389
|
+
i = i + 1
|
|
390
|
+
|
|
391
|
+
packetDescriptor.append("</packet>")
|
|
392
|
+
|
|
393
|
+
contentLength = -10 # don't include the packet tag and content length
|
|
394
|
+
for i in range(0, len(packetDescriptor)):
|
|
395
|
+
contentLength += len(packetDescriptor[i]) + 1
|
|
396
|
+
|
|
397
|
+
x = packetDescriptor[0]
|
|
398
|
+
x = x[0:4] + "%06d" % contentLength + x[10:]
|
|
399
|
+
packetDescriptor[0] = x
|
|
400
|
+
|
|
401
|
+
unit = open(filename, "wb")
|
|
402
|
+
|
|
403
|
+
for i in range(len(streamHeader)):
|
|
404
|
+
unit.write(bytes(streamHeader[i], "utf8"))
|
|
405
|
+
unit.write(bytes("\n", "utf8"))
|
|
406
|
+
|
|
407
|
+
for i in range(len(packetDescriptor)):
|
|
408
|
+
unit.write(bytes(packetDescriptor[i], "utf8"))
|
|
409
|
+
unit.write(bytes("\n", "utf8"))
|
|
410
|
+
|
|
411
|
+
nr = len(dataStruct["x"])
|
|
412
|
+
|
|
413
|
+
keys = dataStruct.keys()
|
|
414
|
+
|
|
415
|
+
newline = ascii
|
|
416
|
+
for i in range(nr):
|
|
417
|
+
unit.write(bytes(":01:", "utf8"))
|
|
418
|
+
for j in range(nt):
|
|
419
|
+
tag = tags[j]
|
|
420
|
+
if ascii:
|
|
421
|
+
rec = dataStruct[tag][i]
|
|
422
|
+
if hasattr(rec, "__len__"):
|
|
423
|
+
l = len(rec)
|
|
424
|
+
for k in range(l):
|
|
425
|
+
s = format[j] % rec[k]
|
|
426
|
+
unit.write(bytes(s, "utf8"))
|
|
427
|
+
if j == nt - 1:
|
|
428
|
+
newline = False
|
|
429
|
+
else:
|
|
430
|
+
s = format[j] % rec
|
|
431
|
+
unit.write(bytes(s, "utf8"))
|
|
432
|
+
else:
|
|
433
|
+
import struct
|
|
434
|
+
|
|
435
|
+
rec = dataStruct[tag][i]
|
|
436
|
+
if hasattr(rec, "__len__"):
|
|
437
|
+
l = len(rec)
|
|
438
|
+
for j in range(l):
|
|
439
|
+
unit.write(struct.pack(">d", rec[j]))
|
|
440
|
+
else:
|
|
441
|
+
unit.write(struct.pack(">d", rec))
|
|
442
|
+
|
|
443
|
+
if newline:
|
|
444
|
+
unit.write(bytes("\n", "utf8"))
|
|
445
|
+
|
|
446
|
+
unit.close()
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
def qstream(
|
|
450
|
+
dataStruct,
|
|
451
|
+
filename,
|
|
452
|
+
ytags=None,
|
|
453
|
+
ascii=True,
|
|
454
|
+
xunits="",
|
|
455
|
+
delta_plus=None,
|
|
456
|
+
delta_minus=None,
|
|
457
|
+
):
|
|
458
|
+
"""Write the data to a qstream. for rank 2, ytags must be specified ASCII, boolean, use ASCII transfer types"""
|
|
459
|
+
tags = dataStruct["tags"]
|
|
460
|
+
nt = len(tags)
|
|
461
|
+
name = tags[-1]
|
|
462
|
+
tname = tags[0]
|
|
463
|
+
|
|
464
|
+
print("writing qstream to " + filename + " using " + version())
|
|
465
|
+
import time
|
|
466
|
+
|
|
467
|
+
streamHeader = [
|
|
468
|
+
'<stream dataset_id="'
|
|
469
|
+
+ name
|
|
470
|
+
+ '" source="autoplot.py" localDate="'
|
|
471
|
+
+ time.asctime()
|
|
472
|
+
+ '">',
|
|
473
|
+
"</stream>",
|
|
474
|
+
]
|
|
475
|
+
contentLength = 0
|
|
476
|
+
for i in range(len(streamHeader)):
|
|
477
|
+
contentLength += len(streamHeader[i]) + 1
|
|
478
|
+
|
|
479
|
+
x = streamHeader[0]
|
|
480
|
+
x = "[00]" + "%06d" % contentLength + x
|
|
481
|
+
streamHeader[0] = x
|
|
482
|
+
|
|
483
|
+
if ascii:
|
|
484
|
+
xdatatype = "ascii30"
|
|
485
|
+
else:
|
|
486
|
+
xdatatype = "double"
|
|
487
|
+
if ascii:
|
|
488
|
+
datatype = "ascii16"
|
|
489
|
+
else:
|
|
490
|
+
datatype = "double"
|
|
491
|
+
|
|
492
|
+
if ytags != None:
|
|
493
|
+
ny = len(ytags)
|
|
494
|
+
svals = str(ytags[0])
|
|
495
|
+
for j in range(1, len(ytags)):
|
|
496
|
+
svals = svals + "," + str(ytags[j]).strip()
|
|
497
|
+
|
|
498
|
+
dep1Descriptor = ["<packet>"]
|
|
499
|
+
dep1Descriptor.append(' <qdataset id="DEP1" rank="1" >')
|
|
500
|
+
dep1Descriptor.append(" <properties>")
|
|
501
|
+
dep1Descriptor.append(
|
|
502
|
+
' <property name="NAME" type="String" value="DEP1" />'
|
|
503
|
+
)
|
|
504
|
+
dep1Descriptor.append(" </properties>")
|
|
505
|
+
dep1Descriptor.append(
|
|
506
|
+
' <values encoding="'
|
|
507
|
+
+ datatype
|
|
508
|
+
+ '" length="'
|
|
509
|
+
+ str(ny)
|
|
510
|
+
+ '" values="'
|
|
511
|
+
+ svals
|
|
512
|
+
+ '" />'
|
|
513
|
+
)
|
|
514
|
+
dep1Descriptor.append(" </qdataset>")
|
|
515
|
+
dep1Descriptor.append(" </packet>")
|
|
516
|
+
|
|
517
|
+
contentLength = 0 # don't include the packet tag and content length
|
|
518
|
+
for i in range(len(dep1Descriptor)):
|
|
519
|
+
contentLength += len(dep1Descriptor[i]) + 1
|
|
520
|
+
|
|
521
|
+
x = dep1Descriptor[0]
|
|
522
|
+
x = "[02]" + "%06d" % contentLength + x
|
|
523
|
+
dep1Descriptor[0] = x
|
|
524
|
+
|
|
525
|
+
packetDescriptor = ["[01]xxxxxx<packet>"]
|
|
526
|
+
|
|
527
|
+
nt = len(tags)
|
|
528
|
+
packetDescriptor.append(' <qdataset id="' + tname + '" rank="1" >')
|
|
529
|
+
packetDescriptor.append(" <properties>")
|
|
530
|
+
packetDescriptor.append(
|
|
531
|
+
' <property name="NAME" type="String" value="'
|
|
532
|
+
+ tname
|
|
533
|
+
+ '" />'
|
|
534
|
+
)
|
|
535
|
+
packetDescriptor.append(
|
|
536
|
+
' <property name="UNITS" type="units" value="'
|
|
537
|
+
+ xunits
|
|
538
|
+
+ '" />'
|
|
539
|
+
)
|
|
540
|
+
packetDescriptor.append(" </properties>")
|
|
541
|
+
packetDescriptor.append(
|
|
542
|
+
' <values encoding="' + xdatatype + '" length="" />'
|
|
543
|
+
)
|
|
544
|
+
packetDescriptor.append(" </qdataset>")
|
|
545
|
+
|
|
546
|
+
totalItems = 1
|
|
547
|
+
|
|
548
|
+
format = ["%30f"]
|
|
549
|
+
formats = {"x": format}
|
|
550
|
+
|
|
551
|
+
reclen = 4 + 30 + (nt - 1) * 20
|
|
552
|
+
|
|
553
|
+
i = 1
|
|
554
|
+
for tag in tags[1:]:
|
|
555
|
+
formats1 = []
|
|
556
|
+
d = dataStruct[tag]
|
|
557
|
+
if isinstance(d, list):
|
|
558
|
+
rank = 1
|
|
559
|
+
elif hasattr(d, "shape"): # check for numpy
|
|
560
|
+
rank = len(d.shape)
|
|
561
|
+
|
|
562
|
+
name = tag ### stream reader needs a default plane
|
|
563
|
+
if rank == 1:
|
|
564
|
+
packetDescriptor.append(
|
|
565
|
+
' <qdataset id="' + name + '" rank="1" >'
|
|
566
|
+
)
|
|
567
|
+
packetDescriptor.append(" <properties>")
|
|
568
|
+
packetDescriptor.append(
|
|
569
|
+
' <property name="NAME" type="String" value="'
|
|
570
|
+
+ name
|
|
571
|
+
+ '" />'
|
|
572
|
+
)
|
|
573
|
+
packetDescriptor.append(
|
|
574
|
+
' <property name="DEPEND_0" type="qdataset" value="'
|
|
575
|
+
+ tname
|
|
576
|
+
+ '" />'
|
|
577
|
+
)
|
|
578
|
+
if i == 1:
|
|
579
|
+
if not delta_plus is None:
|
|
580
|
+
packetDescriptor.append(
|
|
581
|
+
' <property name="DELTA_PLUS" type="qdataset" value="'
|
|
582
|
+
+ delta_plus
|
|
583
|
+
+ '" />'
|
|
584
|
+
)
|
|
585
|
+
if not delta_minus is None:
|
|
586
|
+
packetDescriptor.append(
|
|
587
|
+
' <property name="DELTA_MINUS" type="qdataset" value="'
|
|
588
|
+
+ delta_minus
|
|
589
|
+
+ '" />'
|
|
590
|
+
)
|
|
591
|
+
packetDescriptor.append(" </properties>")
|
|
592
|
+
packetDescriptor.append(
|
|
593
|
+
' <values encoding="' + datatype + '" length="" />'
|
|
594
|
+
)
|
|
595
|
+
packetDescriptor.append(" </qdataset>")
|
|
596
|
+
if i < nt - 1:
|
|
597
|
+
formats1.append("%16.4e")
|
|
598
|
+
else:
|
|
599
|
+
formats1.append("%15.4e")
|
|
600
|
+
totalItems += 1
|
|
601
|
+
else:
|
|
602
|
+
nitems = d.shape[1]
|
|
603
|
+
packetDescriptor.append(' <qdataset id="' + name + '" rank="2" >')
|
|
604
|
+
packetDescriptor.append(" <properties>")
|
|
605
|
+
packetDescriptor.append(
|
|
606
|
+
' <property name="DEPEND_0" type="qdataset" value="'
|
|
607
|
+
+ tname
|
|
608
|
+
+ '" />'
|
|
609
|
+
)
|
|
610
|
+
packetDescriptor.append(
|
|
611
|
+
' <property name="DEPEND_1" type="qdataset" value="DEP1" />'
|
|
612
|
+
)
|
|
613
|
+
packetDescriptor.append(
|
|
614
|
+
' <property name="NAME" type="String" value="'
|
|
615
|
+
+ name
|
|
616
|
+
+ '" />'
|
|
617
|
+
)
|
|
618
|
+
packetDescriptor.append(" </properties>")
|
|
619
|
+
packetDescriptor.append(
|
|
620
|
+
' <values encoding="'
|
|
621
|
+
+ datatype
|
|
622
|
+
+ '" length="'
|
|
623
|
+
+ str(nitems)
|
|
624
|
+
+ '" />'
|
|
625
|
+
)
|
|
626
|
+
packetDescriptor.append(" </qdataset>")
|
|
627
|
+
for i in range(0, nitems - 1):
|
|
628
|
+
formats1.append("%16.4e")
|
|
629
|
+
if i < nt - 1:
|
|
630
|
+
formats1.append("%16.4e")
|
|
631
|
+
else:
|
|
632
|
+
formats1.append("%15.4e")
|
|
633
|
+
totalItems += nitems
|
|
634
|
+
i = i + 1
|
|
635
|
+
formats[tag] = formats1
|
|
636
|
+
packetDescriptor.append("</packet>")
|
|
637
|
+
|
|
638
|
+
contentLength = -10 # don't include the packet tag and content length
|
|
639
|
+
for i in range(len(packetDescriptor)):
|
|
640
|
+
contentLength += len(packetDescriptor[i]) + 1
|
|
641
|
+
|
|
642
|
+
x = packetDescriptor[0]
|
|
643
|
+
x = x[0:4] + "%06d" % contentLength + x[10:]
|
|
644
|
+
packetDescriptor[0] = x
|
|
645
|
+
|
|
646
|
+
unit = open(filename, "wb")
|
|
647
|
+
|
|
648
|
+
for i in range(len(streamHeader)):
|
|
649
|
+
unit.write(bytes(streamHeader[i], "utf8"))
|
|
650
|
+
unit.write(bytes("\n", "utf8"))
|
|
651
|
+
|
|
652
|
+
for i in range(len(packetDescriptor)):
|
|
653
|
+
unit.write(bytes(packetDescriptor[i], "utf8"))
|
|
654
|
+
unit.write(bytes("\n", "utf8"))
|
|
655
|
+
|
|
656
|
+
nr = len(dataStruct["x"])
|
|
657
|
+
|
|
658
|
+
if not ytags is None:
|
|
659
|
+
for i in range(len(dep1Descriptor)):
|
|
660
|
+
unit.write(bytes(dep1Descriptor[i], "utf8"))
|
|
661
|
+
unit.write(bytes("\n", "utf8"))
|
|
662
|
+
|
|
663
|
+
nr = len(dataStruct["x"]) # number of records to output
|
|
664
|
+
|
|
665
|
+
keys = dataStruct.keys()
|
|
666
|
+
|
|
667
|
+
newline = False
|
|
668
|
+
# import pdb
|
|
669
|
+
# pdb.set_trace()
|
|
670
|
+
|
|
671
|
+
for i in range(nr):
|
|
672
|
+
unit.write(bytes(":01:", "utf8"))
|
|
673
|
+
for j in range(nt):
|
|
674
|
+
tag = tags[j]
|
|
675
|
+
format = formats[tag]
|
|
676
|
+
if ascii:
|
|
677
|
+
rec = dataStruct[tag][i]
|
|
678
|
+
if hasattr(rec, "__len__"):
|
|
679
|
+
l = len(rec)
|
|
680
|
+
for k in range(l):
|
|
681
|
+
print(format[k])
|
|
682
|
+
s = format[k] % rec[k]
|
|
683
|
+
unit.write(bytes(s, "utf8"))
|
|
684
|
+
else:
|
|
685
|
+
s = format[0] % rec
|
|
686
|
+
unit.write(bytes(s, "utf8"))
|
|
687
|
+
if j == nt - 1:
|
|
688
|
+
newline = True
|
|
689
|
+
else:
|
|
690
|
+
import struct
|
|
691
|
+
|
|
692
|
+
rec = dataStruct[tag][i]
|
|
693
|
+
if hasattr(rec, "__len__"):
|
|
694
|
+
l = len(rec)
|
|
695
|
+
for j in range(l):
|
|
696
|
+
unit.write(struct.pack(">d", rec[j]))
|
|
697
|
+
else:
|
|
698
|
+
unit.write(struct.pack(">d", rec))
|
|
699
|
+
if newline:
|
|
700
|
+
unit.write(bytes("\n", "utf8"))
|
|
701
|
+
unit.close()
|
|
702
|
+
|
|
703
|
+
|
|
704
|
+
def tryPortConnect(host, port):
|
|
705
|
+
print("tryPortConnect")
|
|
706
|
+
import socket
|
|
707
|
+
|
|
708
|
+
s = socket.socket()
|
|
709
|
+
s.connect(("localhost", port))
|
|
710
|
+
s.close()
|
|
711
|
+
|
|
712
|
+
|
|
713
|
+
def load(uri):
|
|
714
|
+
"""tell Autoplot to load a .vap or plot an Autoplot URI. Autoplot must be running and its optional server must be listening
|
|
715
|
+
on port 12345."""
|
|
716
|
+
port = 12345
|
|
717
|
+
|
|
718
|
+
import socket
|
|
719
|
+
|
|
720
|
+
s = socket.socket()
|
|
721
|
+
s.connect(("localhost", port))
|
|
722
|
+
|
|
723
|
+
cmd = "load( '" + uri + "')\n"
|
|
724
|
+
|
|
725
|
+
foo = sendCommand(s, cmd)
|
|
726
|
+
s.shutdown(1)
|
|
727
|
+
s.close()
|
|
728
|
+
|
|
729
|
+
|
|
730
|
+
def sendCommand(s, cmd):
|
|
731
|
+
s.send(bytes(cmd, "utf8"))
|
|
732
|
+
print("done")
|
|
733
|
+
|
|
734
|
+
|
|
735
|
+
def applot(
|
|
736
|
+
x=None,
|
|
737
|
+
y=None,
|
|
738
|
+
z=None,
|
|
739
|
+
z4=None,
|
|
740
|
+
xunits="",
|
|
741
|
+
ylabel="",
|
|
742
|
+
tmpfile=None,
|
|
743
|
+
noplot=0,
|
|
744
|
+
respawn=0,
|
|
745
|
+
delta_plus=None,
|
|
746
|
+
delta_minus=None,
|
|
747
|
+
):
|
|
748
|
+
"""
|
|
749
|
+
NAME:
|
|
750
|
+
plot
|
|
751
|
+
PURPOSE:
|
|
752
|
+
Plot to Autoplot instead of the direct graphics plotting, by creating a temporary file of the data and sending a plot
|
|
753
|
+
command to Autoplot with the server turned on.
|
|
754
|
+
ARGUMENTS:
|
|
755
|
+
X,Y,Z as with plot. If X is an integer, then it is the position in Autoplot, so that multiple plots can be sent to
|
|
756
|
+
one Autoplot canvas.
|
|
757
|
+
CALLING SEQUENCE:
|
|
758
|
+
applot( X, Y )
|
|
759
|
+
applot( X, Y, Z ) for a spectrogram
|
|
760
|
+
|
|
761
|
+
KEYWORDS:
|
|
762
|
+
tmpfile= explicitly set the file used to move data into Autoplot. This can also be used with /noplot
|
|
763
|
+
noplot=True just make the tmpfile, don't actually try to plot.
|
|
764
|
+
xunits= units as a string, especially like "seconds since 2010-01-01T00:00"
|
|
765
|
+
ylabel='' label is currently ignored.
|
|
766
|
+
delta_plus= array of positive lengths showing the upper limit of the 1-sigma confidence interval.
|
|
767
|
+
delta_minus= array of positive lengths showing the lower limit of the 1-sigma confidence interval.
|
|
768
|
+
"""
|
|
769
|
+
|
|
770
|
+
port = 12345
|
|
771
|
+
|
|
772
|
+
useDas2Stream = False
|
|
773
|
+
|
|
774
|
+
if useDas2Stream:
|
|
775
|
+
ext = "d2s"
|
|
776
|
+
else:
|
|
777
|
+
ext = "qds"
|
|
778
|
+
|
|
779
|
+
if delta_plus != None:
|
|
780
|
+
ext = "qds"
|
|
781
|
+
|
|
782
|
+
if tmpfile == None:
|
|
783
|
+
import datetime
|
|
784
|
+
|
|
785
|
+
dt = datetime.datetime.today()
|
|
786
|
+
tag = dt.strftime("%Y%m%dT%H%M%S")
|
|
787
|
+
import glob
|
|
788
|
+
|
|
789
|
+
ff = glob.glob("/tmp/" + "autoplot." + tag + ".???." + ext)
|
|
790
|
+
seq = ".%03d." % len(ff)
|
|
791
|
+
tmpfile = "/tmp/" + "autoplot." + tag + seq + ext
|
|
792
|
+
else:
|
|
793
|
+
if tmpfile.index("." + ext) != len(tmpfile) - 4:
|
|
794
|
+
tmpfile = tmpfile + "." + ext # add the extension
|
|
795
|
+
|
|
796
|
+
if z4 is not None:
|
|
797
|
+
np = 4
|
|
798
|
+
elif z is not None:
|
|
799
|
+
np = 3
|
|
800
|
+
elif y is not None:
|
|
801
|
+
np = 2
|
|
802
|
+
elif x is not None:
|
|
803
|
+
np = 1
|
|
804
|
+
else:
|
|
805
|
+
raise Exception("no x, which must be specified")
|
|
806
|
+
|
|
807
|
+
# serialize the data to a das2stream in a temporary file
|
|
808
|
+
if isinstance(x, int):
|
|
809
|
+
pos = x
|
|
810
|
+
xx = y
|
|
811
|
+
if not z is None:
|
|
812
|
+
yy = z
|
|
813
|
+
if not z4 is None:
|
|
814
|
+
zz = z4
|
|
815
|
+
np = np - 1
|
|
816
|
+
else:
|
|
817
|
+
pos = -1
|
|
818
|
+
xx = x
|
|
819
|
+
if not y is None:
|
|
820
|
+
yy = y
|
|
821
|
+
if not z is None:
|
|
822
|
+
zz = z
|
|
823
|
+
|
|
824
|
+
ascii = 1
|
|
825
|
+
|
|
826
|
+
if ext == "qds":
|
|
827
|
+
print("*****")
|
|
828
|
+
print(type(xx))
|
|
829
|
+
print(xunits)
|
|
830
|
+
if np == 3:
|
|
831
|
+
data = {"x": xx, "z": zz, "tags": ["x", "z"]}
|
|
832
|
+
qstream(data, tmpfile, ytags=yy, xunits=xunits, ascii=ascii)
|
|
833
|
+
elif np == 2:
|
|
834
|
+
if delta_plus != None:
|
|
835
|
+
data = {
|
|
836
|
+
"x": xx,
|
|
837
|
+
"y": yy,
|
|
838
|
+
"delta_plus": delta_plus,
|
|
839
|
+
"delta_minus": delta_minus,
|
|
840
|
+
"tags": ["x", "y", "delta_plus", "delta_minus"],
|
|
841
|
+
}
|
|
842
|
+
qstream(
|
|
843
|
+
data,
|
|
844
|
+
tmpfile,
|
|
845
|
+
ascii=ascii,
|
|
846
|
+
xunits=xunits,
|
|
847
|
+
delta_plus="delta_plus",
|
|
848
|
+
delta_minus="delta_minus",
|
|
849
|
+
)
|
|
850
|
+
else:
|
|
851
|
+
data = {"x": xx, "y": yy, "tags": ["x", "y"]}
|
|
852
|
+
qstream(data, tmpfile, ascii=ascii, xunits=xunits)
|
|
853
|
+
else:
|
|
854
|
+
ndim = len(xx.shape)
|
|
855
|
+
if ndim == 2:
|
|
856
|
+
data = {"x": range(len(xx)), "z": xx, "tags": ["x", "z"]}
|
|
857
|
+
qstream(
|
|
858
|
+
data,
|
|
859
|
+
tmpfile,
|
|
860
|
+
ytags=range(xx.shape[1]),
|
|
861
|
+
ascii=ascii,
|
|
862
|
+
xunits="",
|
|
863
|
+
)
|
|
864
|
+
else:
|
|
865
|
+
if delta_plus != None and delta_minus != None:
|
|
866
|
+
data = {
|
|
867
|
+
"x": range(len(xx)),
|
|
868
|
+
"y": xx,
|
|
869
|
+
"delta_plus": delta_plus,
|
|
870
|
+
"delta_minus": delta_minus,
|
|
871
|
+
"tags": ["x", "y", "delta_plus", "delta_minus"],
|
|
872
|
+
}
|
|
873
|
+
qstream(
|
|
874
|
+
data,
|
|
875
|
+
tmpfile,
|
|
876
|
+
ascii=ascii,
|
|
877
|
+
xunits="",
|
|
878
|
+
delta_plus="delta_plus",
|
|
879
|
+
delta_minus="delta_minus",
|
|
880
|
+
)
|
|
881
|
+
else:
|
|
882
|
+
data = {"x": range(len(xx)), "y": xx, "tags": ["x", "y"]}
|
|
883
|
+
qstream(data, tmpfile, ascii=ascii, xunits="")
|
|
884
|
+
|
|
885
|
+
else:
|
|
886
|
+
if np == 3:
|
|
887
|
+
data = {"x": xx, "z": zz, "tags": ["x", "z"]}
|
|
888
|
+
das2stream(data, tmpfile, ytags=yy, xunits=xunits, ascii=ascii)
|
|
889
|
+
elif np == 2:
|
|
890
|
+
data = {"x": xx, "y": yy, "tags": ["x", "y"]}
|
|
891
|
+
das2stream(data, tmpfile, ascii=ascii, xunits=xunits)
|
|
892
|
+
else:
|
|
893
|
+
rank = 1
|
|
894
|
+
if rank == 2:
|
|
895
|
+
data = {"x": range(len(xx)), "z": xx, "tags": ["x", "z"]}
|
|
896
|
+
das2stream(
|
|
897
|
+
data, tmpfile, ytags=range(s[2]), ascii=ascii, xunits=""
|
|
898
|
+
)
|
|
899
|
+
else:
|
|
900
|
+
data = {"x": range(len(xx)), "y": xx, "tags": ["x", "y"]}
|
|
901
|
+
das2stream(data, tmpfile, ascii=ascii, xunits="")
|
|
902
|
+
|
|
903
|
+
if noplot == 1:
|
|
904
|
+
return
|
|
905
|
+
|
|
906
|
+
err = 0
|
|
907
|
+
if err == 0:
|
|
908
|
+
import socket
|
|
909
|
+
|
|
910
|
+
s = socket.socket()
|
|
911
|
+
s.connect(("localhost", port))
|
|
912
|
+
|
|
913
|
+
if pos > -1:
|
|
914
|
+
cmd = (
|
|
915
|
+
"plot( " + str(pos) + ', "file:' + tmpfile + '" );\n'
|
|
916
|
+
) # semicolon means no echo
|
|
917
|
+
|
|
918
|
+
else:
|
|
919
|
+
cmd = 'plot( "file:' + tmpfile + '" );\n' # semicolon means no echo
|
|
920
|
+
|
|
921
|
+
foo = sendCommand(s, cmd)
|
|
922
|
+
s.shutdown(1)
|
|
923
|
+
s.close()
|
|
924
|
+
|
|
925
|
+
else:
|
|
926
|
+
raise Exception("error encountered!")
|
|
927
|
+
|
|
928
|
+
|
|
929
|
+
if __name__ == "__main__":
|
|
930
|
+
import autoplot as ap
|
|
931
|
+
|
|
932
|
+
ap.init()
|
|
933
|
+
apds = ap.getDataSet(
|
|
934
|
+
"vap+jyds:https://jfaden.net/~jbf/autoplot/data/kmz/Jul_8,_2024_12_58_54_PM.kmz/doc.kml?speed&script=https://github.com/autoplot/dev/blob/master/demos/formats/kml/tracksKML.jyds"
|
|
935
|
+
)
|
|
936
|
+
ap.formatDataSet(apds, "/home/jbf/tmp/foo.qds")
|
|
937
|
+
print("see /home/jbf/tmp/foo.qds")
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Copyright 2019 Jeremy Faden
|
|
2
|
+
|
|
3
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
4
|
+
|
|
5
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
6
|
+
|
|
7
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
8
|
+
|
|
9
|
+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
10
|
+
|
|
11
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: autoplot
|
|
3
|
+
Version: 0.9.3
|
|
4
|
+
Summary: Interface to Autoplot Java library
|
|
5
|
+
Home-page: https://github.com/autoplot/python/
|
|
6
|
+
Author: Jeremy Faden
|
|
7
|
+
Author-email: faden@cottagesystems.com
|
|
8
|
+
License: LICENSE.txt
|
|
9
|
+
Description-Content-Type: text/x-rst
|
|
10
|
+
License-File: LICENSE.txt
|
|
11
|
+
Requires-Dist: jpype1
|
|
12
|
+
Requires-Dist: numpy
|
|
13
|
+
|
|
14
|
+
Autoplot is a Java application which can read data from many sources, such as ASCII tables, NASA CDF files, and HDF5 files. It can also read data from data servers, such as the server at NASA/Goddard/CDAWeb, Das2Servers used by the Radio and
|
|
15
|
+
Plasma Wave Group at the University of Iowa, and servers supporting the HAPI API.
|
|
16
|
+
|
|
17
|
+
Autoplot identifies data using "URIs", which are one-line strings containing a data source ID and configuration to read the data.
|
|
18
|
+
These URIs can be created using the Autoplot application, available at http://autoplot.org/.
|
|
19
|
+
Data are read into a standard data model, QDataSet, which is easily adapted to Python using "JPype".
|
|
20
|
+
Helper procedures from the autoplot package convert QDataSets into ndarrays.
|
|
21
|
+
|
|
22
|
+
Autoplot/Python Interface Tools
|
|
23
|
+
-------------------------------
|
|
24
|
+
|
|
25
|
+
Install using `pip install autoplot`
|
|
26
|
+
|
|
27
|
+
.. code:: python
|
|
28
|
+
|
|
29
|
+
import autoplot as ap
|
|
30
|
+
|
|
31
|
+
# Download autoplot.jar if needed and return Python bridge object
|
|
32
|
+
ap.init()
|
|
33
|
+
|
|
34
|
+
# Create Autoplot Data Set. This object manages loading the data and then containing it until extracted.
|
|
35
|
+
apds = ap.APDataSet()
|
|
36
|
+
|
|
37
|
+
# Set URI
|
|
38
|
+
apds.setDataSetURI('http://autoplot.org/data/swe-np.xls?column=data&depend0=dep0')
|
|
39
|
+
|
|
40
|
+
# Get the data
|
|
41
|
+
apds.doGetDataSet()
|
|
42
|
+
|
|
43
|
+
print(apds.toString())
|
|
44
|
+
# http://autoplot.org/data/swe-np.xls?column=data&depend0=dep0
|
|
45
|
+
# data: data[dep0=288] (dimensionless)
|
|
46
|
+
# dep0: dep0[288] (days since 1899-12-30T00:00:00.000Z) (DEPEND_0)
|
|
47
|
+
|
|
48
|
+
# Extract data values
|
|
49
|
+
vv = ap.to_ndarray(apds, 'data')
|
|
50
|
+
tt = ap.to_ndarray(apds, 'dep0')
|
|
51
|
+
|
|
52
|
+
from matplotlib import pyplot as plt
|
|
53
|
+
plt.plot(tt,vv)
|
|
54
|
+
plt.show()
|
|
55
|
+
|
|
56
|
+
Contact
|
|
57
|
+
-------------------------------
|
|
58
|
+
Jeremy Faden <faden@cottagesystems.com>
|
|
59
|
+
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
autoplot/__init__.py,sha256=vb0ekIw-CgLKZDCYDboTBBi40hfIcWVw-5VRI0IzXBI,503
|
|
2
|
+
autoplot/autoplot.py,sha256=uYmHeQpl3RDwahjllSLshiUr8jEt_JhH7D2NhKoB778,27899
|
|
3
|
+
autoplot-0.9.3.dist-info/LICENSE.txt,sha256=mbLr2q4Hor_XRDQv1zeG9A-5AKvX57iDnR8qXJ4MzAk,1456
|
|
4
|
+
autoplot-0.9.3.dist-info/METADATA,sha256=7n2HJKN00-yYKmDcy9DWMrkMcbd7euING0cZE2_WQvI,2007
|
|
5
|
+
autoplot-0.9.3.dist-info/WHEEL,sha256=BNRMDyzLkkcmlv0J8ppDQkk2VED33SesJDynr9ED1gc,91
|
|
6
|
+
autoplot-0.9.3.dist-info/top_level.txt,sha256=vbDQLmHiAraoamI-wSup8HNTEuk0fSRAxQLFM41IUUM,9
|
|
7
|
+
autoplot-0.9.3.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
autoplot
|