Skip to content

tomotvos/ronchi-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ronchi Generator

A telescope mirror optical testing tool that generates synthetic Ronchi grating test images (Ronchigrams) to analyze parabolic mirror surface quality and to produce training data for vision-language models (e.g., LLaVA).

The generator uses dimensionless parameters at its core, making it scale-invariant. Images generated with the same dimensionless parameters will be identical regardless of absolute physical mirror size or grating frequency.

Project layout

  • ronchi-generator-app/ — .NET 8 console app using SixLabors.ImageSharp
  • js/ — legacy browser-based reference implementation (not executed)
  • output/ — generated images and metadata (ignored by Git)

Build and run

Requirements: .NET 8 SDK

cd ronchi-generator-app
# Build
dotnet build

# Single image generation
# Required switches: --diameter, --roc, --grating, --offset, --paraboliccorrection, --output
# Optional: --imagesize (defaults to 500)
# Example:
dotnet run -- --diameter 16 --roc 120 --grating 100 --offset -0.2 --paraboliccorrection 0.5 --output output/example.png

# Custom image size (1000x1000 pixels)
dotnet run -- --diameter 16 --roc 120 --grating 100 --offset -0.2 --paraboliccorrection 0.5 --imagesize 1000 --output output/example.png

# Auto-generate training dataset (dimensionless mode)
# Required: --autogen true
# Optional: --imagesize (defaults to 500)
dotnet run -- --autogen true

# Auto-generate with custom image size
dotnet run -- --autogen true --imagesize 256

# Note: Autogen mode is fully dimensionless - all parameters (focal ratio, 
# offset, parabolic correction, lines across mirror) are automatically varied
# across systematic dimensionless ranges

Command-line switches

The app parses named parameters in pairs: --name value.

Parameter Requirements by Mode

Single Image Mode:

  • Required: --diameter, --roc, --grating, --offset, --paraboliccorrection, --output
  • Optional: --imagesize

Autogen Training Dataset Mode:

  • Required: --autogen true
  • Optional: --imagesize
  • Ignored: All other parameters (autogen uses dimensionless parameter ranges)

Supported switches:

  • --diameter <inches>
    • Mirror diameter in inches. Required.
  • --roc <inches>
    • Radius of curvature. Required for single-image mode.
    • In autogen mode, RoC is recalculated for each focal ratio as diameter × focalRatio × 2.
  • --grating <lpi>
    • Grating frequency (lines per inch). Required.
  • --offset <inches>
    • Grating offset distance from the radius of curvature. Required for single-image mode.
    • Range commonly −0.5 to +0.5.
  • --paraboliccorrection <0.0–1.0>
    • Parabolic correction factor: 0.0 spherical to 1.0 fully parabolic. Required for single-image mode.
  • --output <path>
    • Output image file path (PNG). Required for single-image mode.
  • --imagesize <pixels>
    • Output image dimensions (square). Optional, defaults to 500.
    • Example: --imagesize 1000 creates 1000×1000 pixel images.
  • --autogen true|false
    • Enables dimensionless dataset generation when true.
    • Required parameters for autogen mode:
      • --autogen true — Enables autogen mode
    • Optional parameters for autogen mode:
      • --imagesize <pixels> — Image dimensions (defaults to 500×500)
    • Parameters NOT used in autogen mode: ALL physical parameters (--diameter, --roc, --grating, --offset, --paraboliccorrection, --output) are ignored
    • In this mode:
      • Images are generated using dimensionless parameter ranges:
        • Lines across mirror: 680-1600 (step 80) — covers 8-16" mirrors with 85-100 LPI gratings
        • Focal ratios: 2.5-3.5 (step 0.1) — fast telescope mirrors
        • Normalized offsets: -0.05 to +0.05 (step 0.01, skipping ~0.0) — offset/diameter ratio
        • Parabolic correction: 0.0-1.0 (step 0.2) — spherical to fully parabolic
      • Output directories created: output/images/ and output/holdout/.
      • Every 12th image is moved to output/holdout/ as a holdout.
      • Training metadata is written to output/manifest.jsonl in JSON Lines format.

Output metadata format

Each training entry in manifest.jsonl looks like:

{
  "id": "ronchi_2.5_-0.030_0.4_760",
  "image": "output/images/ronchi_2.5_-0.030_0.4_760.png",
  "meta": { 
    "f": 2.5, 
    "offset": -0.030, 
    "lines": 760 
  },
  "labels": { 
    "p_corr": 0.4 
  }
}

Metadata Field Descriptions:

  • meta.f: Focal ratio (f/#) - dimensionless
  • meta.offset: Normalized offset (offset/diameter ratio) - dimensionless
  • meta.lines: Lines across mirror diameter - dimensionless key parameter
  • labels.p_corr: Parabolic correction factor (0.0-1.0) - dimensionless

Notes:

  • Filenames now include lines across mirror (e.g., 760) for dimensionless identification.
  • Normalized offset ~0.0 is skipped in autogen to avoid mathematical singularities.
  • Image size defaults to 500×500 px (configurable with --imagesize).
  • Quadrant symmetry is used to speed up rendering.

Dimensionless Parameters

The core insight is that Ronchi patterns depend only on dimensionless ratios, not absolute physical scales. Two mirrors will produce identical Ronchi images if they have the same:

  1. Lines across mirror diameter = diameter × grating_LPI
  2. Focal ratio (f/#) = RoC / (diameter × 2)
  3. Normalized offset = offset / diameter
  4. Parabolic correction (0.0 = spherical, 1.0 = parabolic)

Example: Equivalent Parameter Sets

These two configurations produce identical Ronchi images:

Set 1: 12" mirror, 85 LPI grating, f/3.5, -0.2" offset
Set 2: 10.2" mirror, 100 LPI grating, f/3.5, -0.17" offset

Both have: 1020 lines across mirror, f/3.5, normalized offset -0.0167

Physics core

The Ronchi band calculation uses:

  • Zonal radius of curvature: zonalRoC = RoC + (zone^2 / RoC) * parabolicCorrection
  • Grating displacement: gratingToZonalRoC = RoC + offset*2 − zonalRoC
  • Ray projection at grating: xAtGrating = |gratingToZonalRoC * x / zonalRoC|

The implementation has two layers:

  • GenerateRonchiImageCore() — dimensionless core logic
  • GenerateRonchiImage() — converts physical parameters and delegates to core

These are implemented in ronchi-generator-app/Program.cs.

Training data workflow

  • Run autogen to produce a diverse set of Ronchigrams and a manifest.jsonl for model training.
  • Holdout images are placed in output/holdout/ for evaluation.

Common Usage Issues

"Missing parameter" errors:

  • Single image mode requires all 6 parameters: diameter, roc, grating, offset, paraboliccorrection, output
  • Autogen mode only requires 1 parameter: autogen true

Autogen not starting:

  • Ensure you're in the ronchi-generator-app/ directory when running dotnet run
  • Check that --autogen true is specified (not just --autogen)
  • Autogen is now fully dimensionless - no physical parameters needed!

Large dataset generation:

  • Autogen generates ~7,920 images with current parameters
  • Use --imagesize 256 or smaller for faster generation and smaller file sizes
  • Generation can take several minutes depending on image size

License

This repository contains original optics simulation code and is intended for research and educational purposes. Add a specific license if needed.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors