Overview
TheAstronomicalWidget class (defined in widgets/sky_widget.py) is the primary rendering widget for TerraLab’s astronomical visualization system. It provides real-time sky rendering with celestial objects, atmospheric effects, and interactive controls.
Class Definition
Key Components
Helper Classes
ClickableLabel
A clickable QLabel widget that emits signals when pressed. Signals:clicked: pyqtSignal()- Emitted when the label is clicked
mousePressEvent(event)- Handles mouse press events and emits the clicked signal
AstroEngine
High-precision astronomical calculation engine based on Meeus/ELP 2000-82 and VSOP87 algorithms. Constants:DEG_TO_RAD: float- π/180.0RAD_TO_DEG: float- 180.0/πAU_IN_KM: float- 149597870.7EARTH_RADIUS_KM: float- 6378.14
dt_utc(datetime) - UTC datetime object
- Tuple of (T: Julian century from J2000.0, jd: Julian Day)
angle(float) - Angle in degrees
- float - Normalized angle (0-360°)
T(float) - Julian centuries from J2000.0
- Tuple of (longitude: geocentric ecliptic longitude in degrees, latitude: ecliptic latitude in degrees, distance: Earth-Moon distance in km)
T(float) - Julian centuries from J2000.0
- Tuple of (true_longitude: ecliptic longitude in degrees, 0.0: ecliptic latitude (always 0 for Sun), distance: Earth-Sun distance in km)
lon(float) - Ecliptic longitude in degreeslat(float) - Ecliptic latitude in degreesT(float) - Julian centuries from J2000.0
- Tuple of (ra: right ascension in degrees, dec: declination in degrees)
ra_geo(float) - Geocentric right ascension in degreesdec_geo(float) - Geocentric declination in degreesdist_km(float) - Distance from Earth center in kmobs_lat(float) - Observer latitude in degreesobs_lon(float) - Observer longitude in degreesjd(float) - Julian Day
- Tuple of (ra_topo: topocentric RA in degrees, dec_topo: topocentric Dec in degrees, lst: local sidereal time in degrees)
name(str) - Planet name: ‘mercury’, ‘venus’, ‘mars’, ‘jupiter’, ‘saturn’T(float) - Julian centuries from J2000.0
- Tuple of (L_hel: heliocentric longitude in degrees, B_hel: heliocentric latitude in degrees, R_hel: radius vector in AU)
p_L(float) - Planet heliocentric longitude in degreesp_B(float) - Planet heliocentric latitude in degreesp_R(float) - Planet radius vector in AUearth_L(float) - Earth heliocentric longitude in degreesearth_B(float) - Earth heliocentric latitude in degreesearth_R(float) - Earth radius vector in AU
- Tuple of (longitude: geocentric ecliptic longitude in degrees, latitude: geocentric ecliptic latitude in degrees, delta: Earth-planet distance in AU)
sat_range_km(float) - Distance to satellite in kmphase_angle_rad(float) - Phase angle in radians (0 = full, π = new)std_mag(float) - Standard magnitude at 1000km, default -1.8
- float - Calculated visual magnitude
RusticTimeBar
A custom time control widget displaying a 24-hour timeline with sun altitude-based coloring. Signals:valueChanged: pyqtSignal(float)- Emitted when time value changes, passes hour value (0-24)
current_hour: float- Current hour value (0-24)lat: float- Observer latitude in degreeslon: float- Observer longitude in degreesday_of_year: int- Day of year (1-365)
hour(float) - Hour value (0-24), automatically normalized to 0-24 range
lat(float) - Latitude in degreeslon(float) - Longitude in degreesday_of_year(int) - Day of year (1-365)
hour(float) - Local hour (0-24)lat(float) - Latitude in degreeslon(float) - Longitude in degreesday(int) - Day of year
- float - Sun altitude in degrees
Background Workers
CatalogLoaderWorker
Background worker for loading star catalogs without freezing the UI. Supports both JSON and binary NumPy cache formats. Signals:catalog_ready: pyqtSignal(list, object, object, object, object, object, object)- Emitted when catalog is loaded. Parameters: (celestial_objects, np_ra, np_dec, np_mag, np_r, np_g, np_b)
json_path(str) - Path to JSON catalog file
SkyfieldLoaderWorker
Background worker for loading Skyfield ephemeris data. Signals:skyfield_ready: pyqtSignal(object, object)- Emitted when Skyfield is initialized. Parameters: (ts: timescale, eph: ephemeris)
StarRenderWorker
Background worker for rendering stars to QImage with atmospheric extinction, refraction, and light pollution effects. Signals:result_ready: pyqtSignal(QImage, list)- Emitted when star rendering completes. Parameters: (image: QImage, visible_stars: list of (x, y, object) tuples)trails_ready: pyqtSignal(QImage)- Emitted when star trail rendering completes. Parameters: (image: QImage)
params(dict) - Rendering parameters including:width(int) - Image width in pixelsheight(int) - Image height in pixelszoom_level(float) - Zoom factorvertical_ratio(float) - Vertical offset ratioelevation_angle(float) - Camera elevation in degreesazimuth_offset(float) - Camera azimuth in degreesra,dec,mag,r,g,b(np.ndarray) - Star data arrayslst(float) - Local sidereal time in degreeslat_rad(float) - Observer latitude in radiansmag_limit(float) - Magnitude limit for visibilitystar_scale(float) - Star size scaling factorbortle(int) - Bortle scale value (1-9)is_auto(bool) - Auto mode flagextinction_coeff(float) - Atmospheric extinction coefficienthorizon_profile(object) - Horizon profile with light_domes datapure_colors(bool) - Use legacy pure color rendering (no bloom)spike_threshold(float) - Magnitude threshold for diffraction spikescel_objs_ref(list) - Reference to celestial objects list
params(dict) - Trail rendering parameters including all render() params plus:start_hour(float) - Trail start hourend_hour(float) - Trail end hourday_of_year(int) - Day of yearlongitude(float) - Observer longitudeis_moving(bool) - Quality mode flag
Usage Example
Notes
- The
AstroEngineuses high-precision algorithms suitable for professional astronomical applications - Star rendering is performed in background threads to maintain UI responsiveness
- NumPy is required for vectorized star rendering operations
- Atmospheric effects include extinction (airmass), refraction, and local light pollution
- Diffraction spikes are rendered for bright stars (magnitude < spike_threshold)
- Binary cache files (.npy) are automatically generated to speed up subsequent catalog loads