phoebe_calculations

phoebe_calculations

Synopsis

enum                PHOEBE_cost_function;
double              frac                                (double x);
int                 diff                                (const void *a,
                                                         const void *b);
int                 diff_int                            (const void *a,
                                                         const void *b);
int                 phoebe_interpolate                  (int N,
                                                         double *x,
                                                         double *lo,
                                                         double *hi,
                                                         PHOEBE_type type,
                                                         ...);
int                 phoebe_cf_compute                   (double *cfval,
                                                         PHOEBE_cost_function cf,
                                                         PHOEBE_vector *syndep,
                                                         PHOEBE_vector *obsdep,
                                                         PHOEBE_vector *obsweight,
                                                         double scale);
int                 phoebe_join_chi2                    (double *chi2,
                                                         PHOEBE_vector *chi2s,
                                                         PHOEBE_vector *weights);
#define             wd_lc                               (atmtab,pltab,request,vertno,L3perc,indeps,deps,poscoy,poscoz,params)
int                 call_wd_to_get_fluxes               (PHOEBE_curve *curve,
                                                         PHOEBE_vector *indep);
int                 call_wd_to_get_rv1                  (PHOEBE_curve *rv1,
                                                         PHOEBE_vector *indep);
int                 call_wd_to_get_rv2                  (PHOEBE_curve *rv2,
                                                         PHOEBE_vector *indep);
int                 call_wd_to_get_pos_coordinates      (PHOEBE_vector *poscoy,
                                                         PHOEBE_vector *poscoz,
                                                         double phase);
int                 call_wd_to_get_logg_values          (double *logg1,
                                                         double *logg2);
int                 phoebe_calculate_level_correction   (double *alpha,
                                                         PHOEBE_curve *syn,
                                                         PHOEBE_curve *obs);
int                 phoebe_calculate_gamma_correction   (double *gamma,
                                                         PHOEBE_curve *syn,
                                                         PHOEBE_curve *obs);
double              phoebe_calculate_pot1               (bool ELLIPTIC,
                                                         double D,
                                                         double q,
                                                         double r,
                                                         double F,
                                                         double lambda,
                                                         double nu);
double              phoebe_calculate_pot2               (bool ELLIPTIC,
                                                         double D,
                                                         double q,
                                                         double r,
                                                         double F,
                                                         double lambda,
                                                         double nu);
int                 phoebe_calculate_critical_potentials
                                                        (double q,
                                                         double F,
                                                         double e,
                                                         double *L1crit,
                                                         double *L2crit);
int                 calculate_periastron_orbital_phase  (double *pp,
                                                         double perr0,
                                                         double ecc);
int                 calculate_median                    (double *median,
                                                         PHOEBE_vector *vec);
int                 calculate_sum                       (double *sum,
                                                         PHOEBE_vector *vec);
int                 calculate_average                   (double *average,
                                                         PHOEBE_vector *vec);
int                 calculate_sigma                     (double *sigma,
                                                         PHOEBE_vector *vec);
int                 calculate_weighted_sum              (double *sum,
                                                         PHOEBE_vector *dep,
                                                         PHOEBE_vector *weight);
int                 calculate_weighted_average          (double *average,
                                                         PHOEBE_vector *dep,
                                                         PHOEBE_vector *weight);
int                 calculate_weighted_sigma            (double *sigma,
                                                         PHOEBE_vector *dep,
                                                         PHOEBE_vector *weight);
double              intern_calculate_phase_from_ephemeris
                                                        (double hjd,
                                                         double hjd0,
                                                         double period,
                                                         double dpdt,
                                                         double pshift);
double              calculate_vga                       (PHOEBE_vector *rv1,
                                                         PHOEBE_vector *rv2,
                                                         double rv1avg,
                                                         double rv2avg,
                                                         double origvga);
int                 transform_hjd_to_phase              (PHOEBE_vector *vec,
                                                         double hjd0,
                                                         double period,
                                                         double dpdt,
                                                         double pshift);
int                 transform_phase_to_hjd              (PHOEBE_vector *vec,
                                                         double hjd0,
                                                         double period,
                                                         double dpdt,
                                                         double pshift);
int                 transform_magnitude_to_flux         (PHOEBE_vector *vec,
                                                         double mnorm);
int                 transform_magnitude_sigma_to_flux_sigma
                                                        (PHOEBE_vector *weights,
                                                         PHOEBE_vector *fluxes);
int                 transform_flux_to_magnitude         (PHOEBE_vector *vec,
                                                         double mnorm);
int                 transform_flux_sigma_to_magnitude_sigma
                                                        (PHOEBE_vector *weights,
                                                         PHOEBE_vector *fluxes);
int                 normalize_kms_to_orbit              (PHOEBE_vector *vec,
                                                         double sma,
                                                         double period);
int                 transform_sigma_to_weight           (PHOEBE_vector *vec);
int                 transform_weight_to_sigma           (PHOEBE_vector *vec);
int                 phoebe_curve_alias                  (PHOEBE_curve *curve,
                                                         double phmin,
                                                         double phmax);
int                 calculate_main_sequence_parameters  (double T1,
                                                         double T2,
                                                         double P0,
                                                         double *L1,
                                                         double *L2,
                                                         double *M1,
                                                         double *M2,
                                                         double *q,
                                                         double *a,
                                                         double *R1,
                                                         double *R2,
                                                         double *Omega1,
                                                         double *Omega2);
int                 calculate_synthetic_scatter_seed    (double *seed);
int                 apply_extinction_correction         (PHOEBE_curve *curve,
                                                         double A);
int                 apply_third_light_correction        (PHOEBE_curve *curve,
                                                         PHOEBE_el3_units el3units,
                                                         double el3value);
int                 apply_interstellar_extinction_correction
                                                        (PHOEBE_vector *wavelength,
                                                         PHOEBE_vector *spectrum,
                                                         double R,
                                                         double E);
int                 calculate_teff_from_bv_index        (int star_type,
                                                         double bv,
                                                         double *teff);

Description

Details

enum PHOEBE_cost_function

typedef enum PHOEBE_cost_function {
	PHOEBE_CF_STANDARD_DEVIATION,
	PHOEBE_CF_WEIGHTED_STANDARD_DEVIATION,
	PHOEBE_CF_SUM_OF_SQUARES,
	PHOEBE_CF_EXPECTATION_CHI2,
	PHOEBE_CF_CHI2
} PHOEBE_cost_function;


frac ()

double              frac                                (double x);

x :

Returns :


diff ()

int                 diff                                (const void *a,
                                                         const void *b);

a :

b :

Returns :


diff_int ()

int                 diff_int                            (const void *a,
                                                         const void *b);

a :

b :

Returns :


phoebe_interpolate ()

int                 phoebe_interpolate                  (int N,
                                                         double *x,
                                                         double *lo,
                                                         double *hi,
                                                         PHOEBE_type type,
                                                         ...);

This is a general multi-dimensional linear interpolation function. It should be reasonably optimized - I gave it a lot of thought. It should also be reasonably well tested.

The order of nodes and function values is very important; because of optimization, its order is inverse-binary:

lo[0] = lo[par1], lo[1] = lo[par2], ..., lo[N-1] = lo[parN]

hi[0] = hi[par1], hi[1] = hi[par2], ..., hi[N-1] = hi[parN]

fv[0] = fv (0 0 0 ... 0)

fv[1] = fv (1 0 0 ... 0)

fv[2] = fv (0 1 0 ... 0)

fv[3] = fv (1 1 0 ... 0)

fv[4] = fv (0 0 1 ... 0)

fv[5] = fv (1 0 1 ... 0)

fv[6] = fv (0 1 1 ... 0)

fv[7] = fv (1 1 1 ... 0)

.....................

where 0 and 1 are used for lower and upper node values, respectively, listed in a consecutive parameter order.

The function *modifies* the passed array fv[], so make sure you copy its contents if it is needed later. The result of the interpolation is contained in the first element of that array, fv[0].

N :

dimension of the interpolation space

x :

N-dimensional vector to the point of interest

lo :

N-dimensional vector of lower node values

hi :

N-dimensional vector of upper node values

type :

PHOEBE_type od interpolation values

... :

(2^N)-dimensional vector of node function values of type type.

Returns :

PHOEBE_error_code.

phoebe_cf_compute ()

int                 phoebe_cf_compute                   (double *cfval,
                                                         PHOEBE_cost_function cf,
                                                         PHOEBE_vector *syndep,
                                                         PHOEBE_vector *obsdep,
                                                         PHOEBE_vector *obsweight,
                                                         double scale);

Computes the cost function value cfval of the passed cost function cf. The residuals are computed from vectors syndep and obsdep. If the cost function is weighted, each residual is multiplied by the inverse square of the individual obsweight value. Since the residuals for different curves are usually compared, a scaling constant scale can be used to renormalize the data. The scale is usually computed as 4\pi/(L1+L2+4\piL3).

Cost function cf is of the following:

PHOEBE_CF_STANDARD_DEVIATION

PHOEBE_CF_WEIGHTED_STANDARD_DEVIATION

PHOEBE_CF_SUM_OF_SQUARES

PHOEBE_CF_EXPECTATION_CHI2

PHOEBE_CF_CHI2

cfval :

the computed cost function value.

cf :

a PHOEBE_cost_function to be evaluated.

syndep :

a PHOEBE_vector of the model data.

obsdep :

a PHOEBE_vector of the observed data.

obsweight :

scale :

a scaling constant for computing the residuals.

Returns :

a PHOEBE_error_code.

phoebe_join_chi2 ()

int                 phoebe_join_chi2                    (double *chi2,
                                                         PHOEBE_vector *chi2s,
                                                         PHOEBE_vector *weights);

chi2 :

chi2s :

weights :

Returns :


wd_lc()

#define wd_lc(atmtab,pltab,request,vertno,L3perc,indeps,deps,poscoy,poscoz,params) lc_(atmtab,pltab,request,vertno,L3perc,indeps,deps,poscoy,poscoz,params,strlen(atmtab),strlen(pltab))

atmtab :

pltab :

request :

vertno :

L3perc :

indeps :

deps :

poscoy :

poscoz :

params :


call_wd_to_get_fluxes ()

int                 call_wd_to_get_fluxes               (PHOEBE_curve *curve,
                                                         PHOEBE_vector *indep);

Uses WD's LC code through a FORTRAN wrapper to obtain the fluxes. Structure PHOEBE_curve must not be allocated, only initialized.

curve :

a pointer to PHOEBE_curve structure that will hold computed fluxes

indep :

an array of independent variable values (HJDs or phases);

Returns :

PHOEBE_error_code.

call_wd_to_get_rv1 ()

int                 call_wd_to_get_rv1                  (PHOEBE_curve *rv1,
                                                         PHOEBE_vector *indep);

rv1 :

indep :

Returns :


call_wd_to_get_rv2 ()

int                 call_wd_to_get_rv2                  (PHOEBE_curve *rv2,
                                                         PHOEBE_vector *indep);

rv2 :

indep :

Returns :


call_wd_to_get_pos_coordinates ()

int                 call_wd_to_get_pos_coordinates      (PHOEBE_vector *poscoy,
                                                         PHOEBE_vector *poscoz,
                                                         double phase);

Uses WD's LC code through a FORTRAN wrapper to obtain the plane-of-sky coordinates. The vectors poscoy and poscoz must not be allocated, only initialized.

poscoy :

PHOEBE_vector placeholder that will hold y coordinates of the plane-of-sky

poscoz :

PHOEBE_vector placeholder that will hold z coordinates of the plane-of-sky

phase :

phase node in which the plane-of-sky (pos) coordinates should be computed

Returns :

PHOEBE_error_code.

call_wd_to_get_logg_values ()

int                 call_wd_to_get_logg_values          (double *logg1,
                                                         double *logg2);

logg1 :

logg2 :

Returns :


phoebe_calculate_level_correction ()

int                 phoebe_calculate_level_correction   (double *alpha,
                                                         PHOEBE_curve *syn,
                                                         PHOEBE_curve *obs);

Computes the correction alpha that solves the equation:

\sum_i w_i (o_i - alpha c_i)^2 = min

where o_i are observed data points with individual weights w_i, and c_i are the computed fluxes with the original value of L1. Solving this system requires solving the following least squares equation:

alpha = (A W A^T)^{-1} A W b = \sum_i w_i o_i c_i / \sum_i w_i o_i^2

alpha :

level correction: L1 -> L1/alpha, L2 -> L2/alpha

syn :

synthetic (model) light curve

obs :

observed light curve

Returns :

PHOEBE_error_code.

phoebe_calculate_gamma_correction ()

int                 phoebe_calculate_gamma_correction   (double *gamma,
                                                         PHOEBE_curve *syn,
                                                         PHOEBE_curve *obs);

Computes the correction gamma that solves the equation:

\sum_i w_i (o_i - c_i - gamma)^2 = min

where o_i are observed data points with individual weights w_i, and c_i are the computed fluxes with the original value of gamma. Solving this system requires solving the following least squares equation:

gamma = (A W A^T)^{-1} A W b = \sum_i w_i o_i / \sum_i w_i

gamma :

gamma (center-of-mass) velocity correction: v -> v + gamma

syn :

synthetic (model) light curve

obs :

observed light curve

Returns :

PHOEBE_error_code.

phoebe_calculate_pot1 ()

double              phoebe_calculate_pot1               (bool ELLIPTIC,
                                                         double D,
                                                         double q,
                                                         double r,
                                                         double F,
                                                         double lambda,
                                                         double nu);

Calculates the primary star surface potential according to Eq.(3.16) in PHOEBE scientific reference.

ELLIPTIC :

elliptic orbit switch: 1 for elliptic orbits, 0 for circular

D :

instantaneous separation in units of semi-major axis

q :

mass ratio

r :

effective radius of the star

F :

asynchronicity parameter

lambda :

direction cosine, lambda = sin(theta) cos(phi)

nu :

direction cosine, nu = cos(theta)

Returns :

value of the primary star surface potential

phoebe_calculate_pot2 ()

double              phoebe_calculate_pot2               (bool ELLIPTIC,
                                                         double D,
                                                         double q,
                                                         double r,
                                                         double F,
                                                         double lambda,
                                                         double nu);

Calculates the secondary star surface potential by transforming the coordinate system to the center of the secondary star according to Eq.(3.15) in PHOEBE scientific reference, and using Eq.(3.16) to do the calculation.

ELLIPTIC :

elliptic orbit switch: 1 for elliptic orbits, 0 for circular

D :

instantaneous separation in units of semi-major axis

q :

mass ratio

r :

effective radius of the star

F :

asynchronicity parameter

lambda :

direction cosine, lambda = sin(theta) cos(phi)

nu :

direction cosine, nu = cos(theta)

Returns :

value of the secondary star surface potential

phoebe_calculate_critical_potentials ()

int                 phoebe_calculate_critical_potentials
                                                        (double q,
                                                         double F,
                                                         double e,
                                                         double *L1crit,
                                                         double *L2crit);

Calculates the value of the primary surface potential in Lagrange points L1 and L2.

q :

mass ratio

F :

asynchronicity parameter

e :

eccentricity

L1crit :

placeholder for the inner (Roche) lobe value of the potential

L2crit :

placeholder for the outer lobe value of the potential

Returns :

PHOEBE_error_code

calculate_periastron_orbital_phase ()

int                 calculate_periastron_orbital_phase  (double *pp,
                                                         double perr0,
                                                         double ecc);

pp :

perr0 :

ecc :

Returns :


calculate_median ()

int                 calculate_median                    (double *median,
                                                         PHOEBE_vector *vec);

median :

vec :

Returns :


calculate_sum ()

int                 calculate_sum                       (double *sum,
                                                         PHOEBE_vector *vec);

sum :

vec :

Returns :


calculate_average ()

int                 calculate_average                   (double *average,
                                                         PHOEBE_vector *vec);

average :

vec :

Returns :


calculate_sigma ()

int                 calculate_sigma                     (double *sigma,
                                                         PHOEBE_vector *vec);

sigma :

vec :

Returns :


calculate_weighted_sum ()

int                 calculate_weighted_sum              (double *sum,
                                                         PHOEBE_vector *dep,
                                                         PHOEBE_vector *weight);

sum :

dep :

weight :

Returns :


calculate_weighted_average ()

int                 calculate_weighted_average          (double *average,
                                                         PHOEBE_vector *dep,
                                                         PHOEBE_vector *weight);

average :

dep :

weight :

Returns :


calculate_weighted_sigma ()

int                 calculate_weighted_sigma            (double *sigma,
                                                         PHOEBE_vector *dep,
                                                         PHOEBE_vector *weight);

sigma :

dep :

weight :

Returns :


intern_calculate_phase_from_ephemeris ()

double              intern_calculate_phase_from_ephemeris
                                                        (double hjd,
                                                         double hjd0,
                                                         double period,
                                                         double dpdt,
                                                         double pshift);

hjd :

hjd0 :

period :

dpdt :

pshift :

Returns :


calculate_vga ()

double              calculate_vga                       (PHOEBE_vector *rv1,
                                                         PHOEBE_vector *rv2,
                                                         double rv1avg,
                                                         double rv2avg,
                                                         double origvga);

rv1 :

rv2 :

rv1avg :

rv2avg :

origvga :

Returns :


transform_hjd_to_phase ()

int                 transform_hjd_to_phase              (PHOEBE_vector *vec,
                                                         double hjd0,
                                                         double period,
                                                         double dpdt,
                                                         double pshift);

vec :

hjd0 :

period :

dpdt :

pshift :

Returns :


transform_phase_to_hjd ()

int                 transform_phase_to_hjd              (PHOEBE_vector *vec,
                                                         double hjd0,
                                                         double period,
                                                         double dpdt,
                                                         double pshift);

vec :

hjd0 :

period :

dpdt :

pshift :

Returns :


transform_magnitude_to_flux ()

int                 transform_magnitude_to_flux         (PHOEBE_vector *vec,
                                                         double mnorm);

vec :

mnorm :

Returns :


transform_magnitude_sigma_to_flux_sigma ()

int                 transform_magnitude_sigma_to_flux_sigma
                                                        (PHOEBE_vector *weights,
                                                         PHOEBE_vector *fluxes);

weights :

fluxes :

Returns :


transform_flux_to_magnitude ()

int                 transform_flux_to_magnitude         (PHOEBE_vector *vec,
                                                         double mnorm);

vec :

mnorm :

Returns :


transform_flux_sigma_to_magnitude_sigma ()

int                 transform_flux_sigma_to_magnitude_sigma
                                                        (PHOEBE_vector *weights,
                                                         PHOEBE_vector *fluxes);

weights :

fluxes :

Returns :


normalize_kms_to_orbit ()

int                 normalize_kms_to_orbit              (PHOEBE_vector *vec,
                                                         double sma,
                                                         double period);

vec :

sma :

period :

Returns :


transform_sigma_to_weight ()

int                 transform_sigma_to_weight           (PHOEBE_vector *vec);

vec :

Returns :


transform_weight_to_sigma ()

int                 transform_weight_to_sigma           (PHOEBE_vector *vec);

vec :

Returns :


phoebe_curve_alias ()

int                 phoebe_curve_alias                  (PHOEBE_curve *curve,
                                                         double phmin,
                                                         double phmax);

This function redimensiones the array of data phases by aliasing points to outside the [-0.5, 0.5] range. If the new interval is narrower, the points are omitted, otherwise they are aliased.

curve :

the curve to be aliased

phmin :

start phase

phmax :

end phase

Returns :

PHOEBE_error_code.

calculate_main_sequence_parameters ()

int                 calculate_main_sequence_parameters  (double T1,
                                                         double T2,
                                                         double P0,
                                                         double *L1,
                                                         double *L2,
                                                         double *M1,
                                                         double *M2,
                                                         double *q,
                                                         double *a,
                                                         double *R1,
                                                         double *R2,
                                                         double *Omega1,
                                                         double *Omega2);

T1 :

T2 :

P0 :

L1 :

L2 :

M1 :

M2 :

q :

a :

R1 :

R2 :

Omega1 :

Omega2 :

Returns :


calculate_synthetic_scatter_seed ()

int                 calculate_synthetic_scatter_seed    (double *seed);

seed :

Returns :


apply_extinction_correction ()

int                 apply_extinction_correction         (PHOEBE_curve *curve,
                                                         double A);

curve :

A :

Returns :


apply_third_light_correction ()

int                 apply_third_light_correction        (PHOEBE_curve *curve,
                                                         PHOEBE_el3_units el3units,
                                                         double el3value);

curve :

el3units :

el3value :

Returns :


apply_interstellar_extinction_correction ()

int                 apply_interstellar_extinction_correction
                                                        (PHOEBE_vector *wavelength,
                                                         PHOEBE_vector *spectrum,
                                                         double R,
                                                         double E);

wavelength :

spectrum :

R :

E :

Returns :


calculate_teff_from_bv_index ()

int                 calculate_teff_from_bv_index        (int star_type,
                                                         double bv,
                                                         double *teff);

star_type :

bv :

teff :

Returns :