This project provides tools for processing UK Met Office Rain Radar NIMROD image files. It allows extraction of raster data from NIMROD .dat format files and conversion to ESRI ASCII (.asc) format. It also allows the creation of timeseries data from the ASC files, formatted for Infoworks ICM.
The project consists of a main pipeline workflow that processes multiple modules in sequence:
main.py: Main pipeline orchestrator that calls on the modules as neededbatch_nimrod.py: Module for batch processing multiple NIMROD files with configurable bounding boxesgenerate_timeseries.py: Module for extracting cropped rain data and creating rainfall timeseriesextract.py: Module for extracting the dat files from the .gz.tar files that are downloaded from source
- Startup Safety Check: Scans the
COMBINED_FOLDERat startup and warns the user if existing files are found, Deleting existing files if continue is accepted. - Batch Processing: Processes input tar files in configurable batches to manage resource usage.
- Tidy by Default: Default settings wil delete all mid step files and keep only the original Tar files. Can be changed in config.py
- End-to-End Processing: Extracts GZ files, processes DAT/ASC, and appends to CSV in a single thread per file.
- Concurrency: Uses multi-threading to process individual GZ files within a batch concurrently.
- Cumulative Data: Automatically appends new query results to the existing CSV files in
COMBINED_FOLDERfor each batch, ensuring no data is lost and columns are correctly aligned. - Dynamic ETA: Provides a real-time estimate of completion time.
- Converts all .gz.tar files first to 288 (1 day) of .gz files
- Converts all .gz files to .dat files ready for processing.
- Process multiple NIMROD dat files
- Automatically extract datetime from file data
- Export raster data to ASC format
- Extract cropped rain data based on specified locations
- Create rainfall timeseries CSVs for each location
- Parse datetime from filename and create proper datetime index
- Group locations by specified output groups
- Create consolidated CSV files for each group
This is a multi-threaded application and requires Python 3.14t (free-threaded) to run correctly and efficiently. Please ensure you are using the free-threaded build of Python 3.14.
It is recommended to use UV for environment and package handling. Link to uv install
- Ensure all required packages are installed
uv sync - Adjust the config.py file to match your needs.
- Ensure your .gz.tar files are in the TAR_TOP_FOLDER (as per config location)
- Ensure your zone csv files are in the ZONE_FOLDER (as per config location)
- RunMain Pipeline
uv run main.pyNote that you will have to set your environment variablePYTHON_GIL=0first - find the output in the COMBINED_FOLDER (as per config location)
The main pipeline will:
- Uncompress the .gz.tar files ready for processing
- Process DAT files to ASC format
- Generate timeseries data for specified locations
- Combine grouped locations into consolidated datasets
The config.py file defines folder paths and file deletion options:
- TAR_TOP_FOLDER = "./tar_files"
- GZ_TOP_FOLDER = "./gz_files"
- DAT_TOP_FOLDER = "./dat_files"
- ASC_TOP_FOLDER = "./asc_files"
- COMBINED_FOLDER = "./combined_files"
- ZONE_FOLDER = "./zone_inputs"
- BATCH_SIZE = 5 (Number of tar files to process per batch)
Example of how the zone csv files should look:
1K Grid, easting, northing, zone_number
TM0816, 608500, 216500, 1
TF6842, 568500, 342500, 1Thank you to the following projects for their inspiration and code: