![]() |
![]() |
![]() |
PHOEBE Reference Manual | ![]() |
---|---|---|---|---|
PHOEBE_specrep_tag; PHOEBE_specrep; extern PHOEBE_specrep PHOEBE_spectra_repository; int phoebe_spectra_set_repository (char *rep_name); int phoebe_spectra_free_repository (); PHOEBE_spectrum* phoebe_spectrum_new (); PHOEBE_spectrum* phoebe_spectrum_new_from_file (char *filename); PHOEBE_spectrum* phoebe_spectrum_new_from_repository (double Teff, double logg, double met); PHOEBE_spectrum* phoebe_spectrum_create (double ll, double ul, double R, PHOEBE_spectrum_dispersion disp); PHOEBE_spectrum* phoebe_spectrum_duplicate (PHOEBE_spectrum *spectrum); PHOEBE_vector* phoebe_spectrum_get_column (PHOEBE_spectrum *spectrum, int col); int phoebe_spectrum_alloc (PHOEBE_spectrum *spectrum, int dim); int phoebe_spectrum_realloc (PHOEBE_spectrum *spectrum, int dim); int phoebe_spectrum_free (PHOEBE_spectrum *spectrum); int phoebe_spectrum_rebin (PHOEBE_spectrum **src, PHOEBE_spectrum_dispersion disp, double ll, double ul, double R); int phoebe_spectrum_integrate (PHOEBE_spectrum *spectrum, double ll, double ul, double *result); int phoebe_spectrum_broaden (PHOEBE_spectrum **dest, PHOEBE_spectrum *src, double R); int phoebe_spectrum_crop (PHOEBE_spectrum *spectrum, double ll, double ul); int phoebe_spectrum_apply_doppler_shift (PHOEBE_spectrum **dest, PHOEBE_spectrum *src, double velocity); int phoebe_spectrum_apply_rotational_broadening (PHOEBE_spectrum **dest, PHOEBE_spectrum *src, double vsini, double ldx); int phoebe_spectrum_set_sampling (PHOEBE_spectrum *spectrum, double Rs); int phoebe_spectrum_set_resolution (PHOEBE_spectrum *spectrum, double R); int phoebe_spectrum_multiply_by (PHOEBE_spectrum **dest, PHOEBE_spectrum *src, double factor); int phoebe_spectrum_dispersion_guess (PHOEBE_spectrum_dispersion *disp, PHOEBE_spectrum *spectrum); char* phoebe_spectrum_dispersion_type_get_name (PHOEBE_spectrum_dispersion disp); int phoebe_spectra_add (PHOEBE_spectrum **dest, PHOEBE_spectrum *src1, PHOEBE_spectrum *src2); int phoebe_spectra_subtract (PHOEBE_spectrum **dest, PHOEBE_spectrum *src1, PHOEBE_spectrum *src2); int phoebe_spectra_merge (PHOEBE_spectrum **dest, PHOEBE_spectrum *src1, PHOEBE_spectrum *src2, double w1, double w2, double ll, double ul, double Rs); int phoebe_spectra_multiply (PHOEBE_spectrum **dest, PHOEBE_spectrum *src1, PHOEBE_spectrum *src2, double ll, double ul, double R); int phoebe_spectra_divide (PHOEBE_spectrum **dest, PHOEBE_spectrum *src1, PHOEBE_spectrum *src2); bool phoebe_spectra_compare (PHOEBE_spectrum *spec1, PHOEBE_spectrum *spec2);
These are the functions that facilitate spectra manipulation, including the repository I/O.
typedef struct { char *filename; int type; int resolution; int lambda_min; int lambda_max; int temperature; int metallicity; int gravity; int alpha; int microturbulence; } PHOEBE_specrep_tag;
typedef struct { int no; PHOEBE_specrep_tag *prop; PHOEBE_array *Teffnodes; PHOEBE_array *loggnodes; PHOEBE_array *metnodes; PHOEBE_specrep_tag ****table; } PHOEBE_specrep;
int phoebe_spectra_set_repository (char *rep_name);
Traverses the path rep_name
and parses all found filenames for spectra.
Filenames must match the predefined format:
T%5dG
%2d
%c
%2dV000K
%1dS
%2cNV
%3c
%c
.ASC
Only 0 rotational velocity spectra are parsed because PHOEBE uses its
internal function for rotational broadening. Where available, this
function calls ftw()
for traversing the tree; the spectra can then be
separated into subdirectories (i.e. Munari et al. 2005) and ftw()
will
traverse up to 10 subdirectories deep. When ftw()
is not available,
a simplified parsing function is used that requires the spectra to be
all in a single subdirectory.
|
path to the repository |
Returns : |
PHOEBE_error_code. |
int phoebe_spectra_free_repository ();
Frees all fields of the spectrum repository. Since PHOEBE currently allows for a single spectrum repository, the function takes no arguments.
Returns : |
PHOEBE_error_code. |
PHOEBE_spectrum* phoebe_spectrum_new ();
Allocates memory for the new spectrum.
Returns : |
a newly allocated PHOEBE_spectrum. |
PHOEBE_spectrum* phoebe_spectrum_new_from_file (char *filename);
Opens a two-column filename
and reads its contents to a newly allocated
spectrum. The columns are assumed to contain bin centers and fluxes. The
function tries to guess the dispersion type and assigns all spectrum
fields accordingly.
|
spectrum filename |
Returns : |
a read-in PHOEBE_spectrum. |
PHOEBE_spectrum* phoebe_spectrum_new_from_repository (double Teff, double logg, double met);
Queries the spectrum repository and interpolates a spectrum with the passed parameters. If the parameters are out of range for the given repository, NULL is returned. The function uses all available nodes in the repository for the interpolation; if the queried spectrum is missing, the first adjacent spectrum is looked up. The interpolation is linear.
|
effective temperature in K |
|
surface gravity in cgs units |
|
metallicity in solar abundances |
Returns : |
a queried PHOEBE_spectrum, or NULL in case of failure.
|
PHOEBE_spectrum* phoebe_spectrum_create (double ll, double ul, double R, PHOEBE_spectrum_dispersion disp);
Creates an empty spectrum of resolving power R
, sampled on the
wavelength interval [ll
, ul
]. If the dispersion type is
PHOEBE_SPECTRUM_DISPERSION_LOG
, the resolving power is constant and the
dispersion changes throughout the spectrum. If the dispersion type is
PHOEBE_SPECTRUM_DISPERSION_LINEAR
, the dispersion is constant and the
resolving power changes. Dispersion relates to resolving power simply
as delta = 1/R
.
|
lower wavelength limit in angstroms |
|
upper wavelength limit in angstroms |
|
spectrum resolving power |
|
spectrum dispersion type |
Returns : |
a newly created PHOEBE_spectrum. |
PHOEBE_spectrum* phoebe_spectrum_duplicate (PHOEBE_spectrum *spectrum);
Makes a duplicate copy of spectrum
.
|
spectrum to be duplicated |
Returns : |
a duplicated PHOEBE_spectrum. |
PHOEBE_vector* phoebe_spectrum_get_column (PHOEBE_spectrum *spectrum, int col);
Allocates a vector and copies the contents of the col
-th spectrum
column to it. The value of col
may be 1 (wavelength) or 2 (flux).
|
input spectrum |
|
column index |
Returns : |
PHOEBE_vector, or NULL in case of a failure. |
int phoebe_spectrum_alloc (PHOEBE_spectrum *spectrum, int dim);
Allocates memory for spectrum
with dimension dim
. The spectrum
must
be initialized with phoebe_spectrum_new()
.
|
initialized spectrum |
|
spectrum dimension |
Returns : |
PHOEBE_error_code. |
int phoebe_spectrum_realloc (PHOEBE_spectrum *spectrum, int dim);
Reallocates memory for spectrum
with the new dimension dim
. If dim
is smaller than the current dimension, spectrum
will be truncated.
Otherwise all original values are retained.
|
initialized or allocated spectrum |
|
new spectrum dimension |
Returns : |
PHOEBE_error_code. |
int phoebe_spectrum_free (PHOEBE_spectrum *spectrum);
Frees the allocated space for spectrum
.
|
spectrum to be freed |
Returns : |
PHOEBE_error_code. |
int phoebe_spectrum_rebin (PHOEBE_spectrum **src, PHOEBE_spectrum_dispersion disp, double ll, double ul, double R);
|
|
|
|
|
|
|
|
|
|
Returns : |
int phoebe_spectrum_integrate (PHOEBE_spectrum *spectrum, double ll, double ul, double *result);
Integrates the spectrum
on the wavelength interval [ll
, ul
] using a
simple rectangular rule:
I = \int_ll^ul s (\lambda) d\lambda = \sum s (\lambda) \Delta \lambda
The units of ll
and ul
must match the units of the passed spectrum
.
The sum goes over all covered \Delta \lambda's, taking into account the partial coverage at interval borders.
|
input spectrum |
|
lower wavelength interval limit |
|
upper wavelength interval limit |
|
placeholder for the integral value |
Returns : |
PHOEBE_error_code. |
int phoebe_spectrum_broaden (PHOEBE_spectrum **dest, PHOEBE_spectrum *src, double R);
|
|
|
|
|
|
Returns : |
int phoebe_spectrum_crop (PHOEBE_spectrum *spectrum, double ll, double ul);
Crops the passed spectrum to the [ll, ul] interval. All other spectrum properties are retained.
|
spectrum to be cropped |
|
lower wavelength limit |
|
upper wavelength limit |
Returns : |
PHOEBE_error_code. |
int phoebe_spectrum_apply_doppler_shift (PHOEBE_spectrum **dest, PHOEBE_spectrum *src, double velocity);
Applies a non-relativistic Doppler shift to the spectrum. It does that by first shifting the ranges according to the passed velocity and then rebinning the obtained histogram to the original bins. c=299791 km/s is used for the speed of light.
|
a placeholter for the shifted spectrum |
|
original (unshifted) spectrum |
|
radial velocity in km/s |
Returns : |
PHOEBE_error_code. |
int phoebe_spectrum_apply_rotational_broadening (PHOEBE_spectrum **dest, PHOEBE_spectrum *src, double vsini, double ldx);
|
|
|
|
|
|
|
|
Returns : |
int phoebe_spectrum_set_sampling (PHOEBE_spectrum *spectrum, double Rs);
|
|
|
|
Returns : |
int phoebe_spectrum_set_resolution (PHOEBE_spectrum *spectrum, double R);
|
|
|
|
Returns : |
int phoebe_spectrum_multiply_by (PHOEBE_spectrum **dest, PHOEBE_spectrum *src, double factor);
|
|
|
|
|
|
Returns : |
int phoebe_spectrum_dispersion_guess (PHOEBE_spectrum_dispersion *disp, PHOEBE_spectrum *spectrum);
Tries to guess the type of the spectrum dispersion by evaluating all
bin differences and quotients. If a difference is constant, disp
is
set to linear dispersion; if a quotient is constant, disp
is set to
log dispersion; otherwise disp
is set to no dispersion. The constancy
of the differences and quotients is checked to 1e-6 numerical accuracy.
|
placeholder for the guessed dispersion |
|
spectrum for which the dispersion should be guessed |
Returns : |
PHOEBE_error_code. |
char* phoebe_spectrum_dispersion_type_get_name (PHOEBE_spectrum_dispersion disp);
Converts the enumerated value to a string.
|
enumerated PHOEBE_spectrum_dispersion |
Returns : |
string |
int phoebe_spectra_add (PHOEBE_spectrum **dest, PHOEBE_spectrum *src1, PHOEBE_spectrum *src2);
|
|
|
|
|
|
Returns : |
int phoebe_spectra_subtract (PHOEBE_spectrum **dest, PHOEBE_spectrum *src1, PHOEBE_spectrum *src2);
|
|
|
|
|
|
Returns : |
int phoebe_spectra_merge (PHOEBE_spectrum **dest, PHOEBE_spectrum *src1, PHOEBE_spectrum *src2, double w1, double w2, double ll, double ul, double Rs);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Returns : |
int phoebe_spectra_multiply (PHOEBE_spectrum **dest, PHOEBE_spectrum *src1, PHOEBE_spectrum *src2, double ll, double ul, double R);
|
|
|
|
|
|
|
|
|
|
|
|
Returns : |
int phoebe_spectra_divide (PHOEBE_spectrum **dest, PHOEBE_spectrum *src1, PHOEBE_spectrum *src2);
|
|
|
|
|
|
Returns : |
bool phoebe_spectra_compare (PHOEBE_spectrum *spec1, PHOEBE_spectrum *spec2);
Compares spectra spec1
and spec2
by comparing the resolving power,
sampling, dispersion, and by evaluating the absolute value of
the differences of all elements (both wavelength and flux) and comparing
it against PHOEBE_NUMERICAL_ACCURACY.