From e55c5b14edc02f075824fd4a89aba31638d0d7e3 Mon Sep 17 00:00:00 2001 From: Nestor Espinoza Date: Fri, 15 Oct 2021 15:54:15 -0400 Subject: [PATCH 1/5] Added working spam algorithm. --- exoctk/limb_darkening/__init__.py | 2 +- exoctk/limb_darkening/spam.py | 184 ++++++++++++++++++++++++++++++ 2 files changed, 185 insertions(+), 1 deletion(-) create mode 100644 exoctk/limb_darkening/spam.py diff --git a/exoctk/limb_darkening/__init__.py b/exoctk/limb_darkening/__init__.py index 571b7101..bf0cc6a0 100644 --- a/exoctk/limb_darkening/__init__.py +++ b/exoctk/limb_darkening/__init__.py @@ -1,4 +1,4 @@ """ Package to generate limb darkening coefficients from a grid of model spectra """ -from . import limb_darkening_fit \ No newline at end of file +from . import limb_darkening_fit, spam diff --git a/exoctk/limb_darkening/spam.py b/exoctk/limb_darkening/spam.py new file mode 100644 index 00000000..ce058c07 --- /dev/null +++ b/exoctk/limb_darkening/spam.py @@ -0,0 +1,184 @@ +import numpy as np +from scipy.optimize import minimize + +try: + import batman + +except: + print('Batman library not installed. Install it by doing "pip install batman-package" to use exoctk.limb_darkening.spam.') + +from .. import utils + +def init_batman(t, ld_law, nresampling = None, etresampling = None): + """ + This function initializes the batman lightcurve generator object. + + Parameters + ---------- + + t: array + Array containing the times at which the lightcurve will be evaluated. Assumes units of days. + ld_law: string + Limb-darkening law used to compute the model. Available ld laws: uniform, linear, quadratic, + logarithmic, exponential, squareroot, nonlinear, power2. + nresampling: int + Number of resampled points in case resampling is wanted. + etresampling: float + Exposure time of the resampling, same units as input time. + + Returns + ------- + + params: batman object + Object containing the parameters of the lightcurve model. + m: batman object + Object that enables the lightcurve calculation. + + """ + + params = batman.TransitParams() + params.t0 = 0. + params.per = 1. + params.rp = 0.1 + params.a = 15. + params.inc = 87. + params.ecc = 0. + params.w = 90. + + if ld_law == 'linear': + params.u = [0.5] + + elif ld_law == 'nonlinear': + params.u = [0.1, 0.1, 0.1, 0.1] + + else: + params.u = [0.1,0.3] + + params.limb_dark = ld_law + + if nresampling is None or etresampling is None: + m = batman.TransitModel(params, t) + + else: + m = batman.TransitModel(params, t, supersample_factor=nresampling, exp_time=etresampling) + + return params,m + +def spam_objective_function(theta, params, m, params_twop, m_twop): + """ + Objective function that the SPAM algorithm is looking to minimize. + """ + + u1, u2 = theta + params_twop.u = [u1, u2] + + return np.sum((m.light_curve(params) - m_twop.light_curve(params_twop))**2) + +def transform_coefficients(c1, c2, c3, c4, planet_name = '', planet_data = None, ld_law = 'quadratic', ndatapoints = 1000, method = 'BFGS', u1_guess = 0.5, u2_guess = 0.5) + """ + Given a set of non-linear limb-darkening coefficients (c1, c2, c3 and c4) and either a planet name ('planet_name') or a dictionary with + the planet's data ('planet_data'), this function returns the Synthetic-Photometry/Atmosphere-Model (SPAM; https://arxiv.org/abs/1106.4659) + limb-darkening coefficients of the star. + + Reference: + Howarth, I., 2011, "On stellar limb darkening and exoplanetary transits", MNRAS, 418, 1165 + https://ui.adsabs.harvard.edu/abs/2011MNRAS.418.1165H/abstract + + Parameters + ---------- + + c1: float + First limb-darkening coefficient of the non-linear law. + c2: float + Same as c1, but second. + c3: float + Same as c1, but third. + c4: float + Same as c1, but fourth. + planet_name: string + String with the name of the input planet (e.g., 'WASP-19b'); this will be used to query the planet properties from MAST. + planet_data: dict + Dictionary containing the planet properties. In particular, this dictionary should contain the keys + 'transit_duration', 'orbital_period' (days), 'Rp/Rs', 'a/Rs', 'inclination' (degrees), 'eccentricity' and 'omega' (degrees) + for the algorithm to work. Properties in this dictionary take prescedence over the ones retrieved from MAST. + ld_law: string + Limb-darkening law for which SPAM coefficients are wanted. Default is 'quadratic', but can also be 'squareroot' or 'logarithmic'. + ndatapoints: int + Number of datapoints that will be used for the lightcurve simulations to extract back the SPAM coefficients. + method: string + Minimization method to match lightcurves. Default is 'BFGS', but can be any of the ones available for scipy.optimize.minimize. + Details: https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html + u1_guess: float + Guess starting value for u1. Default is 0.5 + u2_guess: flat + Guess starting value for u2. Default is 0.5. + + Returns + ------- + + u1: float + The first limb-darkening coefficient of the selected two-parameter law. + u2: flat + Same as u1, but for the second coefficient. + + """ + + planet_properties = ['transit_duration', 'orbital_period', 'Rp/Rs', 'a/Rs', 'inclination', 'eccentricity', 'omega'] + + if planet_name != '': + + # If planet_name is given, retrieve MAST properties: + mast_planet_data, url = utils.get_target_data(planet_name) + + # If planet properties also given, add the ones not in that dictinoary: + if planet_data is not None: + + for planet_property in planet_properties: + + if planet_property not in list(planet_data.keys()): + + planet_data[planet_property] = mast_planet_data[planet_property] + + else: + + planet_data = mast_planet_data + + else: + + if planet_data is None: + + raise Exception("User must input either 'planet_name' and/or 'planet_data' for SPAM to work. See details by doing exoctk.limb_darkening.spam.transform_coefficients?.") + + # Check that all properties exist in the input dictionary: + for planet_property in planet_properties: + + if planet_property not in list(planet_data.keys()): + + raise Exception("Input 'planet_data' does not have a '"+planet_property+"' key. This is a needed key for SPAM to work.") + + # User inputs check done. Now jump into the algorithm. First, define times around transit: + times = np.linspace(-planet_data['transit_duration']/2., planet_data['transit_duration']/2., n) + + # Now initialize models: + params, m = init_batman(times, 'nonlinear') + params_twop, m_twop = init_batman(times, ld_law) + + # Define params according to the planet_data dictionary: + for par in [params, params_twop]: + + par.per = planet_data['orbital_period'] + par.rp = planet_data['Rp/Rs'] + par.a = planet_data['a/Rs'] + par.inc = planet_data['inclination'] + par.ecc = planet_data['eccentricity'] + par.w = planet_data['omega'] + + # Set non-linear law coefficients: + params.u = [c1, c2, c3, c4] + + # Allright, now given these models, optimize u1 and u2 such that they match as good as possible the lightcurves of + # the non-linear law. We use scipy.optimize for this: + results = minimize(spam_objective_function, [u1_guess, u2_guess], args=(params, m, params_twop, m_twop)) + + # Return SPAM coefficients: + return results.x From 46b9ee009d868794a447107c193a95e059bc9adf Mon Sep 17 00:00:00 2001 From: Nestor Espinoza Date: Fri, 15 Oct 2021 16:43:30 -0400 Subject: [PATCH 2/5] fixed syntax error on transform_coefficients --- exoctk/limb_darkening/spam.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exoctk/limb_darkening/spam.py b/exoctk/limb_darkening/spam.py index ce058c07..1f77dd45 100644 --- a/exoctk/limb_darkening/spam.py +++ b/exoctk/limb_darkening/spam.py @@ -74,7 +74,7 @@ def spam_objective_function(theta, params, m, params_twop, m_twop): return np.sum((m.light_curve(params) - m_twop.light_curve(params_twop))**2) -def transform_coefficients(c1, c2, c3, c4, planet_name = '', planet_data = None, ld_law = 'quadratic', ndatapoints = 1000, method = 'BFGS', u1_guess = 0.5, u2_guess = 0.5) +def transform_coefficients(c1, c2, c3, c4, planet_name = '', planet_data = None, ld_law = 'quadratic', ndatapoints = 1000, method = 'BFGS', u1_guess = 0.5, u2_guess = 0.5): """ Given a set of non-linear limb-darkening coefficients (c1, c2, c3 and c4) and either a planet name ('planet_name') or a dictionary with the planet's data ('planet_data'), this function returns the Synthetic-Photometry/Atmosphere-Model (SPAM; https://arxiv.org/abs/1106.4659) From 19bcc311264ca5c7b9421a46f98b41e43b3e5a92 Mon Sep 17 00:00:00 2001 From: Nestor Espinoza Date: Fri, 15 Oct 2021 16:45:19 -0400 Subject: [PATCH 3/5] Fixed NameError. Now spam working. --- exoctk/limb_darkening/spam.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exoctk/limb_darkening/spam.py b/exoctk/limb_darkening/spam.py index 1f77dd45..cc9b9b72 100644 --- a/exoctk/limb_darkening/spam.py +++ b/exoctk/limb_darkening/spam.py @@ -157,7 +157,7 @@ def transform_coefficients(c1, c2, c3, c4, planet_name = '', planet_data = None, raise Exception("Input 'planet_data' does not have a '"+planet_property+"' key. This is a needed key for SPAM to work.") # User inputs check done. Now jump into the algorithm. First, define times around transit: - times = np.linspace(-planet_data['transit_duration']/2., planet_data['transit_duration']/2., n) + times = np.linspace(-planet_data['transit_duration']/2., planet_data['transit_duration']/2., ndatapoints) # Now initialize models: params, m = init_batman(times, 'nonlinear') From 614a169836dc0afb1ca66becdc98b763fe95718a Mon Sep 17 00:00:00 2001 From: Joe Filippazzo Date: Tue, 22 Feb 2022 14:06:45 -0500 Subject: [PATCH 4/5] Enabled SPAM coefficient LDC calculation in Web app --- exoctk/exoctk_app/app_exoctk.py | 85 +++++++++++++++- exoctk/exoctk_app/form_validation.py | 18 +++- .../exoctk_app/templates/limb_darkening.html | 99 +++++++++++++++++-- .../templates/limb_darkening_results.html | 46 ++++++++- exoctk/limb_darkening/limb_darkening_fit.py | 67 ++++++++++++- exoctk/limb_darkening/spam.py | 60 ++++++----- 6 files changed, 329 insertions(+), 46 deletions(-) diff --git a/exoctk/exoctk_app/app_exoctk.py b/exoctk/exoctk_app/app_exoctk.py index 9566d864..7d783e7b 100644 --- a/exoctk/exoctk_app/app_exoctk.py +++ b/exoctk/exoctk_app/app_exoctk.py @@ -23,6 +23,7 @@ from exoctk.forward_models.forward_models import fortney_grid, generic_grid from exoctk.groups_integrations.groups_integrations import perform_calculation from exoctk.limb_darkening import limb_darkening_fit as lf +from exoctk.limb_darkening import spam from exoctk.modelgrid import ModelGrid from exoctk.phase_constraint_overlap.phase_constraint_overlap import phase_overlap_constraint, calculate_pre_duration from exoctk.throughputs import Throughput @@ -546,6 +547,20 @@ def limb_darkening(): # Load default form form = fv.LimbDarkeningForm() + # Planet properties + planet_properties = ['transit_duration', 'orbital_period', 'rp_rs', 'a_rs', 'inclination', 'eccentricity', 'omega'] + + def empty_fields(form): + form.transit_duration.data = form.transit_duration.data or '' + form.orbital_period.data = form.orbital_period.data or '' + form.rp_rs.data = form.rp_rs.data or '' + form.a_rs.data = form.a_rs.data or '' + form.inclination.data = form.inclination.data or '' + form.eccentricity.data = form.eccentricity.data or '' + form.omega.data = form.omega.data or '' + + return form + # Reload page with stellar data from ExoMAST if form.resolve_submit.data: @@ -557,16 +572,28 @@ def limb_darkening(): form.targname.data = get_canonical_name(form.targname.data) data, target_url = get_target_data(form.targname.data) - # Update the form data + # Update the star data form.feh.data = data.get('Fe/H') form.teff.data = data.get('Teff') form.logg.data = data.get('stellar_gravity') form.target_url.data = str(target_url) + # Update the planet data + form.transit_duration.data = data.get('transit_duration') + form.orbital_period.data = data.get('orbital_period') + form.rp_rs.data = data.get('Rp/Rs') + form.a_rs.data = data.get('a/Rs') + form.inclination.data = data.get('inclination') + form.eccentricity.data = data.get('eccentricity') + form.omega.data = data.get('omega') + except Exception: form.target_url.data = '' form.targname.errors = ["Sorry, could not resolve '{}' in exoMAST.".format(form.targname.data)] + # Ensure planet fields are not None + form = empty_fields(form) + # Send it back to the main page return render_template('limb_darkening.html', form=form) @@ -587,6 +614,9 @@ def limb_darkening(): form.wave_min.data = bandpass.wave_min.value form.wave_max.data = bandpass.wave_max.value + # Ensure planet fields are not None + form = empty_fields(form) + # Send it back to the main page return render_template('limb_darkening.html', form=form) @@ -610,6 +640,9 @@ def limb_darkening(): setattr(form.feh.validators[1], 'max', float(feh_rng[1])) setattr(form.feh.validators[1], 'message', 'Metallicity must be between {} and {}'.format(*feh_rng)) + # Ensure planet fields are not None + form = empty_fields(form) + # Send it back to the main page return render_template('limb_darkening.html', form=form) @@ -647,6 +680,21 @@ def limb_darkening(): for prof in form.profiles.data: ld.calculate(*star_params, prof, mu_min=float(form.mu_min.data), bandpass=bandpass) + # Check if spam coefficients can be calculated + planet_data = {param: getattr(form, param).data for param in planet_properties} + planet_data['Rp/Rs'] = planet_data['rp_rs'] + planet_data['a/Rs'] = planet_data['a_rs'] + spam_calc = all([val is not None and val != '' for key, val in planet_data.items()]) + if spam_calc: + + # Make sure non-linear profile is included for spam calculation if all planet parameters are provided + if '4-parameter' not in form.profiles.data: + ld.calculate(*star_params, '4-parameter', mu_min=float(form.mu_min.data), bandpass=bandpass) + + # Calculate spam coeffs + planet_data = {key: float(val) for key, val in planet_data.items()} + ld.spam(planet_data=planet_data) + # Draw tabbed figure final = ld.plot_tabs() @@ -689,8 +737,41 @@ def limb_darkening(): # Log the successful form inputs log_exoctk.log_form_input(form_input, 'limb_darkening', DB) + # Make a table for each profile with a row for each wavelength bin + profile_spam_tables = '' + spam_file_as_string = '' + if ld.spam_results is not None: + + # Store SPAM tables as string + keep_cols = ['Teff', 'logg', 'FeH', 'profile', 'filter', 'wave_min', 'wave_eff', 'wave_max', 'c1', 'c2'] + print_spam_table = ld.spam_results[[col for col in keep_cols if col in ld.spam_results.colnames]] + spam_file_as_string = '\n'.join(print_spam_table.pformat(max_lines=-1, max_width=-1)) + profile_spam_tables = [] + for profile in list(np.unique(ld.spam_results['profile'])): + + # Make LaTeX for polynomials + latex = lf.ld_profile(profile, latex=True) + poly = '\({}\)'.format(latex).replace('*', '\cdot').replace('\e', 'e') + + # Make the table into LaTeX + table = filter_table(ld.spam_results, profile=profile) + co_cols = [c for c in ld.spam_results.colnames if c.startswith('c') and c not in ['coeffs', 'color']] + table = table[['wave_eff', 'wave_min', 'wave_max'] + co_cols] + table.rename_column('wave_eff', '\(\lambda_\mbox{eff}\hspace{5px}(\mu m)\)') + table.rename_column('wave_min', '\(\lambda_\mbox{min}\hspace{5px}(\mu m)\)') + table.rename_column('wave_max', '\(\lambda_\mbox{max}\hspace{5px}(\mu m)\)') + + # Add the results to the lists + html_table = '\n'.join(table.pformat(max_width=-1, max_lines=-1, html=True)).replace('Limb Darkening Calculator
K
The stellar effective temperature ({{ form.teff.validators[1].min }} - {{ form.teff.validators[1].max }}) + {% for error in form.teff.errors[:1] %} +

{{ error }}

+ {% endfor %}
@@ -55,6 +58,9 @@

Limb Darkening Calculator

dex
The logarithm of the stellar surface gravity ({{ form.logg.validators[1].min }} - {{ form.logg.validators[1].max }}) + {% for error in form.logg.errors[:1] %} +

{{ error }}

+ {% endfor %}
@@ -63,20 +69,96 @@

Limb Darkening Calculator

dex
The logarithm of the stellar metallicity ({{ form.feh.validators[1].min }} - {{ form.feh.validators[1].max }}) + {% for error in form.feh.errors[:1] %} +

{{ error }}

+ {% endfor %}
- {% for error in form.teff.errors[:1] %} + + + +
+
+ +
+ +
+
Transit Duration
+ {{ form.transit_duration(value=form.transit_duration.data, size=10, placeholder="0 - 50", rows=1, class='form-control') }} +
hour
+
+ The transit duration ({{ form.transit_duration.validators[1].min }} - {{ form.transit_duration.validators[1].max }}) + {% for error in form.transit_duration.errors[:1] %}

{{ error }}

{% endfor %} - {% for error in form.logg.errors[:1] %} +
+ +
+
Orbital Period
+ {{ form.orbital_period(value=form.orbital_period.data, size=10, placeholder="0 - 1000", rows=1, class='form-control') }} +
day
+
+ The orbital period ({{ form.orbital_period.validators[1].min }} - {{ form.orbital_period.validators[1].max }}) + {% for error in form.orbital_period.errors[:1] %}

{{ error }}

{% endfor %} - {% for error in form.feh.errors[:1] %} +
+ +
+
\(R_\text{p}/R_\text{*}\)
+ {{ form.rp_rs(value=form.rp_rs.data, size=10, placeholder="0 - 1.0", rows=1, class='form-control') }} +
+
+ The ratio of the planet radius to the stellar radius ({{ form.rp_rs.validators[1].min }} - {{ form.rp_rs.validators[1].max }}) + {% for error in form.rp_rs.errors[:1] %}

{{ error }}

{% endfor %} - {% for error in form.mu_min.errors[:1] %} +
+ +
+
\(a/R_\text{*}\)
+ {{ form.a_rs(value=form.a_rs.data, size=10, placeholder="0 - 1.0", rows=1, class='form-control') }} +
+
+ The ratio of the semi-major axis to the stellar radius ({{ form.a_rs.validators[1].min }} - {{ form.a_rs.validators[1].max }}) + {% for error in form.a_rs.errors[:1] %} +

{{ error }}

+ {% endfor %} +
+ +
+
Inclination
+ {{ form.inclination(value=form.inclination.data, size=10, placeholder="0 - 180", rows=1, class='form-control') }} +
deg
+
+ The inclination of the orbit ({{ form.inclination.validators[1].min }} - {{ form.inclination.validators[1].max }}) + {% for error in form.inclination.errors[:1] %}

{{ error }}

{% endfor %} +
+ +
+
Eccentricity
+ {{ form.eccentricity(value=form.eccentricity.data, size=10, placeholder="0 - 1.0", rows=1, class='form-control') }} +
+
+ The eccentricity of the orbit ({{ form.eccentricity.validators[1].min }} - {{ form.eccentricity.validators[1].max }}) + {% for error in form.eccentricity.errors[:1] %} +

{{ error }}

+ {% endfor %} +
+ +
+
\(\omega \)
+ {{ form.omega(value=form.omega.data, size=10, placeholder="0 - 360", rows=1, class='form-control') }} +
deg
+
+ The longitude of the periapsis ({{ form.omega.validators[1].min }} - {{ form.omega.validators[1].max }}) + {% for error in form.omega.errors[:1] %} +

{{ error }}

+ {% endfor %} +
+
@@ -173,6 +255,9 @@

Limb Darkening Calculator

{% endfor %} + {% for error in form.profiles.errors %} + {{ error }} + {% endfor %}
@@ -181,11 +266,11 @@

Limb Darkening Calculator

The minimum angle to consider when fitting the LD profile + {% for error in form.mu_min.errors[:1] %} +

{{ error }}

+ {% endfor %}
- {% for error in form.profiles.errors %} - {{ error }} - {% endfor %} diff --git a/exoctk/exoctk_app/templates/limb_darkening_results.html b/exoctk/exoctk_app/templates/limb_darkening_results.html index 9eb56c51..196216c6 100644 --- a/exoctk/exoctk_app/templates/limb_darkening_results.html +++ b/exoctk/exoctk_app/templates/limb_darkening_results.html @@ -51,6 +51,36 @@

Input

Models {{ form.modeldir.data }} + {% if spam_table != '' %} + + Transit Duration + {{ form.transit_duration.data }} + + + Orbital Period + {{ form.orbital_period.data }} + + + Rp/R* + {{ form.rp_rs.data }} + + + a/R* + {{ form.a_rs.data }} + + + Inclination + {{ form.inclination.data }} + + + Eccentricity + {{ form.eccentricity.data }} + + + \( \omega \) + {{ form.omega.data }} + + {% endif %} @@ -69,17 +99,27 @@

Result


+

Coefficients

- -
{% for tab in table %} {{ tab|safe }} -
{% endfor %} + {% if spam_table != '' %} +
+

SPAM Coefficients

+
+
+ +
+ {% for tab in spam_table %} + {{ tab|safe }} + {% endfor %} + {% endif %} + diff --git a/exoctk/limb_darkening/limb_darkening_fit.py b/exoctk/limb_darkening/limb_darkening_fit.py index 2f6236e9..798cc17b 100755 --- a/exoctk/limb_darkening/limb_darkening_fit.py +++ b/exoctk/limb_darkening/limb_darkening_fit.py @@ -5,6 +5,7 @@ spectra """ +from copy import copy import inspect import os import warnings @@ -24,6 +25,7 @@ from .. import modelgrid from .. import utils +from . import spam rc('font', **{'family': 'sans-serif', 'sans-serif': ['Helvetica'], 'size': 16}) rc('text', usetex=True) @@ -126,7 +128,8 @@ class LDC: bp = Filter('WFC3_IR.G141', n_bins=5) ld.calculate(4000, 4.5, 0.0, 'quadratic', bandpass=bp) ld.calculate(4000, 4.5, 0.0, '4-parameter', bandpass=bp) - ld.plot(show=True) + ld.spam(planet_name='WASP-12b', profiles=['quadratic', 'logarithmic']) + ld.plot_tabs(show=True) """ def __init__(self, model_grid='ACES'): """Initialize an LDC object @@ -155,6 +158,10 @@ def __init__(self, model_grid='ACES'): dtypes = ['|S20', float, float, float, '|S20', '|S20', '|S20', object, object, object, np.float16, np.float16, np.float16, object, object, np.float16, object, object, np.float16, object, object, object, '|S20'] self.results = at.Table(names=columns, dtype=dtypes) + # Table for spam results + self.spam_results = None + + # Colors for plotting self.ld_color = {'quadratic': 'blue', '4-parameter': 'red', 'exponential': 'green', 'linear': 'orange', 'square-root': 'cyan', '3-parameter': 'magenta', 'logarithmic': 'pink', 'uniform': 'purple'} self.count = 1 @@ -519,3 +526,61 @@ def save(self, filepath): # Save to file ii.write(results, filepath, format='fixed_width_two_line') + + def spam(self, planet_name=None, planet_data=None, profiles=['quadratic'], **kwargs): + """ + Calculates SPAM coefficients by transforming non-linear coefficients + + Parameters + ---------- + planet_name: string + The name of the input planet (e.g., 'WASP-19b'); this will be used to query the planet properties from MAST. + planet_data: dict + Dictionary containing the planet properties. Must include 'transit_duration', 'orbital_period' (days), 'Rp/Rs', 'a/Rs', 'inclination' (degrees), 'eccentricity' and 'omega' (degrees) + profiles: sequence + The profiles to calculate, ['quadratic', 'logarithmic', 'square-root'] + """ + # Profiles supported by SPAM transformation code + spam_supported = ['quadratic', 'square-root', 'logarithmic'] + + if not all([profile in spam_supported for profile in profiles]): + raise ValueError("{}: Supported profiles include {}".format(profiles, spam_supported)) + + # Require 4-parameter calculation + if '4-parameter' in self.results['profile']: + + # For each desired profile... + for profile in profiles: + + # Rows of non-linear calculations + nonlin = copy(self.results[self.results['profile'] == '4-parameter']) + + # Update profile + nonlin['profile'] = profile + + # ...and for each wavelength channel... + for row in nonlin: + + # Calculate SPAM coefficients + (c1, c2), properties = spam.transform_coefficients(row['c1'], row['c2'], row['c3'], row['c4'], ld_law=profile, planet_name=planet_name, planet_data=planet_data, **kwargs) + row['c1'], row['c2'] = c1.round(3), c2.round(3) + + # Remove unused columns + omit_cols = ['c3', 'c4', 'e1', 'e2', 'e3', 'e4'] + nonlin = nonlin[[col for col in nonlin.columns if col not in omit_cols]] + + # Add planet properties to table + planet_properties = ['transit_duration', 'orbital_period', 'Rp/Rs', 'a/Rs', 'inclination', 'eccentricity', 'omega'] + for prop in planet_properties: + nonlin.add_column([round(properties[prop], 4)] * len(nonlin), name=prop) + + # Add the results to the spam table + if self.spam_results is None: + self.spam_results = nonlin + else: + self.spam_results = at.vstack([self.spam_results, nonlin]) + + else: + + print("Limb darkening coefficients must first be calculated using the 4-parameter profile to get SPAM coefficient transformations.") + diff --git a/exoctk/limb_darkening/spam.py b/exoctk/limb_darkening/spam.py index cc9b9b72..031e5fb2 100644 --- a/exoctk/limb_darkening/spam.py +++ b/exoctk/limb_darkening/spam.py @@ -9,7 +9,8 @@ from .. import utils -def init_batman(t, ld_law, nresampling = None, etresampling = None): + +def init_batman(t, ld_law, nresampling=None, etresampling=None): """ This function initializes the batman lightcurve generator object. @@ -62,7 +63,8 @@ def init_batman(t, ld_law, nresampling = None, etresampling = None): else: m = batman.TransitModel(params, t, supersample_factor=nresampling, exp_time=etresampling) - return params,m + return params, m + def spam_objective_function(theta, params, m, params_twop, m_twop): """ @@ -74,7 +76,8 @@ def spam_objective_function(theta, params, m, params_twop, m_twop): return np.sum((m.light_curve(params) - m_twop.light_curve(params_twop))**2) -def transform_coefficients(c1, c2, c3, c4, planet_name = '', planet_data = None, ld_law = 'quadratic', ndatapoints = 1000, method = 'BFGS', u1_guess = 0.5, u2_guess = 0.5): + +def transform_coefficients(c1, c2, c3, c4, planet_name=None, planet_data=None, ld_law='quadratic', ndatapoints=1000, method='BFGS', u1_guess=0.5, u2_guess=0.5): """ Given a set of non-linear limb-darkening coefficients (c1, c2, c3 and c4) and either a planet name ('planet_name') or a dictionary with the planet's data ('planet_data'), this function returns the Synthetic-Photometry/Atmosphere-Model (SPAM; https://arxiv.org/abs/1106.4659) @@ -125,45 +128,39 @@ def transform_coefficients(c1, c2, c3, c4, planet_name = '', planet_data = None, planet_properties = ['transit_duration', 'orbital_period', 'Rp/Rs', 'a/Rs', 'inclination', 'eccentricity', 'omega'] - if planet_name != '': + # Check if planet name is given + if planet_name is not None: - # If planet_name is given, retrieve MAST properties: + # If planet_name is given, retrieve MAST properties mast_planet_data, url = utils.get_target_data(planet_name) - # If planet properties also given, add the ones not in that dictinoary: - if planet_data is not None: - - for planet_property in planet_properties: - - if planet_property not in list(planet_data.keys()): + # Merge the dictionaries, prioritizing the manual input + mast_planet_data.update(planet_data or {}) + planet_data = mast_planet_data - planet_data[planet_property] = mast_planet_data[planet_property] + if planet_data is None: - else: + raise Exception("User must input either 'planet_name' and/or 'planet_data' for SPAM to work. See details by doing exoctk.limb_darkening.spam.transform_coefficients?.") - planet_data = mast_planet_data + # Check that all properties exist in the input dictionary + missing = [planet_property for planet_property in planet_properties if planet_data.get(planet_property) is None] + if len(missing) > 0: - else: - - if planet_data is None: - - raise Exception("User must input either 'planet_name' and/or 'planet_data' for SPAM to work. See details by doing exoctk.limb_darkening.spam.transform_coefficients?.") - - # Check that all properties exist in the input dictionary: + # Print current data for user + print('{} properties'.format(planet_name or 'Planet')) for planet_property in planet_properties: + print('{}: {}'.format(planet_property, planet_data.get(planet_property))) - if planet_property not in list(planet_data.keys()): - - raise Exception("Input 'planet_data' does not have a '"+planet_property+"' key. This is a needed key for SPAM to work.") + raise ValueError("{} missing planet propert{} needed for SPAM to work. Please include this in the 'planet_data' input dictionary".format(len(missing), 'y is' if len(missing) == 1 else 'ies are')) - # User inputs check done. Now jump into the algorithm. First, define times around transit: + # User inputs check done. Now jump into the algorithm. First, define times around transit times = np.linspace(-planet_data['transit_duration']/2., planet_data['transit_duration']/2., ndatapoints) - # Now initialize models: + # Now initialize models params, m = init_batman(times, 'nonlinear') params_twop, m_twop = init_batman(times, ld_law) - # Define params according to the planet_data dictionary: + # Define params according to the planet_data dictionary for par in [params, params_twop]: par.per = planet_data['orbital_period'] @@ -173,12 +170,11 @@ def transform_coefficients(c1, c2, c3, c4, planet_name = '', planet_data = None, par.ecc = planet_data['eccentricity'] par.w = planet_data['omega'] - # Set non-linear law coefficients: + # Set non-linear law coefficients params.u = [c1, c2, c3, c4] # Allright, now given these models, optimize u1 and u2 such that they match as good as possible the lightcurves of - # the non-linear law. We use scipy.optimize for this: - results = minimize(spam_objective_function, [u1_guess, u2_guess], args=(params, m, params_twop, m_twop)) + # the non-linear law. We use scipy.optimize for this + results = minimize(spam_objective_function, [u1_guess, u2_guess], args=(params, m, params_twop, m_twop), method=method.lower()) - # Return SPAM coefficients: - return results.x + return results.x, {prop: val for prop, val in planet_data.items() if prop in planet_properties} From 5cd9dc9613ffc63d2b943b3fdacf8afa2a3f8351 Mon Sep 17 00:00:00 2001 From: Joe Filippazzo Date: Tue, 8 Mar 2022 11:47:23 -0500 Subject: [PATCH 5/5] Added TESS and CHEOPS bands to LDC and make NIRSpec PRISM the default --- .../data/throughputs/CHEOPS_CHEOPS.band.txt | 153 +++++ exoctk/data/throughputs/TESS_TESS.Red.txt | 561 ++++++++++++++++++ exoctk/exoctk_app/form_validation.py | 7 +- 3 files changed, 718 insertions(+), 3 deletions(-) create mode 100644 exoctk/data/throughputs/CHEOPS_CHEOPS.band.txt create mode 100644 exoctk/data/throughputs/TESS_TESS.Red.txt diff --git a/exoctk/data/throughputs/CHEOPS_CHEOPS.band.txt b/exoctk/data/throughputs/CHEOPS_CHEOPS.band.txt new file mode 100644 index 00000000..dbcf7fa4 --- /dev/null +++ b/exoctk/data/throughputs/CHEOPS_CHEOPS.band.txt @@ -0,0 +1,153 @@ +3400 0.0 +3450 0.005238095238095264 +3500 0.01480331262939965 +3550 0.027784679089026997 +3600 0.048907867494824155 +3650 0.09075569358178082 +3700 0.14814699792960673 +3750 0.2063354037267085 +3800 0.2666418219461706 +3850 0.32336291038154436 +3900 0.37528837622005373 +3950 0.4213250517598327 +4000 0.45859903381642164 +4050 0.49228985507245887 +4100 0.5235362318840523 +4150 0.5538020473889972 +4200 0.5828519668736979 +4250 0.6113084886128296 +4300 0.6393664596273252 +4350 0.6664982746721849 +4400 0.6928557625948901 +4450 0.7192132505175952 +4500 0.7413043478260842 +4550 0.7584726867335548 +4600 0.7756410256410254 +4650 0.789003166483985 +4700 0.801381683108026 +4750 0.813760199732067 +4800 0.8262525879917187 +4850 0.8390062111801245 +4900 0.8517598343685302 +4950 0.8645134575569359 +5000 0.87746066252588 +5050 0.890533126293996 +5100 0.9036055900621119 +5150 0.9166780538302279 +5200 0.929165976535542 +5250 0.9410693581780541 +5300 0.9529727398205664 +5350 0.963627329192547 +5400 0.9725548654244309 +5450 0.9797705314009664 +5500 0.984021739130435 +5550 0.9882729468599036 +5600 0.9925241545893723 +5650 0.9965476190476192 +5700 0.9965476190476192 +5750 0.9965476190476192 +5800 0.9965476190476192 +5850 0.9965476190476192 +5900 0.9960992494824018 +5950 0.9925122929606627 +6000 0.9889253364389236 +6050 0.9853383799171844 +6100 0.9804134316770188 +6150 0.9752322722567289 +6200 0.970051112836439 +6250 0.9633255693581781 +6300 0.9553545548654245 +6350 0.9473835403726709 +6400 0.9394125258799173 +6450 0.9314415113871637 +6500 0.9224741200828159 +6550 0.9129089026915115 +6600 0.903343685300207 +6650 0.8937784679089026 +6700 0.8842132505175982 +6750 0.8746480331262939 +6800 0.8650828157349896 +6850 0.8555175983436852 +6900 0.8459523809523809 +6950 0.8365769496204278 +7000 0.8280745341614907 +7050 0.8195721187025535 +7100 0.8110697032436164 +7150 0.8025672877846792 +7200 0.7936397515527952 +7250 0.7834368530020706 +7300 0.7732339544513458 +7350 0.7630310559006211 +7400 0.7525288376220053 +7450 0.7402307009760426 +7500 0.7279325643300798 +7550 0.7156344276841171 +7600 0.7033362910381544 +7650 0.6910381543921916 +7700 0.6779018197668083 +7750 0.6634700882641387 +7800 0.6490383567614689 +7850 0.6346066252587993 +7900 0.6204397737355813 +7950 0.6065474341910678 +8000 0.5926550946465544 +8050 0.5787627551020409 +8100 0.5648704155575275 +8150 0.5509780760130141 +8200 0.5372777896765903 +8250 0.5236446062682946 +8300 0.5100114228599987 +8350 0.49637823945170284 +8400 0.482745056043407 +8450 0.46911187263511117 +8500 0.45449965493443767 +8550 0.4396204278812976 +8600 0.42474120082815753 +8650 0.40987657270265987 +8700 0.39516085363911485 +8750 0.38044513457556983 +8800 0.36572941551202476 +8850 0.35101369644847974 +8900 0.3362979773849347 +8950 0.3214596273291932 +9000 0.3065804002760528 +9050 0.29170117322291245 +9100 0.27689786059351257 +9150 0.2634357027835286 +9200 0.2499735449735447 +9250 0.2365113871635608 +9300 0.22349206349206327 +9350 0.21126984126984122 +9400 0.19904761904761914 +9450 0.1868253968253971 +9500 0.17460317460317504 +9550 0.16297308488612877 +9600 0.15213250517598365 +9650 0.14129192546583855 +9700 0.13045134575569345 +9750 0.12002070393374721 +9800 0.11045548654244296 +9850 0.10089026915113872 +9900 0.09138198757763984 +9950 0.08341097308488621 +10000 0.07543995859213257 +10050 0.06746894409937892 +10100 0.059497929606625276 +10150 0.05175983436853009 +10200 0.04596273291925478 +10250 0.040165631469979465 +10300 0.03436853002070415 +10350 0.028571428571428834 +10400 0.024624741200828346 +10450 0.02196773636991045 +10500 0.01948956840261203 +10550 0.0182632584806499 +10600 0.017036948558687773 +10650 0.015810638636725643 +10700 0.014584328714763515 +10750 0.013358018792801386 +10800 0.012659555315509925 +10850 0.012105049959492301 +10900 0.011550544603474676 +10950 0.01099603924745705 +11000 0.0 diff --git a/exoctk/data/throughputs/TESS_TESS.Red.txt b/exoctk/data/throughputs/TESS_TESS.Red.txt new file mode 100644 index 00000000..83ce0102 --- /dev/null +++ b/exoctk/data/throughputs/TESS_TESS.Red.txt @@ -0,0 +1,561 @@ +5670 0 +5680 0.00010376 +5690 0.00013632 +5700 0.00018166 +5710 0.00024546 +5720 0.00033674 +5730 0.00046958 +5740 0.00066615 +5750 0.00096281 +5760 0.0014197 +5770 0.0021394 +5780 0.0033016 +5790 0.005229 +5800 0.0085175 +5810 0.014294 +5820 0.024716 +5830 0.043845 +5840 0.078669 +5850 0.13808 +5860 0.22389 +5870 0.31647 +5880 0.38681 +5890 0.42959 +5900 0.45957 +5910 0.4907 +5920 0.52992 +5930 0.57909 +5940 0.63664 +5950 0.69842 +5960 0.75855 +5970 0.81102 +5980 0.85157 +5990 0.87899 +6000 0.89486 +6010 0.90246 +6020 0.9051 +6030 0.90551 +6040 0.90547 +6050 0.90588 +6060 0.90698 +6070 0.90863 +6080 0.91051 +6090 0.91228 +6100 0.9137 +6110 0.91465 +6120 0.91518 +6130 0.91541 +6140 0.91546 +6150 0.91551 +6160 0.91569 +6170 0.91608 +6180 0.91673 +6190 0.91761 +6200 0.91867 +6210 0.91984 +6220 0.921 +6230 0.92208 +6240 0.923 +6250 0.92372 +6260 0.92423 +6270 0.92455 +6280 0.92473 +6290 0.92482 +6300 0.92489 +6310 0.92501 +6320 0.92522 +6330 0.92557 +6340 0.92608 +6350 0.92673 +6360 0.92752 +6370 0.92841 +6380 0.92936 +6390 0.93031 +6400 0.93123 +6410 0.93207 +6420 0.93281 +6430 0.93344 +6440 0.93395 +6450 0.93435 +6460 0.93467 +6470 0.93494 +6480 0.93519 +6490 0.93546 +6500 0.93578 +6510 0.93601 +6520 0.93633 +6530 0.93674 +6540 0.93725 +6550 0.93785 +6560 0.9385 +6570 0.9392 +6580 0.93991 +6590 0.9406 +6600 0.94125 +6610 0.94184 +6620 0.94235 +6630 0.94277 +6640 0.94311 +6650 0.94338 +6660 0.94358 +6670 0.94375 +6680 0.94389 +6690 0.94404 +6700 0.94421 +6710 0.94443 +6720 0.94471 +6730 0.94507 +6740 0.94551 +6750 0.94603 +6760 0.94662 +6770 0.94726 +6780 0.94795 +6790 0.94865 +6800 0.94935 +6810 0.95002 +6820 0.95064 +6830 0.9512 +6840 0.95168 +6850 0.95207 +6860 0.95238 +6870 0.95259 +6880 0.95273 +6890 0.9528 +6900 0.95282 +6910 0.95281 +6920 0.95279 +6930 0.95279 +6940 0.95282 +6950 0.95291 +6960 0.95306 +6970 0.95329 +6980 0.95361 +6990 0.95402 +7000 0.9545 +7010 0.95473 +7020 0.95502 +7030 0.95535 +7040 0.95571 +7050 0.95608 +7060 0.95644 +7070 0.95678 +7080 0.95707 +7090 0.95732 +7100 0.95749 +7110 0.9576 +7120 0.95763 +7130 0.95758 +7140 0.95745 +7150 0.95726 +7160 0.95701 +7170 0.95672 +7180 0.9564 +7190 0.95606 +7200 0.95572 +7210 0.9561 +7220 0.95651 +7230 0.95696 +7240 0.95746 +7250 0.95802 +7260 0.95865 +7270 0.95935 +7280 0.96012 +7290 0.96095 +7300 0.96185 +7310 0.9628 +7320 0.96379 +7330 0.96481 +7340 0.96585 +7350 0.96689 +7360 0.96793 +7370 0.96895 +7380 0.96994 +7390 0.9709 +7400 0.9718 +7410 0.97241 +7420 0.97297 +7430 0.97347 +7440 0.97391 +7450 0.97431 +7460 0.97467 +7470 0.975 +7480 0.9753 +7490 0.97558 +7500 0.97585 +7510 0.97613 +7520 0.97643 +7530 0.97674 +7540 0.97709 +7550 0.97747 +7560 0.9779 +7570 0.97837 +7580 0.97888 +7590 0.97944 +7600 0.98004 +7610 0.98074 +7620 0.98146 +7630 0.98221 +7640 0.98299 +7650 0.98377 +7660 0.98455 +7670 0.98533 +7680 0.98609 +7690 0.98683 +7700 0.98754 +7710 0.98821 +7720 0.98884 +7730 0.98942 +7740 0.98995 +7750 0.99044 +7760 0.99088 +7770 0.99128 +7780 0.99164 +7790 0.99196 +7800 0.99226 +7810 0.99188 +7820 0.99149 +7830 0.99109 +7840 0.9907 +7850 0.99032 +7860 0.98995 +7870 0.98961 +7880 0.9893 +7890 0.98903 +7900 0.9888 +7910 0.9886 +7920 0.98845 +7930 0.98834 +7940 0.98828 +7950 0.98825 +7960 0.98825 +7970 0.98829 +7980 0.98834 +7990 0.98842 +8000 0.98851 +8010 0.989 +8020 0.98949 +8030 0.98997 +8040 0.99043 +8050 0.99088 +8060 0.99129 +8070 0.99168 +8080 0.99203 +8090 0.99234 +8100 0.99262 +8110 0.99285 +8120 0.99304 +8130 0.9932 +8140 0.99333 +8150 0.99342 +8160 0.99349 +8170 0.99354 +8180 0.99357 +8190 0.9936 +8200 0.99362 +8210 0.99345 +8220 0.99328 +8230 0.99314 +8240 0.99301 +8250 0.99291 +8260 0.99284 +8270 0.99281 +8280 0.99281 +8290 0.99285 +8300 0.99293 +8310 0.99305 +8320 0.9932 +8330 0.99339 +8340 0.99362 +8350 0.99387 +8360 0.99416 +8370 0.99446 +8380 0.99479 +8390 0.99513 +8400 0.99547 +8410 0.99592 +8420 0.99637 +8430 0.9968 +8440 0.99722 +8450 0.99762 +8460 0.998 +8470 0.99836 +8480 0.99868 +8490 0.99897 +8500 0.99922 +8510 0.99944 +8520 0.99961 +8530 0.99975 +8540 0.99986 +8550 0.99993 +8560 0.99998 +8570 1 +8580 1 +8590 0.99997 +8600 0.99994 +8610 0.99924 +8620 0.99853 +8630 0.99783 +8640 0.99712 +8650 0.99643 +8660 0.99574 +8670 0.99507 +8680 0.99442 +8690 0.99379 +8700 0.99319 +8710 0.99261 +8720 0.99205 +8730 0.99153 +8740 0.99103 +8750 0.99056 +8760 0.99012 +8770 0.9897 +8780 0.98931 +8790 0.98894 +8800 0.98858 +8810 0.98699 +8820 0.98542 +8830 0.98385 +8840 0.98229 +8850 0.98073 +8860 0.97917 +8870 0.9776 +8880 0.97603 +8890 0.97445 +8900 0.97285 +8910 0.97124 +8920 0.96962 +8930 0.96797 +8940 0.9663 +8950 0.96461 +8960 0.9629 +8970 0.96117 +8980 0.95941 +8990 0.95764 +9000 0.95584 +9010 0.95312 +9020 0.95038 +9030 0.94763 +9040 0.94486 +9050 0.94209 +9060 0.9393 +9070 0.93651 +9080 0.93371 +9090 0.93091 +9100 0.92811 +9110 0.92532 +9120 0.92253 +9130 0.91974 +9140 0.91697 +9150 0.91421 +9160 0.91146 +9170 0.90872 +9180 0.90599 +9190 0.90328 +9200 0.90059 +9210 0.8964 +9220 0.89223 +9230 0.88807 +9240 0.88393 +9250 0.8798 +9260 0.87568 +9270 0.87157 +9280 0.86747 +9290 0.86338 +9300 0.8593 +9310 0.85522 +9320 0.85114 +9330 0.84706 +9340 0.84299 +9350 0.83891 +9360 0.83483 +9370 0.83075 +9380 0.82666 +9390 0.82257 +9400 0.81847 +9410 0.81351 +9420 0.80854 +9430 0.80356 +9440 0.79857 +9450 0.79358 +9460 0.78858 +9470 0.78357 +9480 0.77855 +9490 0.77353 +9500 0.7685 +9510 0.76346 +9520 0.75842 +9530 0.75338 +9540 0.74833 +9550 0.74328 +9560 0.73823 +9570 0.73318 +9580 0.72813 +9590 0.72309 +9600 0.71804 +9610 0.71189 +9620 0.70575 +9630 0.69961 +9640 0.69347 +9650 0.68734 +9660 0.68121 +9670 0.67509 +9680 0.66898 +9690 0.66286 +9700 0.65676 +9710 0.65065 +9720 0.64455 +9730 0.63846 +9740 0.63237 +9750 0.62627 +9760 0.62018 +9770 0.6141 +9780 0.60801 +9790 0.60192 +9800 0.59583 +9810 0.58808 +9820 0.58033 +9830 0.57257 +9840 0.56482 +9850 0.55705 +9860 0.54929 +9870 0.54151 +9880 0.53374 +9890 0.52596 +9900 0.51817 +9910 0.51038 +9920 0.50258 +9930 0.49478 +9940 0.48698 +9950 0.47917 +9960 0.47135 +9970 0.46354 +9980 0.45572 +9990 0.4479 +10000 0.44007 +10010 0.43179 +10020 0.42351 +10030 0.41524 +10040 0.40696 +10050 0.39868 +10060 0.3906 +10070 0.38253 +10080 0.37446 +10090 0.36639 +10100 0.35833 +10110 0.35067 +10120 0.34301 +10130 0.33536 +10140 0.32771 +10150 0.32006 +10160 0.31242 +10170 0.30478 +10180 0.29715 +10190 0.28952 +10200 0.28189 +10210 0.27587 +10220 0.26985 +10230 0.26384 +10240 0.25783 +10250 0.25182 +10260 0.24461 +10270 0.2374 +10280 0.2302 +10290 0.22299 +10300 0.21578 +10310 0.20998 +10320 0.20418 +10330 0.19837 +10340 0.19257 +10350 0.18676 +10360 0.18116 +10370 0.17555 +10380 0.16994 +10390 0.16434 +10400 0.15872 +10410 0.15552 +10420 0.15232 +10430 0.14912 +10440 0.14591 +10450 0.14271 +10460 0.1389 +10470 0.13509 +10480 0.13127 +10490 0.12746 +10500 0.12364 +10510 0.12003 +10520 0.11641 +10530 0.11279 +10540 0.10917 +10550 0.10556 +10560 0.10222 +10570 0.09888 +10580 0.095542 +10590 0.092203 +10600 0.088865 +10610 0.086813 +10620 0.084761 +10630 0.08271 +10640 0.080658 +10650 0.078606 +10660 0.076274 +10670 0.073941 +10680 0.071609 +10690 0.069277 +10700 0.066945 +10710 0.065297 +10720 0.063648 +10730 0.062 +10740 0.060352 +10750 0.058704 +10760 0.056934 +10770 0.055165 +10780 0.053395 +10790 0.051625 +10800 0.049854 +10810 0.049108 +10820 0.048361 +10830 0.047614 +10840 0.046865 +10850 0.046115 +10860 0.044982 +10870 0.043848 +10880 0.042712 +10890 0.041576 +10900 0.040437 +10910 0.039318 +10920 0.038197 +10930 0.037074 +10940 0.03595 +10950 0.034825 +10960 0.033698 +10970 0.032571 +10980 0.031442 +10990 0.030312 +11000 0.029182 +11010 0.028051 +11020 0.02692 +11030 0.025789 +11040 0.024658 +11050 0.023528 +11060 0.022399 +11070 0.021271 +11080 0.020145 +11090 0.019021 +11100 0.017899 +11110 0.016781 +11120 0.015666 +11130 0.014555 +11140 0.013448 +11150 0.012346 +11160 0.011248 +11170 0.010157 +11180 0.0090715 +11190 0.0079924 +11200 0.0069202 +11210 0.005855 +11220 0.0047974 +11230 0.0037476 +11240 0.0027059 +11250 0.0016725 +11260 0.00064763 +11270 0 diff --git a/exoctk/exoctk_app/form_validation.py b/exoctk/exoctk_app/form_validation.py index 89e1d257..563ad65d 100644 --- a/exoctk/exoctk_app/form_validation.py +++ b/exoctk/exoctk_app/form_validation.py @@ -9,6 +9,7 @@ from exoctk.modelgrid import ModelGrid from exoctk.utils import get_env_variables, FILTERS_LIST, PROFILES +from exoctk.throughputs import Throughput class BaseForm(FlaskForm): @@ -140,12 +141,12 @@ class LimbDarkeningForm(BaseForm): profiles = MultiCheckboxField('profiles', choices=[(x, x) for x in PROFILES], validators=[InputRequired('At least one profile is required!')]) # Bandpass - default_filter = 'Kepler.K' - defilt = svo.Filter(default_filter) + default_filter = 'NIRSpec.CLEAR.PRISM.S200A1' + defilt = Throughput(default_filter) bandpass = SelectField('bandpass', default=default_filter, choices=[('tophat', 'Top Hat')] + [(filt, filt) for filt in FILTERS_LIST], validators=[InputRequired('A filter is required!')]) wave_min = DecimalField('wave_min', default=defilt.wave_min.value, validators=[NumberRange(min=0, max=30, message='Minimum wavelength must be between 0 and 30 microns!')]) wave_max = DecimalField('wave_max', default=defilt.wave_max.value, validators=[NumberRange(min=0, max=30, message='Maximum wavelength must be between 0 and 30 microns!')]) - n_bins = IntegerField('n_bins', default=1) + n_bins = IntegerField('n_bins', default=30) # Form submits calculate_submit = SubmitField('Calculate Coefficients')