All Projects → mapbox → snuggs

mapbox / snuggs

Licence: MIT License
Snuggs are s-expressions for Numpy

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to snuggs

untiler
Stitch image tiles into larger composite TIFs
Stars: ✭ 35 (+133.33%)
Mutual labels:  satellite, imagery, pxm
pxm-manifest-specification
File specification for PXM (Pixel Monster)
Stars: ✭ 14 (-6.67%)
Mutual labels:  satellite, imagery, pxm
supermercado
Supercharger for mercantile
Stars: ✭ 100 (+566.67%)
Mutual labels:  satellite, imagery, pxm
rio-pansharpen
pansharpening landsat scenes
Stars: ✭ 42 (+180%)
Mutual labels:  satellite, imagery
rio-hist
Histogram matching plugin for rasterio
Stars: ✭ 71 (+373.33%)
Mutual labels:  satellite, imagery
rio-rgbify
Encoded arbitrary bit depth rasters in psuedo base-256
Stars: ✭ 62 (+313.33%)
Mutual labels:  satellite, imagery
grib-doctor
Utilities for handling quirks of weather data grib files.
Stars: ✭ 20 (+33.33%)
Mutual labels:  satellite, imagery
rio-glui
Explore CloudOptimized geotiff on your browser using Mapbox GL JS
Stars: ✭ 47 (+213.33%)
Mutual labels:  satellite, imagery
rio-toa
Top Of Atmosphere (TOA) calculations for Landsat 8
Stars: ✭ 38 (+153.33%)
Mutual labels:  satellite, imagery
sentinel-tiler
A serverless Sentinel-2 tiles server using AWS Lambda
Stars: ✭ 59 (+293.33%)
Mutual labels:  satellite, imagery
S.T.A.R
Satellite Trajectory Animating & Rendering: Satellite Orbit Visualiser using Blender
Stars: ✭ 29 (+93.33%)
Mutual labels:  satellite
aptdec
NOAA APT satellite imagery decoder (not-so-WIP)
Stars: ✭ 43 (+186.67%)
Mutual labels:  satellite
obdh2
On-Board Data Handling Module 2
Stars: ✭ 12 (-20%)
Mutual labels:  satellite
geowarp
Super Low-Level Raster Reprojection and Resampling Library
Stars: ✭ 20 (+33.33%)
Mutual labels:  imagery
tweegeemee
Twitter Genetic Algorithm Imagery
Stars: ✭ 83 (+453.33%)
Mutual labels:  imagery
google-maps-at-88-mph
Google Maps keeps old satellite imagery around for a while – this tool collects what's available for a user-specified region in the form of a GIF.
Stars: ✭ 93 (+520%)
Mutual labels:  satellite
SatDump
A generic satellite data processing software.
Stars: ✭ 223 (+1386.67%)
Mutual labels:  satellite
oriented-imagery
Find developer resources for Oriented Imagery, including a Web AppBuilder widget and oriented imagery catalog (OIC) schema.
Stars: ✭ 21 (+40%)
Mutual labels:  imagery
KS-1Q
Opensat first generation cubesat bus, launch into orbit at 2016/11/11
Stars: ✭ 22 (+46.67%)
Mutual labels:  satellite
CANopen-monitor
An NCurses-based TUI application for tracking activity over the CAN bus and decoding messages with provided EDS/OD files.
Stars: ✭ 15 (+0%)
Mutual labels:  satellite

snuggs

https://travis-ci.org/mapbox/snuggs.svg?branch=master

Snuggs are s-expressions for Numpy

>>> snuggs.eval("(+ (asarray 1 1) (asarray 2 2))")
array([3, 3])

Syntax

Snuggs wraps Numpy in expressions with the following syntax:

expression = "(" (operator | function) *arg ")"
arg = expression | name | number | string

Examples

Addition of two numbers

import snuggs
snuggs.eval('(+ 1 2)')
# 3

Multiplication of a number and an array

Arrays can be created using asarray.

snuggs.eval("(* 3.5 (asarray 1 1))")
# array([ 3.5,  3.5])

Evaluation context

Expressions can also refer by name to arrays in a local context.

snuggs.eval("(+ (asarray 1 1) b)", b=np.array([2, 2]))
# array([3, 3])

This local context may be provided using keyword arguments (e.g., b=np.array([2, 2])), or by passing a dictionary that stores the keys and associated array values. Passing a dictionary, specifically an OrderedDict, is important when using a function or operator that references the order in which values have been provided. For example, the read function will lookup the i-th value passed:

ctx = OrderedDict((
    ('a', np.array([5, 5])),
    ('b', np.array([2, 2]))
))
snuggs.eval("(- (read 1) (read 2))", ctx)
# array([3, 3])

Functions and operators

Arithmetic (* + / -) and logical (< <= == != >= > & |) operators are available. Members of the numpy module such as asarray(), mean(), and where() are also available.

snuggs.eval("(mean (asarray 1 2 4))")
# 2.3333333333333335
snuggs.eval("(where (& tt tf) 1 0)",
    tt=numpy.array([True, True]),
    tf=numpy.array([True, False]))
# array([1, 0])

Higher-order functions

New in snuggs 1.1 are higher-order functions map and partial.

snuggs.eval("((partial * 2) 2)")
# 4

snuggs.eval('(asarray (map (partial * 2) (asarray 1 2 3)))')
# array([2, 4, 6])

Performance notes

Snuggs makes simple calculator programs possible. None of the optimizations of, e.g., numexpr (multithreading, elimination of temporary data, etc) are currently available.

If you're looking to combine Numpy with a more complete Lisp, see Hy:

=> (import numpy)
=> (* 2 (.asarray numpy [1 2 3]))
array([2, 4, 6])
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].