Reference#
read_rainbow(filepath, **kw)
#
A friendly wrapper to load time-series spectra and/or
multiwavelength light curves into a chromatic
Rainbow
object. It will try its best to pick the best reader
and return the most useful kind of object.
🦋🌅2️⃣🪜🎬👀🇮🇹📕🧑🏫🌈
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath |
str, list
|
The file or files to open. |
required |
**kw |
dict
|
All other keyword arguments will be passed to
the |
{}
|
Returns:
Name | Type | Description |
---|---|---|
rainbow |
Rainbow, RainbowWithModel
|
The loaded data! |
Source code in chromatic/rainbows/__init__.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
Rainbow
#
Rainbow
(🌈) objects represent brightness as a function
of both wavelength and time.
These objects are useful for reading or writing multiwavelength
time-series datasets in a variety of formats, visualizing these
data with simple commands, and performing basic calculations.
RainbowWithModel
and SimulatedRainbow
objects inherit from
Rainbow
, so all basically all methods and attributes described
below are available for them too.
Attributes:
Name | Type | Description |
---|---|---|
wavelike |
dict
|
A dictionary for quantities with shape `(nwave,), for which there's one value for each wavelength. |
timelike |
dict
|
A dictionary for quantities with shape `(ntime,), for which there's one value for each time. |
fluxlike |
dict
|
A dictionary for quantities with shape `(nwave,ntime), for which there's one value for each wavelength and time. |
metadata |
dict
|
A dictionary containing all other useful information
that should stay connected to the |
wavelength |
Quantity
|
The 1D array of wavelengths for this |
time |
Quantity
|
The 1D array of times for this |
flux |
array, Quantity
|
The 2D array of fluxes for this |
uncertainty |
array, Quantity
|
The 2D array of flux uncertainties for this |
ok |
array
|
The 2D array of "ok-ness" for this |
shape |
tuple
|
The shape of this |
nwave |
int
|
The number of wavelengths in this |
ntime |
int
|
The number of times in this |
nflux |
int
|
The total number of fluxes in this |
dt |
Quantity
|
The typical time offset between adjacent times in this |
name |
array, Quantity
|
The name of this |
Source code in chromatic/rainbows/rainbow.py
6 7 8 9 10 11 12 13 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 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 340 341 342 343 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 428 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 492 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 535 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 629 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 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 |
|
__init__(filepath=None, format=None, wavelength=None, time=None, flux=None, uncertainty=None, wavelike=None, timelike=None, fluxlike=None, metadata=None, name=None, **kw)
#
Initialize a Rainbow
object.
The __init__
function is called when a new Rainbow
is
instantiated as r = Rainbow(some, kinds, of=inputs)
.
The options for inputs are flexible, including the possibility to initialize from a file, from arrays with appropriate units, from dictionaries with appropriate ingredients, or simply as an empty object if no arguments are given.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath |
str, optional
|
The filepath pointing to the file or group of files that should be read. |
None
|
format |
str, optional
|
The file format of the file to be read. If None, the format will be guessed automatically from the filepath. |
None
|
wavelength |
Quantity, optional
|
A 1D array of wavelengths, in any unit. |
None
|
time |
Quantity, Time, optional
|
A 1D array of times, in any unit. |
None
|
flux |
array, optional
|
A 2D array of flux values. |
None
|
uncertainty |
array, optional
|
A 2D array of uncertainties, associated with the flux. |
None
|
wavelike |
dict, optional
|
A dictionary containing 1D arrays with the same shape as the wavelength axis. It must at least contain the key 'wavelength', which should have astropy units of wavelength associated with it. |
None
|
timelike |
dict, optional
|
A dictionary containing 1D arrays with the same shape as the time axis. It must at least contain the key 'time', which should have astropy units of time associated with it. |
None
|
fluxlike |
dict, optional
|
A dictionary containing 2D arrays with the shape of (nwave, ntime), like flux. It must at least contain the key 'flux'. |
None
|
metadata |
dict, optional
|
A dictionary containing all other metadata associated with the dataset, generally lots of individual parameters or comments. |
None
|
**kw |
dict, optional
|
Additional keywords will be passed along to
the function that initializes the rainbow.
If initializing from arrays ( |
{}
|
Examples:
Initialize from a file. While this works, a more robust
solution is probably to use read_rainbow
, which will
automatically choose the best of Rainbow
and RainbowWithModel
r1 = Rainbow('my-neat-file.abc', format='abcdefgh')
Initalize from arrays. The wavelength and time must have
appropriate units, and the shape of the flux array must
match the size of the wavelength and time arrays. Other
arrays that match the shape of any of these quantities
will be stored in the appropriate location. Other inputs
not matching any of these will be stored as metadata.
r2 = Rainbow(
wavelength=np.linspace(1, 5, 50)*u.micron,
time=np.linspace(-0.5, 0.5, 100)*u.day,
flux=np.random.normal(0, 1, (50, 100)),
some_other_array=np.ones((50,100)),
some_metadata='wow!'
)
Initialize from dictionaries. The dictionaries must contain
at least wavelike['wavelength']
, timelike['time']
, and
fluxlike['flux']
, but any other additional inputs can be
provided.
r3 = Rainbow(
wavelike=dict(wavelength=np.linspace(1, 5, 50)*u.micron),
timelike=dict(time=np.linspace(-0.5, 0.5, 100)*u.day),
fluxlike=dict(flux=np.random.normal(0, 1, (50, 100)))
)
Source code in chromatic/rainbows/rainbow.py
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 |
|
__getattr__(key)
#
If an attribute/method isn't explicitly defined, try to pull it from one of the core dictionaries.
Let's say you want to get the 2D uncertainty array
but don't want to type self.fluxlike['uncertainty']
.
You could instead type self.uncertainty
, and this
would try to search through the four standard
dictionaries to pull out the first uncertainty
it finds.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
The attribute we're trying to get. |
required |
Source code in chromatic/rainbows/rainbow.py
625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 |
|
__setattr__(key, value)
#
When setting a new attribute, try to sort it into the appropriate core directory based on its size.
Let's say you have some quantity that has the same shape as the wavelength array and you'd like to attach it to this Rainbow object. This will try to save it in the most relevant core dictionary (of the choices timelike, wavelike, fluxlike).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
The attribute we're trying to get. |
required |
value |
array
|
The quantity we're trying to attach to that name. |
required |
Source code in chromatic/rainbows/rainbow.py
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 684 685 686 |
|
__getitem__(key)
#
Trim a rainbow by indexing, slicing, or masking.
Two indices must be provided ([:,:]
).
Examples:
r[:,:]
r[10:20, :]
r[np.arange(10,20), :]
r[r.wavelength > 1*u.micron, :]
r[:, np.abs(r.time) < 1*u.hour]
r[r.wavelength > 1*u.micron, np.abs(r.time) < 1*u.hour]
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
tuple
|
The (wavelength, time) slices, indices, or masks. |
required |
Source code in chromatic/rainbows/rainbow.py
880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 |
|
RainbowWithModel
#
RainbowWithModel
objects have a fluxlike model
attached to them, meaning that they can
This class definition inherits from Rainbow
.
Source code in chromatic/rainbows/withmodel.py
4 5 6 7 8 9 10 11 12 13 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 |
|
chi_squared()
property
#
Calculate $\chi^2$.
This calculates the sum of the squares of the uncertainty-normalized residuals, sum(((flux - model)/uncertainty)**2)
Data points marked as not OK are ignored.
Returns:
Name | Type | Description |
---|---|---|
chi_squared |
float
|
The chi-squared value. |
Source code in chromatic/rainbows/withmodel.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
|
ones()
property
#
Generate an array of ones that looks like the flux.
(A tiny wrapper needed for plot_with_model
)
Returns:
Name | Type | Description |
---|---|---|
ones |
array, Quantity
|
The 2D array ones (nwave, ntime). |
Source code in chromatic/rainbows/withmodel.py
66 67 68 69 70 71 72 73 74 75 76 77 |
|
residuals()
property
#
Calculate the residuals on the fly, to make sure they're always up to date.
The residuals are calculated simply
as the .flux
- .model
, so they are
in whatever units those arrays have.
Returns:
Name | Type | Description |
---|---|---|
residuals |
array, Quantity
|
The 2D array of residuals (nwave, ntime). |
Source code in chromatic/rainbows/withmodel.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
residuals_plus_one()
property
#
A tiny wrapper to get the residuals + 1.
Returns:
Name | Type | Description |
---|---|---|
residuals_plus_one |
array, Quantity
|
The 2D array of residuals + 1 (nwave, ntime). |
Source code in chromatic/rainbows/withmodel.py
54 55 56 57 58 59 60 61 62 63 64 |
|
SimulatedRainbow
#
SimulatedRainbow
objects are created from scratch
within chromatic
, with options for various different
wavelength grids, time grids, noise sources, and injected
models. They can be useful for generating quick simulated
dataset for testing analysis and visualization tools.
This class definition inherits from RainbowWithModel
,
which itself inherits from Rainbow
.
Source code in chromatic/rainbows/simulated.py
4 5 6 7 8 9 10 11 12 13 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 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 |
|
__init__(tlim=[-2.5, 2.5] * u.hour, dt=2 * u.minute, time=None, wlim=[0.5, 5] * u.micron, R=100, dw=None, wavelength=None, star_flux=None, name=None, signal_to_noise=None)
#
Initialize a SimulatedRainbow
object from some parameters.
This sets up an effectively empty Rainbow
with defined
wavelengths and times. For making more interesting
simulated datasets, this will often be paired with
some combination of the .inject...
actions that inject
various astrophysical, instrumental, or noise signatures
into the dataset.
The time-setting order of precendence is: 1) time 2) tlim + dt
The wavelength-setting order of precendence is: 1) wavelength 2) wlim + dw 3) wlim + R
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tlim |
list or Quantity
|
The pip install -e '.[develop]'[min, max] times for creating the time grid. These should have astropy units of time. |
[-2.5, 2.5] * u.hour
|
dt |
Quantity
|
The d(time) bin size for creating a grid that is uniform in linear space. |
2 * u.minute
|
time |
Quantity
|
An array of times, if you just want to give it an entirely custom array. |
None
|
wlim |
list or Quantity
|
The [min, max] wavelengths for creating the grid. These should have astropy units of wavelength. |
[0.5, 5] * u.micron
|
R |
float
|
The spectral resolution for creating a grid that is uniform in logarithmic space. |
100
|
dw |
Quantity
|
The d(wavelength) bin size for creating a grid that is uniform in linear space. |
None
|
wavelength |
Quantity
|
An array of wavelengths, if you just want to give it an entirely custom array. |
None
|
star_flux |
numpy 1D array
|
An array of fluxes corresponding to the supplied wavelengths. If left blank, the code assumes a normalized flux of flux(wavelength) = 1 for all wavelengths. |
None
|
Source code in chromatic/rainbows/simulated.py
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 |
|
🌈 Helpers#
get(self, key, default=None)
#
Retrieve an attribute by its string name.
(This is a friendlier wrapper for getattr()
).
r.get('flux')
is identical to r.flux
This is different from indexing directly into
a core dictionary (for example, r.fluxlike['flux']
),
because it can also be used to get the results of
properties that do calculations on the fly (for example,
r.residuals
in the RainbowWithModel
class).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
The name of the attribute, property, or core dictionary item to get. |
required |
default |
any, optional
|
What to return if the attribute can't be found. |
None
|
Returns:
Name | Type | Description |
---|---|---|
thing |
any
|
The thing you were trying to get. If unavailable,
return the |
Source code in chromatic/rainbows/helpers/get.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
|
help(self)
#
Print a quick reference of key actions available for this Rainbow
.
Source code in chromatic/rainbows/helpers/help.py
6 7 8 9 10 11 12 13 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 |
|
history(self)
#
Return a summary of the history of actions that have gone into this Rainbow
.
Returns:
Name | Type | Description |
---|---|---|
history |
str
|
A string that does its best to try to summarize
all the actions that have been applied to this
|
Source code in chromatic/rainbows/helpers/history.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
|
save(self, filepath='test.rainbow.npy', format=None, **kw)
#
Save this Rainbow
out to a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath |
str
|
The filepath pointing to the file to be written.
(For now, it needs a |
'test.rainbow.npy'
|
format |
str, optional
|
The file format of the file to be written. If |
None
|
**kw |
dict, optional
|
All other keywords will be passed to the writer. |
{}
|
Source code in chromatic/rainbows/helpers/save.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
|
🌈 Actions#
align_wavelengths(self, minimum_acceptable_ok=1, minimum_points_per_bin=0, wscale='linear', supersampling=1, visualize=False)
#
Use 2D wavelength information to align onto a single 1D wavelength array.
This relies on the existence of a .fluxlike['wavelength_2d']
array,
expressing the wavelength associated with each flux element.
Those wavelengths will be used to (a) establish a new compromise
wavelength grid and (b) bin the individual timepoints onto that
new grid, effectively shifting the wavelengths to align.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
minimum_acceptable_ok |
float, optional
|
The numbers in the |
1
|
wscale |
str, optional
|
What kind of a new wavelength axis should be created? Options include: 'linear' = constant d[wavelength] between grid points 'log' = constant d[wavelength]/[wavelength] between grid points |
'linear'
|
supersampling |
float, optional
|
By how many times should we increase or decrease the wavelength sampling? In general, values >1 will split each input wavelength grid point into multiple supersampled wavelength grid points, values close to 1 will produce approximately one output wavelength for each input wavelength, and values <1 will average multiple input wavelengths into a single output wavelength bin. Unless this is significantly less than 1, there's a good chance your output array may have strong correlations between one or more adjacent wavelengths. Be careful when trying to use the resulting uncertainties! |
1
|
visualize |
bool
|
Should we make some plots showing how the shared wavelength axis compares to the original input wavelength axes? |
False
|
Returns:
Name | Type | Description |
---|---|---|
rainbow |
RainbowWithModel
|
A new |
Source code in chromatic/rainbows/actions/align_wavelengths.py
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 |
|
attach_model(self, model, **kw)
#
Attach a fluxlike
model, thus making a new RainbowWithModel.
Having a model attached makes it possible to make calculations (residuals, chi^2) and visualizations comparing data to model.
The model
array will be stored in .fluxlike['model']
.
After running this to make a RainbowWithModel
it's OK
(and faster) to simply update .fluxlike['model']
or .model
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
array, Quantity
|
An array of model values, with the same shape as 'flux' |
required |
**kw |
dict, optional
|
All other keywords will be interpreted as items
that can be added to a |
{}
|
Returns:
Name | Type | Description |
---|---|---|
rainbow |
RainbowWithModel
|
A new |
Source code in chromatic/rainbows/actions/attach_model.py
10 11 12 13 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 |
|
bin(self, dt=None, time=None, time_edges=None, ntimes=None, R=None, dw=None, wavelength=None, wavelength_edges=None, nwavelengths=None, minimum_acceptable_ok=1, minimum_points_per_bin=None, trim=True)
#
Bin in wavelength and/or time.
Average together some number of adjacent data points, in wavelength and/or time. For well-behaved data where data points are independent from each other, binning down by N data points should decrease the noise per bin by approximately 1/sqrt(N), making it easier to see subtle signals. To bin data points together, data are combined using inverse-variance weighting through interpolation of cumulative distributions, in an attempt to make sure that flux integrals between limits are maintained.
Currently, the inverse-variance weighting is most reliable only for datasets that have been normalized to be close to 1. We still need to do a little work to make sure it works well on unnormalized datasets with dramatically non-uniform uncertainties.
By default, time binning happens before wavelength binning.
To control the order, use separate calls to .bin()
.
The time-setting order of precendence is
[time_edges
, time
, dt
, ntimes
]
The first will be used, and others will be ignored.
The wavelength-setting order of precendence is
[wavelength_edges
, wavelength
, dw
, R
, nwavelengths
]
The first will be used, and others will be ignored.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dt |
Quantity
|
The d(time) bin size for creating a grid that is uniform in linear space. |
None
|
time |
Quantity
|
An array of times, if you just want to give it an entirely custom array. The widths of the bins will be guessed from the centers (well, if the spacing is uniform constant; pretty well but not perfectly otherwise). |
None
|
time_edges |
Quantity
|
An array of times for the edges of bins,
if you just want to give an entirely custom array.
The bins will span |
None
|
ntimes |
int
|
A fixed number of time to bin together. Binning will start from the 0th element of the starting times; if you want to start from a different index, trim before binning. |
None
|
R |
float
|
The spectral resolution for creating a grid that is uniform in logarithmic space. |
None
|
dw |
Quantity
|
The d(wavelength) bin size for creating a grid that is uniform in linear space. |
None
|
wavelength |
Quantity
|
An array of wavelengths for the centers of bins, if you just want to give an entirely custom array. The widths of the bins will be guessed from the centers (well, if the spacing is uniform constant; pretty well but not perfectly otherwise). |
None
|
wavelength_edges |
Quantity
|
An array of wavelengths for the edges of bins,
if you just want to give an entirely custom array.
The bins will span |
None
|
nwavelengths |
int
|
A fixed number of wavelengths to bin together. Binning will start from the 0th element of the starting wavelengths; if you want to start from a different index, trim before binning. |
None
|
minimum_acceptable_ok |
float
|
The numbers in the |
1
|
minimum_points_per_bin |
float
|
If you're creating bins that are smaller than those in
the original dataset, it's possible to end up with bins
that effectively contain fewer than one original datapoint
(in the sense that the contribution of one original datapoint
might be split across multiple new bins). By default,
we allow this behavior with |
None
|
trim |
bool
|
Should any wavelengths or columns that end up as entirely nan be trimmed out of the result? (default = True) |
True
|
Returns:
Name | Type | Description |
---|---|---|
binned |
Rainbow
|
The binned |
Source code in chromatic/rainbows/actions/binning.py
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 |
|
bin_in_time(self, dt=None, time=None, time_edges=None, ntimes=None, minimum_acceptable_ok=1, minimum_points_per_bin=None, trim=True)
#
Bin in time.
The time-setting order of precendence is
[time_edges
, time
, dt
, ntimes
]
The first will be used, and others will be ignored.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dt |
Quantity
|
The d(time) bin size for creating a grid that is uniform in linear space. |
None
|
time |
Quantity
|
An array of times, if you just want to give it an entirely custom array. The widths of the bins will be guessed from the centers (well, if the spacing is uniform constant; pretty well but not perfectly otherwise). |
None
|
time_edges |
Quantity
|
An array of times for the edges of bins,
if you just want to give an entirely custom array.
The bins will span |
None
|
ntimes |
int
|
A fixed number of time to bin together. Binning will start from the 0th element of the starting times; if you want to start from a different index, trim before binning. |
None
|
minimum_acceptable_ok |
float
|
The numbers in the |
1
|
minimum_points_per_bin |
float
|
If you're creating bins that are smaller than those in
the original dataset, it's possible to end up with bins
that effectively contain fewer than one original datapoint
(in the sense that the contribution of one original datapoint
might be split across multiple new bins). By default,
we allow this behavior with |
None
|
trim |
bool
|
Should any wavelengths or columns that end up as entirely nan be trimmed out of the result? (default = True) |
True
|
Returns:
Name | Type | Description |
---|---|---|
binned |
Rainbow
|
The binned |
Source code in chromatic/rainbows/actions/binning.py
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 340 341 342 343 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 |
|
bin_in_wavelength(self, R=None, dw=None, wavelength=None, wavelength_edges=None, nwavelengths=None, minimum_acceptable_ok=1, minimum_points_per_bin=None, trim=True, starting_wavelengths='1D')
#
Bin in wavelength.
The wavelength-setting order of precendence is
[wavelength_edges
, wavelength
, dw
, R
, nwavelengths
]
The first will be used, and others will be ignored.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
R |
float
|
The spectral resolution for creating a grid that is uniform in logarithmic space. |
None
|
dw |
Quantity
|
The d(wavelength) bin size for creating a grid that is uniform in linear space. |
None
|
wavelength |
Quantity
|
An array of wavelength centers, if you just want to give it an entirely custom array. The widths of the bins will be guessed from the centers. It will do a good job if the widths are constant, but don't 100% trust it otherwise. |
None
|
wavelength_edges |
Quantity
|
An array of wavelengths for the edges of bins,
if you just want to give an entirely custom array.
The bins will span |
None
|
nwavelengths |
int
|
A fixed number of wavelengths to bin together. Binning will start from the 0th element of the starting wavelengths; if you want to start from a different index, trim before binning. |
None
|
minimum_acceptable_ok |
float
|
The numbers in the |
1
|
minimum_points_per_bin |
float
|
If you're creating bins that are smaller than those in
the original dataset, it's possible to end up with bins
that effectively contain fewer than one original datapoint
(in the sense that the contribution of one original datapoint
might be split across multiple new bins). By default,
we allow this behavior with |
None
|
trim |
bool
|
Should any wavelengths or columns that end up as entirely nan be trimmed out of the result? (default = True) |
True
|
starting_wavelengths |
str
|
What wavelengths should be used as the starting
value from which we will be binning? Options include:
'1D' = (default) the shared 1D wavelengths for all times
stored in |
'1D'
|
Returns:
Name | Type | Description |
---|---|---|
binned |
Rainbow
|
The binned |
Source code in chromatic/rainbows/actions/binning.py
426 427 428 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 492 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 535 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 629 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 |
|
get_average_lightcurve_as_rainbow(self)
#
Produce a wavelength-integrated light curve.
The average across wavelengths is uncertainty-weighted.
This uses bin
, which is a horribly slow way of doing what is
fundamentally a very simply array calculation, because we
don't need to deal with partial pixels.
Returns:
Name | Type | Description |
---|---|---|
lc |
Rainbow
|
A |
Source code in chromatic/rainbows/actions/binning.py
686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 |
|
get_average_spectrum_as_rainbow(self)
#
Produce a time-integrated spectrum.
The average across times is uncertainty-weighted.
This uses bin
, which is a horribly slow way of doing what is
fundamentally a very simply array calculation, because we
don't need to deal with partial pixels.
Returns:
Name | Type | Description |
---|---|---|
lc |
Rainbow
|
A |
Source code in chromatic/rainbows/actions/binning.py
711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 |
|
compare(self, rainbows)
#
Compare this Rainbow
to others.
(still in development) This connects the current Rainbow
to a collection of other Rainbow
objects, which can then
be visualized side-by-side in a uniform way.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rainbows |
list
|
A list containing one or more other |
required |
Returns:
Name | Type | Description |
---|---|---|
rainbow |
MultiRainbow
|
A |
Source code in chromatic/rainbows/actions/compare.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
|
flag_outliers(self, how_many_sigma=5, remove_trends=True, inflate_uncertainty=True)
#
Flag outliers as not ok
.
This examines the flux array, identifies significant outliers,
and marks them 0 in the ok
array. The default procedure is to use
a median filter to remove temporal trends (remove_trends
),
inflate the uncertainties based on the median-absolute-deviation
scatter (inflate_uncertainty
), and call points outliers if they
deviate by more than a certain number of sigma (how_many_sigma
)
from the median-filtered level.
The returned Rainbow
object should be identical to the input
one, except for the possibility that some elements in ok
array
will have been marked as zero. (The filtering or inflation are
not applied to the returned object.)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
how_many_sigma |
float, optional
|
Standard deviations (sigmas) allowed for individual data points before they are flagged as outliers. |
5
|
remove_trends |
bool, optional
|
Should we remove trends from the flux data before trying to look for outliers? |
True
|
inflate_uncertainty |
bool, optional
|
Should uncertainties per wavelength be inflated to match the (MAD-based) standard deviation of the data? |
True
|
Returns:
Name | Type | Description |
---|---|---|
rainbow |
Rainbow
|
A new Rainbow object with the outliers flagged as 0 in |
Source code in chromatic/rainbows/actions/flag_outliers.py
7 8 9 10 11 12 13 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 |
|
fold(self, period=None, t0=None, event='Mid-Transit')
#
Fold this Rainbow
to a period and reference epoch.
This changes the times from some original time into a phased time, for example the time within an orbital period, relative to the time of mid-transit. This is mostly a convenience function for plotting data relative to mid-transit and/or trimming data based on orbital phase.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
period |
Quantity
|
The orbital period of the planet (with astropy units of time). |
None
|
t0 |
Quantity
|
Any mid-transit epoch (with astropy units of time). |
None
|
event |
str
|
A description of the event that happens periodically.
For example, you might want to switch this to
'Mid-Eclipse' (as well as offsetting the |
'Mid-Transit'
|
Returns:
Name | Type | Description |
---|---|---|
folded |
Rainbow
|
The folded |
Source code in chromatic/rainbows/actions/fold.py
6 7 8 9 10 11 12 13 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 |
|
inflate_uncertainty(self, method='MAD', remove_trends=True, remove_trends_method='median_filter', remove_trends_kw={}, minimum_inflate_ratio=1.0)
#
Inflate uncertainties to match observed scatter.
This is a quick and approximate tool for inflating
the flux uncertainties in a Rainbow
to match the
observed scatter. With defaults, this will estimate
the scatter using a robust median-absolute-deviation
estimate of the standard deviation (method='MAD'
),
applied to time-series from which temporal trends
have been removed (remove_trends=True
), and inflate
the uncertainties on a per-wavelength basis. The trend
removal, by default by subtracting off local medians
(remove_trends_method='median_filter'
), will squash
many types of both astrophysical and systematic trends,
so this function should be used with caution in
applicants where precise and reliable uncertainties
are needed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
method |
string
|
What method to use to obtain measured scatter. Current options are 'MAD', 'standard-deviation'. |
'MAD'
|
remove_trends |
bool
|
Should we remove trends before estimating by how much we need to inflate the uncertainties? |
True
|
remove_trends_method |
str
|
What method should be used to remove trends?
See |
'median_filter'
|
remove_trends_kw |
dict
|
What keyword arguments should be passed to |
{}
|
minimum_inflate_ratio |
float, optional
|
the minimum inflate_ratio that can be. We don't want people to deflate uncertainty unless a very specific case of unstable pipeline output. |
1.0
|
Returns:
Name | Type | Description |
---|---|---|
removed |
Rainbow
|
The Rainbow with estimated signals removed. |
Source code in chromatic/rainbows/actions/inflate_uncertainty.py
6 7 8 9 10 11 12 13 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 |
|
inject_noise(self, signal_to_noise=100, number_of_photons=None)
#
Inject uncorrelated random noise into the .flux
array.
This injects independent noise to each data point,
drawn from either a Gaussian or Poisson distribution.
If the inputs can be scalar, or they can be arrays
that we will try to broadcast into the shape of the
.flux
array.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
signal_to_noise |
float, array, optional
|
The signal-to-noise per wavelength per time. For example, S/N=100 would mean that the uncertainty on the flux for each each wavelength-time data point will be 1%. If it is a scalar, then even point is the same. If it is an array with a fluxlike, wavelike, or timelike shape it will be broadcast appropriately. |
100
|
number_of_photons |
float, array, optional
|
The number of photons expected to be recieved
from the light source per wavelength and time.
If it is a scalar, then even point is the same.
If it is an array with a fluxlike, wavelike,
or timelike shape it will be broadcast
appropriately.
If |
None
|
Returns:
Name | Type | Description |
---|---|---|
rainbow |
Rainbow
|
A new |
Source code in chromatic/rainbows/actions/inject_noise.py
6 7 8 9 10 11 12 13 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 |
|
inject_outliers(self, fraction=0.01, amplitude=10)
#
Inject some random outliers.
To approximately simulate cosmic rays or other rare weird outliers, this randomly injects outliers into a small fraction of pixels. For this simple method, outliers will have the same amplitude, either as a ratio above the per-data-point or as a fixed number (if no uncertainties exist).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fraction |
float, optional
|
The fraction of pixels that should get outliers. (default = 0.01) |
0.01
|
amplitude |
float, optional
|
If uncertainty > 0, how many sigma should outliers be? If uncertainty = 0, what number should be injected? (default = 10) |
10
|
Returns:
Name | Type | Description |
---|---|---|
rainbow |
Rainbow
|
A new |
Source code in chromatic/rainbows/actions/inject_outliers.py
6 7 8 9 10 11 12 13 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 |
|
inject_spectrum(self, temperature=5800 * u.K, logg=4.43, metallicity=0.0, radius=1 * u.Rsun, distance=10 * u.pc, phoenix=True)
#
Inject a stellar spectrum into the flux.
This injects a constant stellar spectrum into
all times in the Rainbow
. Injection happens
by multiplying the .model
flux array, so for
example a model that already has a transit in
it will be scaled up to match the stellar spectrum
in all wavelengths.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
temperature |
Quantity, optional
|
Temperature, in K (with no astropy units attached). |
5800 * u.K
|
logg |
float, optional
|
Surface gravity log10[g/(cm/s**2)] (with no astropy units attached). |
4.43
|
metallicity |
float, optional
|
Metallicity log10[metals/solar] (with no astropy units attached). |
0.0
|
radius |
Quantity, optional
|
The radius of the star. |
1 * u.Rsun
|
distance |
Quantity, optional
|
The distance to the star. |
10 * u.pc
|
phoenix |
bool, optional
|
If |
True
|
Returns:
Name | Type | Description |
---|---|---|
rainbow |
Rainbow
|
A new |
Source code in chromatic/rainbows/actions/inject_spectrum.py
7 8 9 10 11 12 13 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 |
|
inject_systematics(self, amplitude=0.003, wavelike=[], timelike=['x', 'y', 'time'], fluxlike=['background'])
#
Inject some (very cartoony) instrumental systematics.
Here's the basic procedure:
1) Generate some fake variables that vary either just with
wavelength, just with time, or with both time and wavelength.
Store these variables for later use. For example, these might
represent an average x
and y
centroid of the trace on the
detector (one for each time), or the background flux associated
with each wavelength (one for each time and for each wavelength).
2) Generate a flux model as some function of those variables. In reality, we probably don't know the actual relationship between these inputs and the flux, but we can imagine one!
3) Inject the model flux into the flux
of this Rainbow,
and store the combined model in systematics-model
and
each individual component in systematic-model-{...}
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
amplitude |
float, optional
|
The (standard deviation-ish) amplitude of the systematics in units normalized to 1. For example, an amplitude of 0.003 will produce systematic trends that tend to range (at 1 sigma) from 0.997 to 1.003. |
0.003
|
wavelike |
list of strings, optional
|
A list of wave-like cotrending quantities to serve as ingredients to a linear combination systematics model. Existing quantities will be pulled from the appropriate core dictionary; fake data will be created for quantities that don't already exist, from a cartoony Gaussian process model. |
[]
|
timelike |
list of strings, optional
|
A list of time-like cotrending quantities to serve as ingredients to a linear combination systematics model. Existing quantities will be pulled from the appropriate core dictionary; fake data will be created for quantities that don't already exist, from a cartoony Gaussian process model. |
['x', 'y', 'time']
|
fluxlike |
list of strings, optional
|
A list of flux-like cotrending quantities to serve as ingredients to a linear combination systematics model. Existing quantities will be pulled from the appropriate core dictionary; fake data will be created for quantities that don't already exist, from a cartoony Gaussian process model. |
['background']
|
Returns:
Name | Type | Description |
---|---|---|
rainbow |
Rainbow
|
A new Rainbow object with the systematics injected. |
Source code in chromatic/rainbows/actions/inject_systematics.py
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 |
|
inject_transit(self, planet_radius=0.1, method='exoplanet', **transit_parameters)
#
Simulate a wavelength-dependent planetary transit.
This uses one of a few methods to inject a transit
signal into the Rainbow
, allowing the transit
depth to change with wavelength (for example due to a
planet's effective radius changing with wavelength due
to its atmospheric transmission spectrum). Other
parameters can also be wavlength-dependent, but
some (like period, inclination, etc...) probably
shouldn't be.
The current methods include:
'trapezoid'
to inject a cartoon transit, using nomenclature
from Winn (2010).
This is the default method, to avoid package dependencies
that can be finicky to compile and/or install on different
operating systems.
'exoplanet'
to inject a limb-darkened transit using exoplanet-core.
This option requires exoplanet-core
be installed,
but it doesn't require complicated dependencies or
compiling steps, so it's already included as a dependency.
'batman'
to inject a limb-darkened transit using batman-package
This method requires that batman-package
be installed,
and it will try to throw a helpful warning message if
it's not.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
planet_radius |
float, array, None
|
The planet-to-star radius ratio = [transit depth]**0.5, which can be either a single value for all wavelengths, or an array with one value for each wavelength. |
0.1
|
method |
str
|
What method should be used to inject the transits? Different
methods will produce different results and have different options.
The currently implement options are |
'exoplanet'
|
**transit_parameters |
dict
|
All additional keywords will be passed to the transit model.
The accepted keywords for the different methods are as follows.
|
{}
|
Source code in chromatic/rainbows/actions/inject_transit.py
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 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 428 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 492 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 |
|
normalize(self, axis='wavelength', percentile=50)
#
Normalize by dividing through by the median spectrum and/or lightcurve.
This normalizes a Rainbow
by estimating dividing
through by a wavelength-dependent normalization. With
default inputs, this would normalize each wavelength
to have flux values near 1, to make it easier to see
differences across time (such as a transit or eclipse).
This function could also be used to divide through by
a median light curve, to make it easier to see variations
across wavelength.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
axis |
str
|
The axis that should be normalized out.
|
'wavelength'
|
percentile : float
A number between 0 and 100, specifying the percentile
of the data along an axis to use as the reference.
The default of percentile=50
corresponds to the median.
If you want to normalize to out-of-transit, maybe you
want a higher percentile. If you want to normalize to
the baseline below a flare, maybe you want a lower
percentage.
Returns:
Name | Type | Description |
---|---|---|
normalized |
Rainbow
|
The normalized Rainbow. |
Source code in chromatic/rainbows/actions/normalization.py
6 7 8 9 10 11 12 13 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 |
|
__add__(self, other)
#
Add the flux of a rainbow and an input array (or another rainbow) and output in a new rainbow other.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other |
Array or float.
|
Multiple options: 1) float 2) 1D array with same length as wavelength axis 3) 1D array with same length as time axis 4) 2D array with same shape as rainbow flux 5) Rainbow other with same dimensions as self. |
required |
Returns:
Name | Type | Description |
---|---|---|
rainbow |
Rainbow
|
A new |
Source code in chromatic/rainbows/actions/operations.py
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 |
|
__sub__(self, other)
#
Subtract the flux of a rainbow from an input array (or another rainbow) and output in a new rainbow other.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other |
Array or float.
|
Multiple options: 1) float 2) 1D array with same length as wavelength axis 3) 1D array with same length as time axis 4) 2D array with same shape as rainbow flux 5) Rainbow other with same dimensions as self. |
required |
Returns:
Name | Type | Description |
---|---|---|
rainbow |
Rainbow
|
A new |
Source code in chromatic/rainbows/actions/operations.py
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 |
|
__mul__(self, other)
#
Multiply the flux of a rainbow and an input array (or another rainbow) and output in a new rainbow other.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other |
Array or float.
|
Multiple options: 1) float 2) 1D array with same length as wavelength axis 3) 1D array with same length as time axis 4) 2D array with same shape as rainbow flux 5) Rainbow other with same dimensions as self. |
required |
Returns:
Name | Type | Description |
---|---|---|
rainbow |
Rainbow
|
A new |
Source code in chromatic/rainbows/actions/operations.py
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 |
|
__truediv__(self, other)
#
Divide the flux of a rainbow and an input array (or another rainbow) and output in a new rainbow other.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other |
Array or float.
|
Multiple options: 1) float 2) 1D array with same length as wavelength axis 3) 1D array with same length as time axis 4) 2D array with same shape as rainbow flux 5) Rainbow other with same dimensions as self. |
required |
Returns:
Name | Type | Description |
---|---|---|
rainbow |
Rainbow
|
A new |
Source code in chromatic/rainbows/actions/operations.py
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 |
|
__eq__(self, other)
#
Test whether self == other
.
This compares the wavelike, timelike, and fluxlike arrays for exact matches. It skips entirely over the metadata.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other |
Rainbow
|
Another |
required |
Returns:
Name | Type | Description |
---|---|---|
equal |
bool
|
Are they (effectively) equivalent? |
Source code in chromatic/rainbows/actions/operations.py
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 |
|
remove_trends(self, method='median_filter', **kw)
#
A quick tool to approximately remove trends.
This function provides some simple tools for kludgily
removing trends from a Rainbow
, through a variety of
filtering methods. If you just want to remove all
slow trends, whether astrophysical or instrumental,
options like the median_filter
or savgol_filter
will effectively suppress all trends on timescales
longer than their filtering window. If you want a
more restricted approach to removing long trends,
the polyfit
option allows you to fit out slow trends.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
method |
str, optional
|
What method should be used to make an approximate model
for smooth trends that will then be subtracted off?
|
'median_filter'
|
**kw |
dict, optional
|
Any additional keywords will be passed to the function
that does the filtering. See |
{}
|
Returns:
Name | Type | Description |
---|---|---|
removed |
Rainbow
|
The Rainbow with estimated signals removed. |
Source code in chromatic/rainbows/actions/remove_trends.py
6 7 8 9 10 11 12 13 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 |
|
shift(self, velocity=0 * u.km / u.s)
#
Doppler shift the wavelengths of this Rainbow
.
This shifts the wavelengths in a Rainbow
by
applying a velocity shift. Positive velocities make
wavelengths longer (redshift); negative velocities make
wavelengths shorter (bluesfhit).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
velocity |
Quantity
|
The systemic velocity by which we should shift, with units of velocity (for example, u.km/u.s) |
0 * u.km / u.s
|
Source code in chromatic/rainbows/actions/shift.py
6 7 8 9 10 11 12 13 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 |
|
trim(self, just_edges=True, when_to_give_up=1, minimum_acceptable_ok=1)
#
Trim away bad wavelengths and/or times.
If entire wavelengths or times are marked as not ok
,
we can probably remove them to simplify calculations
and visualizations. This function will trim those away,
by default only removing problem rows/columns on the ends,
to maintain a contiguous block.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
just_edges |
bool, optional
|
Should we only trim the outermost bad wavelength bins?
|
True
|
when_to_give_up |
float, optional
|
The fraction of times that must be nan or not OK
for the entire wavelength to be considered bad (default = 1).
|
1
|
minimum_acceptable_ok |
float, optional
|
The numbers in the |
1
|
Returns:
Name | Type | Description |
---|---|---|
trimmed |
Rainbow
|
The trimmed |
Source code in chromatic/rainbows/actions/trim.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 |
|
🌈 Get/Timelike#
get_average_lightcurve(self)
#
Return a lightcurve of the star, averaged over all wavelengths.
This uses bin
, which is a horribly slow way of doing what is
fundamentally a very simply array calculation, because we
don't need to deal with partial pixels.
Returns:
Name | Type | Description |
---|---|---|
lightcurve |
array
|
Timelike array of fluxes. |
Source code in chromatic/rainbows/get/timelike/average_lightcurve.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
get_median_lightcurve(self)
#
Return a lightcurve of the star, medianed over all wavelengths.
Returns:
Name | Type | Description |
---|---|---|
median_lightcurve |
array
|
Timelike array of fluxes. |
Source code in chromatic/rainbows/get/timelike/median_lightcurve.py
6 7 8 9 10 11 12 13 14 15 16 17 |
|
get_for_time(self, i, quantity='flux')
#
Get 'quantity'
associated with time 'i'
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
i |
int
|
The time index to retrieve. |
required |
quantity |
string
|
The quantity to retrieve. If it is flux-like, column 'i' will be returned. If it is wave-like, the array itself will be returned. |
'flux'
|
Returns:
Name | Type | Description |
---|---|---|
quantity |
array, Quantity
|
The 1D array of 'quantity' corresponding to time 'i'. |
Source code in chromatic/rainbows/get/timelike/subset.py
9 10 11 12 13 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 |
|
get_ok_data_for_time(self, i, x='wavelength', y='flux', sigma='uncertainty', minimum_acceptable_ok=1, express_badness_with_uncertainty=False)
#
A small wrapper to get the good data from a time.
Extract a slice of data, marking data that are not ok
either
by trimming them out entirely or by inflating their
uncertainties to infinity.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
i |
int
|
The time index to retrieve. |
required |
x |
string, optional
|
What quantity should be retrieved as 'x'? (default = 'time') |
'wavelength'
|
y |
string, optional
|
What quantity should be retrieved as 'y'? (default = 'flux') |
'flux'
|
sigma |
string, optional
|
What quantity should be retrieved as 'sigma'? (default = 'uncertainty') |
'uncertainty'
|
minimum_acceptable_ok |
float, optional
|
The smallest value of |
1
|
express_badness_with_uncertainty |
bool, optional
|
If False, data that don't pass the |
False
|
Returns:
Name | Type | Description |
---|---|---|
x |
array
|
The time. |
y |
array
|
The desired quantity (default is |
sigma |
array
|
The uncertainty on the desired quantity |
Source code in chromatic/rainbows/get/timelike/subset.py
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 |
|
get_times_as_astropy(self, time=None, format=None, scale=None, is_barycentric=None)
#
Convert times from a Rainbow
into an astropy Time
object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
time |
Quantity, optional
|
The time-like Quantity to be converted.
If None (default), convert the time values in |
None
|
format |
str, optional
|
The time format to supply to astropy.time.Time.
If None (default), format will be pulled from
|
None
|
scale |
str, optional
|
The time scale to supply to astropy.time.Time.
If None (default), scale will be pulled from
|
None
|
is_barycentric |
bool, optional
|
Are the times already measured relative to the
Solar System barycenter? This is mostly for warning
the user that it's not.
If |
None
|
Returns:
Name | Type | Description |
---|---|---|
astropy_time |
Time
|
The times as an astropy |
Source code in chromatic/rainbows/get/timelike/time.py
4 5 6 7 8 9 10 11 12 13 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 |
|
set_times_from_astropy(self, astropy_time, is_barycentric=None)
#
Set the times for this Rainbow
from an astropy Time
object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
astropy_time |
Time
|
The times as an astropy |
required |
is_barycentric |
bool, optional
|
Are the times already measured relative to the Solar System barycenter? This is mostly for warning the user that it's not. Options are True, False, None (= don't know). |
None
|
Returns:
Name | Type | Description |
---|---|---|
time |
Quantity
|
An astropy Quantity with units of time, expressing the Time as julian day. In addition to this returned variable, the function sets the following internal variables:
|
Source code in chromatic/rainbows/get/timelike/time.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 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
|
🌈 Get/Wavelike#
get_average_spectrum(self)
#
Return a average_spectrum of the star, averaged over all times.
This uses bin
, which is a horribly slow way of doing what is
fundamentally a very simply array calculation, because we
don't need to deal with partial pixels.
Returns:
Name | Type | Description |
---|---|---|
average_spectrum |
array
|
Wavelike array of average spectrum. |
Source code in chromatic/rainbows/get/wavelike/average_spectrum.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
get_expected_uncertainty(self, function=np.nanmedian, *args, **kw)
#
Get the typical per-wavelength uncertainty.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
function |
function, optional
|
What function should be used to choose the "typical"
value for each wavelength? Good options are probably
things like |
np.nanmedian
|
*args |
list, optional
|
Addition arguments will be passed to |
()
|
**kw |
dict, optional
|
Additional keyword arguments will be passed to |
{}
|
Returns:
Name | Type | Description |
---|---|---|
uncertainty_per_wavelength |
array
|
The uncertainty associated with each wavelength. |
Source code in chromatic/rainbows/get/wavelike/expected_uncertainty.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
|
get_measured_scatter_in_bins(self, ntimes=2, nbins=4, method='standard-deviation', minimum_acceptable_ok=1e-10)
#
Get measured scatter in time bins of increasing sizes.
For uncorrelated Gaussian noise, the scatter should decrease as 1/sqrt(N), where N is the number points in a bin. This function calculates the scatter for a range of N, thus providing a quick test for correlated noise.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ntimes |
int
|
How many times should be binned together? Binning will continue recursively until fewer that nbins would be left. |
2
|
nbins |
int
|
What's the smallest number of bins that should be used to calculate a scatter? The absolute minimum is 2. |
4
|
method |
string
|
What method to use to obtain measured scatter. Current options are 'MAD', 'standard-deviation'. |
'standard-deviation'
|
minimum_acceptable_ok |
float
|
The smallest value of |
1e-10
|
Returns:
Name | Type | Description |
---|---|---|
scatter_dictionary |
dict
|
Dictionary with lots of information about scatter in bins per wavelength. |
Source code in chromatic/rainbows/get/wavelike/measured_scatter_in_bins.py
6 7 8 9 10 11 12 13 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 |
|
get_measured_scatter(self, quantity='flux', method='standard-deviation', minimum_acceptable_ok=1e-10)
#
Get measured scatter for each wavelength.
Calculate the standard deviation (or outlier-robust equivalent) for each wavelength, which can be compared to the expected per-wavelength uncertainty.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
quantity |
string, optional
|
The |
'flux'
|
method |
string, optional
|
What method to use to obtain measured scatter. Current options are 'MAD', 'standard-deviation'. |
'standard-deviation'
|
minimum_acceptable_ok |
float, optional
|
The smallest value of |
1e-10
|
Returns:
Name | Type | Description |
---|---|---|
scatter |
array
|
Wavelike array of measured scatters. |
Source code in chromatic/rainbows/get/wavelike/measured_scatter.py
6 7 8 9 10 11 12 13 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 |
|
get_median_spectrum(self)
#
Return a spectrum of the star, medianed over all times.
Returns:
Name | Type | Description |
---|---|---|
median_spectrum |
array
|
Wavelike array of fluxes. |
Source code in chromatic/rainbows/get/wavelike/median_spectrum.py
6 7 8 9 10 11 12 13 14 15 16 17 |
|
get_spectral_resolution(self, pixels_per_resolution_element=1)
#
Estimate the R=w/dw spectral resolution.
Higher spectral resolutions correspond to more wavelength
points within a particular interval. By default, it's
estimated for the interval between adjacent wavelength
bins. In unbinned data coming directly from a telescope,
there's a good chance that adjacent pixels both sample
the same resolution element as blurred by the telescope
optics, so the pixels_per_resolution_element
keyword
should likely be larger than 1.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pixels_per_resolution_element |
float, optional
|
How many pixels do we consider as a resolution element? |
1
|
Returns:
Name | Type | Description |
---|---|---|
R |
array
|
The spectral resolution at each wavelength. |
Source code in chromatic/rainbows/get/wavelike/spectral_resolution.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
|
get_for_wavelength(self, i, quantity='flux')
#
Get 'quantity'
associated with wavelength 'i'
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
i |
int
|
The wavelength index to retrieve. |
required |
quantity |
string
|
The quantity to retrieve. If it is flux-like, row 'i' will be returned. If it is time-like, the array itself will be returned. |
'flux'
|
Returns:
Name | Type | Description |
---|---|---|
quantity |
array, Quantity
|
The 1D array of 'quantity' corresponding to wavelength 'i'. |
Source code in chromatic/rainbows/get/wavelike/subset.py
9 10 11 12 13 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 |
|
get_ok_data_for_wavelength(self, i, x='time', y='flux', sigma='uncertainty', minimum_acceptable_ok=1, express_badness_with_uncertainty=False)
#
A small wrapper to get the good data from a wavelength.
Extract a slice of data, marking data that are not ok
either
by trimming them out entirely or by inflating their
uncertainties to infinity.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
i |
int
|
The wavelength index to retrieve. |
required |
x |
string, optional
|
What quantity should be retrieved as 'x'? (default = 'time') |
'time'
|
y |
string, optional
|
What quantity should be retrieved as 'y'? (default = 'flux') |
'flux'
|
sigma |
string, optional
|
What quantity should be retrieved as 'sigma'? (default = 'uncertainty') |
'uncertainty'
|
minimum_acceptable_ok |
float, optional
|
The smallest value of |
1
|
express_badness_with_uncertainty |
bool, optional
|
If False, data that don't pass the |
False
|
Returns:
Name | Type | Description |
---|---|---|
x |
array
|
The time. |
y |
array
|
The desired quantity (default is |
sigma |
array
|
The uncertainty on the desired quantity |
Source code in chromatic/rainbows/get/wavelike/subset.py
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 |
|
🌈 Visualizations#
animate_lightcurves(self, filename='animated-lightcurves.gif', fps=5, dpi=None, bitrate=None, **kwargs)
#
Create an animation to show how the lightcurve changes as we flip through every wavelength.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
Name of file you'd like to save results in. Currently supports only .gif or .html files. |
'animated-lightcurves.gif'
|
fps |
float
|
frames/second of animation |
5
|
ax |
Axes
|
The axes into which this animated plot should go. |
required |
xlim |
tuple
|
Custom xlimits for the plot |
required |
ylim |
tuple
|
Custom ylimits for the plot |
required |
cmap |
str
|
The color map to use for expressing wavelength |
required |
vmin |
Quantity
|
The minimum value to use for the wavelength colormap |
required |
vmax |
Quantity
|
The maximum value to use for the wavelength colormap |
required |
scatterkw |
dict
|
A dictionary of keywords to be passed to |
required |
textkw |
dict
|
A dictionary of keywords passed to |
required |
Source code in chromatic/rainbows/visualizations/animate.py
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 |
|
animate_spectra(self, filename='animated-spectra.gif', fps=5, dpi=None, bitrate=None, **kw)
#
Create an animation to show how the spectrum changes as we flip through every timepoint.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
Name of file you'd like to save results in. Currently supports only .gif files. |
'animated-spectra.gif'
|
ax |
Axes
|
The axes into which this animated plot should go. |
required |
fps |
float
|
frames/second of animation |
5
|
xlim |
tuple
|
Custom xlimits for the plot |
required |
ylim |
tuple
|
Custom ylimits for the plot |
required |
cmap |
str
|
The color map to use for expressing wavelength |
required |
vmin |
Quantity
|
The minimum value to use for the wavelength colormap |
required |
vmax |
Quantity
|
The maximum value to use for the wavelength colormap |
required |
scatterkw |
dict
|
A dictionary of keywords to be passed to |
required |
textkw |
dict
|
A dictionary of keywords passed to |
required |
Source code in chromatic/rainbows/visualizations/animate.py
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 428 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 |
|
get_wavelength_color(self, wavelength)
#
Determine the color corresponding to one or more wavelengths.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wavelength |
Quantity
|
The wavelength value(s), either an individual wavelength or an array of N wavelengths. |
required |
Returns:
Name | Type | Description |
---|---|---|
colors |
array
|
An array of RGBA colors [or an (N,4) array]. |
Source code in chromatic/rainbows/visualizations/colors.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
|
setup_wavelength_colors(self, cmap=None, vmin=None, vmax=None, log=None)
#
Set up a color map and normalization function for colors datapoints by their wavelengths.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cmap |
str, Colormap
|
The color map to use. |
None
|
vmin |
Quantity
|
The wavelength at the bottom of the cmap. |
None
|
vmax |
Quantity
|
The wavelength at the top of the cmap. |
None
|
log |
bool
|
If True, colors will scale with log(wavelength). If False, colors will scale with wavelength. If None, the scale will be guessed from the internal wscale. |
None
|
Source code in chromatic/rainbows/visualizations/colors.py
10 11 12 13 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 |
|
imshow(self, ax=None, quantity='flux', xaxis='time', w_unit='micron', t_unit='day', colorbar=True, aspect='auto', mask_ok=True, color_ok='tomato', alpha_ok=0.8, vmin=None, vmax=None, filename=None, **kw)
#
Paint a 2D image of flux as a function of time and wavelength,
using plt.imshow
where pixels will have constant size.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ax |
Axes, optional
|
The axes into which to make this plot. |
None
|
quantity |
str, optional
|
The fluxlike quantity to imshow.
(Must be a key of |
'flux'
|
w_unit |
str, Unit, optional
|
The unit for plotting wavelengths. |
'micron'
|
t_unit |
str, Unit, optional
|
The unit for plotting times. |
'day'
|
colorbar |
bool, optional
|
Should we include a colorbar? |
True
|
aspect |
str, optional
|
What aspect ratio should be used for the imshow? |
'auto'
|
mask_ok |
bool, optional
|
Should we mark which data are not OK? |
True
|
color_ok |
str, optional
|
The color to be used for masking data points that are not OK. |
'tomato'
|
alpha_ok |
float, optional
|
The transparency to be used for masking data points that are not OK. |
0.8
|
**kw |
dict, optional
|
All other keywords will be passed on to |
{}
|
Source code in chromatic/rainbows/visualizations/imshow.py
6 7 8 9 10 11 12 13 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 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 |
|
imshow_interact(self, quantity='Flux', t_unit='d', w_unit='micron', cmap='viridis', ylim=[], ylog=None, filename=None)
#
Display interactive spectrum plot for chromatic Rainbow with a wavelength-averaged 2D quantity defined by the user. The user can interact with the 3D spectrum to choose the wavelength range over which the average is calculated.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
Rainbow object
|
chromatic Rainbow object to plot |
required |
quantity |
str
|
(optional, default='flux')
The quantity to imshow, currently either |
'Flux'
|
ylog |
boolean
|
(optional, default=None) Boolean for whether to take log10 of the y-axis data. If None, will be guessed from the data. |
None
|
t_unit |
str
|
(optional, default='d') The time unit to use (seconds, minutes, hours, days etc.) |
'd'
|
w_unit |
str
|
(optional, default='micron') The wavelength unit to use |
'micron'
|
cmap |
str
|
(optional, default='viridis') The color scheme to use from Vega documentation |
'viridis'
|
ylim |
list
|
(optional, default=[]) If the user wants to define their own ylimits on the lightcurve plot |
[]
|
Source code in chromatic/rainbows/visualizations/interactive.py
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 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
|
pcolormesh(self, ax=None, quantity='flux', xaxis='time', w_unit='micron', t_unit='day', colorbar=True, mask_ok=True, color_ok='tomato', alpha_ok=0.8, vmin=None, vmax=None, filename=None, **kw)
#
Paint a 2D image of flux as a function of time and wavelength.
By using .pcolormesh
, pixels can transform based on their edges,
so non-uniform axes are allowed. This is a tiny bit slower than
.imshow
, but otherwise very similar.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ax |
Axes, optional
|
The axes into which to make this plot. |
None
|
quantity |
str, optional
|
The fluxlike quantity to imshow.
(Must be a key of |
'flux'
|
w_unit |
str, Unit, optional
|
The unit for plotting wavelengths. |
'micron'
|
t_unit |
str, Unit, optional
|
The unit for plotting times. |
'day'
|
colorbar |
bool, optional
|
Should we include a colorbar? |
True
|
mask_ok |
bool, optional
|
Should we mark which data are not OK? |
True
|
color_ok |
str, optional
|
The color to be used for masking data points that are not OK. |
'tomato'
|
alpha_ok |
float, optional
|
The transparency to be used for masking data points that are not OK. |
0.8
|
**kw |
dict, optional
|
All other keywords will be passed on to |
{}
|
Source code in chromatic/rainbows/visualizations/pcolormesh.py
7 8 9 10 11 12 13 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 |
|
plot_lightcurves(self, quantity='flux', ax=None, spacing=None, w_unit='micron', t_unit='day', cmap=None, vmin=None, vmax=None, errorbar=True, text=True, minimum_acceptable_ok=0.8, plotkw={}, errorbarkw={}, textkw={}, filename=None, scaling=1, label_scatter=False, **kw)
#
Plot flux as sequence of offset light curves.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ax |
Axes, optional
|
The axes into which to make this plot. |
None
|
spacing |
None, float, optional
|
The spacing between light curves. (Might still change how this works.) None uses half the standard dev of entire flux data. |
None
|
w_unit |
str, Unit, optional
|
The unit for plotting wavelengths. |
'micron'
|
t_unit |
str, Unit, optional
|
The unit for plotting times. |
'day'
|
cmap |
str, Colormap, optional
|
The color map to use for expressing wavelength. |
None
|
vmin |
Quantity, optional
|
The minimum value to use for the wavelength colormap. |
None
|
vmax |
Quantity, optional
|
The maximum value to use for the wavelength colormap. |
None
|
errorbar |
boolean, optional
|
Should we plot errorbars? |
True
|
text |
boolean, optional
|
Should we label each lightcurve? |
True
|
minimum_acceptable_ok |
float
|
The smallest value of |
0.8
|
plotkw |
dict, optional
|
A dictionary of keywords passed to |
{}
|
errorbarkw |
dict, optional
|
A dictionary of keywords passed to |
{}
|
textkw |
dict, optional
|
A dictionary of keywords passed to |
{}
|
**kw |
dict, optional
|
Any additional keywords will be stored as |
{}
|
Source code in chromatic/rainbows/visualizations/plot_lightcurves.py
6 7 8 9 10 11 12 13 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 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
|
plot_spectra(self, quantity='flux', ax=None, spacing=0.1, w_unit='micron', t_unit='day', cmap=None, vmin=None, vmax=None, errorbar=True, text=True, minimum_acceptable_ok=1, scatterkw={}, errorbarkw={}, plotkw={}, textkw={}, filename=None, **kw)
#
Plot flux as sequence of offset spectrum.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ax |
Axes
|
The axes into which to make this plot. |
None
|
spacing |
None, float
|
The spacing between light curves. (Might still change how this works.) None uses half the standard dev of entire flux data. |
0.1
|
w_unit |
str, Unit
|
The unit for plotting wavelengths. |
'micron'
|
t_unit |
str, Unit
|
The unit for plotting times. |
'day'
|
cmap |
str, Colormap
|
The color map to use for expressing wavelength. |
None
|
vmin |
Quantity
|
The minimum value to use for the wavelength colormap. |
None
|
vmax |
Quantity
|
The maximum value to use for the wavelength colormap. |
None
|
errorbar |
boolean
|
Should we plot errorbars? |
True
|
text |
boolean
|
Should we label each spectrum? |
True
|
minimum_acceptable_ok |
float
|
The smallest value of |
1
|
scatterkw |
dict
|
A dictionary of keywords passed to |
{}
|
errorbarkw |
dict
|
A dictionary of keywords passed to |
{}
|
plotkw |
dict
|
A dictionary of keywords passed to |
{}
|
textkw |
dict
|
A dictionary of keywords passed to |
{}
|
**kw |
dict
|
Any additional keywords will be stored as |
{}
|
Source code in chromatic/rainbows/visualizations/plot_spectra.py
6 7 8 9 10 11 12 13 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 186 187 188 189 190 191 192 193 194 195 196 |
|
plot(self, xaxis='time', **kw)
#
Plot flux either as a sequence of offset lightcurves (default) or as a sequence of offset spectra.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xaxis |
string
|
What should be plotted on the x-axis of the plot? 'time' will plot a different light curve for each wavelength 'wavelength' will plot a different spectrum for each timepoint |
'time'
|
**kw |
dict
|
All other keywords will be passed along to either
|
{}
|
Source code in chromatic/rainbows/visualizations/plot.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
|
🔨 Tools#
get_planck_photons(temperature=3000, wavelength=None, R=100, wlim=[0.04, 6] * u.micron, **kw)
#
Calculate the surface flux from a thermally emitted surface, according to Planck function, in units of photons/(s * m**2 * nm).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
temperature |
Quantity
|
The temperature of the thermal emitter, with units of K. |
3000
|
wavelength |
Quantity, optional
|
The wavelengths at which to calculate, with units of wavelength. |
None
|
R |
float, optional
|
The spectroscopic resolution for creating a log-uniform
grid that spans the limits set by |
100
|
wlim |
Quantity, optional
|
The two-element [lower, upper] limits of a wavelength
grid that would be populated with resolution |
[0.04, 6] * u.micron
|
**kw |
dict, optional
|
Other keyword arguments will be ignored. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
photons |
Quantity
|
The surface flux in photon units |
This evaluates the Planck function at the exact wavelength values; it doesn't do anything fancy to integrate over binwidths, so if you're using very wide (R~a few) bins your integrated fluxes will be messed up.
Source code in chromatic/spectra/planck.py
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 |
|
get_phoenix_photons(temperature=5780, logg=4.43, metallicity=0.0, R=100, wavelength=None, wavelength_edges=None, visualize=False)
#
Get a PHOENIX model spectrum for an arbitrary temperature, logg, metallicity.
Calculate the surface flux from a thermally emitted surface, according to PHOENIX model spectra, in units of photons/(s * m**2 * nm).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
temperature |
float, optional
|
Temperature, in K (with no astropy units attached). |
5780
|
logg |
float, optional
|
Surface gravity log10[g/(cm/s**2)] (with no astropy units attached). |
4.43
|
metallicity |
float, optional
|
Metallicity log10[metals/solar] (with no astropy units attached). |
0.0
|
R |
float, optional
|
Spectroscopic resolution (lambda/dlambda). Currently, this must
be in one of [3,10,30,100,300,1000,3000,10000,30000,100000], but
check back soon for custom wavelength grids. There is extra
overhead associated with switching resolutions, so if you're
going to retrieve many spectra, try to group by resolution.
(If you're using the |
100
|
wavelength |
Quantity, optional
|
A grid of wavelengths on which you would like your spectrum. If this is None, the complete wavelength array will be returned at your desired resolution. Otherwise, the spectrum will be returned exactly at those wavelengths. Grid points will be cached for this new wavelength grid to speed up applications that need to retreive lots of similar spectra for the same wavelength (like many optimization or sampling problems). |
None
|
wavelength_edges |
Quantity, optional
|
Same as |
None
|
Returns:
Name | Type | Description |
---|---|---|
wavelength |
Quantity
|
The wavelengths, at the specified resolution. |
photons |
Quantity
|
The surface flux in photon units |
Source code in chromatic/spectra/phoenix.py
1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 |
|
Tools for resampling array from one grid of independent variables to another.
bintoR(x, y, unc=None, R=50, xlim=None, weighting='inversevariance', drop_nans=True)
#
Bin any x and y array onto a logarithmicly uniform grid.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
array
|
The original independent variable. (For a spectrum example = wavelength) |
required |
y |
array
|
The original dependent variable (same size as x). (For a spectrum example = flux) |
required |
unc |
array, None, optional
|
The unceratinty on the dependent variable (For a spectrum example = the flux uncertainty) |
None
|
R |
array, optional
|
The spectral resolution R=x/dx for creating a new, logarithmically uniform grid that starts at the first value of x. |
50
|
xlim |
list, array, optional
|
A two-element list indicating the min and max values of x for the new logarithmically spaced grid. If None, these limits will be created from the data themselves |
None
|
weighting |
str, optional
|
How should we weight values when averaging
them together into one larger bin?
|
'inversevariance'
|
drop_nans |
bool, optional
|
Should we skip any bins turn out to be nans? This most often happens when bins are empty. |
True
|
Returns:
Name | Type | Description |
---|---|---|
result |
dict
|
A dictionary containing at least...
|
Source code in chromatic/resampling.py
666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 |
|
bintogrid(x=None, y=None, unc=None, newx=None, newx_edges=None, dx=None, nx=None, weighting='inversevariance', drop_nans=True, x_edges=None, visualize=False)
#
Bin any x and y array onto a linearly uniform grid.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
array
|
The original independent variable. (For a spectrum example = wavelength) |
None
|
y |
array
|
The original dependent variable (same size as x). (For a spectrum example = flux) |
None
|
unc |
array, None
|
The unceratinty on the dependent variable (For a spectrum example = the flux uncertainty) |
None
|
nx |
array
|
The number of bins from the original grid to bin together into the new one. |
None
|
dx |
array
|
The fixed spacing for creating a new, linearly uniform
grid that start at the first value of x. This will
be ignored if |
None
|
newx |
array
|
A new custom grid onto which we should bin. |
None
|
newx_edges |
array
|
The edges of the new grid of bins for the independent
variable, onto which you want to resample the y
values. The left and right edges of the bins will be,
respectively, |
None
|
weighting |
str
|
How should we weight values when averaging
them together into one larger bin?
|
'inversevariance'
|
drop_nans |
bool
|
Should we skip any bins turn out to be nans? This most often happens when bins are empty. |
True
|
x_edges |
array
|
The edges of the original independent variable bins.
The left and right edges of the bins are interpreted
to be |
None
|
Returns:
Name | Type | Description |
---|---|---|
result |
dict
|
A dictionary containing at least...
|
The order of precendence for setting the new grid is
[newx_edges
, newx
, dx
, nx
]
The first will be used, and others will be ignored.
Source code in chromatic/resampling.py
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 428 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 492 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 535 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 629 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 |
|
resample_while_conserving_flux(xin=None, yin=None, xout=None, xin_edges=None, xout_edges=None, replace_nans=0.0, visualize=False, pause=False)
#
Starting from some initial x and y, resample onto a different grid (either higher or lower resolution), while conserving total flux.
When including the entire range of xin
,
sum(yout) == sum(yin)
should be true.
When including only part of the range of xin
,
the integral between any two points should be conserved.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xin |
array
|
The original independent variable. |
None
|
yin |
array
|
The original dependent variable (same size as x). |
None
|
xout |
array
|
The new grid of independent variables onto which
you want to resample the y values. Refers to the
center of each bin (use |
None
|
xin_edges |
array
|
The edges of the original independent variable bins.
The left and right edges of the bins are interpreted
to be |
None
|
xout_edges |
array
|
The edges of the new grid of bins for the independent
variable, onto which you want to resample the y
values. The left and right edges of the bins will be,
respectively, |
None
|
replace_nans |
float, str
|
Replace nan values with this value.
|
0.0
|
visualize |
bool
|
Should we make a plot showing whether it worked? |
False
|
pause |
bool
|
Should we pause to wait for a key press? |
False
|
Returns:
Name | Type | Description |
---|---|---|
result |
dict
|
A dictionary containing...
|
Source code in chromatic/resampling.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 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 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
|
expand_filenames(filepath)
#
A wrapper to expand a string or list into a list of filenames.
Source code in chromatic/imports.py
97 98 99 100 101 102 103 104 105 106 107 |
|
name2color(name)
#
Return the 3-element RGB array of a given color name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of a color |
required |
Returns:
Name | Type | Description |
---|---|---|
rgb |
tuple
|
3-element RGB color, with numbers from 0.0 to 1.0 |
Source code in chromatic/imports.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
one2another(bottom='white', top='red', alpha_bottom=1.0, alpha_top=1.0, N=256)
#
Create a cmap that goes smoothly (linearly in RGBA) from "bottom" to "top".
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bottom |
str
|
Name of a color for the bottom of cmap (0.0) |
'white'
|
top |
str
|
Name of a color for the top of the cmap (1.0) |
'red'
|
alpha_bottom |
float
|
Opacity at the bottom of the cmap |
1.0
|
alpha_top |
float
|
Opacitiy at the top of the cmap |
1.0
|
N |
int
|
The number of levels in the listed color map |
256
|
Returns:
Name | Type | Description |
---|---|---|
cmap |
Colormap
|
A color map that goes linearly from the bottom to top color (and alpha). |
Source code in chromatic/imports.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 |
|
remove_unit(x)
#
Quick wrapper to remove the unit from a quantity, but not complain if it doesn't have one.
Source code in chromatic/imports.py
175 176 177 178 179 180 181 182 183 |
|