Parser for ROMS .in configuration files
Project description
ROMSInParser
A lightweight Python parser for ROMS (.in) configuration files.
This tool allows users to read, modify, and write ROMS input files while preserving the original file structure as much as possible.
The parser is designed for workflows where automated modification of ROMS configuration files is required, such as model experiment management, batch simulation generation, or integration with workflow frameworks.
Features
-
Parse ROMS
.inconfiguration files into Python data structures -
Modify parameters programmatically
-
Write updated configuration files back to disk
-
Preserve the original file layout as much as possible:
- comments are retained
- blank lines are retained
- parameter order is retained
-
Support common ROMS input syntax:
=and==parameter assignments- line continuation using
\ - repeated values using
n*value - logical values
TandF - Fortran double precision notation (
1.0d-6) - file lists separated by
|
Installation
Clone the repository:
git clone https://github.com/yourname/roms-in-parser.git
cd roms-in-parser
Install locally:
pip install .
Or install in editable mode during development:
pip install -e .
Usage
Reading a ROMS .in file
from roms_in_parser import ROMSInParser
parser = ROMSInParser("roms_basin.in")
parser.parse()
print(parser["Lm"])
Modifying parameters
parser["Lm"] = 200
parser["DT"] = 60
For parameters stored as lists:
parser["Dout(iTsdif)"][0] = False
Writing a new .in file
parser.write("new_roms.in")
Only the parameter values will be updated; other parts of the file will remain unchanged.
Example
Original configuration:
Lm == 180 ! grid size
Mm == 140
After modification:
parser["Lm"] = 200
parser.write("new_roms.in")
Output:
Lm == 200 ! grid size
Mm == 140
Supported Value Types
The parser automatically converts values into Python types.
| ROMS syntax | Python type | |
|---|---|---|
10 |
int |
|
0.5 |
float |
|
1.0d-6 |
float |
|
T / F |
bool |
|
2*1.0d-6 |
expanded list | |
| `file1.nc | file2.nc` | list |
Limitations
Some formatting differences may occur when writing files:
- multi-line parameters using
\may be written as a single line n*valueshorthand is expanded to explicit lists
These changes do not affect ROMS functionality.
License
GPL-v3 License
Author
Yupeng Shao
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file romsinpy-1.0.0.tar.gz.
File metadata
- Download URL: romsinpy-1.0.0.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57bf00cbd714a06686f6b23a3d41767a3a75fc5ddff4c02e5e4fb7005dcd5f8c
|
|
| MD5 |
480484d1cc470c3bdd2812d89dbf54cc
|
|
| BLAKE2b-256 |
4eb100dbfb50fa70a6fd1287cafa623de4dbff61b8f9fa6fe9d66ba806ad38d1
|
File details
Details for the file romsinpy-1.0.0-py3-none-any.whl.
File metadata
- Download URL: romsinpy-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5eaa07be92bcff8463fc80725286ecbc2497cb433797c4fdc35fbc0b99813b1b
|
|
| MD5 |
82466b2449c505018fe405e4b36cc229
|
|
| BLAKE2b-256 |
602f6a39e5238fbc5ebebbf9d48e0659847917939efcc2c2e05ce8053b5f03fc
|