npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@ncar/musica

v0.14.1

Published

Native Node.js addon for MUSICA atmospheric chemistry modeling

Readme

MUSICA

GitHub Releases License docker macOS ubuntu windows Python tests Javascript tests DOI PyPI version FAIR checklist badge codecov Binder

Multi-Scale Infrastructure for Chemistry and Aerosols

MUSICA is a collection of modeling software, tools, and grids, that allow for robust modeling of chemistry in Earth's atmosphere.

At present the project encompasses these core components

  • TUV-x

    • A photolysis rate calculator
  • MICM

    • Model Independent Chemical Module
  • CARMA

    • Community Aerosol and Radiation Model for Atmospheres (integration in development)
  • Mechanism Configuration

    • The standardized format to describe atmospheric chemistry

These components are used to drive the MUSICA software ecosystem. This is a snapshot of how MUSICA can be used with different models.

MUSICA Ecosystem

Installation

MUSICA is installable via pip for Python or CMake for C++.

Pip

pip install musica

If you would like GPU support, you must first add the NVIDIA pypi index and then you can specify the gpu install option for MUSICA. Note that GPU support has only been tested on linux.

pip install --upgrade setuptools pip wheel
pip install nvidia-pyindex
pip install musica[gpu]

To build the package locally,

pip install -e .

If you have an NVIDIA GPU and cuda installed, you can enable a build of musica with GPU support by setting the environment variable BUILD_GPU.

BUILD_GPU=1 pip install -e .

CMake

If you plan to build from source, you will need to install these packages, at a minimum. More packages may be required for more advancded installations.

  • cmake
  • pkg-config
  • netcdf
  • netcdf-fortran
  • blas
  • lapack

MUSICA does have more dependencies that it builds with, but those are pulled in with cmake. If you want to use your own installation of these, you may, and our files are setup so that an installed package will be used rather than downloading one during the build, assuming you've installed it into a place where cmake can find it.

optional, pulled in by cmake

  • pybind11
  • google test
  • micm
  • tuvx
  • mechanism configuration
  • carma
$ git clone https://github.com/NCAR/musica.git
$ cd musica
$ mkdir build
$ cd build
$ ccmake ..
$ make
$ make install

Using the MUSICA Python API

MUSICA makes its chemical mechanism analysis and visualization available through a Python API. The following example works through solving a simple chemistry system. Please refer to the official documentation for further tutorials and examples.

# --- Import Musica ---
import musica
import musica.mechanism_configuration as mc

# --- 1. Define the chemical system of interest ---
A = mc.Species(name="A")
B = mc.Species(name="B")
C = mc.Species(name="C")
species = [A, B, C]
gas = mc.Phase(name="gas", species=species)

# --- 2. Define a mechanism of interest ---
# Through Musica, several different mechanisms can be explored to define reaction rates. Here, we use the Arrhenius equation as a simple example.

r1 = mc.Arrhenius(name="A->B", A=4.0e-3, C=50, reactants=[A], products=[B], gas_phase=gas)
r2 = mc.Arrhenius(name="B->C", A=1.2e-4, B=2.5, C=75, D=50, E=0.5, reactants=[B], products=[C], gas_phase=gas)

mechanism = mc.Mechanism(name="musica_example", species=species, phases=[gas], reactions=[r1, r2])

# --- 3. Create MICM solver ---
# A solver must be initialized with either a configuration file or a mechanism:

solver = musica.MICM(mechanism=mechanism, solver_type=musica.SolverType.rosenbrock_standard_order)

# --- 4. Define environmental conditions ---
temperature=300.0
pressure=101000.0

# --- 5. Create and initialize State ---
# In the model, conditions represent the starting environment for the reactions and are assigned by modifying the state.

state = solver.create_state()
state.set_concentrations({"A": 1.0, "B": 3.0, "C": 5.0})
state.set_conditions(temperature, pressure)

# --- 6. Time parameters ---
time_step = 4  # stepping
sim_length = 20  # total simulation time

# --- (Optional) 7. Save initial state (t=0) for output visualization ---
initial_row = {"time.s": 0.0, "ENV.temperature.K": temperature, "ENV.pressure.Pa": pressure, "ENV.air number density.mol m-3": state.get_conditions()['air_density'][0]}
initial_row.update({f"CONC.{k}.mol m-3": v[0] for k, v in state.get_concentrations().items()})

# --- 8. Solve through time loop only ---
# The following loop simply solves the model per each time step:

curr_time = time_step
while curr_time <= sim_length:
    solver.solve(state, time_step)
    concentrations = state.get_concentrations()
    curr_time += time_step

# --- 9. Solve and create DataFrame ---
# It is likely more useful to solve at each time step and store the associated data:
import pandas as pd

output_data = [] # prepare to store output per time step
output_data.append(initial_row) # save t=0 data

curr_time = time_step
while curr_time <= sim_length:
    solver.solve(state, time_step)
    row = {
        "time.s": curr_time,
        "ENV.temperature.K": state.get_conditions()['temperature'][0],
        "ENV.pressure.Pa": state.get_conditions()['pressure'][0],
        "ENV.air number density.mol m-3": state.get_conditions()['air_density'][0]
    }
    row.update({f"CONC.{k}.mol m-3": v[0] for k, v in state.get_concentrations().items()})
    output_data.append(row)
    curr_time += time_step

df = pd.DataFrame(output_data)
print(df)

# --- 10. Visualize Specific Results ---
import matplotlib.pyplot as plt

df.plot(x='time.s', y=['CONC.A.mol m-3', 'CONC.B.mol m-3', 'CONC.C.mol m-3'], title='Concentration over time', ylabel='Concentration (mol m-3)', xlabel='Time (s)')
plt.show()

Using the MUSICA CLI

MUSICA provides a command-line interface (musica-cli) for working with examples and configuration conversion. The CLI is installed automatically when you install MUSICA via pip.

Installation with Tutorial Dependencies

To use all features of the examples, install MUSICA with the tutorial dependencies:

pip install 'musica[tutorial]'

Basic Usage

Check the installed version:

musica-cli --version

View available options:

musica-cli -h

Available Options

| Option | Description | | ------ | ----------- | | -h, --help | Show help message and exit | | -e, --example | Name of the example to copy out | | -o, --output | Path to save the output to | | -v, --verbose | Increase logging verbosity. Use -v for info, -vv for debug | | --version | Show the installed MUSICA version | | --convert | Path to a MUSICA v0 configuration to convert to v1 format |

Available Examples

| Example Name | Description | | ------------ | ----------- | | CARMA_Aluminum | A CARMA example for simulating aluminum aerosol particles | | CARMA_Sulfate | A CARMA example for simulating sulfate aerosol particles | | Sulfate_Box_Model | A box model example for simulating sulfate aerosol particles | | TS1LatinHyperCube | A Latin hypercube sampling example for the TS1 mechanism |

Example Workflow

Copy an example to your current directory:

musica-cli -e TS1LatinHyperCube

Copy an example to a specific directory:

musica-cli -e TS1LatinHyperCube -o /path/to/output/

Convert a MUSICA v0 configuration to v1 format:

musica-cli --convert /path/to/v0/config.json -o /path/to/output/

For more detailed documentation, see the official documentation.

Available grids

Pre-made grids for use in MUSICA are available here.

Developer Options

Specifying dependency versions via parameterization at configure time

Introduced in Pull Request #124, it is possible for developers to specify which versions of various dependencies should be used. These options are currently limited to those dependencies managed via FetchContent. This change allows for more easily testing musica against changes committed in different repositories and branches. The environmental variables introduced are outlined in the following table.

CMake Dependency Variables

| Musica Dependency | Repository | Branch, Tag or Hash| | ------------------------------------------------------ | --------------------------|--------------------| | Google Test| GOOGLETEST_GIT_REPOSITORY | GOOGLETEST_GIT_TAG | | MICM | MICM_GIT_REPOSITORY | MICM_GIT_TAG | | TUV-X | TUVX_GIT_REPOSITORY | TUVX_GIT_TAG | | PyBind11 | PYBIND11_GIT_REPOSITORY | PYBIND11_GIT_TAG | | Mechanism Configuration | MECH_CONFIG_GIT_REPOSITORY | MECH_CONFIG_GIT_TAG |

Example Usage

The following examples assume the working directory is a build/ directory inside the musica source directory.

Specifying a different version of tuv-x, to ensure a change won't break anything.

$ cmake .. \
    -DTUVX_GIT_REPOSITORY="https://github.com/WardF/tuv-x.git" \
    -DTUVX_GIT_TAG=test-fix

Specifying a specific version of tuv-x by has, but using the official repository.

$ cmake .. \
    -DTUVX_GIT_TAG=a6b2c4d8745

Contributing

We welcome contributions from the community! Please see our Contributing Guide for information on how to get involved.

For a complete list of contributors and authors, see AUTHORS.md.

Citations

MUSICA can be cited in at least two ways:

  1. Cite the foundational paper that defines the vision of the MUSICA software:

    • Pfister et al., 2020, Bulletin of the American Meteorological Society
    • Use the following BibTeX entry:
      @Article { acom.software.musica-vision,
          author = "Gabriele G. Pfister and Sebastian D. Eastham and Avelino F. Arellano and Bernard Aumont and Kelley C. Barsanti and Mary C. Barth and Andrew Conley and Nicholas A. Davis and Louisa K. Emmons and Jerome D. Fast and Arlene M. Fiore and Benjamin Gaubert and Steve Goldhaber and Claire Granier and Georg A. Grell and Marc Guevara and Daven K. Henze and Alma Hodzic and Xiaohong Liu and Daniel R. Marsh and John J. Orlando and John M. C. Plane and Lorenzo M. Polvani and Karen H. Rosenlof and Allison L. Steiner and Daniel J. Jacob and Guy P. Brasseur",
          title = "The Multi-Scale Infrastructure for Chemistry and Aerosols (MUSICA)",
          journal = "Bulletin of the American Meteorological Society",
          year = "2020",
          publisher = "American Meteorological Society",
          address = "Boston MA, USA",
          volume = "101",
          number = "10",
          doi = "10.1175/BAMS-D-19-0331.1",
          pages= "E1743 - E1760",
          url = "https://journals.ametsoc.org/view/journals/bams/101/10/bamsD190331.xml"
      }
  2. Cite the MUSICA software and its evaluation (MUSICAv0):

    • Schwantes et al., 2022, Journal of Advances in Modeling Earth Systems
    • Use the following BibTeX entry:
      @Article{acom.software.musica,
          author = {Schwantes, Rebecca H. and Lacey, Forrest G. and Tilmes, Simone and Emmons, Louisa K. and Lauritzen, Peter H. and Walters, Stacy and Callaghan, Patrick and Zarzycki, Colin M. and Barth, Mary C. and Jo, Duseong S. and Bacmeister, Julio T. and Neale, Richard B. and Vitt, Francis and Kluzek, Erik and Roozitalab, Behrooz and Hall, Samuel R. and Ullmann, Kirk and Warneke, Carsten and Peischl, Jeff and Pollack, Ilana B. and Flocke, Frank and Wolfe, Glenn M. and Hanisco, Thomas F. and Keutsch, Frank N. and Kaiser, Jennifer and Bui, Thao Paul V. and Jimenez, Jose L. and Campuzano-Jost, Pedro and Apel, Eric C. and Hornbrook, Rebecca S. and Hills, Alan J. and Yuan, Bin and Wisthaler, Armin},
          title = {Evaluating the Impact of Chemical Complexity and Horizontal Resolution on Tropospheric Ozone Over the Conterminous US With a Global Variable Resolution Chemistry Model},
          journal = {Journal of Advances in Modeling Earth Systems},
          volume = {14},
          number = {6},
          pages = {e2021MS002889},
          doi = {https://doi.org/10.1029/2021MS002889},
          url = {https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2021MS002889},
          eprint = {https://agupubs.onlinelibrary.wiley.com/doi/pdf/10.1029/2021MS002889},
          year = {2022}
      }