Usage
Installation
To use luseepy, install the LuSEE-Night Docker image (For more information, see https://github.com/lusee-night/luseepy/tree/main/docker):
The “unity” Image
This is the minimal useable image based on requirements-foundation.txt. The main “Dockerfile” in the “docker” folder uses a build-arg argument, which also has a reasonable default. For example, building the “unity” image is done like this:
$ docker build . -f docker/Dockerfile-unity-luseepy -t lusee/lusee-night-unity-luseepy:1.0 --build-arg reqs=requirements-unity-luseepy.txt
Jupyter
This image also includes Jupyter Lab software. Jupyter is not started automatically, i.e. by default the user gets bash running and a functional Python/refspec/luseepy environment. To get Jupyter running, one first starts the container like this (or in a similar manner):
$ docker run -p 8888:8888 -e JUPYTER_ENABLE_LAB=yes -e JUPYTER_TOKEN=docker lusee/lusee-night-unity-luseepy:0.1
Once the container is running, this command is invoked to bring up Jupyter:
$ jupyter lab --allow-root --ip 0.0.0.0 --port 8888
The port 8888 can be mapped to any other convenient port on the host machine, and then access through localhost.
The Observation
- class lusee.Observation.Observation(time_range=2500, lun_lat_deg=-23.814, lun_long_deg=182.258, lun_height_m=0, deltaT_sec=900)
Class that initializes a basic Lunar Observation object for an observatory in selenographic coordinates.
Lunar day can be specified as:
int = lunar day as per LunarCalendar“CY##” or “CY####” = full calendar year 1/1 to 12/31“FY##” or “FY####” = full fiscale year 10/1 to 9/30“UTC to UTC”, i.e. ‘2025-02-01 13:00:00 to 2025-04-01 16:00:00’- param lunar_day:
Lunar day on which observation takes place
- type lunar_day:
int or str, see above
- param lun_lat_deg:
Lunar latitude of observatory in degrees
- type lun_lat_deg:
float
- param lun_long_deg:
Lunar longitude of observatory in degrees
- type lun_long_deg:
float
- param lun_height_m:
Height of observatory above lunar surface in meters
- type lun_height_m:
float
- param deltaT_sec:
Time resolution of observations
- type deltaT_sec:
float
- get_l_b_from_alt_az(alt, az, times=None)
Function that calculates a track in (l, b) galactic coordinates given coordinates in lunarcentric (Alt, Az). Alt and Az are given following the astronomical convention (angles measured from N towards E). Returns (l, b) in radians
- Parameters:
alt (numpy array) – Altitude
az (numpy array) – Azimuth
times (numpy array) – Times for observation. Defaults to self.times if not specified
- Returns:
(l, b) coordinates of object at self.times
- Return type:
numpy array
- get_ra_dec_from_alt_az(alt, az, times=None)
Function that calculates a track in (RA, Dec) given coordinates in lunarcentric (Alt, Az). Alt and Az are given following the astronomical convention (angles measured from N towards E). Returns (RA, Dec) in radians
- Parameters:
alt (numpy array) – Altitude
az (numpy array) – Azimuth
times (numpy array) – Times for observation. Defaults to self.times if not specified
- Returns:
(RA, Dec) coordinates of object at self.times
- Return type:
numpy array
- get_track_l_b(l, b, times=None)
Function that calculates a track in (Alt, Az) coordinates for an object with celestial coordinates (l, b) in the galactic coordinate system, at the self.times time stamps. (l, b) are given in degrees
- Parameters:
l (numpy array) – Galactic longitude, zero angle is from sun to galactic center
b (numpy array) – Galactic latitude, measures angle above the galactic plane
times (numpy array) – Times for observation. Defaults to self.times if not specified
- Returns:
(Alt, Az) coordinates of object at self.times
- Return type:
numpy array
- get_track_ra_dec(ra, dec, times=None)
Function that calculates a track in (Alt, Az) coordinates for an object with celestial coordinates in (RA, Dec) at the self.times time stamps. (RA, Dec) are given in degrees
- Parameters:
ra (numpy array) – Right Ascension
dec (numpy array) – Declination
times (numpy array) – Times for observation. Defaults to self.times if not specified
- Returns:
(Alt, Az) coordinates of object at self.times
- Return type:
numpy array
- get_track_solar(objid)
Function that calculates a track in (Alt, Az) coordinates for an object in the solar system at the self.times time stamps. objid can be ‘sun’, ‘moon’ (as debug, should be alt=-90), or planet id (jupiter, etc)
- Parameters:
objid (str) – Object ID (‘sun’, ‘moon’, ‘jupiter’, etc.)
- Returns:
(Alt, Az) coordinates of object at self.times
- Return type:
numpy array
The Beams
- class lusee.Beam.Beam(fname=None, id=None)
The main beam class, contains beam data and meta parameters. Only filename of beam to load and ID string are explicitly set in class initialization. All others are normally read in from the beam FITS file, but are included here in documentation for completeness.
- Parameters:
fname (str) – Filename of beam to load
id (str) – ID string for beam, optional
version (int) – Beam version
Etheta (numpy array[complex]) – Theta component of electric field
Ephi (numpy array[complex]) – Phi component of electric field
ZRe (numpy array) – Real component of antenna impedance
ZIm (numpy array) – Imaginary component of antenna impedance
Z (numpy array[complex]) – Complex impedance
gain (numpy array) – Antenna gain
f_ground (numpy array) – Ground fraction
gain_conv (numpy array) – Gain convention
freq (numpy array) – Frequency list
freq_min (float) – Minimum frequency
freq_max (float) – Maximum frequency
Nfreq (int) – Number of frequencies
theta_min (float) – Minimum theta angle
theta_max (float) – Maximum theta angle
Ntheta (int) – Number of theta bins
phi_min (float) – Minimum phi angle
phi_max (float) – Maximum phi angle
Nphi (int) – Number of phi bins
header (dict) – File header
theta_deg (numpy array) – Array of theta bins in degrees
phi_deg (numpy array) – Array of theta bins in degrees
theta (numpy array) – Array of theta bins in radians
phi (numpy array) – Array of phi bins in radians
- copy_beam(Etheta=None, Ephi=None)
Function that copies a beam object. Optional field array inputs to, eg. rotate copied beam.
- cross_power(other)
Function that calculates the cross-power between two beams
- Parameters:
other (class) – Second beam object for cross-power
- Returns:
Cross power
- Return type:
- flip_over_yz()
Function that flips beams across yz plane
- Returns:
Flipped beam as copy of beam object
- Return type:
class
- get_healpix(lmax, field, freq_ndx=None)
Function that produces a healpix map of specified field
- ground_fraction(cross=None)
Function that calculates the fraction of beam power that terminates on the ground (ground fraction), for a single beam or two crossed beams
- Parameters:
cross (class) – Optional second beam object
- Returns:
Ground fraction
- Return type:
- plotE(freqndx, toplot=None, noabs=False)
Function that plots 1D cuts of the E-field as a function of theta and phi
- Parameters:
- Returns:
None
- power()
Function that calculates the beam power of a single beam
- Returns:
Beam power
- Return type:
- power_hp(ellmax, Nside, freq_ndx=None, theta_tapr=None, cross=None, stokes=False)
Function that calculates the healpix rendering of the beam power
- Parameters:
ellmax (int) – Maximum l value
Nside (int) – Size of output Healpix map
freq_ndx (list(int)) – Optional list of frequency bin indices. Integer indices, not freq values
theta_tapr (numpy array) – Optional tapering profile to apply to beam in theta direction
cross (class) – Optional second beam object for cross-power
stokes (bool) – Whether to compute Stokes parameters
- Returns:
Healpix map containing beam power
- Return type:
numpy array or list(numpy array) if type(freq_ndx) is not int
- power_stokes(cross=None)
Function that calculates the beam power in Stokes components
- lusee.Beam.getLegendre(lmax, theta)
Function that calculates Legendre polynomial functions up to specified degree
- lusee.Beam.grid2healpix(theta, phi, img, lmax, Nside, fast=True)
Function that converts from theta-phi orthogonal spherical coordinates to heapix coordinates
- Parameters:
- Returns:
Healpix map of size Nside
- Return type:
numpy array
- lusee.Beam.grid2healpix_alm_fast(theta, phi, img, lmax)
Function that calculates a_lm spherical harmonic decomposition for input image, using fast method
- Parameters:
theta (numpy array) – Input spherical angle coordinates
phi (numpy array) – Input spherical angle coordinates
img (numpy array) – Input image (2D)
lmax (int) – Maximum l value
- Returns:
2D a_lm spherical harmonic array
- Return type:
numpy array
- lusee.Beam.grid2healpix_alm_reference(theta, phi, img, lmax)
Function that calculates a_lm spherical harmonic decomposition for input image
- Parameters:
theta (numpy array) – Input spherical angle coordinates
phi (numpy array) – Input spherical angle coordinates
img (numpy array) – Input image (2D)
lmax (int) – Maximum l value
- Returns:
2D a_lm spherical harmonic array
- Return type:
numpy array
- lusee.Beam.project_to_theta_phi(theta_rad, phi_rad, E)
Function that projects E_theta and E_phi components of instrument beam from E field in cartesian coordinates, E(x, y, z)
- Parameters:
theta (numpy array) – Input spherical angle coordinates
phi (numpy array) – Input spherical angle coordinates
E (numpy array) – Electric field
- Returns:
[Etheta, Ephi], Theta and phi components of electric field at [theta, phi] coordinates
- Return type:
numpy array
The Gaussian Beam
- class lusee.BeamGauss.BeamGauss(dec_deg, sigma_deg, phi_deg=90, one_over_freq_scaling=False, id=None)
Class that creates a Gaussian Beam object, centered at the given declination (and phi=360-azimuth=0) and of width sigma.
- Parameters:
Beam (class) – Beam object
dec_deg (float) – Declination of the center of the gaussian beam, in degrees
sigma_deg – Sigma of the gaussian beam at 1MHz, in degrees
phi_deg (float) – Phi center of the gaussian beam, in degrees, phi=0->E, phi=90->N
one_over_freq_scaling (bool) – Whether to scale beam sigma with 1/f
id (str) – ID string for beam, optional
- lusee.BeamGauss.gauss_beam(theta, phi, sigma, theta_c, phi_c=0.0)
Function that creates a map-level gaussian beam in theta and phi of width sigma, centered at theta=theta_c and phi=phi_c. Uses a naive gaussian function, with wrap around for theta, and phi. Used by BeamGauss class to create a Gaussiam Beam object.
The Beam Couplings
- class lusee.BeamCouplings.BeamCouplings(beams=[], from_yaml_dict=None)
Class that defines beam couplings for one and two port simulated beams
- Parameters:
Beam (class) – Beam object
from_yaml_dict (class) – Beam items to load from yaml dictionary
The Simulator
- class lusee.Simulation.Simulator(obs, beams, sky_model, combinations=[(0, 0), (1, 1), (0, 2), (1, 3), (1, 2)], lmax=128, taper=0.03, Tground=200.0, freq=None, cross_power=None, beam_smooth=None, extra_opts={})
Simulator class
- Parameters:
obs (class) – Observation parameters, from lusee.observation class
beams (class) – Instrument beams, from lusee.beam class
sky_model (class) – Simulated model of the sky, from lusee.skymodels
combinations (list[tuple]) – Indices for beam combinations/cross correlations to simulate
lmax (int) – Maximum l value of beams
taper (float) – Instrument beam taper
Tground (float) – Temperature of lunar ground
freq (list[float]) – Frequencies at which instrument observes sky. If empty, taken from lusee.beam class.
cross_power (list[float]) – Cross power for beam combinations. If empty, taken from lusee.beamcouplings.
beam_smooth (float) – Standard deviation of Gaussian filter for beam smoothing
extra_opt (list[str]) – Any extra options to pass to simulation. Currently includes “dump_beams” (saves instrument beams to file) and “cache_transform” (loads beam transformations from file).
- prepare_beams(beams, combinations)
Function that prepares beams for simulator
- simulate(times=None)
Main simulation function. Produces mock observation of sky model from self.sky_model with beams from self.beams
- Parameters:
times (list) – List of times, defaults to lusee.observation.times if empty
- Returns:
Waterfall style observation data for input times and self.freq
- Return type:
numpy array
- lusee.Simulation.eul2rot(theta)
Function that converts from Euler angles to rotation matrix
- Parameters:
theta (array) – Euler angles
- Returns:
Rotation matrix
- Return type:
numpy array
- lusee.Simulation.mean_alm(alm1, alm2, lmax)
Function that calculates the mean of the product of two a_lm arrrays
- lusee.Simulation.rot2eul(R)
Function that converts from rotation matrix to Euler angles
- Parameters:
R (array) – Rotation matrix
- Returns:
Euler angles
- Return type:
numpy array
The Satellite classes
- class lusee.Satellite.ObservedSatellite(observation, satellite)
Class that calculates satellite observables
- Parameters:
observation (class) – Observation parameters, from lusee.observation class
satellite (class) – Satellite parameters, from lusee.satellite class
- alt_rad()
Function that returns satellite altitude in radians
- Returns:
Satellite altitude
- Return type:
numpy array
- az_rad()
Function that returns satellite azimuth in radians
- Returns:
Satellite azimuth
- Return type:
numpy array
- dist_km()
Function that returns distance to satellite in km
- Returns:
Satellite distance
- Return type:
numpy array
- get_track_coverage(Nphi=10, Nmu=10)
Function that returns array of alt-az bins showing where satellite transit passed. Bins are 1 if satellite passed through bin, 0 if not.
- get_transit_indices()
Function that returns an array of transit indices for satellite and observation times specified in ObservedSatellite class
- Returns:
Transit Indices
- Return type:
array
- class lusee.Satellite.Satellite(semi_major_km=5738, eccentricity=0.56489, inclination_deg=57.097, raan_deg=0, argument_of_pericenter_deg=72.625, aposelene_ref_time=<Time object: scale='utc' format='isot' value=2024-05-01T00:00:00.000>)
Class that defines satellite parameters and position
- Parameters:
semi_major_km (float) – Semi-major axis of body in km
eccentricity (float) – Eccentricity of orbit
inclination_deg (float) – Inclination of orbit
raan_deg (float) – Right-ascension angle in degrees
argument_of_pericenter_deg (float) – Argument of pericenter of orbit in degrees
aposelene_ref_time (lunarsky.time) – Aposelene Reference Time
- predict_position_mcmf(times)
Function that returns an array of satellite positions for input times
- Parameters:
times (array[lunarsky.time]) – Array of lunarsky.time times at which to evaluate satellite position
- Returns:
Position of satellite body
- Return type:
Numpy array
The Monopole Sky Model classes
- lusee.MonoSkyModels.B2T(B, f)
Function that returns sky temperature, T, in [K] from brightness, B, in [W/m*2/Hz/sr] and frequency, f, in [MHz]
- lusee.MonoSkyModels.B2V(B, f, leff, gamma)
Function that returns power spectral density in [V^2/Hz] for a dipole of effective length leff in [m] and preamp coupling efficiency gamma c.f. Zaslavsky (11)
- lusee.MonoSkyModels.B_C(f)
Function that returns sky brightness, B, in [W/m**2/Hz/sr] at frequency, f, in [MHz] according to the model of Cane from MNRAS 189.3 (1979): 465-478.
- lusee.MonoSkyModels.B_NB(f)
Function that returns sky brightness, B, in [W/m**2/Hz/sr] at a frequency, f, in [MHz] according to the model of Novaco and Brown from ApJ 221 (1978): 114-123
- class lusee.MonoSkyModels.BalePlasmaEffects(fname='R1_L300cm_n500t2k6v0nf300.sav')
Class that loads data from simulations by Stuart Bale modeling plasma effects on observed radio signal, and interpolates the signal at a specified frequency in [MHz].
- lusee.MonoSkyModels.T2B(T, f)
Function that returns sky brightness, B, in [W/m*2/Hz/sr] from temperature, T, in [K] and frequency, f, in [MHz]
- lusee.MonoSkyModels.T_C(f)
Function that returns sky temperature, T, in [K] at frequency, f, in [MHz] according to the model of Cane from MNRAS 189.3 (1979): 465-478.
- lusee.MonoSkyModels.T_DarkAges_Scaled(nu, nu_min=16.4, nu_rms=14, A=0.04)
Function that rescales the location, width, and depth of the Dark Ages temperature decrement signal (the Dark Ages “trough”), and interpolates the temperature decrement at the specified frequencies, nuu. Dark Ages model uses the _DA_nu_cut and _DA_TSig_cut data, which are cut to below 50 MHz, and interpolated to zero at 50 MHz.
- Parameters:
- Returns:
Sky temperature, T, in [K]
- Return type:
- lusee.MonoSkyModels.T_J(f)
Function that returns sky temperature, T, in [K] at frequency, f, in [MHz] according to Eq. 2 of Chen et al (Exp Astronomy 2018 45:231-253)
The Sky Model classes
- class lusee.SkyModels.ConstSky(Nside, lmax, T, freq=None, zero_cone=True)
Class that initializes a healpix sky map with a frequency dependent monopole signal given by one of the available Constant Sky models: 1) the Cane (1979) radio background model, or 2) the Dark Ages monopole model
- Parameters:
- T(ndx)
Function that returns sky temperature at specified frequency index or indices
- get_alm(ndx, freq=None)
Function that calculates a_lm spherical harmonic decomposition for input sky map(s) at specified frequency indices. Uses healpy map2alm.
- class lusee.SkyModels.ConstSkyCane1979(Nside, lmax, freq=None)
Class that constructs a monopole sky temperature map using the Cane (1979) radio background sky model. Uses ConstSky class to initialize map.
- class lusee.SkyModels.DarkAgesMonopole(Nside, lmax, scaled=True, nu_min=16.4, nu_rms=14.0, A=0.04, freq=None)
Class that constructs a monopole sky temperature map using the Dark Ages monopole model. Uses ConstSky class to initialize map. Can optionally generate maps from the monopole model scaled to specified nu_min, nu_rms, and A, or from an explicit list of temperatures, T, as a function of frequency. Scaled model given by lusee.MonoSkyModels.T_DarkAges_Scaled, non-scaled by lusee.MonoSkyModels.T_DarkAges.
- Parameters:
Nside (int) – Size of Healpix map to create
lmax (int) – Maximum l value for maps
scaled (bool) – Whether to generate maps from frequency scaled model (True), or temperature list model (False)
nu_min (float) – Frequency of the minimum of the Dark Ages trough
nu_rms (float) – Width of the Dark Ages trough
A (float) – Monopole signal amplitude scaling factor
freq (list) – List of frequencies at which to make sky maps.
- class lusee.SkyModels.FitsSky(fname, lmax)
Class that reads in a sky map from a FITS file, and reads in the freq list from the FITS header. Computes map A_lms with healpy map2alm, up to specified lmax.
- get_alm(ndx, freq)
Function that calculates a_lm spherical harmonic decomposition for input FITS file sky map(s) at specified frequency indices. Uses healpy map2alm.
- class lusee.SkyModels.GalCenter(Nside, lmax, T, freq=None)
Class that constructs a temperature map using the Galaxy Center model. Uses ConstSky class to initialize map.
The Lunar Calendar
- class lusee.LunarCalendar.LunarCalendar(cache='', cleanup=True, verbose=False)
Class that defines the cache file name and sets whether it is to be used
- Parameters:
- close_db()
Function that closes cache, removes it if cleanup set to true
- Returns:
None
- get_lunar_nights(year=2025)
Function that calculates a list of lunar noon-to-noon cycles in a year. Returns a list of tuples. Each tuple is (time_start, time_end) Where times are astropy times at lunar “noon” (Sun transits) on the farside time_end corresponds to time_start of the next day.
- get_lunar_start_end(lunar_night=2500)
Function that calculates dates for specified noon-to-noon lunar cycle. Format of cycles is: two digit year in 21st century, followed by zero-indexed two digit cycle count for that year. E.g.: 2600 is the first lunar cycle in 2026.
- get_sun_alt(times)
Function that returns Sun altitude at a given Moon location for a set of times
- Parameters:
times (numpy array) – Array of times at which to calculate sun alt
- Returns:
Altitudes
- Return type:
numpy array
The Throughput
- class lusee.Throughput.Throughput(beam=None, noise_e=2, Cfront=35, R4=1000000.0)
Class that holds front-end throughput parameters
- Parameters:
- AntennaImpedanceInterp(f)
Function that extrapolates antenna impedance as a function of frequency
- Parameters:
f (array) – Array of frequencies at which to calculate impedance
- Returns:
Antenna impedance
- Return type:
array
- Gamma_VD(freq)
Function that calculates gamma at a specified frequency for antenna impedance matching
- SG2V(freq)
Function that calculates 4*lambda*R*Gamma^2 for antenna match
- T2Vsq(freq)
Function that calculates 4*k_B*R*Gamma^2 for antenna match
- complex_gain(freq_MHz, gain_set='M')
Function that calculates the complex gain of the front-end amplifiers at a specified frequency
- power_gain(freq_MHz, gain_set='M')
Function that calculates the gain of the front-end amplifiers in power at a specified frequency
The Data
The PCA Analyzer
- class lusee.PCAanalyzer.CompositePCAanalyzer(alist)
Class that performs Principle Component Analysis on the composite of several sets of sky data
- Parameters:
alist (list(class)) – list of PCAanalyzer classes for the sky data sets
- SNR(template_list, plot=None, verbose=False)
Function that calculates the signal-to-noise ratio of input sky signal template against sky noise
- get_chi2(template_list, data, istart=2)
Function that calculates the cumulative Chi-squared value for the list of sky data and sky signal templates in self.alist and template_list
- get_chi2_table(templates, data, istart=2)
Function that calculates an array of Chi-squared values for a list of different templates, with each template applied to every analyzer in self.alist and set of sky data in data
- class lusee.PCAanalyzer.PCAanalyzer(data, noise, weight=None)
Class that performs Principle Component Analysis on sky data and sky signal templates
- Parameters:
data (class) – Sky data for analysis, two dimensional array where second dimension is frequency
noise (array) – Noise array for data at N frequencies
weight (array) – Weight array for data at N frequencies
- SNR(template, plot=None)
Function that calculates the signal-to-noise ratio of input sky signal template against sky noise
- get_chi2(template, data, istart=2)
Function that calculates the Chi-squared value of the input sky signal template against sky data
- get_chi2_table(templates, data, istart=2)
Function that calculates the Chi-squared value of a list of input sky signal templates against sky data
- get_template_power(template)
Function that calculates power from weighted sky signal template
- Parameters:
template (array) – Sky signal template
- Returns:
Power in sky signal
- Return type:
array
- sim_data(template)
Function that calculates a simulated sky spectrum by summing 1) The mean un-weighted sky data in each frequency bin (from the sky data input to the PCAanalyzer class) as a background DC level, 2) the input sky signal template, and 3) a randomly generated instance of sky noise, with mean zero and standard deviation self.noise, at each of the N frequencies in the input sky data.
- Parameters:
template (array) – Sky signal template
- Returns:
Simulated sky spectrum
- Return type:
array