GithubHelp home page GithubHelp logo

ciresdem / bathycube Goto Github PK

View Code? Open in Web Editor NEW

This project forked from noaa-ocs-hydrography/bathycube

0.0 0.0 0.0 91 KB

Python implementation of Brian Calder's CUBE module

License: MIT License

Python 100.00%

bathycube's Introduction

Bathycube

Bathycube is a Python implementation of the CUBE module, Combined Uncertainty and Bathymetry Estimator. It only contains the cube grid/node objects, the original library included other data structures that were not translated here.

CUBE was developed as a research project within the Center of for Coastal and Ocean Mapping and NOAA/UNH Joint Hydrographic Center (CCOM/JHC) at the University of New Hampshire, starting in the fall of 2000.

Bathycube offers two approaches towards a Python CUBE Implementation.

cube.py is a less performant method, does not involve numba, but does offer more interactivity with the objects.

numba_cube.py is a more performant method (approx 55x faster), but do to the limitations of numba jitclasses, does not allow for the user to inspect the grid structure. This might be resolvable by switching to structref, based on dialogue with users/developers on the numba gitter.

Installation

Bathycube is not on PyPi, but can be installed using pip.

Download and install git (If you have not already): git installation

pip install git+https://github.com/noaa-ocs-hydrography/bathycube.git#egg=bathycube

Quickstart

To simply grid some points and get the gridded data back, use the run_cube_gridding function:

    # less performant version
    from bathycube.cube import run_cube_gridding

    x = np.linspace(403744, 403747, 50)
    y = np.linspace(4122687, 4122690, 50)
    x, y = np.meshgrid(x, y)
    x = x.flatten()
    y = y.flatten()
    z = np.linspace(10, 20, 2500)
    tvu = np.linspace(0.3, 0.7, 2500)
    thu = np.linspace(0.3, 0.7, 2500)

    numrows, numcols = (3, 3)
    resolution_x, resolution_y = (1.0, 1.0)
    
    depth_grid, uncertainty_grid, ratio_grid, numhyp_grid = run_cube_gridding(z, thu, tvu, x, y, numcols, numrows, min(x), max(y), 'local', 'order1a', resolution_x, resolution_y)   

Numba version operates in the same way:

    # less performant version
    import numpy as np
    from bathycube.numba_cube import run_cube_gridding
    
    x = np.linspace(403744, 403747, 50)
    y = np.linspace(4122687, 4122690, 50)
    x, y = np.meshgrid(x, y)
    x = x.flatten()
    y = y.flatten()
    z = np.linspace(10, 20, 2500)
    tvu = np.linspace(0.3, 0.7, 2500)
    thu = np.linspace(0.3, 0.7, 2500)
    
    numrows, numcols = (3, 3)
    resolution_x, resolution_y = (1.0, 1.0)
    
    depth_grid, uncertainty_grid, ratio_grid, numhyp_grid = run_cube_gridding(z, thu, tvu, x, y, numcols, numrows, min(x), max(y), 'local', 'order1a', resolution_x, resolution_y)

You can specify cube parameters as keyword arguments to these functions as well.

    depth_grid, uncertainty_grid, ratio_grid, numhyp_grid = run_cube_gridding(z, thu, tvu, x, y, numcols, numrows, min(x), max(y), 'local', 'order1a', resolution_x, resolution_y, variance_selection='input')

The numba version takes some time to run the first time you run it in a session. This is the JIT compile cost. You can compile without running a long gridding call by using compile_now(). See numba docs to learn more about JIT compilation.

    from bathycube.numba_cube import compile_now
    
    compile_now()

bathycube's People

Contributors

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