Skip to content

Commit d31800a

Browse files
committed
Major changes in implementation and functionality, including:
- can fix white noise now - can fix nlaws (without errors) - background-fitting only - global fits on raw power spectrum - echelle diagram plotting, including offset in double ED and number of orders plotted (--noy works now) - the way containers (dictionaries) are saved and loaded in (in pysyd/dicts), which will download as package data and users do not need to touch this
1 parent a383ab8 commit d31800a

13 files changed

+1258
-1071
lines changed

.gitignore

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.vscode
22
#docs
3-
*.DS_store
3+
.DS_store
4+
.ipynb_checkpoints
45
*.pyc
56
.*
67
*~
@@ -9,5 +10,7 @@ dist
910
*.egg-info
1011
*background.csv
1112
*excess.csv
12-
*__pycache__/
13+
__pycache__
14+
#*columns.dict
15+
#*params.dict
1316
#examples

pysyd/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
__all__ = ['cli', 'functions', 'pipeline', 'models', 'target', 'plots', 'utils']
1111

12-
__version__ = '2.1.4'
12+
__version__ = '3.9.2'
1313

1414
_ROOT = os.path.abspath(os.getcwd())
1515
TODODIR = os.path.join(_ROOT, 'info', 'todo.txt')

pysyd/cli.py

+145-45
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,18 @@ def main():
1515
parser.add_argument('-version', '--version',
1616
action='version',
1717
version="%(prog)s {}".format(pysyd.__version__),
18-
help="Print version number and exit."
18+
help="Print version number and exit.",
1919
)
2020

2121
# In the parent parser, we define arguments and options common to all subcommands
2222
parent_parser = argparse.ArgumentParser(add_help=False)
23+
24+
parent_parser.add_argument('--cli',
25+
dest='cli',
26+
help='This option should not be adjusted for current users',
27+
default=True,
28+
action='store_false',
29+
)
2330
parent_parser.add_argument('--file', '--list', '--todo',
2431
metavar='path',
2532
dest='todo',
@@ -58,8 +65,26 @@ def main():
5865
# Main options
5966
main_parser = argparse.ArgumentParser(add_help=False)
6067

61-
main_parser.add_argument('--kc', '--kepcorr', '-k',
62-
dest='kepcorr',
68+
main_parser.add_argument('--bg', '--background', '-b',
69+
dest='background',
70+
help='Turn off the automated background fitting routine',
71+
default=True,
72+
action='store_false',
73+
)
74+
main_parser.add_argument('--globe', '--global', '-g',
75+
dest='globe',
76+
help='Do not estimate global asteroseismic parameters (i.e. numax or dnu)',
77+
default=True,
78+
action='store_false',
79+
)
80+
main_parser.add_argument('--par', '--parallel', '-p',
81+
dest='parallel',
82+
help='Use parallel processing for data analysis',
83+
default=False,
84+
action='store_true',
85+
)
86+
main_parser.add_argument('--kc', '--kep_corr', '-k',
87+
dest='kep_corr',
6388
help='Turn on the Kepler short-cadence artefact correction routine',
6489
default=False,
6590
action='store_true',
@@ -78,15 +103,21 @@ def main():
78103
type=int,
79104
default=None,
80105
)
106+
main_parser.add_argument('--over', '--overwrite', '-o',
107+
dest='overwrite',
108+
help='Overwrite existing files with the same name/path',
109+
default=False,
110+
action='store_true',
111+
)
81112
main_parser.add_argument('--save',
82113
dest='save',
83-
help='Do not save output files/figures',
114+
help='Do not save output figures and results.',
84115
default=True,
85116
action='store_false',
86117
)
87118
main_parser.add_argument('--show', '-s',
88119
dest='show',
89-
help='Display figures',
120+
help='Show output figures',
90121
default=False,
91122
action='store_true',
92123
)
@@ -98,6 +129,18 @@ def main():
98129
nargs='*',
99130
default=None,
100131
)
132+
main_parser.add_argument('--test', '-t',
133+
dest='testing',
134+
help='Extra verbose output for testing functionality',
135+
default=False,
136+
action='store_true',
137+
)
138+
main_parser.add_argument('--ex', '--excess', '-x',
139+
dest='excess',
140+
help='Turn off the find excess routine',
141+
default=True,
142+
action='store_false',
143+
)
101144

102145
# CLI relevant for finding power excess
103146
excess = main_parser.add_argument_group('(CRUDE) EXCESS FIT')
@@ -121,7 +164,7 @@ def main():
121164
metavar='value',
122165
dest='smooth_width',
123166
help='Box filter width (in muHz) for smoothing the PS',
124-
default=50.0,
167+
default=20.0,
125168
type=float,
126169
)
127170
excess.add_argument('--lx', '--lowerx',
@@ -161,7 +204,7 @@ def main():
161204
dest='lower_bg',
162205
help='Lower frequency limit of PS',
163206
nargs='*',
164-
default=0.5,
207+
default=1.0,
165208
type=float,
166209
)
167210
background.add_argument('--ub', '--upperb',
@@ -200,22 +243,35 @@ def main():
200243
default=None,
201244
type=int,
202245
)
203-
background.add_argument('--ab', '-ab',
204-
dest='ab',
205-
help='Use the {a,b} parametrization for Harvey models',
206-
default=False,
246+
background.add_argument('--fix', '--fixwn', '--wn', '-f',
247+
dest='fix_wn',
248+
help='Fix the white noise level',
249+
default=False,
207250
action='store_true',
208251
)
209-
background.add_argument('--use',
252+
background.add_argument('--basis',
253+
dest='basis',
254+
help="Which basis to use for background fit (i.e. 'a_b', 'pgran_tau', 'tau_sigma'), *** NOT operational yet ***",
255+
default='tau_sigma',
256+
type=str,
257+
)
258+
background.add_argument('--metric',
210259
metavar='metric',
211-
dest='use',
260+
dest='metric',
212261
help="Which model metric to use, choices=['bic','aic']",
213262
default='bic',
214263
type=str,
215264
)
265+
background.add_argument('--include', '-i',
266+
dest='include',
267+
help="Include metric values in verbose output, default is `False`.",
268+
default=False,
269+
action='store_true',
270+
)
216271

217272
# CLI relevant for the global parameters
218273
numax = main_parser.add_argument_group('NUMAX-RELATED')
274+
219275
numax.add_argument('--sm', '--smpar',
220276
metavar='value',
221277
dest='sm_par',
@@ -256,6 +312,7 @@ def main():
256312
)
257313

258314
dnu = main_parser.add_argument_group('DNU-RELATED')
315+
259316
dnu.add_argument('--dnu',
260317
metavar='value',
261318
dest='dnu',
@@ -264,12 +321,19 @@ def main():
264321
type=float,
265322
default=None,
266323
)
324+
dnu.add_argument('--method',
325+
metavar='method',
326+
dest='method',
327+
help='Method to use to determine dnu, ~[M, A, D]',
328+
default='D',
329+
type=str,
330+
)
267331
dnu.add_argument('--sp', '--smoothps',
268332
metavar='value',
269333
dest='smooth_ps',
270334
help='Box filter width [in muHz] of PS for ACF',
271335
type=float,
272-
default=0.5,
336+
default=1.5,
273337
)
274338
dnu.add_argument('--peak', '--peaks', '--npeaks',
275339
metavar='n',
@@ -287,18 +351,20 @@ def main():
287351
)
288352

289353
echelle = main_parser.add_argument_group('ECHELLE-RELATED')
354+
290355
echelle.add_argument('--cv', '--value',
291356
metavar='value',
292357
dest='clip_value',
293-
help='Clip value to use for echelle diagram (ED)',
294-
default=None,
358+
help='Clip value multiplier to use for echelle diagram (ED). Default is 3x the median, where clip_value == `3`.',
359+
default=3.0,
295360
type=float,
296361
)
297-
echelle.add_argument('--ce', '--clipech',
298-
dest='clip_ech',
299-
help='Disable the auto-clipping of high peaks in the ED',
300-
default=True,
301-
action='store_false',
362+
echelle.add_argument('--ce', '--color',
363+
metavar='cmap',
364+
dest='cmap',
365+
help='Change colormap of ED, which is `binary` by default.',
366+
default='binary',
367+
type=str,
302368
)
303369
echelle.add_argument('--le', '--lowere',
304370
metavar='freq',
@@ -341,22 +407,23 @@ def main():
341407
default=None,
342408
type=float,
343409
)
344-
echelle.add_argument('--xe', '--xech', '--nacross',
410+
echelle.add_argument('--nox', '--nacross',
345411
metavar='n',
346-
dest='n_across',
412+
dest='nox',
347413
help='Resolution for the x-axis of the ED',
348414
default=50,
349415
type=int,
350416
)
351-
echelle.add_argument('--ye', '--yech', '--ndown',
417+
echelle.add_argument('--noy', '--ndown',
352418
metavar='n',
353-
dest='n_down',
419+
dest='noy',
354420
help='The number of orders to plot on the ED y-axis',
355-
default=5,
421+
default=0,
356422
type=int,
357423
)
358424

359425
mcmc = main_parser.add_argument_group('MCMC PARAMETERS')
426+
360427
mcmc.add_argument('--mc', '--iter', '--mciter',
361428
metavar='n',
362429
dest='mc_iter',
@@ -371,37 +438,70 @@ def main():
371438
action='store_true',
372439
)
373440

374-
sub_parser = parser.add_subparsers(title='pySYD modes', dest='modes')
375-
376-
# Setting up
377-
parser_setup = sub_parser.add_parser('setup', help='Easy setup of relevant directories and files',
378-
parents=[parent_parser], formatter_class=argparse.MetavarTypeHelpFormatter)
379-
parser_setup.set_defaults(func=pipeline.setup)
441+
sub_parser = parser.add_subparsers(title='pySYD modes', dest='command')
380442

381443
# Load data in for a target
382-
parser_load = sub_parser.add_parser('load', help='Load in data for a given target',
383-
parents=[parent_parser, main_parser], formatter_class=argparse.MetavarTypeHelpFormatter)
384-
385-
parser_load.set_defaults(func=pipeline.load)
386-
387-
# Running pySYD in regular mode
388-
parser_run = sub_parser.add_parser('run', help='Run the main pySYD pipeline',
389-
parents=[parent_parser, main_parser], formatter_class=argparse.MetavarTypeHelpFormatter)
444+
parser_load = sub_parser.add_parser('load',
445+
conflict_handler='resolve',
446+
parents=[parent_parser],
447+
formatter_class=argparse.MetavarTypeHelpFormatter,
448+
help='Load in data for a given target',
449+
)
390450

391-
parser_run.set_defaults(func=pipeline.run)
451+
parser_load.set_defaults(func=pipeline.main)
392452

393453
# Run pySYD in parallel
394-
parser_parallel = sub_parser.add_parser('parallel', help='Run pySYD in parallel',
395-
parents=[parent_parser, main_parser], formatter_class=argparse.MetavarTypeHelpFormatter)
396-
parser_parallel.add_argument('-nt', '--nt', '-nthread', '--nthread', '-nthreads', '--nthreads',
454+
parser_parallel = sub_parser.add_parser('parallel',
455+
conflict_handler='resolve',
456+
help='Run pySYD in parallel',
457+
parents=[parent_parser, main_parser],
458+
formatter_class=argparse.MetavarTypeHelpFormatter,
459+
)
460+
461+
parser_parallel.add_argument('--nt', '--nthread', '--nthreads', '-n',
397462
metavar='n',
398463
dest='n_threads',
399464
help='Number of processes to run in parallel',
400465
type=int,
401466
default=0,
402467
)
403468

404-
parser_parallel.set_defaults(func=pipeline.parallel)
469+
parser_parallel.set_defaults(func=pipeline.main)
470+
471+
# Running pySYD in regular mode
472+
parser_run = sub_parser.add_parser('run',
473+
conflict_handler='resolve',
474+
help='Run the main pySYD pipeline',
475+
parents=[parent_parser, main_parser],
476+
formatter_class=argparse.MetavarTypeHelpFormatter,
477+
)
478+
479+
parser_run.set_defaults(func=pipeline.main)
480+
481+
# Setting up
482+
parser_setup = sub_parser.add_parser('setup',
483+
parents=[parent_parser],
484+
formatter_class=argparse.MetavarTypeHelpFormatter,
485+
help='Easy setup of relevant directories and files',
486+
)
487+
parser_setup.set_defaults(func=pipeline.setup)
488+
489+
# Testing
490+
parser_test = sub_parser.add_parser('test',
491+
conflict_handler='resolve',
492+
parents=[parent_parser, main_parser],
493+
formatter_class=argparse.MetavarTypeHelpFormatter,
494+
help='Test different utilities (currently under development)',
495+
)
496+
497+
parser_test.add_argument('--models', '-m',
498+
dest='models',
499+
help='Include different model fits',
500+
default=False,
501+
action='store_true',
502+
)
503+
504+
parser_test.set_defaults(func=pipeline.main)
405505

406506
args = parser.parse_args()
407507
args.func(args)

pysyd/dicts/columns.dict

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
'csv':['stars','radius','radius_err','teff','teff_err','logg','logg_err','lower_ex','upper_ex','lower_bg','upper_bg','lower_ps','upper_ps','lower_ech','upper_ech','numax','dnu','seed'],
3+
'required':['radius','logg','teff','numax','dnu','lower_ex','upper_ex','lower_bg','upper_bg','lower_ps','upper_ps','lower_ech','upper_ech','seed'],
4+
'table':['numax_smooth', 'A_smooth', 'FWHM', 'dnu', 'white'],
5+
}

pysyd/dicts/params.dict

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
'numax_smooth':{'unit':'muHz','label':r'$\rm Smooth \,\, \nu_{max} \,\, [\mu Hz]$','latex':{'label':'$\\nu_{\\mathrm{max}}$', 'format':'%.2f', 'unit':'$\\rm \\mu Hz$'}},
3+
'A_smooth':{'unit':'ppm^2/muHz','label':r'$\rm Smooth \,\, A_{max} \,\, [ppm^{2} \mu Hz^{-1}]$','latex':{'label':'$\\rm A_{osc}$', 'format':'%.2f', 'unit':'$\\rm ppm^{2} \\mu Hz^{-1}$'}},
4+
'numax_gauss':{'unit':'muHz','label':r'$\rm Gauss \,\, \nu_{max} \,\, [\mu Hz]$','latex':{'label':'$\\nu_{\\mathrm{max}}$', 'format':'%.2f', 'unit':'$\\rm \\mu Hz$'}},
5+
'A_gauss':{'unit':'ppm^2/muHz','label':r'$\rm Gauss \,\, A_{max} \,\, [ppm^{2} \mu Hz^{-1}]$','latex':{'label':'$\\rm A_{osc}$', 'format':'%.2f', 'unit':'$\\rm ppm^{2} \\mu Hz^{-1}$'}},
6+
'FWHM':{'unit':'muHz','label':r'$\rm Gauss \,\, FWHM \,\, [\mu Hz]$','latex':{'label':'FWHM', 'format':'%.2f', 'unit':'$\\rm \\mu Hz$'}},
7+
'dnu':{'unit':'muHz','label':r'$\rm \Delta\nu \,\, [\mu Hz]$','latex':{'label':'$\\Delta\\nu$', 'format':'%.2f', 'unit':'$\\rm \\mu Hz$'}},
8+
'white':{'unit':'ppm^2/muHz','label':r'$\rm White \,\, [ppm^{2} \mu Hz^{-1}]$','latex':{'label':'White noise', 'format':'%.2f', 'unit':'$\\rm ppm^{2} \\mu Hz^{-1}$'}},
9+
'a_1':{'unit':'ppm^2/muHz','label':r'$\rm a_{1} \,\, [ppm^{2} \mu Hz^{-1}]$','latex':{'label':'$\\rm a_{1}$', 'format':'%.2f', 'unit':'$\\rm ppm^{2} \\mu Hz^{-1}$'}},
10+
'b_1':{'unit':'muHz^-1','label':r'$\rm b_{1} \,\, [\mu Hz^{-1}]$','latex':{'label':'$\rm b_{1}$', 'format':'%.2f', 'unit':'$\rm \mu Hz^{-1}$'}},
11+
'tau_1':{'unit':'s','label':r'$\rm \tau_{1} \,\, [s]$','latex':{'label':'$\tau_{1}$', 'format':'%.2f', 'unit':'s'}},
12+
'sigma_1':{'unit':'ppm','label':r'$\rm \sigma_{1} \,\, [ppm]$','latex':{'label':'$\sigma_{1}$', 'format':'%.2f', 'unit':'ppm'}},
13+
'a_2':{'unit':'ppm^2/muHz','label':r'$\rm a_{2} \,\, [ppm^{2} \mu Hz^{-1}]$','latex':{'label':'$\rm a_{2}$', 'format':'%.2f', 'unit':'$\rm ppm^{2} \mu Hz^{-1}$'}},
14+
'b_2':{'unit':'muHz^-1','label':r'$\rm b_{2} \,\, [\mu Hz^{-1}]$','latex':{'label':'$\rm b_{2}$', 'format':'%.2f', 'unit':'$\rm \mu Hz^{-1}$'}},
15+
'tau_2':{'unit':'s','label':r'$\rm \tau_{2} \,\, [s]$','latex':{'label':'$\tau_{2}$', 'format':'%.2f', 'unit':'s'}},
16+
'sigma_2':{'unit':'ppm','label':r'$\rm \sigma_{2} \,\, [ppm]$','latex':{'label':'$\sigma_{2}$', 'format':'%.2f', 'unit':'ppm'}},
17+
'a_3':{'unit':'ppm^2/muHz','label':r'$\rm a_{3} \,\, [ppm^{2} \mu Hz^{-1}]$','latex':{'label':'$\rm a_{3}$', 'format':'%.2f', 'unit':'$\rm ppm^{2} \mu Hz^{-1}$'}},
18+
'b_3':{'unit':'muHz^-1','label':r'$\rm b_{3} \,\, [\mu Hz^{-1}]$','latex':{'label':'$\rm b_{3}$', 'format':'%.2f', 'unit':'$\rm \mu Hz^{-1}$'}},
19+
'tau_3':{'unit':'s','label':r'$\rm \tau_{3} \,\, [s]$','latex':{'label':'$\tau_{3}$', 'format':'%.2f', 'unit':'s'}},
20+
'sigma_3':{'unit':'ppm','label':r'$\rm \sigma_{3} \,\, [ppm]$','latex':{'label':'$\sigma_{3}$', 'format':'%.2f', 'unit':'ppm'}},
21+
}

0 commit comments

Comments
 (0)