Larger Models

A simple Lentil model can be written in a single file but as the model grows, maintaining all the code in a single file becomes more difficult. It usually makes more sense to divide the code into several smaller modules and interact with the modules via a single package. The model package should be divided into modules in some logical way. One way to separate the code is:

  • A top-level module containing the main model and providing linkage between the individual components (primarily the optical model, radiometric model, and detector model

  • An module that defines the model’s optical planes

  • A module defining the model’s radiometric properties (if this is very simple, it can be included in the top-level or planes module)

  • A module for the detector. If a model needs to represent multiple detectors, they can be grouped in a single module, or be broken out into individual modules.

  • A data subdirectory for holding static data. This subdirectory can be further subdivided as needed for easier organization.

  • Top-level subdirectories for documentation and tests

  • A top-level scripts subdirectory can be useful for holding commonly used scripts for interacting with the model

A fairly standard directory structure might look something like this:

├── tiny_telescope/
│   ├──
│   ├──
│   ├──
│   ├──
│   ├──
│   └── data/
│       ├── detector_qe.csv
│       ├── pupil_mask.npy
│       └── sensitivities.npz
├── docs/
├── scripts/
├── tests/
├── .gitignore

If the module contains the top level object called TinyTelescope, the should look like this:

from tiny_telescope.tiny import TinyTelescope

With a model defined in this way, users can interact with it in a standard way:

>>> from tiny_telescope import TinyTelescope
>>> t = TinyTelescope()

import os
from setuptools import setup

    author='Tim Apple',
    package_data={'tiny_telescope': ['data/*']},