Skip to main content

Kamodo

codecov

Kamodo is a CCMC tool for access, interpolation, and visualization of space weather models and data in python. Kamodo allows model developers to represent simulation results as mathematical functions which may be manipulated directly by end users. Kamodo handles unit conversion transparently and supports interactive science discovery through jupyter notebooks with minimal coding and is accessible through python.

The project page is located at the Community Coordinated Modeling Center, located at NASA Goddard Space Flight Center.

Kamodo's official source code is hosted on github under a permissive NASA open source license:

Periodic contributions to Kamodo are made from the unofficial repo located here

Usage

Suppose we have a vector field defined by a function of positions in the x-y plane:

from kamodo import kamodofy
import numpy as np

x = np.linspace(-np.pi, np.pi, 25)
y = np.linspace(-np.pi, np.pi, 30)
xx, yy = np.meshgrid(x,y)
points = np.array(zip(xx.ravel(), yy.ravel()))

@kamodofy(units = 'km/s')
def fvec(rvec = points):
    ux = np.sin(rvec[:,0])
    uy = np.cos(rvec[:,1])
    return np.vstack((ux,uy)).T

The @kamodofy decorator lets us register this field with units to enable unit-conversion downstream:

from kamodo import Kamodo

kamodo = Kamodo(fvec = fvec)
kamodo

When run in a jupyter notebook, the above kamodo object will render as a set of equations:

$$\vec{f}{\left (\vec{r} \right )} [km/s] = \lambda{\left (\vec{r} \right )}$$

We can now evaluate our function using dot notation:

kamodo.fvec(np.array([[-1,1]]))
array([[-0.84147098,  0.54030231]])

We can perform unit conversion by function composition:

kamodo['gvec[m/s]'] = 'fvec'

kamodo automatically generates the appropriate multiplicative factors: $$\vec{g}{\left (\vec{r} \right )} [m/s] = 1000 \vec{f}{\left (\vec{r} \right )}$$ we can verify these results through evaluation

kamodo.gvec(np.array([[-1,1]]))
array([[-841.47098481,  540.30230587]])

Kamodo also generates quick-look graphics via function inspection.

import plotly.io as pio

fig = kamodo.plot('fvec')
pio.write_image(fig, 'images/fig2d-usage.svg')

usage

Head over to the Introduction page for more details.

Getting started

Kamodo may be installed from pip

pip install kamodo

To get the latest version, install from Asher's fork:

pip install git+https://github.com/asherp/Kamodo.git

!!! note Asher's fork is periodically merged into the CCMC's official NASA version.

Kamodo Environment

We strongly recommend using the conda environment system to avoid library conflicts with your host machine's python.

Download and install miniconda from here. The advantage to using miniconda is that each new environment includes the bare-minimum for a project. This allows you to keep many different projects on a single work station.

Create Kamodo environment

Create a new environment for kamodo

conda create -n kamodo python==3.7
conda activate kamodo
(kamodo) pip install kamodo

!!! note The leading (kamodo) in your prompt indicates that you have activated the kamodo environment. From here on, anything you install will be isolated to the kamodo environment.

Loading example notebooks

If you want to run any of the notebooks in docs, you will need to install jupyter:

(kamodo) conda install jupyter

Navigate to the top-level of the kamodo repo, then point jupyter to docs/notebooks:

(kamodo) jupyter notebook docs/notebooks

This should open a browser window that will allow you to load any of the example notebooks.

Requirements

The following requirements are obtained by running pip install kamodo

  • numpy
  • scipy
  • sympy
  • pandas
  • plotly==3.3
  • pytest
  • psutil
  • conda install antlr-python-runtime (rendering latex)
  • conda install -c plotly plotly-orca (for writing images)

!!! note plotly version in flux

Generating Docs

Kamodo's documentation site is a good example of how to embed your own plots in your own website. The documentation site is generated by the mkdocs package with some addons

  • mkdocs - handles site generation and deployment (configured by top-level mkdocs.yaml)
  • markdown-include - allows for embedding of markdown files (and graph divs) outside the docs folder
  • python-markdown-math - enables LaTeX rendering
  • mknotebooks - allows for the embedding of jupyter notebooks

All of the above requirements can be installed with this line:

pip install mkdocs python-markdown-math markdown-include mknotebooks

You can then generate the docs and serve locally with

mkdocs serve

To deploy your own documentation on github-pages:

mkdocs gh-deploy

This generates a gh-pages branch with the static site files and pushes it to github. Github automatically creates a website url based on that branch.

Metadata

Release files for kamodo-core 1.0.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kamodo-core 1.0.11
File Size Uploaded
kamodo_core-1.0.11.tar.gz 80.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kamodo-core 1.0.11
File Interpreter ABI Platform
kamodo_core-1.0.11-py3-none-any.whl Python 3 none any Details

Total release size: 161.5 kB

Release files / kamodo_core-1.0.11.tar.gz

Download URL kamodo_core-1.0.11.tar.gz
Size 80.0 kB
Tags Source
SHA-256 checksum
How to use checksums
79245a5976f48af7b5f894bd6e2b551f00a2a47d93427d4fda2e3e81bca9d150
BLAKE2b-256 checksum
How to use checksums
2d7969795da7a07da2be0992e595a5fcf9ed88c97eafcd81fcec9cd17eda26f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.11

Release files / kamodo_core-1.0.11-py3-none-any.whl

Download URL kamodo_core-1.0.11-py3-none-any.whl
Size 81.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ec92b9b87545d2cd053c517bef0324881ba4b3b20aa2e8053e520c4d25cfeb7
BLAKE2b-256 checksum
How to use checksums
c98c7e563ea0ca6285efba0b6c64d4cf1ade7f8ad51db86357dacd7c6446e10d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.11

Release history Release notifications | RSS feed

This release

1.0.11 This release

2 release files

1.0.10

2 release files

1.0.9

1 release file

1.0.8

2 release files

1.0.7

1 release file

1.0.3

2 release files

1.0.2

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page