Menu

Trouble understanding masks

Pygwy
2017-06-30
2017-06-30
  • Geoff Hutchison

    Geoff Hutchison - 2017-06-30

    Hi,

    I've been trying out Gwyddion and pygwy for some automated data processing in our lab. So far, things are great and the examples have been really helpful (e.g., http://gwyddion.net/documentation/user-guide-en/pygwy.html)

    I have a similar need to the tutorial script - go through a bunch of files, flatten, get some statistics, and save PNG images.
    https://gist.github.com/ghutchis/bbfccd24898cd45be840954a3a6a14aa

    My problem is that I can see that the files have masks (i.e., for invalid points) but the data_field.get_stats() doesn't consider that. I can see that there are methods to exclude masked points.. I just can't figure out how to get the mask for a particular data_field / channel in my container.

    Google searching didn't turn up much. If it's obvious, please just point me to the docs.

    Thanks!
    -Geoff

     
  • David Nečas

    David Nečas - 2017-07-02

    The mask corresponding to image /N/data is stored under /N/mask (see the GWY file description in the user guide). Note that the mask may or may not exist so you usually need to handle both possibilities

    if container.contains_by_name('/0/mask'):
        mask = container['/0/mask']
        # do something with the mask
    else:
        # do something appropriate when ther is no mask
    
     

Log in to post a comment.