1# Licensed under a 3-clause BSD style license - see LICENSE.rst 2""" 3Here are all the test parameters and values for the each 4`~astropy.modeling.FittableModel` defined. There is a dictionary for 1D and a 5dictionary for 2D models. 6 7Explanation of keywords of the dictionaries: 8 9"parameters" : list or dict 10 Model parameters, the model is tested with. Make sure you keep the right 11 order. For polynomials you can also use a dict to specify the 12 coefficients. See examples below. 13 14"x_values" : list 15 x values where the model is evaluated. 16 17"y_values" : list 18 Reference y values for the in x_values given positions. 19 20"z_values" : list 21 Reference z values for the in x_values and y_values given positions. 22 (2D model option) 23 24"x_lim" : list 25 x test range for the model fitter. Depending on the model this can differ 26 e.g. the PowerLaw model should be tested over a few magnitudes. 27 28"y_lim" : list 29 y test range for the model fitter. Depending on the model this can differ 30 e.g. the PowerLaw model should be tested over a few magnitudes. (2D model 31 option) 32 33"log_fit" : bool 34 PowerLaw models should be tested over a few magnitudes. So log_fit should 35 be true. 36 37"requires_scipy" : bool 38 If a model requires scipy (Bessel functions etc.) set this flag. 39 40"integral" : float 41 Approximate value of the integral in the range x_lim (and y_lim). 42 43"deriv_parameters" : list 44 If given the test of the derivative will use these parameters to create a 45 model (optional) 46 47"deriv_initial" : list 48 If given the test of the derivative will use these parameters as initial 49 values for the fit (optional) 50""" 51 52 53from astropy.modeling.functional_models import ( 54 Gaussian1D, 55 Sine1D, Cosine1D, Tangent1D, ArcSine1D, ArcCosine1D, ArcTangent1D, 56 Box1D, Linear1D, Lorentz1D, 57 RickerWavelet1D, Trapezoid1D, Const1D, Moffat1D, 58 Gaussian2D, Const2D, Box2D, RickerWavelet2D, 59 TrapezoidDisk2D, AiryDisk2D, Moffat2D, Disk2D, 60 Ring2D, Sersic1D, Sersic2D, Voigt1D, Planar2D, KingProjectedAnalytic1D, 61 Exponential1D, Logarithmic1D) 62from astropy.modeling.physical_models import Drude1D, Plummer1D 63from astropy.modeling.polynomial import Polynomial1D, Polynomial2D 64from astropy.modeling.powerlaws import ( 65 PowerLaw1D, BrokenPowerLaw1D, SmoothlyBrokenPowerLaw1D, ExponentialCutoffPowerLaw1D, 66 LogParabola1D) 67import numpy as np 68 69# 1D Models 70models_1D = { 71 Gaussian1D: { 72 'parameters': [1, 0, 1], 73 'x_values': [0, np.sqrt(2), -np.sqrt(2)], 74 'y_values': [1.0, 0.367879, 0.367879], 75 'x_lim': [-10, 10], 76 'integral': np.sqrt(2 * np.pi), 77 'bbox_peak': True 78 }, 79 80 Sine1D: { 81 'parameters': [1, 0.1, 0], 82 'x_values': [0, 2.5], 83 'y_values': [0, 1], 84 'x_lim': [-10, 10], 85 'integral': 0 86 }, 87 88 Cosine1D: { 89 'parameters': [1, 0.1, 0], 90 'x_values': [0, 2.5], 91 'y_values': [1, 0], 92 'x_lim': [-10, 10], 93 'integral': 0 94 }, 95 96 Tangent1D: { 97 'parameters': [1, 0.1, 0], 98 'x_values': [0, 1.25], 99 'y_values': [0, 1], 100 'x_lim': [-10, 10], 101 'integral': 0 102 }, 103 104 ArcSine1D: { 105 'parameters': [1, 0.1, 0], 106 'x_values': [0, 1], 107 'y_values': [0, 2.5], 108 'x_lim': [-0.5, 0.5], 109 'integral': 0 110 }, 111 112 ArcCosine1D: { 113 'parameters': [1, 0.1, 0], 114 'x_values': [1, 0], 115 'y_values': [0, 2.5], 116 'x_lim': [-0.5, 0.5], 117 'integral': 0 118 }, 119 120 ArcTangent1D: { 121 'parameters': [1, 0.1, 0], 122 'x_values': [0, 1], 123 'y_values': [0, 1.25], 124 'x_lim': [-10, 10], 125 'integral': 0 126 }, 127 128 Box1D: { 129 'parameters': [1, 0, 10], 130 'x_values': [-5, 5, 0, -10, 10], 131 'y_values': [1, 1, 1, 0, 0], 132 'x_lim': [-10, 10], 133 'integral': 10, 134 'bbox_peak': True 135 }, 136 137 Linear1D: { 138 'parameters': [1, 0], 139 'x_values': [0, np.pi, 42, -1], 140 'y_values': [0, np.pi, 42, -1], 141 'x_lim': [-10, 10], 142 'integral': 0 143 }, 144 145 Lorentz1D: { 146 'parameters': [1, 0, 1], 147 'x_values': [0, -1, 1, 0.5, -0.5], 148 'y_values': [1., 0.2, 0.2, 0.5, 0.5], 149 'x_lim': [-10, 10], 150 'integral': 1, 151 'bbox_peak': True 152 }, 153 154 RickerWavelet1D: { 155 'parameters': [1, 0, 1], 156 'x_values': [0, 1, -1, 3, -3], 157 'y_values': [1.0, 0.0, 0.0, -0.088872, -0.088872], 158 'x_lim': [-20, 20], 159 'integral': 0, 160 'bbox_peak': True 161 }, 162 163 Trapezoid1D: { 164 'parameters': [1, 0, 2, 1], 165 'x_values': [0, 1, -1, 1.5, -1.5, 2, 2], 166 'y_values': [1, 1, 1, 0.5, 0.5, 0, 0], 167 'x_lim': [-10, 10], 168 'integral': 3, 169 'bbox_peak': True 170 }, 171 172 Const1D: { 173 'parameters': [1], 174 'x_values': [-1, 1, np.pi, -42., 0], 175 'y_values': [1, 1, 1, 1, 1], 176 'x_lim': [-10, 10], 177 'integral': 20 178 }, 179 180 Moffat1D: { 181 'parameters': [1, 0, 1, 2], 182 'x_values': [0, 1, -1, 3, -3], 183 'y_values': [1.0, 0.25, 0.25, 0.01, 0.01], 184 'x_lim': [-10, 10], 185 'integral': 1, 186 'deriv_parameters': [23.4, 1.2, 2.1, 2.3], 187 'deriv_initial': [10, 1, 1, 1] 188 }, 189 190 PowerLaw1D: { 191 'parameters': [1, 1, 2], 192 'constraints': {'fixed': {'x_0': True}}, 193 'x_values': [1, 10, 100], 194 'y_values': [1.0, 0.01, 0.0001], 195 'x_lim': [1, 10], 196 'log_fit': True, 197 'integral': 0.99 198 }, 199 200 BrokenPowerLaw1D: { 201 'parameters': [1, 1, 2, 3], 202 'constraints': {'fixed': {'x_break': True}}, 203 'x_values': [0.1, 1, 10, 100], 204 'y_values': [1e2, 1.0, 1e-3, 1e-6], 205 'x_lim': [0.1, 100], 206 'log_fit': True 207 }, 208 209 SmoothlyBrokenPowerLaw1D: { 210 'parameters': [1, 1, -2, 2, 0.5], 211 'constraints': {'fixed': {'x_break': True, 'delta': True}}, 212 'x_values': [0.01, 1, 100], 213 'y_values': [3.99920012e-04, 1.0, 3.99920012e-04], 214 'x_lim': [0.01, 100], 215 'log_fit': True 216 }, 217 218 ExponentialCutoffPowerLaw1D: { 219 'parameters': [1, 1, 2, 3], 220 'constraints': {'fixed': {'x_0': True}}, 221 'x_values': [0.1, 1, 10, 100], 222 'y_values': [9.67216100e+01, 7.16531311e-01, 3.56739933e-04, 223 3.33823780e-19], 224 'x_lim': [0.01, 100], 225 'log_fit': True 226 }, 227 228 LogParabola1D: { 229 'parameters': [1, 2, 3, 0.1], 230 'constraints': {'fixed': {'x_0': True}}, 231 'x_values': [0.1, 1, 10, 100], 232 'y_values': [3.26089063e+03, 7.62472488e+00, 6.17440488e-03, 233 1.73160572e-06], 234 'x_lim': [0.1, 100], 235 'log_fit': True 236 }, 237 238 Polynomial1D: { 239 'parameters': {'degree': 2, 'c0': 1., 'c1': 1., 'c2': 1.}, 240 'x_values': [1, 10, 100], 241 'y_values': [3, 111, 10101], 242 'x_lim': [-3, 3] 243 }, 244 245 Sersic1D: { 246 'parameters': [1, 20, 4], 247 'x_values': [0.1, 1, 10, 100], 248 'y_values': [2.78629391e+02, 5.69791430e+01, 3.38788244e+00, 249 2.23941982e-02], 250 'requires_scipy': True, 251 'x_lim': [0, 10], 252 'log_fit': True 253 }, 254 255 Voigt1D: { 256 'parameters': [0, 1, 0.5, 0.9], 257 'x_values': [0, 0.2, 0.5, 1, 2, 4, 8, 20], 258 'y_values': [0.52092360, 0.479697445, 0.317550374, 0.0988079347, 259 1.73876624e-2, 4.00173216e-3, 9.82351731e-4, 1.56396993e-4], 260 'x_lim': [-3, 3] 261 }, 262 263 KingProjectedAnalytic1D: { 264 'parameters': [1, 1, 2], 265 'x_values': [0, 0.1, 0.5, 0.8], 266 'y_values': [0.30557281, 0.30011069, 0.2, 0.1113258], 267 'x_lim': [0, 10], 268 'y_lim': [0, 10], 269 'bbox_peak': True 270 }, 271 272 Drude1D: { 273 'parameters': [1.0, 8.0, 1.0], 274 'x_values': [7.0, 8.0, 9.0, 10.0], 275 'y_values': [0.17883212, 1.0, 0.21891892, 0.07163324], 276 'x_lim': [1.0, 20.0], 277 'y_lim': [0.0, 10.0], 278 'bbox_peak': True 279 }, 280 281 Plummer1D: { 282 'parameters': [10., 0.5], 283 'x_values': [1.0000e-03, 2.5005e+00, 5.0000e+00], 284 'y_values': [1.90984022e+01, 5.53541843e-03, 1.86293603e-04], 285 'x_lim': [0.001, 100] 286 }, 287 288 Exponential1D: { 289 'parameters': [1, 1], 290 'x_values': [0, 0.5, 1], 291 'y_values': [1, np.sqrt(np.e), np.e], 292 'x_lim': [0, 2], 293 'integral': (np.e**2 - 1.), 294 }, 295 296 Logarithmic1D: { 297 'parameters': [1, 1], 298 'x_values': [1, np.e, np.e**2], 299 'y_values': [0, 1, 2], 300 'x_lim': [1, np.e**2], 301 'integral': (np.e**2 + 1), 302 } 303} 304 305 306# 2D Models 307models_2D = { 308 Gaussian2D: { 309 'parameters': [1, 0, 0, 1, 1], 310 'constraints': {'fixed': {'theta': True}}, 311 'x_values': [0, np.sqrt(2), -np.sqrt(2)], 312 'y_values': [0, np.sqrt(2), -np.sqrt(2)], 313 'z_values': [1, 1. / np.exp(1) ** 2, 1. / np.exp(1) ** 2], 314 'x_lim': [-10, 10], 315 'y_lim': [-10, 10], 316 'integral': 2 * np.pi, 317 'deriv_parameters': [137., 5.1, 5.4, 1.5, 2., np.pi/4], 318 'deriv_initial': [10, 5, 5, 4, 4, .5], 319 'bbox_peak': True 320 }, 321 322 Const2D: { 323 'parameters': [1], 324 'x_values': [-1, 1, np.pi, -42., 0], 325 'y_values': [0, 1, 42, np.pi, -1], 326 'z_values': [1, 1, 1, 1, 1], 327 'x_lim': [-10, 10], 328 'y_lim': [-10, 10], 329 'integral': 400 330 }, 331 332 Box2D: { 333 'parameters': [1, 0, 0, 10, 10], 334 'x_values': [-5, 5, -5, 5, 0, -10, 10], 335 'y_values': [-5, 5, 0, 0, 0, -10, 10], 336 'z_values': [1, 1, 1, 1, 1, 0, 0], 337 'x_lim': [-10, 10], 338 'y_lim': [-10, 10], 339 'integral': 100, 340 'bbox_peak': True 341 }, 342 343 RickerWavelet2D: { 344 'parameters': [1, 0, 0, 1], 345 'x_values': [0, 0, 0, 0, 0, 1, -1, 3, -3], 346 'y_values': [0, 1, -1, 3, -3, 0, 0, 0, 0], 347 'z_values': [1.0, 0.303265, 0.303265, -0.038881, -0.038881, 348 0.303265, 0.303265, -0.038881, -0.038881], 349 'x_lim': [-10, 11], 350 'y_lim': [-10, 11], 351 'integral': 0 352 }, 353 354 TrapezoidDisk2D: { 355 'parameters': [1, 0, 0, 1, 1], 356 'x_values': [0, 0.5, 0, 1.5], 357 'y_values': [0, 0.5, 1.5, 0], 358 'z_values': [1, 1, 0.5, 0.5], 359 'x_lim': [-3, 3], 360 'y_lim': [-3, 3], 361 'bbox_peak': True 362 }, 363 364 AiryDisk2D: { 365 'parameters': [7, 0, 0, 10], 366 'x_values': [0, 1, -1, -0.5, -0.5], 367 'y_values': [0, -1, 0.5, 0.5, -0.5], 368 'z_values': [7., 6.50158267, 6.68490643, 6.87251093, 6.87251093], 369 'x_lim': [-10, 10], 370 'y_lim': [-10, 10], 371 'requires_scipy': True 372 }, 373 374 Moffat2D: { 375 'parameters': [1, 0, 0, 1, 2], 376 'x_values': [0, 1, -1, 3, -3], 377 'y_values': [0, -1, 3, 1, -3], 378 'z_values': [1.0, 0.111111, 0.008264, 0.008264, 0.00277], 379 'x_lim': [-3, 3], 380 'y_lim': [-3, 3] 381 }, 382 383 Polynomial2D: { 384 'parameters': {'degree': 1, 'c0_0': 1., 'c1_0': 1., 'c0_1': 1.}, 385 'x_values': [1, 2, 3], 386 'y_values': [1, 3, 2], 387 'z_values': [3, 6, 6], 388 'x_lim': [1, 100], 389 'y_lim': [1, 100] 390 }, 391 392 Disk2D: { 393 'parameters': [1, 0, 0, 5], 394 'x_values': [-5, 5, -5, 5, 0, -10, 10], 395 'y_values': [-5, 5, 0, 0, 0, -10, 10], 396 'z_values': [0, 0, 1, 1, 1, 0, 0], 397 'x_lim': [-10, 10], 398 'y_lim': [-10, 10], 399 'integral': np.pi * 5 ** 2, 400 'bbox_peak': True 401 }, 402 403 Ring2D: { 404 'parameters': [1, 0, 0, 5, 5], 405 'x_values': [-5, 5, -5, 5, 0, -10, 10], 406 'y_values': [-5, 5, 0, 0, 0, -10, 10], 407 'z_values': [1, 1, 1, 1, 0, 0, 0], 408 'x_lim': [-10, 10], 409 'y_lim': [-10, 10], 410 'integral': np.pi * (10 ** 2 - 5 ** 2), 411 'bbox_peak': True 412 }, 413 414 Sersic2D: { 415 'parameters': [1, 25, 4, 50, 50, 0.5, -1], 416 'x_values': [0.0, 1, 10, 100], 417 'y_values': [1, 100, 0.0, 10], 418 'z_values': [1.686398e-02, 9.095221e-02, 2.341879e-02, 9.419231e-02], 419 'requires_scipy': True, 420 'x_lim': [1, 1e10], 421 'y_lim': [1, 1e10] 422 }, 423 424 Planar2D: { 425 'parameters': [1, 1, 0], 426 'x_values': [0, np.pi, 42, -1], 427 'y_values': [np.pi, 0, -1, 42], 428 'z_values': [np.pi, np.pi, 41, 41], 429 'x_lim': [-10, 10], 430 'y_lim': [-10, 10], 431 'integral': 0 432 } 433} 434