Giter Club home page Giter Club logo

toasty's Introduction

toasty

Coverage Status Build Status

Library to build WorldWide Telescope TOAST tiles.

Dependencies

  • Required: python (2.6, 2.7, 3.2, or 3.3), numpy, cython, Pillow/PIL
  • Optional: astropy (for FITS IO), healpy (for HEALPIX data), pytest (for testing)

Usage

from toasty import toast
toast(sampler, depth, directory)

where:

  • sampler is a function that takes 2D arrays of (lon, lat) as input, samples a dataset at these locations, and returns the resampled image
  • depth is the depth of the tile pyramid to create (4^d tiles are created at a depth of d)
  • directory is the path to create the hierarchy at

Toasty provides a few basic sampler functions:

  • healpix_sampler for sampling from healpix arrays
  • cartesian_sampler for sampling from cartesian-projections
  • normalizer for applying an intensity normalization after sampling

Examples

To toast an all-sky, Cartesian projection, 8 byte image:

from toasty import toast, cartesian_sampler
from skimage.io import imread

data = imread('allsky.png')
sampler = cartesian_sampler(data)
output = 'toast'
depth = 8  # approximately 0.165"/pixel at highest resolution
toast(sampler, depth, output)

To apply a log-stretch to an all sky FITS image:

from toasty import toast, cartesian_sampler, normalizer
from astropy.io import fits

data = fits.open('allsky.fits')[0].data
vmin, vmax = 100, 65535
scaling = 'log'
contrast = 1
sampler = normalizer(cartesian_sampler(data), vmin, vmax
                     scaling, bias, contrast)
output = 'toast'
depth = 8
toast(sampler, depth, output)

To perform a custom transformation

from toasty import toast
from astropy.io import fits

data = fits.open('allsky.fits')[0].data

def sampler(x, y):
    """
    x and y are arrays, giving the RA/Dec centers
    (in radians) for each pixel to extract
    """
    ... code to extract a tile from `data` here ...

output = 'toast'
depth = 8
toast(sampler, depth, output)

See toasty.tile for documentation on these functions.

Using with WorldWide Telescope

To quickly preview a toast directory named test, navigate to the directory where test exists and run

python -m toasty.viewer test

This will start a web server, probably at http://0.0.0.0:8000 (check the output for the actual address). Open this URL in a browser to get a quick look at the data.

For more information about using WorldWide Telescope with custom image data, see the official documentation. The function toasty.gen_wtml can generate the wtml information for images generated with toasty.

For an example of tiles generated with Toasty (originally from Aladin healpix images), see The ADS All Sky Survey. The code used to generate these images is here.

toasty's People

Contributors

rasmi avatar

Watchers

 avatar  avatar  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.