MCFOST API
Various functions to make the communication between xenomorph and MCFOST a bit easier. These are broadly written with running on a HPC-cluster in mind.
filter_bandpasses(filter)
WIP - Filter bandpasses (H,K,L,M) are available at https://irtfweb.ifa.hawaii.edu/~nsfcam2/Filter_Profiles.html
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filter
|
str
|
One of {'H', 'K', 'L', 'M'} corresponding to the filter bandpass wanted. The 'J' band is omitted as it usually can't pick up dust formation. |
required |
Returns:
Name | Type | Description |
---|---|---|
bandpass |
dict
|
A dictionary where the keys are the wavelength samples and the vals are the transmittances at that wavelength |
Source code in xenomorph\mcfost.py
50 51 52 53 54 55 56 57 58 59 60 61 62 |
|
generate_lightcurve(stardata, wavelength, method='equal', n_samples=20, shells=1, n_t=600, n_points=200, photons=20000000.0, T_photons=10000000.0, gas_2_dust=100, resolution=30, root_dir='', cpus=8, run_hours=2, memory=4, job_name='mcfost-lightcurve', email='', mcfost_setup='~/setup_mcfost')
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stardata
|
dict
|
The system parameter file. |
required |
wavelength
|
int or float, or str or dict
|
The wavelength (in microns) that you'd like to generate the image for. If wavelength is a str type, it will be interpreted as one of the pre-defined filters {'H', 'K', 'L', 'M'} and representative samples will be generated from that filter. If wavelength is a dict, it will be as for the str case, but for user-defined wavelengths. |
required |
method
|
str or j / array
|
This parameter dictates how the time samples across orbital phase are distributed. If method=='equal', there will be n_samples equally spaced samples across orbital phase 0 to 1 to construct the light curve. If method=='periastron_dense', there will be proportionally more samples around periastron (when there is active dust production). If method is a j/np array, the values of the one-dimensional array will be used as the phase samples. |
'equal'
|
n_samples
|
int
|
The number of orbital phase samples with which to construct the light curve. This is only relevant if the |
20
|
shells
|
int
|
The number of shells to generate. |
1
|
n_t
|
int
|
The number of rings to generate in each shell. |
600
|
n_points
|
int
|
The number of points to generate in each ring. |
200
|
photons
|
int
|
The number of photons to use in the imaging computation. |
20000000.0
|
T_photons
|
int
|
The number of photons to use in the T computation |
10000000.0
|
gas_2_dust
|
float
|
The mass of gas relative to the dust in each particle |
100
|
resolution
|
int
|
The number of pixels (per side) for the geometric comparison image. |
30
|
root_dir
|
str
|
The directory where you'd like the output of the job to be. |
''
|
cpus
|
int
|
The number of CPUs you'd like to allocate to running this MCFOST job. A power of 2 is usually good. |
8
|
run_hours
|
int
|
How many (wall-time) hours you'd like to set the job to run before the scheduling system cancels it. |
2
|
memory
|
float or int
|
The amount of memory (in GB) to allocate to the job. In my experience they typically use of order a few hundred MB, so setting 1-4GB is usually safe. |
4
|
job_name
|
str
|
A name for the job (only visible on the HPC queue system). |
'mcfost-lightcurve'
|
email
|
str
|
The email of the user, should they want email updates on how the job is doing. Mine by default :) |
''
|
mcfost_setup
|
str
|
The location (and name) of the mcfost_setup file. This file is meant to be read each time an MCFOST job is run on a HPC.
A typical ~/setup_mcfost file will look like:
export PATH=/ |
'~/setup_mcfost'
|
Source code in xenomorph\mcfost.py
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 |
|
generate_para(stardata, paraname, density_file, photons=10000000.0, T_photons=10000000.0, resolution=600, gas_2_dust=100, root_dir='')
WIP -- Generates a .para file to be used in the MCFOST run. Note: - The dust mass must be set at run time (through the density_file provided) Assumes: - Amorphous carbon dust - Each star is effectively right in the centre of the dust cloud (well within 5au of the centre) Todo: - specify the grain distribution in of the dust
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stardata
|
dict
|
The system parameter file. |
required |
paraname
|
str
|
The name that you'd like to give to this parameter file. A '.para' is automatically appended to the end of this input. |
required |
density_file
|
str
|
The name of the .fits file generated by |
required |
photons
|
int
|
The number of photons to use in the imaging computation. |
10000000.0
|
T_photons
|
int
|
The number of photons to use in the T computation |
10000000.0
|
resolution
|
int
|
The pixel side length of the computed image. |
600
|
gas_2_dust
|
float
|
The mass of gas relative to the dust in each particle |
100
|
root_dir
|
str
|
The directory where you'd like the output of the job to be. |
''
|
Source code in xenomorph\mcfost.py
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 |
|
generate_slurm(slurmname, wavelength, para_file, density_file, cpus=4, run_hours=4, memory=4, root_dir='', job_name='mcfost-transfer', email='ryan.white1@hdr.mq.edu.au', mcfost_setup='~/setup_mcfost')
Generates a slurm script to run a single radiative transfer calculation on a xenomorph-generated spiral. The script will generate the temperature profile of the (currently default-only) dust, and then image it and the specified wavelength.
Todo: - ?
Parameters:
Name | Type | Description | Default |
---|---|---|---|
slurmname
|
str
|
The name that you'd like to give to this slurm script. A '.q' is automatically appended to the end of this input. |
required |
wavelength
|
int or float, or str or dict
|
The wavelength (in microns) that you'd like to generate the image for. If wavelength is a str type, it will be interpreted as one of the pre-defined filters {'H', 'K', 'L', 'M'} and representative samples will be generated from that filter. If wavelength is a dict, it will be as for the str case, but for user-defined wavelengths. |
required |
para_file
|
str
|
The name of the MCFOST parameter file for the system. |
required |
density_file
|
str
|
The name of the .fits file generated by |
required |
cpus
|
int
|
The number of CPUs you'd like to allocate to running this MCFOST job. A power of 2 is usually good. |
4
|
run_hours
|
int
|
How many (wall-time) hours you'd like to set the job to run before the scheduling system cancels it. |
4
|
memory
|
float or int
|
The amount of memory (in GB) to allocate to the job. In my experience they typically use of order a few hundred MB, so setting 1-4GB is usually safe. |
4
|
root_dir
|
str
|
The directory where you'd like the output of the job to be. |
''
|
job_name
|
str
|
A name for the job (only visible on the HPC queue system). |
'mcfost-transfer'
|
email
|
str
|
The email of the user, should they want email updates on how the job is doing. Mine by default :) |
'ryan.white1@hdr.mq.edu.au'
|
mcfost_setup
|
str
|
The location (and name) of the mcfost_setup file. This file is meant to be read each time an MCFOST job is run on a HPC.
A typical ~/setup_mcfost file will look like:
export PATH=/ |
'~/setup_mcfost'
|
Source code in xenomorph\mcfost.py
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 |
|
integrate_flux(wavelength, folder)
Searches for MCFOST output files and calculates the integrated flux at a single wavelength or across a filter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wavelength
|
int or float, or str or dict
|
The wavelength (in microns) that you'd like to generate the image for. If wavelength is a str type, it will be interpreted as one of the pre-defined filters {'H', 'K', 'L', 'M'} and representative samples will be generated from that filter. If wavelength is a dict, it will be as for the str case, but for user-defined wavelengths. |
required |
folder
|
str
|
The location of the folder in which each of the MCFOST wavelength outputs are. For example, if the outputs were in f1 --f2 ----data_3.1 ------------RT.fits.gz ----data_3.2 ------------RT.fits.gz etc, this variable should be "f1/f2/" |
required |
Returns:
Name | Type | Description |
---|---|---|
integrated_flux |
float
|
The integrated flux in units of W/m^2 (or W/m^2/μm if wavelength is a single number) for that image. |
Source code in xenomorph\mcfost.py
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 |
|
lightcurve_grid(stardata, wavelength, parameter_grid, method='equal', n_samples=20, shells=1, n_t=600, n_points=200, photons=20000000.0, T_photons=10000000.0, gas_2_dust=100, resolution=30, root_dir='', cpus=8, run_hours=1, memory=2, job_name='mcfost-lightcurve', email='', mcfost_setup='~/setup_mcfost')
stardata : dict
The system parameter file.
wavelength : int or float, or str or dict
The wavelength (in microns) that you'd like to generate the image for.
If wavelength is a str type, it will be interpreted as one of the pre-defined filters {'H', 'K', 'L', 'M'} and representative samples will be generated from that filter.
If wavelength is a dict, it will be as for the str case, but for user-defined wavelengths.
parameter_grid : dict
A dictionary where each key corresponds to the parameter of stardata
being changed. The value for that key should be an array corresponding to the different values
which will be used to generate a light curve. Hence, there will be n_param1 * n_param2 * ... light curves generated from this.
method : str or j/np.array
This parameter dictates how the time samples across orbital phase are distributed. If method=='equal', there will be n_samples equally spaced samples across
orbital phase 0 to 1 to construct the light curve. If method=='periastron_dense', there will be proportionally more samples around periastron (when there
is active dust production). If method is a j/np array, the values of the one-dimensional array will be used as the phase samples.
n_samples : int
The number of orbital phase samples with which to construct the light curve. This is only relevant if the method
parameter is a string.
shells : int
The number of shells to generate.
n_t : int
The number of rings to generate in each shell.
n_points : int
The number of points to generate in each ring.
photons : int
The number of photons to use in the imaging computation.
T_photons : int
The number of photons to use in the T computation
gas_2_dust : float
The mass of gas relative to the dust in each particle
resolution : int
The number of pixels (per side) for the geometric comparison image.
root_dir : str
The directory where you'd like the output of the job to be.
cpus : int
The number of CPUs you'd like to allocate to running this MCFOST job. A power of 2 is usually good.
run_hours : int
How many (wall-time) hours you'd like to set the job to run before the scheduling system cancels it.
memory : float or int
The amount of memory (in GB) to allocate to the job.
In my experience they typically use of order a few hundred MB, so setting 1-4GB is usually safe.
job_name : str
A name for the job (only visible on the HPC queue system).
email : str
The email of the user, should they want email updates on how the job is doing. Mine by default :)
mcfost_setup : str
The location (and name) of the mcfost_setup file. This file is meant to be read each time an MCFOST job is run on a HPC.
A typical ~/setup_mcfost file will look like:
export PATH=/
Source code in xenomorph\mcfost.py
536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 |
|
lightcurve_plot(folder, wavelength, phases='equal')
Some help gotten from https://stackoverflow.com/questions/973473/getting-a-list-of-all-subdirectories-in-the-current-directory Todo: - account for custom phase samples
Parameters:
folder : str wavelength : phases : str or j/np.array
Source code in xenomorph\mcfost.py
493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 |
|
mcfost_points(stardata, shells, filename, n_t=1000, n_points=400, resolution=600, root_dir='')
Generates points that can be fed into a new version of MCFOST for radiative transfer calculations. Once generated, you could use these points with MCFOST via:
mcfost
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stardata
|
dict
|
The system parameter file. |
required |
shells
|
int
|
The number of shells to generate. |
required |
filename
|
str
|
The name of the file to save the points into. This must include a '.fits' suffix. |
required |
n_t
|
int
|
The number of rings to generate in each shell. |
1000
|
n_points
|
int
|
The number of points to generate in each ring. |
400
|
resolution
|
int
|
The number of pixels (per side) for the geometric comparison image. |
600
|
root_dir
|
str
|
The directory where you'd like the output of the job to be. |
''
|
Source code in xenomorph\mcfost.py
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 |
|
read_lightcurve_grid(wavelength, parameter_grid, method='equal', n_samples=20, root_dir='')
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wavelength
|
int or float, or str or dict
|
The wavelength (in microns) that you'd like to generate the image for. If wavelength is a str type, it will be interpreted as one of the pre-defined filters {'H', 'K', 'L', 'M'} and representative samples will be generated from that filter. If wavelength is a dict, it will be as for the str case, but for user-defined wavelengths. |
required |
parameter_grid
|
dict
|
A dictionary where each key corresponds to the parameter of |
required |
method
|
str or j / array
|
This parameter dictates how the time samples across orbital phase are distributed. If method=='equal', there will be n_samples equally spaced samples across orbital phase 0 to 1 to construct the light curve. If method=='periastron_dense', there will be proportionally more samples around periastron (when there is active dust production). If method is a j/np array, the values of the one-dimensional array will be used as the phase samples. |
'equal'
|
n_samples
|
int
|
The number of orbital phase samples with which to construct the light curve. This is only relevant if the |
20
|
root_dir
|
str
|
The directory where you'd like the output of the job to be. |
''
|
Source code in xenomorph\mcfost.py
630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 |
|
sample_phases(method, n_samples)
Source code in xenomorph\mcfost.py
331 332 333 334 335 336 337 338 339 340 341 342 |
|
trapezoid_rule(x1, x2, y1, y2)
Calculates the area of the trapezoid made by two points.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x1
|
float
|
The left and right x positions |
required |
x2
|
float
|
The left and right x positions |
required |
y1
|
float
|
The left and right y positions |
required |
y2
|
float
|
The left and right y positions |
required |
Returns:
Type | Description |
---|---|
float
|
The area of the trapezoid in units of x*y |
Source code in xenomorph\mcfost.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
|