dataset
¶
Classes:
-
EQDataset–Dataset for equilibrium equation solutions.
Functions:
-
read_and_interpolate_solutions–Read a pickle file containing ODE solutions and interpolate them at given
EQDataset
¶
EQDataset(data_path: Path, radial_res: int = 100, uniform_sampling: bool = False, rfp_only: bool = False, keep_rfp_flag: bool = False)
Dataset for equilibrium equation solutions.
Parameters:
-
(data_path¶Path) –Path to the directory containing the dataset
.pklfiles. -
(radial_res¶int, default:100) –Number of radial points to interpolate the solutions at. Each equilibrium will be represented on this radial grid, by default 100.
-
(uniform_sampling¶bool, default:False) –If True, sample the radial points uniformly at random in
[RMIN/2, RMAX]. If False, use a fixed linearly spaced grid in the same interval, by default False. -
(rfp_only¶bool, default:False) –If True, restrict the dataset to rows corresponding to RFP equilibria only (
rfp_flag == 1.0). If False, keep all rows, by default False. -
(keep_rfp_flag¶bool, default:False) –If True, keep the
rfp_flagcolumn as the last feature in the internal data array. This is mainly intended for debugging, since models do not use this flag as input. If False, the column is removed, by default False.
Methods:
-
__getitem__–Get the radial grid, input parameters, and solution profile for a given
-
__len__–Return the length of the dataset.
-
get_data–Get the dataset as input–target pairs.
-
inverse_transform_inputs–Inverse transform the input features from model space back to the
-
transform_inputs–Transform the input features to be fed to the model.
Source code in src/fpga_profile_reco/data/dataset.py
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 | |
__getitem__
¶
__getitem__(idx: int) -> Tuple[ndarray, ndarray, ndarray]
Get the radial grid, input parameters, and solution profile for a given equilibrium (set of parameters).
The dataset is internally stored as a flattened array where each
equilibrium corresponds to radial_res consecutive rows.
Parameters:
-
(idx¶int) –Index of the equilibrium to retrieve in the range
[0, len(self) // radial_res).
Returns:
-
r(ndarray) –One-dimensional array of shape
(radial_res,)containing the radial grid points. -
params(ndarray) –One-dimensional array of shape
(4,)containing the input parameters[alpha, theta_0, delta_h, delta_a]for this equilibrium. -
solution(ndarray) –Two-dimensional array of shape
(radial_res, n_solution_vars)containing the solution variables evaluated on the radial grid.
Source code in src/fpga_profile_reco/data/dataset.py
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 | |
__len__
¶
__len__()
Return the length of the dataset.
Returns:
-
int–Number of rows in the internal data array. This is equal to
n_equilibria * radial_res.
Source code in src/fpga_profile_reco/data/dataset.py
216 217 218 219 220 221 222 223 224 225 226 | |
get_data
¶
get_data(scale_data: bool = True) -> Tuple[ndarray, ndarray]
Get the dataset as input–target pairs.
Parameters:
-
(scale_data¶bool, default:True) –If True, return inputs with the first four features normalized using :meth:
transform_inputs. If False, return raw inputs. Defaults to True.
Returns:
-
inputs(ndarray) –Array of shape
(n_samples, 5)containing the input features[r, alpha, theta_0, delta_h, delta_a]. -
targets(ndarray) –Array of shape
(n_samples, n_solution_vars)containing the solution variables at the corresponding radial points.
Source code in src/fpga_profile_reco/data/dataset.py
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 | |
inverse_transform_inputs
staticmethod
¶
inverse_transform_inputs(data: ndarray) -> ndarray
Inverse transform the input features from model space back to the original physical space.
This method performs an in-place inverse normalization of the first
four columns of data corresponding to [r, alpha, theta_0, delta_h].
Parameters:
-
(data¶ndarray) –Transformed input data of shape
(n_samples, n_features)in model (normalized) space. It is modified in place and also returned.
Returns:
-
ndarray–The same array
dataafter inverse transformation.
Source code in src/fpga_profile_reco/data/dataset.py
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 | |
transform_inputs
staticmethod
¶
transform_inputs(data: ndarray) -> ndarray
Transform the input features to be fed to the model.
This method performs an in-place normalization of the first four
columns of data corresponding to [r, alpha, theta_0, delta_h].
Parameters:
-
(data¶ndarray) –Raw input data of shape
(n_samples, n_features). It is modified in place and also returned.
Returns:
-
ndarray–The same array
dataafter transformation.
Source code in src/fpga_profile_reco/data/dataset.py
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 | |
read_and_interpolate_solutions
¶
Read a pickle file containing ODE solutions and interpolate them at given radial points.
Parameters:
-
(file¶Path) –Path to the pickle file containing a batch of samples.
-
(r¶ndarray) –One-dimensional array of radial points at which to interpolate the solutions, of shape
(radial_res,).
Returns:
-
ndarray–Interpolated data array of shape
(n_samples * radial_res, n_features)for this file, where each block ofradial_resrows corresponds to one equilibrium.
Source code in src/fpga_profile_reco/data/dataset.py
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 | |