Skip to main content

bmi_roms

Documentation Status MIT license Binder

bmi_roms package is an implementation of the Basic Model Interface (BMI) for the ROMS model datasets. This package wraps the dataset with BMI for data control and query. This package is not implemented for people to use but is the key element to convert the ROMS dataset into a data component (pymt_roms) for the PyMT modeling framework developed by Community Surface Dynamics Modeling System (CSDMS).

The current implementation supports 2D, 3D and 4D ROMS output datasets defined with geospatial and/or time dimensions (e.g., dataset defined with dimensions as [time, s_rho, eta_rho, xi_rho])

If you have any suggestion to improve the current function, please create a github issue here.

Get Started

Install package

Stable Release

The bmi_roms package and its dependencies can be installed with pip

$ pip install bmi_roms

or conda

$ conda install -c conda-forge bmi_roms 
From Source

After downloading the source code, run the following command from top-level folder (the one that contains setup.py) to install bmi_roms.

$ pip install -e .

Code Example

Learn more details from the tutorial notebook provided in this package and launch binder to run the notebook.

from bmi_roms import BmiRoms
import numpy as np
import matplotlib.pyplot as plt

data_comp = BmiRoms()
data_comp.initialize('config_file.yaml')

# get variable info
for var_name in  data_comp.get_output_var_names():
    var_unit = data_comp.get_var_units(var_name)
    var_location = data_comp.get_var_location(var_name)
    var_type = data_comp.get_var_type(var_name)
    var_grid = data_comp.get_var_grid(var_name)
    var_itemsize = data_comp.get_var_itemsize(var_name)
    var_nbytes = data_comp.get_var_nbytes(var_name)
    print('variable_name: {} \nvar_unit: {} \nvar_location: {} \nvar_type: {} \nvar_grid: {} \nvar_itemsize: {}' 
            '\nvar_nbytes: {} \n'. format(var_name, var_unit, var_location, var_type, var_grid, var_itemsize, var_nbytes))

# get time info
start_time = data_comp.get_start_time()
end_time = data_comp.get_end_time()
time_step = data_comp.get_time_step()
time_unit = data_comp.get_time_units()
time_steps = int((end_time - start_time)/time_step) + 1
print('start_time:{} \nend_time:{} \ntime_step:{} \ntime_unit:{} \ntime_steps:{} \n'.format(
    start_time, end_time, time_step, time_unit, time_steps))

# get variable grid info 
for var_name in data_comp.get_output_var_names():
    var_grid = data_comp.get_var_grid(var_name)
    
    grid_rank = data_comp.get_grid_rank(var_grid) 
    grid_size = data_comp.get_grid_size(var_grid)
    
    grid_shape = np.empty(grid_rank, int)
    data_comp.get_grid_shape(var_grid, grid_shape)
    
    grid_spacing = np.empty(grid_rank)
    data_comp.get_grid_spacing(var_grid, grid_spacing)
    
    grid_origin = np.empty(grid_rank)
    data_comp.get_grid_origin(var_grid, grid_origin)
    
    print('var_name: {} \ngrid_id: {}\ngrid_rank: {} \ngrid_size: {} \ngrid_shape: {} \ngrid_spacing: {} \ngrid_origin: {} \n'.format(
        var_name, var_grid, grid_rank, grid_size, grid_shape, grid_spacing, grid_origin))

# get variable data 
data = np.empty(1026080, 'float64')
data_comp.get_value('time-averaged salinity', data)
data_3D = data.reshape([40, 106, 242])

# get lon and lat data
lat = np.empty(25652, 'float64')
data_comp.get_value('latitude of RHO-points', lat)

lon = np.empty(25652, 'float64')
data_comp.get_value('longitude of RHO-points', lon)

# make a contour plot
fig = plt.figure(figsize=(10,7))
im = plt.contourf(lon.reshape([106, 242]), lat.reshape([106, 242]), data_3D[0], levels=36)
fig.colorbar(im)
plt.axis('equal')
plt.xlabel('Longitude [degree_east]')
plt.ylabel('Latitude [degree_north]')
plt.title('ROMS model data of time-averaged salinity')

plot

Metadata

Release files for bmi-roms 0.1.0

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

Built distribution (wheel)

Table of built distributions (wheels) for bmi-roms 0.1.0
File Interpreter ABI Platform Actions
bmi_roms-0.1.0-py3-none-any.whl Python 3 none any Details for bmi_roms-0.1.0-py3-none-any.whl

Release files / bmi_roms-0.1.0-py3-none-any.whl

Download URL bmi_roms-0.1.0-py3-none-any.whl
Size 11.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4dd0daf698b5a610a33d740cf2a50241b82af41aa3176c079dc5ee1247b261ad
BLAKE2b-256 checksum
How to use checksums
ff5a99b63b3ffff3c4e3d8679b89177760b9f0db61098485948caf9c22e12018
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Security for bmi-roms 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file No provenance

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