Ignore:
Timestamp:
Sep 21, 2012, 3:03:27 PM (12 years ago)
Author:
acolaitis
Message:

PYTHON GRAPHICS

  • Added option --finddevil which finds the steepest pressure drop in the PSFC field of the file, and add a cross in it's position.

This new function is intended to provide lon and lat of a dust devil to planetoplot. This could be used to drive a slice plot at the corresponding location.

  • Removed dumpbdy for LES files (no relaxation zone)
  • Added --mark mode to tiled plot
  • Added routines in mymath to convert back and forth between greyscale Image objects and 2D arrays
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UTIL/PYTHON/mymath.py

    r647 r792  
    229229    return idx
    230230
     231# Author: A.C.
    231232def fig2data ( fig ):
    232233    import numpy
     
    248249    return buf
    249250
     251# Author: A.C.
    250252def fig2img ( fig ):
    251253    import Image
     
    260262    w, h, d = buf.shape
    261263    return Image.fromstring( "RGBA", ( w ,h ), buf.tostring( ) )
     264
     265# Author: A.C.
     266# Convert a single layer image object (greyscale) to an array
     267def image2array(im):
     268    import numpy as np
     269    if im.mode not in ("L", "F"):
     270        raise ValueError, ("can only convert single-layer images", im.mode)
     271    if im.mode == "L":
     272        a = np.fromstring(im.tostring(), np.uint8)
     273    else:
     274        a = np.fromstring(im.tostring(), np.float32)
     275    a.shape = im.size[1], im.size[0]
     276    return a
     277
     278# Author: A.C.
     279# Convert a 2D array to a single layer image object (greyscale)
     280def array2image(a):
     281    import numpy as np
     282    import Image
     283    if a.dtype == np.uint8:
     284        mode = "L"
     285    elif a.dtype == np.float32:
     286        mode = "F"
     287    else:
     288        raise ValueError, "unsupported image mode"
     289    return Image.fromstring(mode, (a.shape[1], a.shape[0]), a.tostring())
     290
Note: See TracChangeset for help on using the changeset viewer.