Skip to content

Reading_and_Creation

Carles Tena edited this page Oct 6, 2026 · 3 revisions

Reading, creation and parallel execution

open_netcdf reads metadata first; use keep_vars before load() to limit data loaded into memory.

from nes import open_netcdf, create_nes, concatenate_netcdfs

source = open_netcdf("input.nc", parallel_method="Y")
source.keep_vars(["NO2"])
source.load()
source.close()

grid = create_nes(projection="global_monarch", inc_lat=1.0, inc_lon=1.0)

create_nes supports regular, global, global_monarch, rotated, rotated-nested, LCC, Mercator and points (projection=None). global_monarch is the MONARCH-specific global layout; it uses inc_lat and inc_lon, like global. See creation tutorials for projection parameters. Use rotated-nested when creating nested grids.

Reading/creation accepts comm (default MPI.COMM_WORLD), parallel_method (X, Y, T) and balanced=False. Balanced decomposition cannot be written with chunking. Point creation changes Y to X and rejects T. All ranks must participate in collective operations; launch the same Python script with mpirun -n 4 python workflow.py.

avoid_first_hours and avoid_last_hours trim the temporal range; first_level and last_level restrict levels. open_netcdf(..., time_exception=True) permits files without a time dimension. The default is False.

concatenate_netcdfs combines variables from files for the same period; it is not time-series concatenation. See FAQ for a complete example.

from_shapefile(path, method=..., parallel_method=..., **grid_parameters) creates a grid and uses a spatial join to add shapefile data. Pass the same projection parameters as create_nes; see spatial join tutorial.

Clone this wiki locally