00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 from plplotc import *
00022 import types
00023 import numpy
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 _plcont = plcont
00055 def plcont(z, *args):
00056 z = numpy.asarray(z)
00057 if len(z.shape) != 2:
00058 raise ValueError, "Expected 2D z array"
00059
00060 if len(args) > 4 and type(args[0]) == types.IntType:
00061 for i in range(1,4):
00062 if type(args[i]) != types.IntType:
00063 raise ValueError, "Expected 4 ints for kx,lx,ky,ly"
00064
00065 else:
00066
00067 ifdefault_range = 0
00068 kx,lx,ky,ly = args[0:4]
00069 args = args[4:]
00070 else:
00071 ifdefault_range = 1
00072
00073 if len(args) > 0:
00074 clev = numpy.asarray(args[0])
00075 if len(clev.shape) !=1:
00076 raise ValueError, "Expected 1D clev array"
00077 args = args[1:]
00078 else:
00079 raise ValueError, "Missing clev argument"
00080
00081 if len(args) > 0 and ( \
00082 type(args[0]) == types.StringType or \
00083 type(args[0]) == types.FunctionType or \
00084 type(args[0]) == types.BuiltinFunctionType):
00085 pltr = args[0]
00086
00087
00088
00089
00090 if type(pltr) == types.StringType:
00091 if pltr == "pltr0":
00092 pltr = pltr0
00093 elif pltr == "pltr1":
00094 pltr = pltr1
00095 elif pltr == "pltr2":
00096 pltr = pltr2
00097 else:
00098 raise ValueError, "pltr string is unrecognized"
00099
00100 args = args[1:]
00101
00102 if len(args) == 0:
00103
00104 pltr_data = None
00105 elif len(args) == 1:
00106
00107 pltr_data = args[0]
00108 args = args[1:]
00109 elif len(args) >= 2:
00110 xg = numpy.asarray(args[0])
00111 if len(xg.shape) < 1 or len(xg.shape) > 2:
00112 raise ValueError, "xg must be 1D or 2D array"
00113 yg = numpy.asarray(args[1])
00114 if len(yg.shape) != len(xg.shape):
00115 raise ValueError, "yg must have same number of dimensions as xg"
00116 args = args[2:]
00117
00118 if len(args) > 0:
00119 if type(args[0]) == types.IntType:
00120 wrap = args[0]
00121 args = args[1:]
00122 if len(xg.shape) == 2 and len(yg.shape) == 2 and \
00123 z.shape == xg.shape and z.shape == yg.shape:
00124
00125 if wrap == 1:
00126 z = numpy.resize(z, (z.shape[0]+1, z.shape[1]))
00127 xg = numpy.resize(xg, (xg.shape[0]+1, xg.shape[1]))
00128 yg = numpy.resize(yg, (yg.shape[0]+1, yg.shape[1]))
00129 elif wrap == 2:
00130 z = numpy.transpose(numpy.resize( \
00131 numpy.transpose(z), (z.shape[1]+1, z.shape[0])))
00132 xg = numpy.transpose(numpy.resize( \
00133 numpy.transpose(xg), (xg.shape[1]+1, xg.shape[0])))
00134 yg = numpy.transpose(numpy.resize( \
00135 numpy.transpose(yg), (yg.shape[1]+1, yg.shape[0])))
00136 elif wrap != 0:
00137 raise ValueError, "Invalid wrap specifier, must be 0, 1 or 2."
00138 elif wrap != 0:
00139 raise ValueError, "Non-zero wrap specified and xg and yg are not 2D arrays"
00140 else:
00141 raise ValueError, "Specified wrap is not an integer"
00142 pltr_data = (xg, yg)
00143 else:
00144
00145 pltr = pltr0
00146 pltr_data = None
00147 if len(args) > 0:
00148 raise ValueError, "Too many arguments for plcont"
00149 if ifdefault_range:
00150
00151
00152 kx = 1
00153 lx = z.shape[0]
00154 ky = 1
00155 ly = z.shape[1]
00156 _plcont(z, kx, lx, ky, ly, clev, pltr, pltr_data)
00157 plcont.__doc__ = _plcont.__doc__
00158
00159
00160
00161
00162
00163 _plvect = plvect
00164 def plvect(u, v, *args):
00165 u = numpy.asarray(u)
00166 v = numpy.asarray(v)
00167
00168 if len(u.shape) != 2:
00169 raise ValueError, "Expected 2D u array"
00170 if len(v.shape) != 2:
00171 raise ValueError, "Expected 2D v array"
00172 if (u.shape[0] != v.shape[0]) or (u.shape[1] != v.shape[1]) :
00173 raise ValueError, "Expected u and v arrays to be the same dimensions"
00174
00175 if len(args) > 0 and (type(args[0]) == types.FloatType or type(args[0]) == numpy.float64) :
00176 scaling = args[0]
00177 args = args[1:]
00178 else:
00179 raise ValueError, "Missing scaling argument"
00180
00181 if len(args) > 0 and ( \
00182 type(args[0]) == types.StringType or \
00183 type(args[0]) == types.FunctionType or \
00184 type(args[0]) == types.BuiltinFunctionType):
00185 pltr = args[0]
00186
00187
00188
00189
00190 if type(pltr) == types.StringType:
00191 if pltr == "pltr0":
00192 pltr = pltr0
00193 elif pltr == "pltr1":
00194 pltr = pltr1
00195 elif pltr == "pltr2":
00196 pltr = pltr2
00197 else:
00198 raise ValueError, "pltr string is unrecognized"
00199
00200 args = args[1:]
00201
00202 if len(args) == 0:
00203
00204 pltr_data = None
00205 elif len(args) == 1:
00206
00207 pltr_data = args[0]
00208 args = args[1:]
00209 elif len(args) >= 2:
00210 xg = numpy.asarray(args[0])
00211 if len(xg.shape) < 1 or len(xg.shape) > 2:
00212 raise ValueError, "xg must be 1D or 2D array"
00213 yg = numpy.asarray(args[1])
00214 if len(yg.shape) != len(xg.shape):
00215 raise ValueError, "yg must have same number of dimensions as xg"
00216 args = args[2:]
00217
00218 if len(args) > 0:
00219 if type(args[0]) == types.IntType:
00220 wrap = args[0]
00221 args = args[1:]
00222 if len(xg.shape) == 2 and len(yg.shape) == 2 and \
00223 u.shape == xg.shape and u.shape == yg.shape:
00224
00225 if wrap == 1:
00226 u = numpy.resize(u, (u.shape[0]+1, u.shape[1]))
00227 v = numpy.resize(v, (v.shape[0]+1, v.shape[1]))
00228 xg = numpy.resize(xg, (xg.shape[0]+1, xg.shape[1]))
00229 yg = numpy.resize(yg, (yg.shape[0]+1, yg.shape[1]))
00230 elif wrap == 2:
00231 u = numpy.transpose(numpy.resize( \
00232 numpy.transpose(u), (u.shape[1]+1, u.shape[0])))
00233 v = numpy.transpose(numpy.resize( \
00234 numpy.transpose(v), (v.shape[1]+1, v.shape[0])))
00235 xg = numpy.transpose(numpy.resize( \
00236 numpy.transpose(xg), (xg.shape[1]+1, xg.shape[0])))
00237 yg = numpy.transpose(numpy.resize( \
00238 numpy.transpose(yg), (yg.shape[1]+1, yg.shape[0])))
00239 elif wrap != 0:
00240 raise ValueError, "Invalid wrap specifier, must be 0, 1 or 2."
00241 elif wrap != 0:
00242 raise ValueError, "Non-zero wrap specified and xg and yg are not 2D arrays"
00243 else:
00244 raise ValueError, "Specified wrap is not an integer"
00245 pltr_data = (xg, yg)
00246 else:
00247
00248 pltr = pltr0
00249 pltr_data = None
00250 if len(args) > 0:
00251 raise ValueError, "Too many arguments for plvect"
00252 _plvect(u, v, scaling, pltr, pltr_data)
00253 plvect.__doc__ = _plvect.__doc__
00254
00255
00256
00257
00258
00259 _plimagefr = plimagefr
00260 def plimagefr(img, *args):
00261 img = numpy.asarray(img)
00262
00263 if len(img.shape) != 2:
00264 raise ValueError, "Expected 2D img array"
00265
00266 if len(args) >= 8 :
00267 for i in range(8) :
00268 if (type(args[i]) != types.FloatType and \
00269 type(args[i]) != numpy.float64 and \
00270 type(args[i]) != types.IntType) :
00271 raise ValueError, "Expected 8 numbers for xmin, xmax, ymin, ymax, zmin, zmax, valuemin, valuemax"
00272 else:
00273
00274 xmin, xmax, ymin, ymax, zmin, zmax, valuemin, valuemax = args[0:8]
00275 args = args[8:]
00276 else:
00277 raise ValueError, "Expected 8 numbers for xmin, xmax, ymin, ymax, zmin, zmax, valuemin, valuemax"
00278
00279 if len(args) > 0 and ( \
00280 type(args[0]) == types.StringType or \
00281 type(args[0]) == types.FunctionType or \
00282 type(args[0]) == types.BuiltinFunctionType):
00283 pltr = args[0]
00284
00285
00286
00287
00288 if type(pltr) == types.StringType:
00289 if pltr == "pltr0":
00290 pltr = pltr0
00291 elif pltr == "pltr1":
00292 pltr = pltr1
00293 elif pltr == "pltr2":
00294 pltr = pltr2
00295 else:
00296 raise ValueError, "pltr string is unrecognized"
00297
00298 args = args[1:]
00299
00300 if len(args) == 0:
00301
00302 pltr_data = None
00303 elif len(args) == 1:
00304
00305 pltr_data = args[0]
00306 args = args[1:]
00307 elif len(args) >= 2:
00308 xg = numpy.asarray(args[0])
00309 if len(xg.shape) < 1 or len(xg.shape) > 2:
00310 raise ValueError, "xg must be 1D or 2D array"
00311 yg = numpy.asarray(args[1])
00312 if len(yg.shape) != len(xg.shape):
00313 raise ValueError, "yg must have same number of dimensions as xg"
00314 args = args[2:]
00315
00316 if len(args) > 0:
00317 if type(args[0]) == types.IntType:
00318 wrap = args[0]
00319 args = args[1:]
00320 if len(xg.shape) == 2 and len(yg.shape) == 2 and \
00321 img.shape[0] == xg.shape[0]-1 and img.shape[1] == xg.shape[1]-1:
00322
00323 if wrap == 1:
00324 img = numpy.resize(img, (img.shape[0]+1, u.shape[1]))
00325 xg = numpy.resize(xg, (xg.shape[0]+1, xg.shape[1]))
00326 yg = numpy.resize(yg, (yg.shape[0]+1, yg.shape[1]))
00327 elif wrap == 2:
00328 img = numpy.transpose(numpy.resize( \
00329 numpy.transpose(img), (img.shape[1]+1, img.shape[0])))
00330 xg = numpy.transpose(numpy.resize( \
00331 numpy.transpose(xg), (xg.shape[1]+1, xg.shape[0])))
00332 yg = numpy.transpose(numpy.resize( \
00333 numpy.transpose(yg), (yg.shape[1]+1, yg.shape[0])))
00334 elif wrap != 0:
00335 raise ValueError, "Invalid wrap specifier, must be 0, 1 or 2."
00336 elif wrap != 0:
00337 raise ValueError, "Non-zero wrap specified and xg and yg are not 2D arrays"
00338 else:
00339 raise ValueError, "Specified wrap is not an integer"
00340 pltr_data = (xg, yg)
00341 else:
00342
00343 pltr = pltr0
00344 pltr_data = None
00345 if len(args) > 0:
00346 raise ValueError, "Too many arguments for plimagefr"
00347 _plimagefr(img, xmin, xmax, ymin, ymax, zmin, zmax, valuemin, valuemax, pltr, pltr_data)
00348 plimagefr.__doc__ = _plimagefr.__doc__
00349
00350
00351
00352
00353
00354
00355
00356
00357 _plshades = plshades
00358 def plshades(z, *args):
00359 z = numpy.asarray(z)
00360 if len(z.shape) != 2:
00361 raise ValueError, "Expected 2D z array"
00362
00363 if len(args) > 4 and \
00364 (type(args[0]) == types.FloatType or type(args[0]) == numpy.float64 or type(args[0]) == types.IntType) and \
00365 (type(args[1]) == types.FloatType or type(args[1]) == numpy.float64 or type(args[1]) == types.IntType) and \
00366 (type(args[2]) == types.FloatType or type(args[2]) == numpy.float64 or type(args[2]) == types.IntType) and \
00367 (type(args[3]) == types.FloatType or type(args[3]) == numpy.float64 or type(args[3]) == types.IntType):
00368
00369 xmin, xmax, ymin, ymax = args[0:4]
00370 args = args[4:]
00371 else:
00372
00373
00374 xmin = -1.
00375 xmax = 1.
00376 ymin = -1.
00377 ymax = 1.
00378
00379
00380 if len(args) > 0:
00381 clev = numpy.asarray(args[0])
00382 if len(clev.shape) !=1:
00383 raise ValueError, "Expected 1D clev array"
00384 args = args[1:]
00385 else:
00386 raise ValueError, "Missing clev argument"
00387
00388
00389 if len(args) > 0 and type(args[0]) == types.IntType:
00390 fill_width = args[0]
00391 args = args[1:]
00392 else:
00393 raise ValueError, "Missing fill_width argument"
00394
00395
00396 if len(args) > 2 and \
00397 type(args[0]) == types.IntType and \
00398 type(args[1]) == types.IntType:
00399
00400 cont_color, cont_width = args[0:2]
00401 args = args[2:]
00402 else:
00403
00404 cont_color, cont_width = (0,0)
00405
00406
00407 if len(args) > 0 and type(args[0]) == types.IntType:
00408 rect = args[0]
00409 args = args[1:]
00410 else:
00411 raise ValueError, "Missing rect argument"
00412
00413 if len(args) > 0 and ( \
00414 type(args[0]) == types.NoneType or \
00415 type(args[0]) == types.StringType or \
00416 type(args[0]) == types.FunctionType or \
00417 type(args[0]) == types.BuiltinFunctionType):
00418 pltr = args[0]
00419
00420
00421
00422
00423 if type(pltr) == types.StringType:
00424 if pltr == "pltr0":
00425 pltr = pltr0
00426 elif pltr == "pltr1":
00427 pltr = pltr1
00428 elif pltr == "pltr2":
00429 pltr = pltr2
00430 else:
00431 raise ValueError, "pltr string is unrecognized"
00432
00433 args = args[1:]
00434
00435 if len(args) == 0:
00436
00437 pltr_data = None
00438 elif len(args) == 1:
00439
00440 pltr_data = args[0]
00441 args = args[1:]
00442 elif len(args) >= 2:
00443 xg = numpy.asarray(args[0])
00444 if len(xg.shape) < 1 or len(xg.shape) > 2:
00445 raise ValueError, "xg must be 1D or 2D array"
00446 yg = numpy.asarray(args[1])
00447 if len(yg.shape) != len(xg.shape):
00448 raise ValueError, "yg must have same number of dimensions as xg"
00449 args = args[2:]
00450
00451 if len(args) > 0:
00452 if type(args[0]) == types.IntType:
00453 wrap = args[0]
00454 args = args[1:]
00455 if len(xg.shape) == 2 and len(yg.shape) == 2 and \
00456 z.shape == xg.shape and z.shape == yg.shape:
00457
00458 if wrap == 1:
00459 z = numpy.resize(z, (z.shape[0]+1, z.shape[1]))
00460 xg = numpy.resize(xg, (xg.shape[0]+1, xg.shape[1]))
00461 yg = numpy.resize(yg, (yg.shape[0]+1, yg.shape[1]))
00462 elif wrap == 2:
00463 z = numpy.transpose(numpy.resize( \
00464 numpy.transpose(z), (z.shape[1]+1, z.shape[0])))
00465 xg = numpy.transpose(numpy.resize( \
00466 numpy.transpose(xg), (xg.shape[1]+1, xg.shape[0])))
00467 yg = numpy.transpose(numpy.resize( \
00468 numpy.transpose(yg), (yg.shape[1]+1, yg.shape[0])))
00469 elif wrap != 0:
00470 raise ValueError, "Invalid wrap specifier, must be 0, 1 or 2."
00471 elif wrap != 0:
00472 raise ValueError, "Non-zero wrap specified and xg and yg are not 2D arrays"
00473 else:
00474 raise ValueError, "Specified wrap is not an integer"
00475 pltr_data = (xg, yg)
00476 else:
00477
00478 pltr = pltr0
00479 pltr_data = None
00480 if len(args) > 0:
00481 raise ValueError, "Too many arguments for plshades"
00482
00483 _plshades(z, xmin, xmax, ymin, ymax, clev, \
00484 fill_width, cont_color, cont_width, rect, pltr, pltr_data)
00485 plshades.__doc__ = _plshades.__doc__
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499 _plshade = plshade
00500 def plshade(z, *args):
00501 z = numpy.asarray(z)
00502 if len(z.shape) != 2:
00503 raise ValueError, "Expected 2D z array"
00504
00505
00506
00507 if len(args) > 9 and \
00508 (type(args[0]) == types.FloatType or type(args[0]) == numpy.float64 or type(args[0]) == types.IntType) and \
00509 (type(args[1]) == types.FloatType or type(args[1]) == numpy.float64 or type(args[1]) == types.IntType) and \
00510 (type(args[2]) == types.FloatType or type(args[2]) == numpy.float64 or type(args[2]) == types.IntType) and \
00511 (type(args[3]) == types.FloatType or type(args[3]) == numpy.float64 or type(args[3]) == types.IntType) and \
00512 (type(args[4]) == types.FloatType or type(args[4]) == numpy.float64) :
00513
00514 xmin, xmax, ymin, ymax = args[0:4]
00515 args = args[4:]
00516 else:
00517
00518
00519 xmin = -1.
00520 xmax = 1.
00521 ymin = -1.
00522 ymax = 1.
00523
00524
00525
00526 if len(args) > 5 and \
00527 (type(args[0]) == types.FloatType or type(args[0]) == numpy.float64) and \
00528 (type(args[1]) == types.FloatType or type(args[1]) == numpy.float64) and \
00529 type(args[2]) == types.IntType and \
00530 (type(args[3]) == types.FloatType or type(args[3]) == numpy.float64 or type(args[3]) == types.IntType) and \
00531 type(args[4]) == types.IntType:
00532 shade_min, shade_max, sh_cmap, sh_color, sh_width = args[0:5]
00533 args = args[5:]
00534 else:
00535 raise ValueError, \
00536 "shade_min, shade_max, sh_cmap, sh_color, sh_width, must be present"
00537
00538
00539 if len(args) > 4 and \
00540 type(args[0]) == types.IntType and \
00541 type(args[1]) == types.IntType and \
00542 type(args[2]) == types.IntType and \
00543 type(args[3]) == types.IntType:
00544
00545 min_color, min_width, max_color, max_width = args[0:4]
00546 args = args[4:]
00547 else:
00548
00549 min_color, min_width, max_color, max_width = (0,0,0,0)
00550
00551
00552 if len(args) > 0 and type(args[0]) == types.IntType:
00553 rect = args[0]
00554 args = args[1:]
00555 else:
00556 raise ValueError, "Missing rect argument"
00557
00558 if len(args) > 0 and ( \
00559 type(args[0]) == types.NoneType or \
00560 type(args[0]) == types.StringType or \
00561 type(args[0]) == types.FunctionType or \
00562 type(args[0]) == types.BuiltinFunctionType):
00563 pltr = args[0]
00564
00565
00566
00567
00568 if type(pltr) == types.StringType:
00569 if pltr == "pltr0":
00570 pltr = pltr0
00571 elif pltr == "pltr1":
00572 pltr = pltr1
00573 elif pltr == "pltr2":
00574 pltr = pltr2
00575 else:
00576 raise ValueError, "pltr string is unrecognized"
00577
00578 args = args[1:]
00579
00580 if len(args) == 0:
00581
00582 pltr_data = None
00583 elif len(args) == 1:
00584
00585 pltr_data = args[0]
00586 args = args[1:]
00587 elif len(args) >= 2:
00588 xg = numpy.asarray(args[0])
00589 if len(xg.shape) < 1 or len(xg.shape) > 2:
00590 raise ValueError, "xg must be 1D or 2D array"
00591 yg = numpy.asarray(args[1])
00592 if len(yg.shape) != len(xg.shape):
00593 raise ValueError, "yg must have same number of dimensions as xg"
00594 args = args[2:]
00595
00596 if len(args) > 0:
00597 if type(args[0]) == types.IntType:
00598 wrap = args[0]
00599 args = args[1:]
00600 if len(xg.shape) == 2 and len(yg.shape) == 2 and \
00601 z.shape == xg.shape and z.shape == yg.shape:
00602
00603 if wrap == 1:
00604 z = numpy.resize(z, (z.shape[0]+1, z.shape[1]))
00605 xg = numpy.resize(xg, (xg.shape[0]+1, xg.shape[1]))
00606 yg = numpy.resize(yg, (yg.shape[0]+1, yg.shape[1]))
00607 elif wrap == 2:
00608 z = numpy.transpose(numpy.resize( \
00609 numpy.transpose(z), (z.shape[1]+1, z.shape[0])))
00610 xg = numpy.transpose(numpy.resize( \
00611 numpy.transpose(xg), (xg.shape[1]+1, xg.shape[0])))
00612 yg = numpy.transpose(numpy.resize( \
00613 numpy.transpose(yg), (yg.shape[1]+1, yg.shape[0])))
00614 elif wrap != 0:
00615 raise ValueError, "Invalid wrap specifier, must be 0, 1 or 2."
00616 elif wrap != 0:
00617 raise ValueError, "Non-zero wrap specified and xg and yg are not 2D arrays"
00618 else:
00619 raise ValueError, "Specified wrap is not an integer"
00620 pltr_data = (xg, yg)
00621 else:
00622
00623 pltr = pltr0
00624 pltr_data = None
00625 if len(args) > 0:
00626 raise ValueError, "Too many arguments for plshade"
00627
00628 _plshade(z, xmin, xmax, ymin, ymax, \
00629 shade_min, shade_max, sh_cmap, sh_color, sh_width, \
00630 min_color, min_width, max_color, max_width, rect, pltr, pltr_data)
00631 plshade.__doc__ = _plshade.__doc__
00632
00633
00634
00635
00636
00637
00638 _plscmap1l = plscmap1l
00639 def plscmap1l(itype, pos, coord1, coord2, coord3, *args):
00640
00641 pos = numpy.asarray(pos)
00642 if len(pos.shape) != 1:
00643 raise ValueError, "Expected 1D pos array"
00644
00645 if len(args) == 0:
00646
00647 rev = numpy.zeros(pos.shape[0]-1,dtype="int")
00648 elif len(args) == 1:
00649 rev = numpy.asarray(args[0])
00650 else:
00651 raise ValueError, "Too many arguments to plscmap1l"
00652 _plscmap1l(itype, pos, coord1, coord2, coord3, rev)
00653 plscmap1l.__doc__ = _plscmap1l.__doc__