Skip to main content

Convert LPJ-GUESS output files (.out) to NetCDF format

Project description

LPJ-GUESS to NetCDF Converter (lpjg2nc2)

PyPI version Python 3.8+ License: GPLv3 Documentation Status Documentation Build

lpjg2nc2 is a powerful tool for converting LPJ-GUESS output files (.out) to NetCDF format. It efficiently searches for run* folders in a given path, finds .out files inside their output directories, and converts them to the widely-used NetCDF format for easier analysis and visualization.

🚀 Key Features

  • Efficient Processing: Convert LPJ-GUESS .out files to NetCDF with proper coordinates and metadata
  • High Performance: Vectorized implementation delivers up to 20× speedup compared to point-by-point processing
  • Parallel Processing: Two-level parallelization optimizes conversion on multi-core systems
  • Flexible Configuration: Control various aspects of the conversion process
  • Grid Handling: Process both 2D and 3D data (with depth levels), preserving spatial coordinates
  • Time Dimensions: Handle time series data (years, months, and days, if present)
  • Grid Remapping: Option to remap to regular global grids using CDO
  • Data Analysis: Built-in analysis of NaN values to understand data sparsity in global datasets
  • Test Mode: Option to process specific files for testing

📦 Installation

From PyPI (recommended)

pip install lpjg2nc2

From Source

git clone https://github.com/JanStreffing/lpjg2nc2.git
cd lpjg2nc2
pip install -e .

📋 Requirements

  • Python 3.8+
  • Dependencies (automatically installed):
    • numpy>=1.20.0
    • pandas>=1.3.0
    • xarray>=0.19.0
    • netCDF4>=1.5.7
    • tqdm>=4.61.0
  • Optional: Climate Data Operators (CDO) for remapping capabilities

🔍 Usage

Basic Conversion

lpjg2nc -p /path/to/lpj_guess_runs/

This will:

  1. Search for all run* folders in the specified path
  2. Find .out files in each run's output directory
  3. Convert them to NetCDF format
  4. Save the output to "../../outdata/lpj_guess" relative to the input path

Verbose Output with Custom Output Directory

lpjg2nc -p /path/to/lpj_guess_runs/ -v -o /path/to/output/

Remapping to Regular Grid

lpjg2nc -p /path/to/lpj_guess_runs/ --remap 1
# or specify grid dimensions
lpjg2nc -p /path/to/lpj_guess_runs/ --remap 360x180

Testing with a Specific File

lpjg2nc -p /path/to/lpj_guess_runs/ -f /path/to/runs/run1/output/somefile.out -v

🛠️ Command Line Arguments

Required Arguments

  • -p PATH, --path PATH: Path to the directory containing run* folders

Optional Arguments

  • -f FILE, --file FILE: Process a specific file (for testing)
  • -o OUTPUT, --output OUTPUT: Output directory for NetCDF files
  • -v, --verbose: Increase output verbosity
  • --remap RES: Remap output to a regular global grid using CDO (specify resolution in degrees or XxY dimensions)
  • --test {ifs_input}: Test with specific file pattern (e.g., ifs_input.out)
  • -j JOBS, --jobs JOBS: Number of parallel jobs for outer parallelization (patterns), default: 8
  • --inner-jobs INNER_JOBS: Number of parallel jobs for inner parallelization, default: 16
  • --chunk-size CHUNK_SIZE: Chunk size for processing arrays, default: 50000
  • --pattern PATTERN: Specific pattern to process (internal use for parallelization)

Recommended Settings

Environment --jobs (-j) --inner-jobs --chunk-size
Desktop (16GB RAM) 4 8 25000
Workstation (32GB RAM) 8 16 50000
HPC Node (128GB+ RAM) 8 64 75000

📚 Documentation

For complete documentation, visit lpjg2nc2.readthedocs.io.

📜 License

This project is licensed under the GNU General Public License v3 (GPLv3) - see the license file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lpjg2nc2-1.0.0.tar.gz (45.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lpjg2nc2-1.0.0-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

Details for the file lpjg2nc2-1.0.0.tar.gz.

File metadata

  • Download URL: lpjg2nc2-1.0.0.tar.gz
  • Upload date:
  • Size: 45.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.9

File hashes

Hashes for lpjg2nc2-1.0.0.tar.gz
Algorithm Hash digest
SHA256 11a9bbbeb35b4f719995290543f57d67c34a296a18bac242887bbf1a6312f26d
MD5 7cc81e34529b95b19205142cfa13d33c
BLAKE2b-256 88b2a2dd413bd9d39f536747b8d0894b34ede692d34d7c234c3eb2b86eb09321

See more details on using hashes here.

File details

Details for the file lpjg2nc2-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: lpjg2nc2-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 23.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.9

File hashes

Hashes for lpjg2nc2-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0dd9fb56557b56c5c4eed4ba7844e2936e1295f837733452aeea228a2c82a295
MD5 80319d45f4d62004b0af1c4e3e714a6c
BLAKE2b-256 3a6055fe203e2f6a6749440c96873f5df51abea502e1d1ce867dfcbcca730ee7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page