Skip to content

MAST Physics Methods

Built-in Methods For MAST¤

Physics methods for MAST.

MastPhysicsMethods ¤

This class provides methods to retrieve and calculate physics-related data for MAST.

Source code in disruption_py/machine/mast/physics.py
 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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
class MastPhysicsMethods:
    """
    This class provides methods to retrieve and calculate physics-related data
    for MAST.
    """

    @staticmethod
    @cache_method
    @physics_method(
        columns=["ip", "dip_dt", "ip_prog", "dipprog_dt"],
        tokamak=Tokamak.MAST,
    )
    def get_ip_parameters(params: PhysicsMethodParams):
        """Get Ip parameters

        Parameters
        ----------
        params : PhysicsMethodParams
            The parameters containing the Xarray connection, shot id and more.

        Returns
        -------
        dict
            A dictionary containing plasma current (`ip`), its time derivative (`dip_dt`),
            programmed plasma current (`ip_prog`), and its time derivative (`dipprog_dt`).
        """
        conn: XarrayConnection = params.mds_conn
        ip = conn.get_data(params.shot_id, "summary/ip")
        ip_prog = conn.get_data(params.shot_id, "pulse_schedule/i_plasma")
        ip_prog_time = conn.get_data(params.shot_id, "pulse_schedule/time")
        magtime = conn.get_data(params.shot_id, "summary/time")

        dip_dt = np.gradient(ip, magtime)
        dipprog_dt = np.gradient(ip_prog, ip_prog_time)

        times = params.times

        ip = MastUtilMethods.interpolate_1d(magtime, ip, times)
        ip_prog = MastUtilMethods.interpolate_1d(ip_prog_time, ip_prog, times)
        dip_dt = MastUtilMethods.interpolate_1d(magtime, dip_dt, times)
        dipprog_dt = MastUtilMethods.interpolate_1d(ip_prog_time, dipprog_dt, times)

        return {
            "ip": ip,
            "dip_dt": dip_dt,
            "ip_prog": ip_prog,
            "dipprog_dt": dipprog_dt,
        }

    @staticmethod
    @physics_method(
        columns=["p_nbi", "p_rad"],
        tokamak=Tokamak.MAST,
    )
    def get_power(params: PhysicsMethodParams):
        """Get power parameters

        Parameters
        ----------
        params : PhysicsMethodParams
            The parameters containing the Xarray connection, shot id and more.

        Returns
        -------
        dict
            A dictionary containing neutral beam injection power (`power_nbi`) and
            radiated power (`power_radiated`).
        """
        conn: XarrayConnection = params.mds_conn

        power_nbi = conn.get_data(params.shot_id, "summary/power_nbi")
        power_radiated = conn.get_data(params.shot_id, "summary/power_radiated")
        base_time = conn.get_data(params.shot_id, "summary/time")

        times = params.times
        power_nbi = MastUtilMethods.interpolate_1d(base_time, power_nbi, times)
        power_radiated = MastUtilMethods.interpolate_1d(
            base_time, power_radiated, times
        )
        return {"p_nbi": power_nbi, "p_rad": power_radiated}

    @staticmethod
    @physics_method(
        columns=["gas_total_injected", "gas_inboard_total", "gas_outboard_total"],
        tokamak=Tokamak.MAST,
    )
    def get_gas(params: PhysicsMethodParams):
        """Get gas injection parameters

        Parameters
        ----------
        params : PhysicsMethodParams
            The parameters containing the Xarray connection, shot id and more.

        Returns
        -------
        dict
            A dictionary containing total injected gas (`total_injected`),
            inboard total gas (`inboard_total`), and outboard total gas (`outboard_total`).
        """
        conn: XarrayConnection = params.mds_conn

        total_injected = conn.get_data(params.shot_id, "gas_injection/total_injected")
        inboard_total = conn.get_data(params.shot_id, "gas_injection/inboard_total")
        outboard_total = conn.get_data(params.shot_id, "gas_injection/outboard_total")
        base_time = conn.get_data(params.shot_id, "gas_injection/time")

        times = params.times
        total_injected = MastUtilMethods.interpolate_1d(
            base_time, total_injected, times
        )
        inboard_total = MastUtilMethods.interpolate_1d(base_time, inboard_total, times)
        outboard_total = MastUtilMethods.interpolate_1d(
            base_time, outboard_total, times
        )
        return {
            "gas_total_injected": total_injected,
            "gas_inboard_total": inboard_total,
            "gas_outboard_total": outboard_total,
        }

    @staticmethod
    @physics_method(
        columns=["t_e_core", "n_e_core"],
        tokamak=Tokamak.MAST,
    )
    def get_ts_parameters(params: PhysicsMethodParams):
        """Get Thomson parameters

        Parameters
        ----------
        params : PhysicsMethodParams
            The parameters containing the Xarray connection, shot id and more.

        Returns
        -------
        dict
            A dictionary containing core electron temperature (`t_e_core`) and
            core electron density (`n_e_core`).
        """
        times = params.times
        conn: XarrayConnection = params.mds_conn

        t_e_core = conn.get_data(params.shot_id, "thomson_scattering/t_e_core")
        n_e_core = conn.get_data(params.shot_id, "thomson_scattering/n_e_core")
        base_time = conn.get_data(params.shot_id, "thomson_scattering/time")

        t_e_core = MastUtilMethods.interpolate_1d(base_time, t_e_core, times)
        n_e_core = MastUtilMethods.interpolate_1d(base_time, n_e_core, times)
        return {"t_e_core": t_e_core, "n_e_core": n_e_core}

    @staticmethod
    @physics_method(
        columns=["n_e", "dn_dt", "greenwald_fraction"],
        tokamak=Tokamak.MAST,
    )
    def get_densities(params: PhysicsMethodParams):
        r"""
        Calculate electron density, its time derivative, and the Greenwald fraction.

        The Greenwald fraction is the ratio of the measured electron density $n_e$ and
        the Greenwald density limit $n_G$ defined as [^1]:

        $$
        n_G = \frac{I_p}{\pi a^2}
        $$

        where $n_G$ is given in $10^{20} m^{-3}$ and $I_p$ is in MA.

        [^1]: https://wiki.fusion.ciemat.es/wiki/Greenwald_limit

        Parameters
        ----------
        params : PhysicsMethodParams
            The parameters containing the Xarray connection, shot id and more.

        Returns
        -------
        dict
            A dictionary containing electron density (`n_e`), its gradient (`dn_dt`),
            and the Greenwald fraction (`greenwald_fraction`).

        """

        conn: XarrayConnection = params.mds_conn
        n_e = conn.get_data(params.shot_id, "summary/line_average_n_e")
        t_n = conn.get_data(params.shot_id, "summary/time")
        ip = conn.get_data(params.shot_id, "summary/ip")
        t_ip = conn.get_data(params.shot_id, "summary/time")
        a_minor = conn.get_data(params.shot_id, "equilibrium/minor_radius")
        t_a = conn.get_data(params.shot_id, "equilibrium/time")

        return MastPhysicsMethods._get_densities(
            params.times, n_e, t_n, ip, t_ip, a_minor, t_a
        )

    @staticmethod
    def _get_densities(times, n_e, t_n, ip, t_ip, a_minor, t_a):
        """
        Calculate electron density, its time derivative, and the Greenwald fraction.

        Parameters
        ----------
        times : array_like
            Time points at which to interpolate the densities.
        n_e : array_like
            Electron density values.
        t_n : array_like
            Corresponding time values for electron density.
        ip : array_like
            Plasma current values.
        t_ip : array_like
            Corresponding time values for plasma current.
        a_minor : array_like
            Minor radius values.
        t_a : array_like
            Corresponding time values for minor radius.

        Returns
        -------
        dict
            A dictionary containing interpolated electron density (`n_e`),
            its time derivative (`dn_dt`), and the Greenwald fraction (`greenwald_fraction`).
        """
        if len(n_e) != len(t_n):
            raise CalculationError("n_e and t_n are different lengths")
        # get the gradient of n_E
        dn_dt = np.gradient(n_e, t_n)
        n_e = interp1(t_n, n_e, times)
        dn_dt = interp1(t_n, dn_dt, times)
        ip = -ip / 1e6  # Convert from A to MA and take positive value
        ip = interp1(t_ip, ip, times)
        a_minor = interp1(t_a, a_minor, times, bounds_error=False, fill_value=np.nan)
        # make sure aminor is not 0 or less than 0
        a_minor[a_minor <= 0] = 0.001
        n_g = abs(ip) / (np.pi * a_minor**2) * 1e20  # Greenwald density in m ^-3
        g_f = n_e / n_g
        return {"n_e": n_e, "dn_dt": dn_dt, "greenwald_fraction": g_f}

    @staticmethod
    @physics_method(
        columns=["sxr"],
        tokamak=Tokamak.MAST,
    )
    def get_sxr(params: PhysicsMethodParams):
        """
        Retrieve soft X-ray (SXR) data.

        Parameters
        ----------
        params : PhysicsMethodParams
            The parameters containing the Xarray connection, shot id and more.

        Returns
        -------
        dict
            A dictionary containing SXR data (`sxr_data`) and
            corresponding time points (`sxr_time`).
        """
        conn: XarrayConnection = params.mds_conn
        hcam = conn.get_data(
            params.shot_id, "soft_x_rays/horizontal_cam_upper", return_xarray=True
        )

        if hcam is not None:
            hcam = hcam.isel(horizontal_cam_upper_channel=7)
            hcam = hcam.squeeze(drop=True)
            hcam = hcam.drop_vars(["horizontal_cam_upper_channel"])
            sxr_time = hcam.time.values
            sxr_data = hcam.values
        else:
            sxr_time = np.array([np.nan])
            sxr_data = np.array([np.nan])

        times = params.times
        sxr_data = MastUtilMethods.interpolate_1d(sxr_time, sxr_data, times)
        return {"sxr": sxr_data}

    @staticmethod
    @physics_method(
        columns=["d_alpha"],
        tokamak=Tokamak.MAST,
    )
    def get_dalpha(params: PhysicsMethodParams):
        """
        Retrieve D-alpha signal data.

        Parameters
        ----------
        params : PhysicsMethodParams
            The parameters containing the Xarray connection, shot id and more.

        Returns
        -------
        dict
            A dictionary containing D-alpha signal data (`dalpha`).
        """
        conn: XarrayConnection = params.mds_conn

        dalpha = conn.get_data(
            params.shot_id,
            "spectrometer_visible/filter_spectrometer_dalpha_voltage",
            return_xarray=True,
        )

        if dalpha is not None:
            dalpha = dalpha.isel(dalpha_channel=2)
            dalpha = dalpha.dropna(dim="time")
            dalpha = dalpha.squeeze(drop=True)
            dalpha = dalpha.drop_vars("dalpha_channel")

            dalpha_time = dalpha.time.values
            dalpha_data = dalpha.values
        else:
            dalpha_time = np.array([np.nan])
            dalpha_data = np.array([np.nan])

        times = params.times
        dalpha_data = MastUtilMethods.interpolate_1d(dalpha_time, dalpha_data, times)
        return {"d_alpha": dalpha_data}

get_dalpha staticmethod ¤

get_dalpha(params: PhysicsMethodParams)

Retrieve D-alpha signal data.

PARAMETER DESCRIPTION
params

The parameters containing the Xarray connection, shot id and more.

TYPE: PhysicsMethodParams

RETURNS DESCRIPTION
dict

A dictionary containing D-alpha signal data (dalpha).

Source code in disruption_py/machine/mast/physics.py
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
@staticmethod
@physics_method(
    columns=["d_alpha"],
    tokamak=Tokamak.MAST,
)
def get_dalpha(params: PhysicsMethodParams):
    """
    Retrieve D-alpha signal data.

    Parameters
    ----------
    params : PhysicsMethodParams
        The parameters containing the Xarray connection, shot id and more.

    Returns
    -------
    dict
        A dictionary containing D-alpha signal data (`dalpha`).
    """
    conn: XarrayConnection = params.mds_conn

    dalpha = conn.get_data(
        params.shot_id,
        "spectrometer_visible/filter_spectrometer_dalpha_voltage",
        return_xarray=True,
    )

    if dalpha is not None:
        dalpha = dalpha.isel(dalpha_channel=2)
        dalpha = dalpha.dropna(dim="time")
        dalpha = dalpha.squeeze(drop=True)
        dalpha = dalpha.drop_vars("dalpha_channel")

        dalpha_time = dalpha.time.values
        dalpha_data = dalpha.values
    else:
        dalpha_time = np.array([np.nan])
        dalpha_data = np.array([np.nan])

    times = params.times
    dalpha_data = MastUtilMethods.interpolate_1d(dalpha_time, dalpha_data, times)
    return {"d_alpha": dalpha_data}

get_densities staticmethod ¤

get_densities(params: PhysicsMethodParams)

Calculate electron density, its time derivative, and the Greenwald fraction.

The Greenwald fraction is the ratio of the measured electron density \(n_e\) and the Greenwald density limit \(n_G\) defined as 1:

\[ n_G = \frac{I_p}{\pi a^2} \]

where \(n_G\) is given in \(10^{20} m^{-3}\) and \(I_p\) is in MA.

PARAMETER DESCRIPTION
params

The parameters containing the Xarray connection, shot id and more.

TYPE: PhysicsMethodParams

RETURNS DESCRIPTION
dict

A dictionary containing electron density (n_e), its gradient (dn_dt), and the Greenwald fraction (greenwald_fraction).

Source code in disruption_py/machine/mast/physics.py
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
@staticmethod
@physics_method(
    columns=["n_e", "dn_dt", "greenwald_fraction"],
    tokamak=Tokamak.MAST,
)
def get_densities(params: PhysicsMethodParams):
    r"""
    Calculate electron density, its time derivative, and the Greenwald fraction.

    The Greenwald fraction is the ratio of the measured electron density $n_e$ and
    the Greenwald density limit $n_G$ defined as [^1]:

    $$
    n_G = \frac{I_p}{\pi a^2}
    $$

    where $n_G$ is given in $10^{20} m^{-3}$ and $I_p$ is in MA.

    [^1]: https://wiki.fusion.ciemat.es/wiki/Greenwald_limit

    Parameters
    ----------
    params : PhysicsMethodParams
        The parameters containing the Xarray connection, shot id and more.

    Returns
    -------
    dict
        A dictionary containing electron density (`n_e`), its gradient (`dn_dt`),
        and the Greenwald fraction (`greenwald_fraction`).

    """

    conn: XarrayConnection = params.mds_conn
    n_e = conn.get_data(params.shot_id, "summary/line_average_n_e")
    t_n = conn.get_data(params.shot_id, "summary/time")
    ip = conn.get_data(params.shot_id, "summary/ip")
    t_ip = conn.get_data(params.shot_id, "summary/time")
    a_minor = conn.get_data(params.shot_id, "equilibrium/minor_radius")
    t_a = conn.get_data(params.shot_id, "equilibrium/time")

    return MastPhysicsMethods._get_densities(
        params.times, n_e, t_n, ip, t_ip, a_minor, t_a
    )

get_gas staticmethod ¤

get_gas(params: PhysicsMethodParams)

Get gas injection parameters

PARAMETER DESCRIPTION
params

The parameters containing the Xarray connection, shot id and more.

TYPE: PhysicsMethodParams

RETURNS DESCRIPTION
dict

A dictionary containing total injected gas (total_injected), inboard total gas (inboard_total), and outboard total gas (outboard_total).

Source code in disruption_py/machine/mast/physics.py
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
@staticmethod
@physics_method(
    columns=["gas_total_injected", "gas_inboard_total", "gas_outboard_total"],
    tokamak=Tokamak.MAST,
)
def get_gas(params: PhysicsMethodParams):
    """Get gas injection parameters

    Parameters
    ----------
    params : PhysicsMethodParams
        The parameters containing the Xarray connection, shot id and more.

    Returns
    -------
    dict
        A dictionary containing total injected gas (`total_injected`),
        inboard total gas (`inboard_total`), and outboard total gas (`outboard_total`).
    """
    conn: XarrayConnection = params.mds_conn

    total_injected = conn.get_data(params.shot_id, "gas_injection/total_injected")
    inboard_total = conn.get_data(params.shot_id, "gas_injection/inboard_total")
    outboard_total = conn.get_data(params.shot_id, "gas_injection/outboard_total")
    base_time = conn.get_data(params.shot_id, "gas_injection/time")

    times = params.times
    total_injected = MastUtilMethods.interpolate_1d(
        base_time, total_injected, times
    )
    inboard_total = MastUtilMethods.interpolate_1d(base_time, inboard_total, times)
    outboard_total = MastUtilMethods.interpolate_1d(
        base_time, outboard_total, times
    )
    return {
        "gas_total_injected": total_injected,
        "gas_inboard_total": inboard_total,
        "gas_outboard_total": outboard_total,
    }

get_ip_parameters staticmethod ¤

get_ip_parameters(params: PhysicsMethodParams)

Get Ip parameters

PARAMETER DESCRIPTION
params

The parameters containing the Xarray connection, shot id and more.

TYPE: PhysicsMethodParams

RETURNS DESCRIPTION
dict

A dictionary containing plasma current (ip), its time derivative (dip_dt), programmed plasma current (ip_prog), and its time derivative (dipprog_dt).

Source code in disruption_py/machine/mast/physics.py
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
@staticmethod
@cache_method
@physics_method(
    columns=["ip", "dip_dt", "ip_prog", "dipprog_dt"],
    tokamak=Tokamak.MAST,
)
def get_ip_parameters(params: PhysicsMethodParams):
    """Get Ip parameters

    Parameters
    ----------
    params : PhysicsMethodParams
        The parameters containing the Xarray connection, shot id and more.

    Returns
    -------
    dict
        A dictionary containing plasma current (`ip`), its time derivative (`dip_dt`),
        programmed plasma current (`ip_prog`), and its time derivative (`dipprog_dt`).
    """
    conn: XarrayConnection = params.mds_conn
    ip = conn.get_data(params.shot_id, "summary/ip")
    ip_prog = conn.get_data(params.shot_id, "pulse_schedule/i_plasma")
    ip_prog_time = conn.get_data(params.shot_id, "pulse_schedule/time")
    magtime = conn.get_data(params.shot_id, "summary/time")

    dip_dt = np.gradient(ip, magtime)
    dipprog_dt = np.gradient(ip_prog, ip_prog_time)

    times = params.times

    ip = MastUtilMethods.interpolate_1d(magtime, ip, times)
    ip_prog = MastUtilMethods.interpolate_1d(ip_prog_time, ip_prog, times)
    dip_dt = MastUtilMethods.interpolate_1d(magtime, dip_dt, times)
    dipprog_dt = MastUtilMethods.interpolate_1d(ip_prog_time, dipprog_dt, times)

    return {
        "ip": ip,
        "dip_dt": dip_dt,
        "ip_prog": ip_prog,
        "dipprog_dt": dipprog_dt,
    }

get_power staticmethod ¤

get_power(params: PhysicsMethodParams)

Get power parameters

PARAMETER DESCRIPTION
params

The parameters containing the Xarray connection, shot id and more.

TYPE: PhysicsMethodParams

RETURNS DESCRIPTION
dict

A dictionary containing neutral beam injection power (power_nbi) and radiated power (power_radiated).

Source code in disruption_py/machine/mast/physics.py
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
@staticmethod
@physics_method(
    columns=["p_nbi", "p_rad"],
    tokamak=Tokamak.MAST,
)
def get_power(params: PhysicsMethodParams):
    """Get power parameters

    Parameters
    ----------
    params : PhysicsMethodParams
        The parameters containing the Xarray connection, shot id and more.

    Returns
    -------
    dict
        A dictionary containing neutral beam injection power (`power_nbi`) and
        radiated power (`power_radiated`).
    """
    conn: XarrayConnection = params.mds_conn

    power_nbi = conn.get_data(params.shot_id, "summary/power_nbi")
    power_radiated = conn.get_data(params.shot_id, "summary/power_radiated")
    base_time = conn.get_data(params.shot_id, "summary/time")

    times = params.times
    power_nbi = MastUtilMethods.interpolate_1d(base_time, power_nbi, times)
    power_radiated = MastUtilMethods.interpolate_1d(
        base_time, power_radiated, times
    )
    return {"p_nbi": power_nbi, "p_rad": power_radiated}

get_sxr staticmethod ¤

get_sxr(params: PhysicsMethodParams)

Retrieve soft X-ray (SXR) data.

PARAMETER DESCRIPTION
params

The parameters containing the Xarray connection, shot id and more.

TYPE: PhysicsMethodParams

RETURNS DESCRIPTION
dict

A dictionary containing SXR data (sxr_data) and corresponding time points (sxr_time).

Source code in disruption_py/machine/mast/physics.py
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
@staticmethod
@physics_method(
    columns=["sxr"],
    tokamak=Tokamak.MAST,
)
def get_sxr(params: PhysicsMethodParams):
    """
    Retrieve soft X-ray (SXR) data.

    Parameters
    ----------
    params : PhysicsMethodParams
        The parameters containing the Xarray connection, shot id and more.

    Returns
    -------
    dict
        A dictionary containing SXR data (`sxr_data`) and
        corresponding time points (`sxr_time`).
    """
    conn: XarrayConnection = params.mds_conn
    hcam = conn.get_data(
        params.shot_id, "soft_x_rays/horizontal_cam_upper", return_xarray=True
    )

    if hcam is not None:
        hcam = hcam.isel(horizontal_cam_upper_channel=7)
        hcam = hcam.squeeze(drop=True)
        hcam = hcam.drop_vars(["horizontal_cam_upper_channel"])
        sxr_time = hcam.time.values
        sxr_data = hcam.values
    else:
        sxr_time = np.array([np.nan])
        sxr_data = np.array([np.nan])

    times = params.times
    sxr_data = MastUtilMethods.interpolate_1d(sxr_time, sxr_data, times)
    return {"sxr": sxr_data}

get_ts_parameters staticmethod ¤

get_ts_parameters(params: PhysicsMethodParams)

Get Thomson parameters

PARAMETER DESCRIPTION
params

The parameters containing the Xarray connection, shot id and more.

TYPE: PhysicsMethodParams

RETURNS DESCRIPTION
dict

A dictionary containing core electron temperature (t_e_core) and core electron density (n_e_core).

Source code in disruption_py/machine/mast/physics.py
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
@staticmethod
@physics_method(
    columns=["t_e_core", "n_e_core"],
    tokamak=Tokamak.MAST,
)
def get_ts_parameters(params: PhysicsMethodParams):
    """Get Thomson parameters

    Parameters
    ----------
    params : PhysicsMethodParams
        The parameters containing the Xarray connection, shot id and more.

    Returns
    -------
    dict
        A dictionary containing core electron temperature (`t_e_core`) and
        core electron density (`n_e_core`).
    """
    times = params.times
    conn: XarrayConnection = params.mds_conn

    t_e_core = conn.get_data(params.shot_id, "thomson_scattering/t_e_core")
    n_e_core = conn.get_data(params.shot_id, "thomson_scattering/n_e_core")
    base_time = conn.get_data(params.shot_id, "thomson_scattering/time")

    t_e_core = MastUtilMethods.interpolate_1d(base_time, t_e_core, times)
    n_e_core = MastUtilMethods.interpolate_1d(base_time, n_e_core, times)
    return {"t_e_core": t_e_core, "n_e_core": n_e_core}