Skip to content

Sources¤

AlphaCen

dLuxToliman.sources.AlphaCen ¤

Bases: Source()

A parametrised model of the Alpha Centauri binary pair.

Properties

xy_positions : Array The x and y positions of the two stars in radians. raw_fluxes : Array The raw fluxes of the two stars in photons. norm_weights : Array The normalised spectral weights of each modelled wavelength.

Methods:

Name Description
normalise

Normalises the source flux to 1.

model

Models the PSF by propagating the AlphaCen source through the given optics.

Source code in dLuxToliman/sources.py
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
class AlphaCen(Source()):
    """
    A parametrised model of the Alpha Centauri binary pair.

    Properties
    ----------
    xy_positions : Array
        The x and y positions of the two stars in radians.
    raw_fluxes : Array
        The raw fluxes of the two stars in photons.
    norm_weights : Array
        The normalised spectral weights of each modelled wavelength.

    Methods
    -------
    normalise()
        Normalises the source flux to 1.
    model()
        Models the PSF by propagating the AlphaCen source through the given optics.
    """

    separation: float
    position_angle: float
    x_position: float
    y_position: float
    log_flux: float
    contrast: float
    bandpass: tuple
    weights: Array
    wavelengths: Array

    def __init__(
        self,
        n_wavels=5,
        separation=10.0,  # arcseconds
        position_angle=90,  # degrees
        x_position=0.0,  # arcseconds
        y_position=0.0,  # arcseconds
        log_flux=6.979,  # log10 photons in one 0.1 s frame
        contrast=3.37,
        bandpass=(530, 640),  # nm
        weights=None,
    ):
        """
        Parameters
        ----------
        n_wavels : int
            The number of wavelengths to model.
        separation : float
            The binary separation of the two stars in arcseconds.
        position_angle : float
            The position angle of the binary pair in degrees.
        x_position : float
            The horizontal offset of the image in arcseconds.
        y_position : float
            The vertical offset of the image in arcseconds.
        log_flux : float
            The log10 of the total number of photons from both stars in the image.
            The default, 6.979, is one 0.1 s frame of Alpha Cen through the
            TOLIMAN bandpass and collecting area (see photon_count.md).
        contrast : float
            The flux ratio of Alpha Cen A / Alpha Cen B.
        bandpass : tuple
            The wavelength range of the image in nanometers, with syntax (min, max).
        weights : Array
            Spectral weights for each wavelength modelled. If None, the weights are uniform.
        """

        # Positional Parameters
        self.x_position = x_position
        self.y_position = y_position
        self.separation = separation
        self.position_angle = position_angle

        # Flux & Contrast
        self.log_flux = log_flux
        self.contrast = contrast

        # Spectrum (Uniform)  # TODO : Phoenix Models?
        self.bandpass = bandpass
        self.wavelengths = np.linspace(bandpass[0], bandpass[1], n_wavels)
        if weights is None:
            self.weights = np.ones((2, n_wavels)) / n_wavels
        else:
            self.weights = weights

    def normalise(self):
        """
        Normalises the source flux to 1.
        """
        return self.multiply("weights", 1 / self.weights.sum(1)[:, None])

    @property
    def xy_positions(self):
        """
        Returns the x and y positions of the two stars in units of radians.
        """
        # Calculate
        r = self.separation / 2
        phi = dlu.deg2rad(self.position_angle)
        sep_vec = np.array([r * np.sin(phi), r * np.cos(phi)])

        # Add to Position vectors
        pos_vec = np.array([self.x_position, self.y_position])
        output_vec = np.array([pos_vec + sep_vec, pos_vec - sep_vec])
        return dlu.arcsec2rad(output_vec)

    @property
    def raw_fluxes(self):
        """
        Returns the raw integrated fluxes of Alpha Centauri A and B respectively, in units of photons.
        """
        flux = (10**self.log_flux) / 2
        flux_A = 2 * self.contrast * flux / (1 + self.contrast)
        flux_B = 2 * flux / (1 + self.contrast)
        return np.array([flux_A, flux_B])

    @property
    def norm_weights(self):
        """
        Returns the normalised spectral weights of each modelled wavelength.
        """
        return self.weights / self.weights.sum(1)[:, None]

    def model(
        self: Source(),
        optics: Optics(),
        return_wf: bool = False,
        return_psf: bool = False,
    ) -> Array:
        """
        Models the PSF by propagating the AlphaCen source through the given optics.

        Parameters
        ----------
        optics : Optics
            The optics to propagate the source through.
        return_wf
            Whether or not to return the wavefront.
        return_psf
            Whether or not to return the PSF.

        Returns
        -------
        psf : Array
            The PSF of the source modelled through the optics.
        """
        # Get Values
        weights = self.norm_weights
        fluxes = self.raw_fluxes
        positions = self.xy_positions
        wavelengths = 1e-9 * self.wavelengths

        # Model PSF
        input_weights = weights * fluxes[:, None]

        # Return wf case is simple
        prop_fn = lambda position, weight: optics.propagate(
            wavelengths, position, weight, return_wf, return_psf
        )
        output = filter_vmap(prop_fn)(positions, input_weights)

        # Return wf is simple case
        if return_wf:
            return output

        # Return psf just requires constructing object
        if return_psf:
            return dLux.PSF(output.data.sum(0), output.pixel_scale.mean())

        # Return array is simple
        return output.sum(0)

norm_weights property ¤

Returns the normalised spectral weights of each modelled wavelength.

raw_fluxes property ¤

Returns the raw integrated fluxes of Alpha Centauri A and B respectively, in units of photons.

xy_positions property ¤

Returns the x and y positions of the two stars in units of radians.

__init__(n_wavels=5, separation=10.0, position_angle=90, x_position=0.0, y_position=0.0, log_flux=6.979, contrast=3.37, bandpass=(530, 640), weights=None) ¤

Parameters:

Name Type Description Default
n_wavels int

The number of wavelengths to model.

5
separation float

The binary separation of the two stars in arcseconds.

10.0
position_angle float

The position angle of the binary pair in degrees.

90
x_position float

The horizontal offset of the image in arcseconds.

0.0
y_position float

The vertical offset of the image in arcseconds.

0.0
log_flux float

The log10 of the total number of photons from both stars in the image. The default, 6.979, is one 0.1 s frame of Alpha Cen through the TOLIMAN bandpass and collecting area (see photon_count.md).

6.979
contrast float

The flux ratio of Alpha Cen A / Alpha Cen B.

3.37
bandpass tuple

The wavelength range of the image in nanometers, with syntax (min, max).

(530, 640)
weights Array

Spectral weights for each wavelength modelled. If None, the weights are uniform.

None
Source code in dLuxToliman/sources.py
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
def __init__(
    self,
    n_wavels=5,
    separation=10.0,  # arcseconds
    position_angle=90,  # degrees
    x_position=0.0,  # arcseconds
    y_position=0.0,  # arcseconds
    log_flux=6.979,  # log10 photons in one 0.1 s frame
    contrast=3.37,
    bandpass=(530, 640),  # nm
    weights=None,
):
    """
    Parameters
    ----------
    n_wavels : int
        The number of wavelengths to model.
    separation : float
        The binary separation of the two stars in arcseconds.
    position_angle : float
        The position angle of the binary pair in degrees.
    x_position : float
        The horizontal offset of the image in arcseconds.
    y_position : float
        The vertical offset of the image in arcseconds.
    log_flux : float
        The log10 of the total number of photons from both stars in the image.
        The default, 6.979, is one 0.1 s frame of Alpha Cen through the
        TOLIMAN bandpass and collecting area (see photon_count.md).
    contrast : float
        The flux ratio of Alpha Cen A / Alpha Cen B.
    bandpass : tuple
        The wavelength range of the image in nanometers, with syntax (min, max).
    weights : Array
        Spectral weights for each wavelength modelled. If None, the weights are uniform.
    """

    # Positional Parameters
    self.x_position = x_position
    self.y_position = y_position
    self.separation = separation
    self.position_angle = position_angle

    # Flux & Contrast
    self.log_flux = log_flux
    self.contrast = contrast

    # Spectrum (Uniform)  # TODO : Phoenix Models?
    self.bandpass = bandpass
    self.wavelengths = np.linspace(bandpass[0], bandpass[1], n_wavels)
    if weights is None:
        self.weights = np.ones((2, n_wavels)) / n_wavels
    else:
        self.weights = weights

model(optics, return_wf=False, return_psf=False) ¤

Models the PSF by propagating the AlphaCen source through the given optics.

Parameters:

Name Type Description Default
optics Optics

The optics to propagate the source through.

required
return_wf bool

Whether or not to return the wavefront.

False
return_psf bool

Whether or not to return the PSF.

False

Returns:

Name Type Description
psf Array

The PSF of the source modelled through the optics.

Source code in dLuxToliman/sources.py
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
def model(
    self: Source(),
    optics: Optics(),
    return_wf: bool = False,
    return_psf: bool = False,
) -> Array:
    """
    Models the PSF by propagating the AlphaCen source through the given optics.

    Parameters
    ----------
    optics : Optics
        The optics to propagate the source through.
    return_wf
        Whether or not to return the wavefront.
    return_psf
        Whether or not to return the PSF.

    Returns
    -------
    psf : Array
        The PSF of the source modelled through the optics.
    """
    # Get Values
    weights = self.norm_weights
    fluxes = self.raw_fluxes
    positions = self.xy_positions
    wavelengths = 1e-9 * self.wavelengths

    # Model PSF
    input_weights = weights * fluxes[:, None]

    # Return wf case is simple
    prop_fn = lambda position, weight: optics.propagate(
        wavelengths, position, weight, return_wf, return_psf
    )
    output = filter_vmap(prop_fn)(positions, input_weights)

    # Return wf is simple case
    if return_wf:
        return output

    # Return psf just requires constructing object
    if return_psf:
        return dLux.PSF(output.data.sum(0), output.pixel_scale.mean())

    # Return array is simple
    return output.sum(0)

normalise() ¤

Normalises the source flux to 1.

Source code in dLuxToliman/sources.py
100
101
102
103
104
def normalise(self):
    """
    Normalises the source flux to 1.
    """
    return self.multiply("weights", 1 / self.weights.sum(1)[:, None])