Coder Social home page Coder Social logo

gwbischof / workflows-chx Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nsls-ii-chx/workflows

0.0 0.0 0.0 258 KB

Repository of workflows for the CHX beamline.

License: BSD 3-Clause "New" or "Revised" License

Python 56.35% Jupyter Notebook 43.65%

workflows-chx's Introduction

CHX Workflows

Mask Registry

  • The Mask registry is a tiled database for masks.
  • Each registered Mask has a unique identifier (uid).
  • Arbitrary metadata can be registered along with the Mask.
  • We can search for Masks by detector, name, or other metadata.
  • A Mask is a NumPy array of Bools, that matches the detector shape, where False represents the values to be masked.
  • detector_name + mask_name + version is unique
  • When you get a Mask from the registry its type is a DaskArray, this is to support laziness and parallelization. To get the NumPy Array call compute() on it.

Create a MaskClient

from masks import MaskClient

sandbox = from_profile("nsls2", "dask", username=None)\["chx"\]["sandbox"]
mask_clilent = MaskClient(sandbox)

List available Masks It prints the detector_name, mask_name, and version.

In [12]: mask_client.list_masks()
Out[12]:
[('eiger4m_single_image', 'pixel_mask', 0),
 ('eiger4m_single_image', 'bad_pixels', 0),
 ('eiger4m_single_image', 'chip_mask', 0),
 ('eiger4m_single_image', 'jul11_2022_4m_saxs', 0),
 ('eiger500K_single_image', 'chip_mask', 0),
 ('eiger1m_single_image', 'chip_mask', 0)]

Register a Mask

Version is optional and defaults to 0. detector_name + mask_name + version must be unique. The mask shape must match the detector shape The array dtype must be bool

mask = array([[False, False, False, ..., False, False, False],
       [False,  True,  True, ...,  True,  True, False],
       [False,  True,  True, ...,  True,  True, False],
       ...,
       [False,  True,  True, ...,  True,  True, False],
       [False,  True,  True, ...,  True,  True, False],
       [False, False, False, ..., False, False, False]])

mask_client.register_mask('eiger4m_single_image', 'chip_mask', mask)

Get a Mask Version is optional and defaults to returning the highest version number mask. Get mask returns a uid, along with the mask. Without specifying a version, the mask that get_mask returns might not always be the same. So we have to return a uid, so that we know exactly which mask we have.

uid, mask = mask_client.get_mask('eiger4m_single_image', 'chip_mask')


In [8]: mask.compute()
Out[8]:
array([[False, False, False, ..., False, False, False],
       [False,  True,  True, ...,  True,  True, False],
       [False,  True,  True, ...,  True,  True, False],
       ...,
       [False,  True,  True, ...,  True,  True, False],
       [False,  True,  True, ...,  True,  True, False],
       [False, False, False, ..., False, False, False]])

Combine a list of masks.

from masks import combine_masks
uid1, mask1 = mask_client.get_mask('eiger4m_single_image', 'chip_mask', version=0)
uid2, mask2 = mask_client.get_mask('eiger4m_single_image', 'bad_pixels')
masks = [mask1, mask2]
combined_mask = combine_masks(masks).compute()


In [64]: combined_mask
Out[64]:
array([[False, False, False, ..., False, False, False],
       [False,  True,  True, ...,  True,  True, False],
       [False,  True,  True, ...,  True,  True, False],
       ...,
       [False,  True,  True, ...,  True,  True, False],
       [False,  True,  True, ...,  True,  True, False],
       [False, False, False, ..., False, False, False]])

Get the uid of a Mask

mask_client.get_mask_uid('eiger4m_single_image', 'chip_mask', 0)
Out[9]: '73f07be0-d535-41db-9258-2dd01e1ac37b'

Delete Masks

mask_client.delete_mask('eiger4m_single_image', 'chip_mask', 0)

Testing

There are several tests written in test_sparsify.py. You can run the tests by typing pytest

workflows-chx's People

Contributors

gwbischof avatar lcdesilva avatar abbygi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.