41 #define _USE_MATH_DEFINES
47 #define J2000 2451545.0
49 #define ERRMSG_SIZE 1024
52 #define STELLAR_DAY 86164.098903691
54 #ifndef TRACKRATE_SIDEREAL
55 #define TRACKRATE_SIDEREAL ((360.0 * 3600.0) / STELLAR_DAY)
58 #define SOLAR_DAY 86400
60 #ifndef TRACKRATE_SOLAR
61 #define TRACKRATE_SOLAR ((360.0 * 3600.0) / SOLAR_DAY)
63 #ifndef TRACKRATE_LUNAR
64 #define TRACKRATE_LUNAR 14.511415
66 #ifndef EARTHRADIUSEQUATORIAL
67 #define EARTHRADIUSEQUATORIAL 6378137.0
69 #ifndef EARTHRADIUSPOLAR
70 #define EARTHRADIUSPOLAR 6356752.0
72 #ifndef EARTHRADIUSMEAN
73 #define EARTHRADIUSMEAN 6372797.0
76 #define SUNMASS 1.98847E+30
79 #define PLANK_H 6.62607015E-34
82 #define DIRAC_H (PLANK_H/(2*M_PI))
85 #define EINSTEIN_G 6.67408E-11
88 #define EULER 2.71828182845904523536028747135266249775724709369995
91 #define ROOT2 1.41421356237309504880168872420969807856967187537694
97 #define CIRCLE_DEG 360
100 #define CIRCLE_AM (CIRCLE_DEG * 60)
103 #define CIRCLE_AS (CIRCLE_AM * 60)
106 #define RAD_AS (CIRCLE_AS/(M_PI*2))
108 #ifndef ASTRONOMICALUNIT
109 #define ASTRONOMICALUNIT 1.495978707E+11
112 #define PARSEC (ASTRONOMICALUNIT*RAD_AS)
115 #define LIGHTSPEED 299792458.0
118 #define JULIAN_LY (LIGHTSPEED * SOLAR_DAY * 365)
121 #define STELLAR_LY (LIGHTSPEED * STELLAR_DAY * 365)
124 #define FLUX(wavelength) (wavelength/(PLANK_H*LIGHTSPEED))
127 #define CANDLE ((1.0/683.0)*FLUX(555))
130 #define LUMEN(wavelength) (CANDLE/(4*M_PI)*pow((FLUX(wavelength)/FLUX(555)), 0.25))
133 #define REDSHIFT(wavelength, reference) (1.0-(reference/wavelength))
136 #define DOPPLER(shift, speed) (speed*shift)
144 struct ln_lnlat_posn;
180 int tty_read(
int fd,
char *buf,
int nbytes,
int timeout,
int *nbytes_read);
195 int tty_read_expanded(
int fd,
char *buf,
int nbytes,
long timeout_seconds,
long timeout_microseconds,
int *nbytes_read);
205 int tty_read_section(
int fd,
char *buf,
char stop_char,
int timeout,
int *nbytes_read);
233 int tty_nread_section(
int fd,
char *buf,
int nsize,
char stop_char,
int timeout,
int *nbytes_read);
262 int tty_connect(
const char *
device,
int bit_rate,
int word_size,
int parity,
int stop_bits,
int *
fd);
275 void tty_error_msg(
int err_code,
char *err_msg,
int err_msg_len);
310 int fs_sexa(
char *out,
double a,
int w,
int fracbase);
339 int numberFormat(
char *buf,
const char *format,
double value);
396 void get_hrz_from_equ(
struct ln_equ_posn *
object,
struct ln_lnlat_posn *observer,
double JD,
struct ln_hrz_posn *position);
405 void get_equ_from_hrz(
struct ln_hrz_posn *
object,
struct ln_lnlat_posn *observer,
double JD,
406 struct ln_equ_posn *position);
448 double rad2as(
double rad);
460 double m2au(
double m);
469 double calc_delta_magnitude(
double mag_ratio,
double *spectrum,
double *ref_spectrum,
int spectrum_size);
478 double calc_photon_flux(
double rel_magnitude,
double filter_bandwidth,
double wavelength,
double steradian);
487 double calc_rel_magnitude(
double photon_flux,
double filter_bandwidth,
double wavelength,
double steradian);
529 void baseline_2d_projection(
double alt,
double az,
double baseline[3],
double wavelength,
double uvresult[2]);
double estimate_secondary_size(double star_size, double dropoff_ratio)
estimate the size of an object occulting a star in star_size units.
int tty_write_string(int fd, const char *buffer, int *nbytes_written)
Writes a null terminated string to fd.
void tty_set_generic_udp_format(int enabled)
double estimate_geocentric_elevation(double latitude, double sea_level_elevation)
estimate_geocentric_elevation Returns an estimation of the actual geocentric elevation
double rangeDec(double r)
rangeDec Limits declination value to be in -90 to 90 range.
double calc_rel_magnitude(double photon_flux, double filter_bandwidth, double wavelength, double steradian)
calc_rel_magnitude Returns the relative magnitude of the object with the given photon flux measured a...
double estimate_secondary_mass(double star_mass, double star_drift, double orbit_radius)
estimate the mass of an object with known mass orbiting around a star.
void baseline_2d_projection(double alt, double az, double baseline[3], double wavelength, double uvresult[2])
baseline_2d_projection Returns the coordinates of the projection of a single baseline targeting the o...
int tty_read_section(int fd, char *buf, char stop_char, int timeout, int *nbytes_read)
read buffer from terminal with a delimiter
void getSexComponentsIID(double value, int *d, int *m, double *s)
int f_scansexa(const char *str0, double *dp)
convert sexagesimal string str AxBxC to double. x can be anything non-numeric. Any missing A,...
int tty_connect(const char *device, int bit_rate, int word_size, int parity, int stop_bits, int *fd)
Establishes a tty connection to a terminal device.
double calc_photon_flux(double rel_magnitude, double filter_bandwidth, double wavelength, double steradian)
calc_photon_flux Returns the photon flux of the object with the given magnitude observed at a determi...
void tty_set_debug(int debug)
tty_set_debug Enable or disable debug which prints verbose information.
void get_alt_az_coordinates(double hour_angle, double dec, double latitude, double *alt, double *az)
get_alt_az_coordinates Returns alt-azimuth coordinates of an object
double estimate_field_rotation_rate(double Alt, double Az, double latitude)
estimate_field_rotation_rate Returns an estimation of the field rotation rate of the object
double estimate_distance(double parsecs, double parallax_radius)
estimate_distance Convert parallax arcseconds into meters
double estimate_orbit_radius(double obs_lambda, double ref_lambda, double period)
estimate the orbit radius of an object with known mass orbiting around a star.
double get_local_sidereal_time(double longitude)
get_local_sidereal_time Returns local sideral time given longitude and system clock.
int tty_disconnect(int fd)
Closes a tty connection and flushes the bus.
const char * SolarSystem[]
int tty_timeout_microseconds(int fd, long timeout_seconds, long timeout_microseconds)
double rangeHA(double r)
rangeHA Limits the hour angle value to be between -12 —> 12
void getSexComponents(double value, int *d, int *m, int *s)
int tty_read(int fd, char *buf, int nbytes, int timeout, int *nbytes_read)
read buffer from terminal
double estimate_absolute_magnitude(double dist, double delta_mag)
estimate_absolute_magnitude Returns an estimation of the absolute magnitude of an object given its di...
double m2au(double m)
m2au Convert meters into astronomical units
const char * indi_timestamp()
Create an ISO 8601 formatted time stamp. The format is YYYY-MM-DDTHH:MM:SS.
double range24(double r)
range24 Limits a number to be between 0-24 range.
int tty_read_section_expanded(int fd, char *buf, char stop_char, long timeout_seconds, long timeout_microseconds, int *nbytes_read)
read buffer from terminal with a delimiter
void get_hrz_from_equ(struct ln_equ_posn *object, struct ln_lnlat_posn *observer, double JD, struct ln_hrz_posn *position)
get_hrz_from_equ Calculate horizontal coordinates from equatorial coordinates.
double estimate_field_rotation(double hour_angle, double field_rotation_rate)
estimate_field_rotation Returns an estimation of the field rotation rate of the object
int tty_timeout(int fd, int timeout)
double as2rad(double as)
as2rad Convert arcseconds into radians
double estimate_star_mass(double delta_mag, double ref_mass)
estimate the star mass in ref_size units e.g. sun masses or kgs
double range360(double r)
range360 Limits an angle to be between 0-360 degrees.
double baseline_delay(double alt, double az, double baseline[3])
baseline_delay Returns the delay in meters of a single baseline targeting the object by coordinates
void tty_error_msg(int err_code, char *err_msg, int err_msg_len)
Retrieve the tty error message.
int tty_write(int fd, const char *buffer, int nbytes, int *nbytes_written)
Writes a buffer to fd.
double time_ns()
Get a unix timestamp with nanosecond precision.
double calc_delta_magnitude(double mag_ratio, double *spectrum, double *ref_spectrum, int spectrum_size)
calc_delta_magnitude Returns the difference of magnitudes given two spectra
int extractISOTime(const char *timestr, struct ln_date *iso_date)
Extract ISO 8601 time and store it in a tm struct.
void get_equ_from_hrz(struct ln_hrz_posn *object, struct ln_lnlat_posn *observer, double JD, struct ln_equ_posn *position)
ln_get_equ_from_hrz Calculate Equatorial EOD Coordinates from horizontal coordinates
int fs_sexa(char *out, double a, int w, int fracbase)
Converts a sexagesimal number to a string. sprint the variable a in sexagesimal format into out[].
int numberFormat(char *buf, const char *format, double value)
Fill buffer with properly formatted INumber string.
int tty_nread_section(int fd, char *buf, int nsize, char stop_char, int timeout, int *nbytes_read)
read buffer from terminal with a delimiter
int tty_read_expanded(int fd, char *buf, int nbytes, long timeout_seconds, long timeout_microseconds, int *nbytes_read)
read buffer from terminal with a delimiter
void tty_clr_trailing_read_lf(int enabled)
void tty_set_gemini_udp_format(int enabled)
double get_local_hour_angle(double local_sideral_time, double ra)
get_local_hour_angle Returns local hour angle of an object
double rad2as(double rad)
rad2as Convert radians into arcseconds
std::vector< uint8_t > buffer