API Reference
TipTop
- class tiptop_ipy.TipTop(instrument=None, ini_file=None)[source]
Main interface to the TIPTOP microservice.
Usage:
tt = TipTop("MICADO_SCAO") # Load from template tt["atmosphere", "Seeing"] = 0.6 # Tweak parameters tt["telescope", "ZenithAngle"] = 15.0 result = tt.generate_psf() # Run simulation result.plot() # View PSF
- Parameters:
- MAX_FOV = 512
Hard limit on
sensor_science.FieldOfViewwhen loading INI files.Templates and user INI files may specify very large fields of view (e.g. 2048 for MICADO) that cause the ESO server to time out. Values above this cap are silently reduced on load. Users can still increase the value afterwards via
tt["sensor_science", "FieldOfView"] = N.
- __getitem__(key)[source]
Access config values.
tt[“atmosphere”] returns the whole section dict. tt[“atmosphere”, “Seeing”] returns a single value.
- __setitem__(key, value)[source]
Set config values.
tt[“atmosphere”, “Seeing”] = 0.6 tt[“atmosphere”] = {“Seeing”: 0.6, …} # replace whole section
- generate_psf(timeout=120, force_simulation=False, save_psds=False)[source]
Send config to TIPTOP server and return a TipTopResult.
Validates config before sending and shows progress feedback.
- Parameters:
- Returns:
result – The simulation result with PSF data.
- Return type:
- load(path)[source]
Load config from .ini file, replacing current config.
- Parameters:
path (str) – Path to .ini file.
- diff()[source]
Show what changed from the template.
- Returns:
changes – Nested dict of {section: {key: (old, new)}} for changed values.
- Return type:
- property sections
List of config section names.
- property ini_contents
The INI string representation of the current config.
- property wavelengths
Science wavelengths as an astropy Quantity in microns.
Reads
sources_science.Wavelength(stored in metres internally) and returns values asu.um.- Returns:
wavelengths – Wavelengths in microns.
- Return type:
- property positions
Science source positions as (x, y) Quantities in arcsec.
Computed from
sources_science.Zenith(radial distance) andsources_science.Azimuth(angle in degrees).- Returns:
x, y – Cartesian coordinates in arcsec.
- Return type:
- add_off_axis_positions(positions)[source]
Set science source positions from (x, y) coordinates.
Converts Cartesian (x, y) to polar (Zenith, Azimuth) and updates
sources_science.Zenithandsources_science.Azimuth.- Parameters:
positions (tuple or list of tuples) – A single
(x, y)tuple or a list of(x, y)tuples. If values are astropy Quantities, they are converted to arcsec. If plain floats, assumed to be in arcsec.
Examples
tt = TipTop("ERIS") tt.add_off_axis_positions((0, 0)) # on-axis only tt.add_off_axis_positions([(0, 0), (5, 5)]) # on-axis + 5",5" # With units import astropy.units as u tt.add_off_axis_positions([(0, 0)*u.arcsec, (5, 5)*u.arcsec])
TipTopResult
- class tiptop_ipy.TipTopResult(hdulist)[source]
Wraps the FITS HDUList returned by the TIPTOP server.
Provides convenient access to PSF data, coordinates, plotting, and Jupyter display.
The TIPTOP server returns a FITS file with 5 HDUs:
[0] PrimaryHDU — header with config parameters and timing
[1] ImageHDU
PSF CUBE— AO-corrected PSF(s), shape (N, FOV, FOV)[2] ImageHDU
OPEN-LOOP PSF— seeing-limited PSF, shape (FOV, FOV)[3] ImageHDU
DIFFRACTION LIMITED PSF— perfect PSF, shape (FOV, FOV)[4] ImageHDU
Final PSFs profiles— radial profiles
For multi-wavelength requests, there is one PSF CUBE HDU per wavelength. Coordinates are stored in the PSF CUBE header cards (CCX0000, CCY0000, …).
- Parameters:
hdulist (fits.HDUList) – The FITS HDUList from the TIPTOP server.
- hdulist
The underlying FITS data.
- Type:
fits.HDUList
- property psf
The PSF image data from the first PSF CUBE HDU.
For single-position results this is shape (1, H, W). For multi-position results this is shape (N, H, W).
- property open_loop_psf
The seeing-limited (open-loop) PSF, shape (H, W).
- property diffraction_psf
The diffraction-limited PSF, shape (H, W).
- property has_psd
Whether the result contains a Power Spectral Density HDU.
- property psd
The high-order PSD, shape (nPointings, N, N), units nm².
- property x
X-axis coordinates of PSF positions in arcsec.
- property y
Y-axis coordinates of PSF positions in arcsec.
- property n_wavelengths
Number of wavelength channels (PSF CUBE HDUs).
- property strehl
Strehl ratios for each position (from PSF CUBE header).
- property fwhm
FWHM values in mas for each position (from PSF CUBE header).
- psf_cube(wavelength_index=0)[source]
Get PSF cube for a specific wavelength index.
- Parameters:
wavelength_index (int) – Index into the list of wavelength channels.
- Returns:
data – PSF cube or image.
- Return type:
np.ndarray
- plot(log_scale=True, wavelength_index=0, position_index=0, **kwargs)[source]
Quick PSF plot with matplotlib. Works in Jupyter.
INI Parser
Reliable INI parser for TIPTOP-style .ini files.
TIPTOP .ini files are non-standard: they use Python list literals, scientific notation, None values, both ‘;’ and ‘#’ comments, and sometimes have ‘=’ inside string values.
- tiptop_ipy.ini_parser.parse_ini(path_or_string)[source]
Parse a TIPTOP .ini file into nested dict {section: {key: value}}.
Validation
Config validation against the defaults.yaml schema.
Server Configuration
- tiptop_ipy.set_server(name_or_url)[source]
Set the TIPTOP server.
- Parameters:
name_or_url (str) – Either a server name (“eso”, “univie”) or a full URL.
Examples
>>> set_server("univie") # University of Vienna (default) >>> set_server("http://...") # Custom URL
- tiptop_ipy.SERVERS = {'eso': 'https://www.eso.org/p2services/any/tiptop', 'univie': 'https://tiptop.univie.ac.at/api'}
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s
(key, value) pairs
- dict(iterable) -> new dictionary initialized as if via:
d = {} for k, v in iterable:
d[k] = v
- dict(**kwargs) -> new dictionary initialized with the name=value pairs
in the keyword argument list. For example: dict(one=1, two=2)
Utilities
- tiptop_ipy.utils.list_instruments(include_path=False)[source]
List available instrument template names.
- tiptop_ipy.utils.query_tiptop_server(ini_content, timeout=120, force_simulation=False, save_psds=False)[source]
Send an INI config to the TIPTOP server and return the FITS result.
Routes to ESO (synchronous) or custom server (async polling) based on the current server URL set via
set_server()orTIPTOP_SERVER_URL.- Parameters:
ini_content (str) – The raw contents of a TIPTOP config .ini file.
timeout (int) – Request timeout in seconds.
force_simulation (bool) – If True, bypass the server cache and force a fresh simulation. Only supported on custom servers (not ESO).
save_psds (bool) – If True, include the high-order PSD in the output FITS file. Only supported on custom servers (not ESO).
- Returns:
hdus – A FITS file with extensions: - [0] PrimaryHDU: header info - [1] ImageHDU: PSF cube(s) - [-1] ImageHDU: (2, N) cartesian coordinates of PSF positions
- Return type:
fits.HDUList