Code Monkey home page Code Monkey logo

kbmod's Introduction

logo

An image processing library for moving object detection implemented with GPUs.
Based on a Maximum Likelihood detection algorithm for moving astronomical objects.

Build StatusDocumentation LicenseDOIastropy

KBMOD is a set of Python tools to search astronomical images for moving objects based upon method of maximum likelihood detection. For more information on the KBMOD algorithm see the following papers:

Current documentation, including instructions for installation, can be found here.

Requirements

To build kbmod The packages required to build the code are:

  • Cuda Toolkit >= 8.0
  • CMake >= 3.12

Ensure that the NVIDIA's nvcc compiler is available on your system, for example:

nvcc --version

It is possible that the compiler is installed but not discoverable. In that case add its location to PATH. For example, if using bash do export PATH=/path/to/cuda:$PATH. The default location for CUDA Toolkit installation is usually /usr/local/cuda-XY.Z** where XY.Z represent the CUDA Toolkit version that was installed.
If using bash add the appropriate command to ~/.bashrc in order to avoid having to set it repeatedly.

If CUDA Toolkit is not available on your system follow their official installation instructions. Optionally, if you use Anaconda virtual environments, the CUDA Toolkit is also available as conda install cudatoolkit-dev. Depending on the version of drivers on your GPU, you might need to use an older cudatoolkit-dev version.

Installation

Clone this repository, including all of its submodules:

git clone --recursive https://github.com/dirac-institute/kbmod.git

Build

cd kbmod
pip install .

This builds the package and all the dependencies required to test, run KBMOD on images and read the results. To use the additional analysis tools available in the analysis module it is necessary to install additional dependencies:

pip install .[analysis]

Note, however, that some of the dependencies in the analysis module require packages and supplementary data that are not installed nor provided by KBMoD.

To verify that the installation was successful run the tests:

cd tests/
python -m unittest

For Developers

If you want to contribute to the development of KBMOD, it is recommended that you install it in editable mode:

pip install -e .

Changes you make to the Python source files will then take immediate effect. To recompile the C++ code it's easiest to re-install the package in editable mode again.

It is possible to build only the C++ code via cmake.

cmake -B src/kbmod -S .
cmake --build src/kbmod --clean-first

To rebuild, it is sufficient to just re-run the cmake --build command. Optionally, invoke the cmake generated Makefile as make clean && make from the src/kbmod directory.

If you want to build the documentation you must have pandoc which seems not installable by pip. See Pandoc, or if you are using conda:

conda install pandoc

Building the documentation in docs/build/html using sphinx:

pip install .[docs]
sphinx-build -t html docs/source docs/build

Or you can use the make to call sphinx:

cd docs
make clean html

Usage

A short example injecting a simulated object into a stack of images, and then recovering it. This example is also included in tests/test_readme_example.py.

import kbmod.search as kb
from kbmod.candidate_generator import KBMODV1Search
import numpy as np

# Create a point spread function
psf = kb.PSF(1.5)

# Create fake data with ten 512x512 pixel images and starting at MJD of 57130.2.
from kbmod.fake_data.fake_data_creator import *
fake_times = create_fake_times(10, t0=57130.2)
ds = FakeDataSet(512, 512, fake_times)
imgs = ds.stack.get_images()

# Get the timestamp of the first image.
t0 = imgs[0].get_obstime()
print(f"Image times start at {t0}.")

# Specify an artificial object
flux = 275.0
position = (10.7, 15.3)
velocity = (2, 0)

# Inject object into images
for im in imgs:
    dt = im.get_obstime() - t0
    add_fake_object(
        im,
        position[0] + dt * velocity[0],
        position[1] + dt * velocity[1],
        flux,
        psf,
    )

# Create a new image stack with the inserted object.
stack = kb.ImageStack(imgs)

# Generate a set of trajectories to test from each pixel.
gen = KBMODV1Search(
    5,  # Number of search velocities to try (0, 0.8, 1.6, 2.4, 3.2)
    0,  # The minimum search velocity to test (inclusive)
    4,  # The maximum search velocity to test (exclusive)
    5,  # Number of search angles to try (-0.1, -0.06, -0.02, 0.02, 0.6)
    -0.1,  # The minimum search angle to test (inclusive)
    0.1,  # The maximum search angle to test (exclusive)
)
candidates = [trj for trj in gen]

# Do the actual search.
search = kb.StackSearch(stack)
search.search(
    strategy,
    7,  # The minimum number of observations
)

# Get the top 10 results.
results = search.get_results(0, 10)
print(results)

Reference

License

The software is open source and available under the BSD license.

kbmod's People

Contributors

a-chaudhary avatar cchris28 avatar colinorionchandler avatar delucchi-cmu avatar dinobektesevic avatar jbkalmbach avatar jeremykubica avatar maxwest-uw avatar pwhiddy avatar smotherh avatar stephenportillo avatar stevenstetzler avatar vlnistor avatar wilsonbb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

kbmod's Issues

Update old Code

These are the things I remember you said need to be updated:
calcPsi and calcPhi have been combined into one step
result clustering and sorting is now done without the need for some code cells

Update to c++11

Use better language and standard library features available with c++11

ML Method for Real Object filtering

In conversation on Friday, @PWhiddy came up with the idea of training a machine learning algorithm on the postage stamps to classify real vs fake candidates before showing them to the user.

Compare Filtering Algorithms

Once we have developed a deep learning classifier we can compare the methods and pick one to move forward with our data analysis.

Run filtering on all HITS data

Once we have decided on which filtering method to use we will run it on all the HITS data we have already searched and compile a final set of found objects.

Add Unit tests

Test:
File loading/layer extraction
Convolution
Searching in a variety of circumstances
Computed likelihood values
Top results

Make an install script

It's good that we're now using CMake. Let's organize an install script so that we can easily install this on a new machine.

The Big Clean

This Epic deals with updating and organizing the KBMOD code with the new GPU implementation.

Add Pipeline code for running on datasets to repository

Currently I have written python methods to run the HITS data through the kbmod GPU implementation. None of this has been added to the repository yet. It should be cleaned up and added in a general way to enable processing of future datasets.

Finish HITS

We want to finish processing and analyzing the HITS data in order to write our first paper on KBMOD.

Only print unique top results

The top results have a tendency to repeat with slightly different velocities. I need to clean this up and post unique results to the top results.

Add lightcurve debug mode

We want to be able to have a debug option where we have the psi and phi "lightcurves" for the results files.

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.