-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathexofastv2.pro
More file actions
1863 lines (1780 loc) · 87.4 KB
/
exofastv2.pro
File metadata and controls
1863 lines (1780 loc) · 87.4 KB
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
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
;+
; NAME:
; EXOFASTv2
;
; PURPOSE:
; This is the high-level code for EXOFASTv2 to perform global
; models for exoplanetary systems.
;
; Please cite Eastman et al., 2019
; (https://arxiv.org/abs/1907.09480) if you make use of this routine
; in your research.
;
; Report errors or bugs to jason.eastman@cfa.harvard.edu
;
; CALLING SEQUENCE:
;
; exofastv2, PRIORFILE= [RVPATH=, TRANPATH=, FLUXFILE=, PREFIX=,
; /CIRCULAR, NTHIN=, MAXSTEPS=, /DEBUG, RANDOMFUNC=,
; SEED=, /SPECPRIORS, /BESTONLY, NINTERP=, EXPTIME=,
; /LONGCADENCE]
;
; INPUTS:
;
; PRIORFILE - An ASCII file with each line containing 2-6 white
; space delimited columns:
;
; NAME VALUE WIDTH LOWERLIMIT UPPERLIMIT STARTING_VALUE
;
; NAME: must match a parameter.label. If in an array
; (e.g., of planets), add "_i", where "i" is the
; zero-indexed index into the array.
;
; VALUE: If less than 6 columns are supplied, this is
; the starting point of the fit. If this is the last
; value specified, this only changes the starting point
; and no prior is applied. If WIDTH is specified, this
; is the mean of the gaussian prior.
;
; WIDTH: Standard deviation of a Gaussian prior. If
; negative, it is ignored (no Gaussian prior). If zero,
; the parameter is fixed to VALUE.
;
; LOWERLIMIT: Lower bound of a uniform prior. If -Inf,
; it is ignored.
;
; UPPERLIMIT: Upper bound of a uniform prior. If Inf,
; it is ignored.
;
; STARTING_VALUE: If specified, the fit will start here
; regardless of the Gaussian prior
;
; See
; $EXOFAST_PATH/parnames.README for a detailed
; explanation of this file and $EXOFAST_PATH/examples/
; for templates to use.
; PREFIX - Each of the output files will have this string as a
; prefix. You can specify an absolute or relative
; path. If the directories do not exist, they will be
; created. The default is 'fitresults/planet.' to put
; all outputs in a fitresults subdirectory.
;
; DATA FILE INPUTS
; RVPATH - A string specifying the path to the RV data
; file(s). Wildcards are allowed for multiple files
; (e.g., '*.rv'). Each file must have at least 3
; columns:
; 1) Time (BJD_TDB -- See Eastman et al., 2010)
; 2) RV (m/s)
; 3) err (m/s)
;
; If additional columns are supplied, they will be
; detrended against.
;
; The filenames of the RV data files *should* adhere
; to a certain format:
;
; planet_name.telescope.whateveryouwant.
;
; "telescope" is used as the legend text in figures
; and as header entries in the table.
;
; NOTE 1: The units must be as specified, or the fit
; will be wrong or fail.
; NOTE 2: Other input time stamps will likely not
; break the code, but can introduce errors in the
; reported times of more than a minute. The output
; table will display BJD_TDB but makes no attempt to
; convert input times. See
; http://adsabs.harvard.edu/abs/2010PASP..122..935E
; for an explanation of times
; NOTE 3: If RVPATH is omitted, no RV model will be
; generated.
;
; TRANPATH - A string specifying the path to the transit data
; file(s). Wildcards are allowed for multiple files
; (e.g., '*.dat'). Each file must have at least 3
; columns:
;
; 1) Time (BJD_TDB -- See Eastman et al., 2010)
; 2) Normalized flux
; 3) err
; 4) Detrend parameter 1
; ....
; N+3) Detrend parameter N
;
; An optional header specifies which parameters
; should be multiplicatively detrended and which
; should be additively detrended. Without a header,
; all detrending parameters are additively detrended.
;
; The first character in the header line must be
; "#". It must have whitespace delimited columns
; corresponding to the data. Each multiplicative
; detrending variable is preceeded with "M" (case
; sensitive). For example, the header line
;
; #BJD_TDB FLUX ERR MAIRMASS SKY myval
;
; Will fit a multiplicative detrending to the 4th
; column (MAIRMASS) and an additive detrending to the
; 5th and 6th columns (SKY and myval).
;
; The corresponding model will be:
;
; model = (transit + C0*SKY + C1*myval)*(F0 + M0*MAIRMASS)
;
; Where C0, C1, and M0 are fitted detrending
; parameters, F0 is the normalization, and SKY,
; motion, and MAIRMASS are vectors for each data point
; to detrend against.
;
; The names of the files describing the transits
; *must* adhere to a certain format:
; nYYYYMMDD.filtername.telescope.whateveryouwant.
;
; nYYYYMMDD -- The UTC date of mid transit, where YYYY is
; the year, MM is the month, and DD is the day. This
; is only necessary if the data has a single
; transit. This is used to label the transits in the
; output plot.
;
; filtername -- The name of the observed
; filter. If NOCLARET is not set, the filter must be
; among the following list:
;
; Johnson/Cousins: 'U','B','V','R','I','J','H','K'
; Sloan: 'Sloanu','Sloang','Sloanr','Sloani','Sloanz'
; Kepler: 'Kepler'
; CoRoT: 'CoRoT'
; TESS: 'TESS'
; Spitzer: 'Spit36','Spit45','Spit58','Spit80'
; Stromgren: 'u','b','v','y'
;
; This is used to define the limb darkening for the
; transit, dilution, and secondary depth
; parameters.
;
; NOTE: If NOCLARET is set, you may specify anything
; here. If a number where "." is replaced with "_", it
; will be interpreted as a wavelength in microns. If
; TDELTAVS is also set, a plot of depth vs wavelength
; will be created for transmission spectroscopy.
;
; telescope -- a description of the telescope used for
; the observations. Anything is allowed, but all
; observations observed with the same telescope should
; have the same name. This is used in the output plot
; and color codes the TTV plot.
;
; whateveryouwant -- any string you want to
; include for it to make sense to you. This is not
; used by the code.
;
; So a transit taken on UTC 2017-01-27 with MINERVA in
; the V band would be "n20170127.V.MINERVA.dat"
;
; NOTE 2: The units must be as specified, or the fit
; will be wrong or fail.
; NOTE 3: Other input time stamps will likely not
; break the code, but can introduce errors in the
; reported times of more than a minute. The output
; table will display BJD_TDB but makes no attempt to
; convert input times. See
; http://adsabs.harvard.edu/abs/2010PASP..122..935E
; for an explanation of times
; NOTE 4: If omitted, just the RV data will bit fit
;
; *** Astrometry is not currently suppported or thoroughly tested. Future updates are likely to change the expected formats ***
; ASTROMPATH - A string specifying the path to the astrometry data
; file(s). Wildcards are allowed for multiple files
; (e.g., '*.dat'). Each file must have 5 or 8 columns:
;
; 1) Time (BJD_TDB -- See Eastman et al., 2010)
; 2) RA (ICRS deg)
; 3) DEC (ICRS deg)
; 4) ra uncertainty (mas)
; 5) dec uncertainty (mas)
; 6) X position of observatory (AU from Solar System Barycenter)
; 7) Y position of observatory (AU from Solar System Barycenter)
; 8) Z position of observatory (AU from Solar System Barycenter)
;
; The filename must adhere to a certain format:
; epoch.location.whateveryouwant
;
; epoch -- the reference epoch of the
; observations in BJD_TDB (e.g., J2000 is
; 2451545).
; location -- the location of the observatory. Only
; "Earth" (geocenter), "Gaia" and "Hipparcos" are
; understood, in which case the observatory position
; (columns 6-8) will be calculated if not supplied.
; whateveryouwant -- any string you want to include
; for it to make sense to you. This is not used by the
; code.
;
; If supplied, EXOFASTv2 will fit the following
; additional parameters: RA, Dec, PMRA, PMDEC, and
; parallax, plus Omega for each planet. The
; inclination will span the range from 0 to 180 (-1 <
; cosi < 1).
;
; DTPATH - The (optional) path to the Doppler Tomography fits
; file(s). If supplied, the code will fit a vsini and
; macro turbulence of the star, as well as a projected
; spin-orbit alignment for each planet. This must be
; used in conjunction with the FITDT, an NPLANETS array
; specifying which planets should have their DT signal
; modeled.
;
; Each fits file is a 2D array describing all DT
; observations during a single transit with extensions
; describing the axes of the array. The pixel values of
; the 2D array contain the fractional flux decrement at
; a given BJD_TDB (spectrum) and velocity (pixel value
; of the CCF). The first extension should specify the
; BJD_TDB corresponding to each Y pixel and the second
; extension should specify the velocity corresponding
; to each X pixel.
;
; Such a file can be generated given the 2D array of
; fractional flux decrements (DT), a time array
; (BJD_TDB) and a velocity array (VEL, in km/s) like this:
;
; writefits,'nYYYYMMDD.pname.instrument.resolution.fits',DT
; writefits,'nYYYYMMDD.pname.instrument.resolution.fits',BJD_TDB, /append
; writefits,'nYYYYMMDD.pname.instrument.resolution.fits',VEL, /append
;
; The names of these files *must* adhere to a certain format:
; nYYYYMMDD.pname.instrument.resolution.whateveryouwant.fits
;
; nYYYYMMDD -- The UTC date of mid transit. This is
; used to label the transits in the output plot.
;
; pname -- The name of the planet, including the
; letter for the planet order (e.g., KELT-24b)
;
; instrument -- the name of the instrument used for
; the observations. Anything is allowed, but all
; observations observed with the same telescope should
; have the same name. This is used in the labels.
;
; resolution -- The R value of the instrument. This is
; required to accurately model the DT signal and must
; be correct.
;
; whateveryouwant - any string you want to include (or
; nothing) for it to make sense to you (e.g, target
; name). This is not used by the code.
;
; So a transit taken on UTC 2017-01-27 with the TRES
; spectrograph (R=44000) would be called
; "n20170127.TRES.44000.fits"
;
; NOTE 0: When supplied this way, the DT data does not
; constrain vsini. A gaussian prior must be given in
; the prior file.
;
; NOTE 1: NAXIS1 must equal the number of velocities and
; NAXIS2 must equal the number of times.
;
; NOTE 2: Not using BJD_TDB time stamps will likely
; not break the code, but can introduce errors in the
; reported times of more than a minute or cause
; internal inconsistencies if different data sets use
; different timestamps. The output table will display
; BJD_TDB but makes no attempt to convert or reconcile
; input times between data sets.
;
; See
; http://adsabs.harvard.edu/abs/2010PASP..122..935E
; for an explanation of times
;
; NOTE 3: If DTPATH is omitted, Doppler Tomography is
; not included in the global fit
;
; SED MODEL INPUTS:
; FLUXFILE - An ASCII file with each line containing 3-5 white
; space delimited columns:
;
; FILTER MAG UNCERTAINTY CATALOG_UNCERTAINTY STARNDX
;
; FILTER: The filter name. See
; $EXOFAST_PATH/sed/mist/filternames2.txt for
; a complete list of allowed filters.
;
; MAG: The apparent magnitude in the specified filter
;
; UNCERTAINTY: The uncertainty in the apparent magnitude
;
; CATALOG_UNCERTAINTY: Often catalog errors ignore
; systematic error. This is the catalog error for
; reference, but is ignored.
;
; STARNDX: The index of the star(s) this magnitude
; corresponds to. Multiple stars can be specified as a
; comma delimited list (e.g., "0,1"). Differential
; magnitudes can be specified with a "-" (e.g.,
; "2-0,1"). This is ignored when the FLUXFILE model.
;
; NOTE: a parallax prior should be specified or the SED
; model will simply determine a photometric parallax.
;
; $EXOFAST_PATH/mkticsed.pro will automatically
; generate this file using queryVizier to query trusted
; catalogs with appropriate systematic error floors
; based on the object's name or coordinates. Exercise
; caution that the correct object was selected for each
; catalog.
;
; The FLUXFILE SED model assumes top hat filter
; profiles to sum NEXTGEN stellar atmospheres. It does
; not support Gaia bands, multiple stars, differential
; photometry, or spectrophotometry. It is no longer
; recommended for general use but is left for
; comparison.
;
; MISTSEDFILE - Same as FLUXFILE, but uses the MIST bolometric
; correction tables based on the C3K atmospheric
; grids. Supports multiple stars and differential
; photometry, and a much wider range of filters, but
; not spectrophotometry.
;
; SEDFILE - Same as FLUXFILE, but uses detailed filter profiles
; to determine the model flux. The user can supply
; their own filter profiles or generate any from SVO
; using
; $EXOFAST_PATH/sed/filtercurves/getfilter.pro. This
; model supports multiple stars, differential
; photometry, and spectrophotometry.
;
; SPECPHOTPATH- The path to spectrophotometry files. Can only be used
; in conjunction with the SEDFILE SED model.
;
; NOAVPRIOR - By default, when multiple stars are fit, the
; exinction (AV) is assumed to be a monotonically
; increasing function of distance. Set this keyword to
; allow any AV regardless of distance.
;
; FBOLSEDFLOOR- The SED model's constraint on the bolometric flux is
; typically dominated by systematic uncertainty. This
; sets that floor. Default is 0.024 (2.4%). See
; Tayar+2022.
;
; TEFFSEDFLOOR- The SED model's constraint on the effective
; temperature is typically dominated by systematic
; uncertainty. This sets that floor. Default is 0.02
; (2.0%). See Tayar+2022.
;
; FEHSEDFLOOR - The SED model's constraint on the metalicity
; occasionally exceeds the systematic uncertainty. This
; sets that floor. Default is none. If set, a new
; FEHSED is fit.
;
; ONED - For the FLUXFILE and SEDFILE models, the reddened
; NEXTGEN atmospheres are trilinearly interpolated in
; 3D in Teff, logg, and [Fe/H]. If set, the nearest
; gridpoints in logg and [Fe/H] are used (typically
; ~0.5 dex), and the interpolation is only done in
; Teff. Use of this keyword is not recommended.
;
; EVOLUTIONARY MODEL INPUTS:
;
; NOMIST - An NSTARS boolean array specifying not to use the MIST
; evolutionary tracks see
; http://waps.cfa.harvard.edu/MIST/ And please cite
; http://adsabs.harvard.edu/abs/2016ApJS..222....8D
; http://adsabs.harvard.edu/abs/2016ApJ...823..102C
;
; PARSEC - An NSTARS boolean array specifying to use the PARSEC
; evolutionary tracks. This should
; be accompanied by the NOMIST keyword (but is not
; enforced).
;
; YY - An NSTARS boolean array specifying to use the YY
; evolutionary tracks see
; http://adsabs.harvard.edu/abs/2001ApJS..136..417Y to
; constrain the mass/radius of the star. YY should not
; be used for low-mass stars (~< 0.5 msun). This should
; be accompanied by the NOMIST keyword (but is not
; enforced).
;
; TORRES - An NSTARS boolean array specifying to use the Torres
; relations to constrain the mass and radius of the
; star. This may be useful to investigate potential
; systematics and should be accompanied by the NOMIST
; keyword (but is not enforced). The Torres relations
; are not applicable for low mass (< 0.6 msun) stars.
;
; MANNRAD - An NSTARS boolean array specifying to use the Mann+
; 2015 Ks-Rstar relations to constrain the radius of the
; star. A prior on the apparent Ks band magnitude (e.g.,
; from 2MASS) and parallax should be given, and should
; be accompanied by the NOMIST keyword. The Mann
; relations are not applicable to high mass (> 0.7 msun)
; stars. When the transit-based constraint on rhostar
; exceeds ~5%, use of this relation is not recommended.
;
; MANNMASS - An NSTARS boolean array specifying to use the Mann+
; 2019 Ks-Mstar relations to constrain the mass of the
; star. A prior on the apparent Ks-band magnitude (e.g.,
; from 2MASS) and parallax should be given, and should
; be accompanied by the NOMIST keyword. The Mann
; relations are not applicable to high mass (> 0.7 msun)
; stars.
;
; TEFFEMFLOOR- When using MIST, PARSEC, or YY, the evolutionary
; model's constraint on the effective temperature is
; typically dominated by systematic uncertainty. This
; sets that floor. The default is a function of stellar
; mass and evolutionary model. See Tayar+2022.
;
; FEHEMFLOOR - When using MIST, PARSEC, or YY, the evolutionary
; model's constraint on the metallicity is typically
; dominated by systematic uncertainty. This sets that
; floor. Default is 0.08 dex.
;
; RSTAREMFLOOR
; - When using MIST, PARSEC, or YY, the evolutionary
; model's constraint on the stellar radius is typically
; dominated by systematic uncertainty. This sets that
; floor. The default is a function of stellar mass and
; evolutionary model. See Tayar+2022.
;
; AGEEMFLOOR- The evolutionary model's constraint on the stellar age
; is typically dominated by systematic uncertainty
; (maybe?). This sets that floor. The default is a
; function of stellar mass and evolutionary model.
;
; BEER MODEL INPUTS:
;
; FITTHERMAL- An NTRANSITS boolean array specifying which transits to
; fit thermal emission for. This is what you want to set
; to model an isolated secondary eclipse. When set, the
; transit will be modeled with a baseline of 1 between t2
; and t3 of the secondary eclipse and 1 + thermal
; emission (in PPM) out of eclipse.
;
; NOTE: earlier versions of this array specified the band
; name and all similar bands were linked together. This
; functionality can be recreated by linking the THERMAL
; parameters in the prior file for common bands.
;
; FITELLIP - A string array specifying which bands to fit an
; ellipsoidal variation amplitude for. Note: this does
; *not* feedback into the global model through F&M 2011,
; eq 2
; NOTE: this should be (has been?) converted like FITTHERMAL
;
; FITREFLECT- A string array specifying which bands to fit reflected
; light for. Set this along with thermal if you're
; fitting a full phase curve. It will be modeled as a
; sinusoid with the orbital period, a minimum at the
; primary transit, and a fitted amplitude (in PPM).
;
; FITPHASE - An NPLANETS boolean array that specifies if a phase
; shift to the sinusoidal reflection signal should be
; fit. This appears to be broken. Use with caution.
;
; FITBEAM - An NPLANETS boolean array that specifies which planets
; to model a doppler beaming signal. If this beaming
; amplitude is fit directly, it will *not* constrain the
; planetary mass (set DERIVEBEAM instead).
;
; DERIVEBEAM- An NPLANET boolean array that specifies which planets
; to model a doppler beaming signal. If this beaming
; amplitude is derived (from K), it will constrain the
; planetary mass through Faigler & Mazeh, 2011, eq 1 (set
; FITBEAM instead to model the beaming but break this
; connection).
;
; STAR INPUTS:
;
; NSTARS - The number of stars to model. Default=1. Must be larger
; than 0.
;
; STARNDX - An NPLANETS long array that specifies the index of the
; star each planet orbits. The default is 0 for all.
;
; SEDDEBLEND- An NTRANSITSxNSTARS boolean array specifying which
; transits are blended with which stars. These will
; automatically be deblended according to the SED models
; of all stars specified here, assuming an error of 10%.
; NOTE: TESS lightcurves from SPOC are already deblended
; with known companions (in TICv8.1). They can be
; undeblended with the -u option to
; $EXOFAST_PATH/getdata.py.
;
; FITDILUTE -A string array specifying which bands to fit a dilution
; term for. It will fit the fractional contribution from
; the companion. This should be set if the star is blended
; with a neighbor and you expect color-dependent depth
; variations in the transit or photocenter variations in
; the astrometry.
;
; If you just have the flux ratio, X, solve this system of
; equations for Flux_companion:
;
; Flux_companion/Flux_primary = X
; Flux_companion + Flux_primary = 1
; Flux_companion = X/(X+1)
;
; Note 1: For transits, this is likely to be degenerate
; with F0 (transit normalization). You probably need to
; apply a prior (DILUTE_#, where # corresponds to the band
; index) from some external information to constrain it
; (e.g., an SED fit).
;
; Note 2: For astrometry, this is degenerate with the
; semi-major axis/mass. You must supply a prior on the
; dilution (e.g., from AO) in at least one band if one of
; those is not independently determined.
;
; Note 3: This dilution does not impact the SED fit. The
; SED broadband photometry is assumed to be for the
; single, primary component.
;
; PLANET INPUTS:
;
; NPLANETS - The number of planets you wish to fit to the
; data. Default is 1. If 0 is set, it will just fit the
; star.
;
; FITTRAN - An NPLANETS boolean array that specifies which planets
; should be fit with a transit model. If TRANPATH is
; specified, default is bytarr(nplanets) + 1B. If
; TRANPATH is not specified, default is bytarr(nplanets).
; At least one of FITRV and FITTRAN should be true for
; each planet
;
; FITRV - An NPLANETS boolean array that specifies which planets
; should be fit with an RV model. If RVPATH is
; specified, default is bytarr(nplanets) + 1B. If RVPATH
; is not specified, default is bytarr(nplanets). At
; least one of FITRV and FITTRAN should be true for each
; planet
;
; ROSSITER - An NPLANETS boolean array that specifies which planets
; should fit the Rossiter-McLaughlin effect to the RV
; data using the Ohta approximation. See
; https://ui.adsabs.harvard.edu/abs/2005ApJ...622.1118O/abstract
; If a run was dedicated to RM, it should be separated
; into its own RV file to fit a different zero point and
; jitter parameter to it. Default is bytarr(nplanets)
;
; FITDT - An NPLANETS boolean array that specifies which planets
; should be fit using a Doppler Tomography model. Default
; is bytarr(nplanets)
;
; CIRCULAR - An NPLANETS boolean array that specifies which planets
; should be fixed to be circular (1) or left with
; eccentricity free (0). Default is all eccentric planets
; bytarr(nplanets)
;
; TIDES - If set, when (1-Rstar/a-rp/a) < e < (1-3*Rstar/a), we
; set the eccentricity to zero, presuming that the tidal
; circularization timescale is much much smaller than the
; age of the system.
;
; ALLOWORBITCROSSING
; - By default, models that have projected orbits within
; each others' hill spheres are rejected, presuming
; they are unstable and constraining eccentricity. This
; may be too strict when mutual inclinations are
; significant (it would exclude Pluto/Neptune). Set this
; keyword to disable this constraint and allow orbits to
; cross one another.
;
; CHEN - An NPLANETS boolean array that specifies which planets
; should have the Chen & Kipping, 2017 mass-radius
; relation applied. By default CHEN = FITRV xor
; FITTRAN. That is, only apply the mass-radius prior when
; RV is not fit (to derive the planet mass) or when a
; transit is not fit (to derive the planet radius). If the
; defaults have been overridden and FITRV and CHEN are
; both false for a given planet, the RV semi-amplitude
; (planet mass) and all derived parameters will not be
; quoted. Multi-planet systems will be constrained not to
; cross orbits, but the Hill Sphere will be set to zero.
; If FITTRAN and CHEN are both false for a given planet,
; the planetary radius and all derived parameters will not
; be quoted.
;
; I180 - An NPLANETS boolean array specifying which planets'
; inclination should be allowed to be between 0 and 180
; instead of the default of 0 to 90. Note that a typical
; transiting planet has a perfect degeneracy between i and
; 180-i which is likely to cause convergence
; problems. Additional information (e.g., from astrometry
; or mutual eclipses) must be used for this keyword to
; have the desired impact. Even in the case of mutual
; eclipses (which is currently not supported), at least
; one planet must be arbitrarily constrained from 0 to 90.
;
; RV INPUTS
;
; FITSLOPE - If set, it will fit a linear trend to the RV data.
;
; FITQUAD - If set, it will fit a quadratic trend to the RV
; data. FITSLOPE is automatically set if FITQUAD is set.
;
; RVEPOCH - This is the BJD_TDB of a reference epoch for RV linear
; and quadratic trends. Default is the midpoint of all RV
; observations.
;
; RV = planet + gamma + SLOPE*(t-RVEPOCH) + QUAD*(t-RVEPOCH)^2
;
; TRANSIT INPUTS
;
; NOCLARET - An NTRANSITFILES boolean array that, if set, will ignore
; the Claret & Bloeman limb darkening tables and just fit
; the limb darkening. This should be specified for
; low-mass stars where these tables are unreliable or for
; high SNR transits where they can constrain the LD
; directly.
;
; TTVS - An NTRANSITFILESxNPLANETS boolean array, specifying which
; transit files should have a timing offset applied
; corresponding to which planets.
; NOTE: if the same transit applies to more than one
; planet, the same offset will be applied to both. Such
; transits should probably be removed from the analysis.
;
; TIVS - An NTRANSITFILESxNPLANETS boolean array, specifying which
; transit files should have an inclination offset applied
; corresponding to which planets.
; NOTE: if the same transit applies to more than one
; planet, the same offset will be applied to both. Such
; transits should probably be removed from the analysis.
;
; TDELTAVS - An NTRANSITFILESxNPLANETS boolean array, specifying which
; transit files should have a depth offset applied
; corresponding to which planets. NOTE: if the same
; transit applies to more than one planet, the same offset
; will be applied to both. Such transits should probably
; be removed from the analysis.
;
; LONGCADENCE
; - An NTRANSITFILES boolean array, which sets/overwrites
; EXPTIME=29.425 and NINTERP=10 to handle Kepler long
; cadence data. This is measurably different from TESS
; long cadence data (EXPTIME=30, NINTERP=10).
;
; EXPTIME - An NTRANSITFILES array of exposure times, in minutes,
; for each transit. The model data point will be an
; average of NINTERP samples over a duration of EXPTIME
; minutes centered on the input time. Generally, a
; sampling at least every 3 minutes is recommended. For a
; dicussion on binning, see:
; http://adsabs.harvard.edu/abs/2010MNRAS.408.1758K
;
; NINTERP - An NTRANSITFILES long array for the number of points to
; average throughout the EXPTIME. If set, the each model
; data point will be an average of NINTERP samples over a
; duration of EXPTIME minutes centered on the input
; time. Generally, a sampling at least every 3 minutes is
; recommended.
;
; REJECTFLATMODEL
; - An NTRANSITFILES byte array specifying which transits
; must have a signal. If model without a signal is
; generated and REJECTFLATMODEL==1B, the model will be
; rejected a priori. If a flat model is accepted when a
; transit is expected, there is an infinite volume of
; parameter space with equal likelihood, which breaks the
; Markov condition, and it will never converge. Note the
; default allows flat models because 1) the user may wish
; to model out of transit constraints on the ephemeris and
; 2) rejecting flat models a priori may give the user an
; undue confidence in the signficance of the signal. This
; is likely required for low SNR transits or when using
; parallel tempering (see NTEMP and TF).
;
; NOPRIMARY - An NPLANETS byte array specifying which planets are
; allowed to not have a primary transit. Normally, b>1+p
; models are rejected because the transit fit is
; unconstrained and poorly behaved, but in the rare cases
; a planet only has a secondary and not a primary, this is
; required. You probably also want to specify
; REQUIRESECONDARY=NOPRIMARY.
;
; REQUIRESECONDARY -
; An NPLANETS byte array specifying which planets are
; required to have a secondary eclipse. Models with bs>1+p
; will be rejected. When fitting a secondary, this could
; bias non-significant detections. When only fitting a
; secondary, this may be required to keep the fit
; reasonably bounded.
;
; FITSPLINE- An NTRANSITFILES byte array specifying which transits
; should be flatted with Andrew Vanderburg's
; keplerspline. This should only be used for long baseline
; data like Kepler, K2, or TESS.
;
; SPLINESPACE
; - An NTRANSITFILES array specifying the knot spacing
; between adjacent points in the spline, in days. To be
; used in conjunction with FITSPLINE. Default is 0.75
; days. This spacing should be large compared to the
; transit duration (>~ 3x), or there is significant risk
; of introducing a strong covariance between the spline
; and the transit parameters, biasing the inferred values,
; inflating the uncertainties, and increasing convergence
; times. It should be short compared to the variability
; you wish to remove.
;
; FITRAMP - An NTRANSITFILES byte array specifying which transits
; should be fit with an exponential ramp (common for JWST
; and Spitzer LCs). When set, the corresponding lightcurve
; will be multiplied by 1+A*exp((time[0]-time)/tau), where
; A and tau (unique to each LC) are fitted parameters
; reported alongside other transit parameters and time is
; the user-supplied time from the transit file. A is
; typically negative.
;
; FITWAVELET
; - An NTRANSITFILES array specifying which to fit Carter's
; wavelet error to handle correlated errors. See
; https://ui.adsabs.harvard.edu/abs/2009ApJ...704...51C/abstract
;
; REPARAMETERIZATION INPUTS:
;
; FITLOGMP - By default, planet mass is parameterized as MP. Set this
; keyword to parameterize it as LOGMP. This may impose a
; more realistic prior, but is problematic for low SNR RVs
; where the small-planet volume is infinite. It also
; excludes negative masses which biases the mass high.
;
; NOVCVE - When only transits are fit, eccentricity is
; parameterized as VCVE. Set this to keep the usual
; sqrt(e)cos(omega) sqrt(e)sin(omega) parameterization.
;
; NOCHORD - When only transits are fit, cosi is parameterized as
; chord. Set this to keep cosi.
;
; FITSIGN - When only transits are fit, e is parameterized as VCVE,
; but solving for e requires a quadratic. By default, a
; sign is fit to choose the solution. Set this to zeros to
; use the degenerate parameter L to determine the sign.
; See Eastman, 2023 (https://arxiv.org/abs/2309.14410)
;
; FITTT - TT is the minimum projected separation, the intuitive
; defintion of the transit time, but one that must be
; numerically computed. By default, we fit for the time of
; conjunction, TC. For eccentric, inclined orbits, this
; can introduce significant non-linear covariances and it
; may be faster to take the hit to derive TT.
;
; EARTH - If set, the output units of Mp and Rp are in Earth
; units, not Jupiter units.
;
; PLOTTING INPUTS
; TRANSITRANGE
; - A six element array that defines the
; [XMIN,XMAX,YMIN,YMAX,O-C_YMIN,O-CYMAX] plotting limits
; for the transit figure. Any value set to !values.d_nan
; will use the default value. This allows the user a level
; of customization of the plot, but was designed to be
; used in conjunction with mkfitgif to ensure the plot
; ranges are constant throughout the fit.
;
; RVRANGE
; - A six element array that defines the
; [XMIN,XMAX,YMIN,YMAX,O-C_YMIN,O-CYMAX] plotting limits
; for the RV figure. Any value set to !values.d_nan will
; use the default value. This allows the user a level of
; customization of the plot, but was designed to be used
; in conjunction with mkfitgif to ensure the plot ranges
; are constant throughout the fit.
;
; SEDRANGE
; - A six element array that defines the
; [XMIN,XMAX,YMIN,YMAX,O-C_YMIN,O-CYMAX] plotting limits
; for the SED figure. Any value set to !values.d_nan will
; use the default value. This allows the user a level of
; customization of the plot, but was designed to be used
; in conjunction with mkfitgif to ensure the plot ranges
; are constant throughout the fit.
;
; EMRANGE
; - A four element array that defines the
; [XMIN,XMAX,YMIN,YMAX] plotting limits of the
; evolutionary model (MIST, PARSEC, YY) figure. Any value
; set to !values.d_nan will use the default value. This
; allows the user a level of customization of the plot,
; but was designed to be used in conjunction with mkfitgif
; to ensure the plot ranges are constant throughout the
; fit.
;
; DEBUGGING INPUTS
; DEBUG - When this keyword is set, plots will be displayed to the
; screen for each model. This is intended to help identify
; problematic parameters that need additional constraints,
; though it's often too slow to be helpful. Generally,
; VERBOSE serves this purpose better. It can also
; help build intuition about how the different stages of
; EXOFASTv2 work.
;
; VERBOSE - When this keyword is set, more detailed information is
; printed to the screen and logfile at each step,
; including specific reasons why a model was rejected
; (which parameters were out of bounds), the values of all
; fitted parameters, and the chi^2 components for each
; fit. This is often very helpful in identifying
; problematic parameters that need additional constraints.
;
; DELAY - If set, the chi^2 function runs a dummy for loop to
; count to the DELAY value specified, arbitrarily
; inflating the runtime of the chi^2 computation. This is
; designed to benchmark the performance of multi-threading
; and is not intended for general use.
;
; MCMC INPUTS:
;
; NOTE: The MCMC portion of the fit will automatically stop when one
; of the following conditions are met:
;
; GR < MAXGR and TZ > MINTZ at 5 consecutive evaluations
; (and DONTSTOP is not set)
; STEPS > MAXSTEPS
; TIME > MAXTIME
; !STOPNOW=1
;
; MAXSTEPS - The maximum number of steps to take in the MCMC
; chain. Note that a 32-bit installation of IDL cannot
; allocate more than 260 million double-precision numbers,
; and redundant copies of each parameter are
; required. Even a 64-bit installation may require very
; slow disk swapping. A very large number for MAXSTEPS
; will cause memory management problems. The default
; chooses the number that will use 1 GB of RAM, and larger
; values are strongly discouraged (increase NTHIN instead
; if the chains are not well-mixed). Decrease MAXSTEPS for
; preliminary runs.
;
; NOTE1: If the MCMC chains run to MAXSTEPS, doubling this
; value will double the runtime. Short test runs
; (MAXSTEPS=100) are strongly encouraged before running
; week-long fits.
;
; NTHIN - If set, only every NTHINth element will be kept. High
; values typically don't degrade the resultant fit because
; there is the correlation length between adjacent steps
; is long. This has the advantage of improved memory
; management, reduced storage, and faster generation of
; the final plots. Default is roughly set to pass the
; mixing criteria, but this is highly uncertain. Revising
; this parameter based on preliminary fits is strongly
; encouraged.
;
; NOTE: Only saved links in the chain count toward
; MAXSTEPS, so if the MCMC chains run to MAXSTEPS,
; doubling this value will double the runtime.
;
; MAXTIME - The maximum runtime for the DEMC portion of the code, in
; seconds. If set, the fit will begin wrapping up after
; MAXTIME seconds. This is intended for non-interactive
; use with a time constraint (e.g., running on a super
; computer). Note this only applies to the MCMC portion of
; the code, and it finishes the loops over NTEMPS and
; NTHIN before it will check the time. The time AMOEBA
; takes or the time to synthesize the results is not
; counted, therefore, it would be wise to set this at
; least 1800 seconds (30 minutes) less than any hard
; limit.
;
; MAXGR - The maximum Gelman Rubin statistic that is considered
; well-mixed (default=1.01).
;
; MINTZ - The minimum number of independent draws that is
; considered well-mixed (default=1000). The fit will
; automatically stop when GR < MAXGR and TZ > MINTZ at 5
; consecutive evaluations.
;
; DONTSTOP - A keyword that, when set, the fit will take MAXSTEPS
; steps regardless of GR and TZ statistics. This is
; statistically unnecessary, but sometimes useful to
; generate prettier output plots (smoother contours and
; PDFs).
;
; !STOPNOW - This global keyword can be set during a fit to stop a
; fit early and have it summarize the results. This is
; helpful for prelimary or problematic runs. During a run
; that you want to stop, type:
;
; control + c
; !stopnow=1
; .con
;
; NOTE: This is not possible with license-free use.
;
; NTEMPS - This enables parallel tempering and sets the number of
; chains to run at different temperatures, uniformly
; distributed between 1 and TF. The more temperatures, the
; easier it is to make swaps between temperatures, but the
; longer it can take. The default is 1 (no parallel
; tempering). 8 is a good value, but more may be required
; for high dimensional fits. Note that only the T=1 chain
; is kept by default. Parallel tempering is better at
; finding the global minimum in a rough likelihood surface
; and sampling widely spaced, multi-modal distributions
; (often the case for MIST models). Nominally, NTEMPS more
; steps are taken, requiring NTEMPS times longer to
; run. However, many models are rejected as out of bounds,
; and it may lead to better mixing and therefore faster
; convergence, so the effect on runtime is system
; dependent and not obvious. You are strongly encouraged
; to use NTEMPS=8 for initial fits in order to optimize
; the starting location of the next fit.
;
; TF - The temperature of the hottest chain, when NTEMPS >
; 1. The higher the temperature, the more parameter space
; it will probe, but the chains will be less likely to
; swap. Default is 200, which can robustly find minima
; separated by 50 sigma. A value of 1 will result in no
; temperature difference between chains.
;
; KEEPHOT - By default, the hot chains (and their corresponding
; chi^2) from parallel tempering (see NTEMPS and TF) are
; dynamically discarded to save memory. If this keyword is
; set and NTEMPS > 1, the steps from the hot chains
; (HOTPARS) and the corresponding chi2 (HOTCHI2) will be
; stored in memory during the fit and saved in the output
; IDL file. This is not useful to determine the posterior,
; and should only be used for debugging (e.g., determining
; the extent of parameter space explored), as it
; significantly increases the memory footprint.
;
; RANDOMFUNC
; - A string specifying the name of the random number
; generator to use. This generator must be able to return
; 1,2 or 3 dimensional uniform or normal random
; deviates.
;
; When using IDL versions < v8.2, IDL's built-in RANDOMU
; is based on numerical recipe's RAN1, and is not good
; enough for MCMC. In this case, we use 'EXOFAST_RANDOM'
; (which is based on Numerical Recipe's RAN3 and is slow
; but robust).
;
; When using IDL versions >= v8.2, we use IDL's
; built-in RANDOMU.
;
; SEED - The seed to the random number generator used for the
; MCMC fits. Be sure not to mix seeds from different
; generators. The default is -systime(/seconds). This is
; helpful if the user wishes to generate the exact same
; sequence of "random" numbers, the proposed steps will
; quickly diverge if anything else is changed, but this
; can be particularly useful make bugs reproducible.
;
; STRETCH - By default, EXOFASTv2 uses a differential evolution
; method to generate the next proposed set of
; parameters. Set this keyword to use the Affine Invariant
; "stretch" step instead (popularized by emcee). In our
; tests, STRETCH is inferior to DEMC and is not generally
; recommended.
;
; NTHREADS - The number of threads to use during the MCMC portion of
; the fit. For short preliminary runs, often the overhead
; of initializing the threads exceeds its benefit. But for
; longer runs, especially for complex models (that take >~
; 0.005 seconds), the scaling is near perfect up to the
; number of cores on your machine (4 cores => NTHREAD=4 =>
; 4x faster). The default is !CPU.HW_NCPU, meaning it will
; use all available cores on your machine for a dramatic
; speed up. For shared computers/servers, this is likely
; an inappropriate use and counterproductive for you
; (requesting more CPU power than is available adds
; overhead without benefit).
;
; GENERAL INPUTS:
;
; SKIPTT - A keyword that skips the expensive numerical computation
; of TT for each step at the end. This is rarely useful
; unless doing TTVs.
;
; USERNOTE - A string that is printed to the top of the log file,
; intended to help the user keep track of fits.
;
; MKSUMMARYPG