# gridit v3.2.3 **Mercurial revision 5770:c90c3015e72d | 2026-05-22** --- ## Description `gridit` is a tool that **converts unstructured data to structured grids**. It processes input files (e.g., finite element or mesh-based data) and generates structured output in various formats such as ASCII, NetCDF, or BMG. --- ## Usage ```bash gridit input [OPTIONS] file ``` --- ## Options | Option | Description | | ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `-h`, `--help` | Display help and exit. | | `--mapping` | Define grid mapping using the format `[lonmin:dlon:lonmax; latmin:dlat:latmax]`. `dlon` and `dlat` are optional. Supported units: `d` (degrees), `m` (minutes), `'` (arcminutes), `s` (seconds), `"` (arcseconds) | | `--persistence` | Number of iterations for growing unmasked pixels. | | `-discretisation` | Discretization pair for NetCDF input atlas. | | `-c` | NetCDF input atlas file name convention. See [Notes](#notes) for details. | | `-g` | Grid file followed by an empty-terminated list of up to 3 gridded variable names for `e`, `u`, and `v`. | | `-n` | Notebook file containing grid or projection definitions. | | `-m` | Mesh file (required). | | `-z` | Zone name or global resolution. | | `-o` | Output root name. Default: `generic`. | | `-f` | Input format. Default: `ascii`. If set to `netcdf`, discretization is compulsory. | --- ## Examples ### **Basic Conversion (ASCII Output)** Convert an unstructured `.s2r` file to ASCII format: ```bash gridit input.s2r -f ascii -m mesh_file.nc ``` ### **Convert to NetCDF with Custom Output Name** Convert an unstructured `.s2r` file to NetCDF format with a custom output name: ```bash gridit input.s2r -f netcdf -o output_root -m mesh_file.nc ``` ### **Specify Grid Span and Resolution** Convert an input file with a custom grid span and resolution: ```bash gridit input.s2r -xmin 0 -xmax 10 -ymin 0 -ymax 10 -dx 0.1 -dy 0.1 -m mesh_file.nc ``` ### **Use a Predefined Zone** Convert an input file using a predefined zone: ```bash gridit input.s2r -z "global_1deg" -m mesh_file.nc ``` ### **Apply Persistence for Unmasked Pixels** Convert an input file with persistence applied to unmasked pixels: ```bash gridit input.s2r --persistence 5 -m mesh_file.nc ``` ### **Custom Mapping** Convert an input file with a custom mapping: ```bash gridit input.s2r --mapping "[0:0.5:10; 0:0.5:10]" -m mesh_file.nc ``` ### **Convert Vector Data (V2R to NetCDF)** Convert a vector `.v2r` file to NetCDF format: ```bash gridit input.v2r -f netcdf -m mesh_file.nc -g grid_file.nc u v ``` ### **Use a Notebook File** Convert an input file using a notebook file for grid definitions: ```bash gridit input.s2r -n notebook_file.txt -m mesh_file.nc ``` --- ## Environment Variables `gridit` does not explicitly rely on environment variables for its core functionality. However, if used in conjunction with other tools or scripts, standard environment variables (e.g., `PATH`, `LD_LIBRARY_PATH`) may apply. --- (notes)= ## Notes 1. **Input Files:** - Supported input formats: `.s2r`, `.s2c`, `.v2r`, `.v2c`. - The `-m` (mesh file) option is **required** for all conversions. 2. **Output Formats:** - Supported output formats: `ascii`, `netcdf`, `grd`, `bmg`. - If the output format is `netcdf`, the `-discretisation` option may be required for proper handling of the input atlas. 3. **Grid and Mesh:** - The `-g` option requires a grid file followed by up to 3 variable names (e.g., for `e`, `u`, and `v` components in vector data). - The `--mapping` option allows flexible grid definitions. Ensure the syntax is correct (e.g., `[lonmin:dlon:lonmax; latmin:dlat:latmax]`). 4. **Resolution Units:** - Units for `-dx` and `-dy` can be specified as: - `d`: Degrees - `m`: Minutes - `'` : Arcminutes - `s`: Seconds - `"`: Arcseconds - Example: `-dx 30'` (30 arcminutes) or `-dy 0.5d` (0.5 degrees). 5. **Persistence:** - The `--persistence` option is useful for filling gaps in unmasked regions by iteratively growing unmasked pixels. 6. **Zone and Global Resolution:** - The `-z` option can specify a predefined zone (e.g., `global_1deg`) or a global resolution. --- ## See Also - [NetCDF Documentation](https://www.unidata.ucar.edu/software/netcdf/) - [CF Conventions for Gridded Data](http://cfconventions.org/) - [Quoddy Finite Element Model](https://www.quoddy.com/) (for `.s2r`, `.s2c`, `.v2r`, `.v2c` formats)