C-Munipack 1.2 / Application programming interface / API reference
C-Munipack 1.2 / Application programming interface / API reference
CmpackDate | Date in full format. |
CmpackTime | Time in full format. |
CmpackDateTime | Date and time in full format. |
CmpackBorder | Border size. |
CMPACK_BITPIX_AUTO |
CmpackOpenMode | Open flags. |
CmpackLoadMode | Load flags. |
CmpackBitpix | Image data types. |
CmpackParam | Parameter identifiers. |
CmpackError | Error codes. |
CmpackMask | Mask flags (tells which fields are valid). |
cmpack_init | Initialize library. |
cmpack_cleanup | Clean-up library. |
cmpack_formaterror | Translates error code to its human readable representation. |
cmpack_versionid | Get C-Munipack library version. |
cmpack_major_version | Get major version number. |
cmpack_minor_version | Get minor version number. |
cmpack_revision_number | Get revision number. |
cmpack_packagename | Get C-Munipack package name. |
cmpack_date_set | Fill date structure. |
cmpack_time_set | Fill time structure. |
cmpack_datetime_set | Fill date and time structure. |
cmpack_border_set | Fill border structure. |
cmpack_get_param_long | Get configuration parameter. |
cmpack_malloc | Allocate memory. |
cmpack_calloc | Allocate and clear memory block. |
cmpack_realloc | Change size of the memory block or make new one. |
cmpack_strdup | Makes copy of a null-terminated string. |
cmpack_strset | Updates a null-terminated string. |
cmpack_free | Release allocated memory. |
cmpack_malloc_dbg | Allocate memory (debug version). |
cmpack_realloc_dbg | Change size of the memory block or make new one. |
cmpack_calloc_dbg | Allocate and clear memory block (debug version). |
cmpack_strdup_dbg | Makes copy of a null-terminated string. |
cmpack_strset_dbg | Updates a null-terminated string. |
cmpack_addref | Increment reference counter. |
cmpack_unref | Decrement reference counter and when it is zero free the allocated memory. |
cmpack_strtodate | Parse string and return parts of the date. |
cmpack_strtotime | Parse string and return parts of the time. |
cmpack_datetostr | Print date to the string. |
cmpack_timetostr | Print time to the string. |
cmpack_encodejd | Convert date and time parts to julian date. |
cmpack_decodejd | Convert julian date to parts of date and time. |
cmpack_strtora | Convert the string to R.A. |
cmpack_strtodec | Converts the string to DEC. |
cmpack_ratostr | Converts the R.A. |
cmpack_dectostr | Converts the DEC. |
cmpack_strtolat | Converts string to latitude. |
cmpack_strtolon | Converts string to longitude. |
cmpack_lattostr | Converts the latitude to the string (N DDD MM SS). |
cmpack_lontostr | Converts the longitude to the string (E DDD MM SS). |
cmpack_airmass | Computes Airmass coefficient. |
cmpack_helcorr | Computes heliocentric correction. |
cmpack_robustmean | Computes robust mean and standard deviation. |
cmpack_fastmean | Computes estimation of robust mean and standard deviation. |
Set of functions, data types for general use.
Date in full format.
typedef struct _CmpackDate
{
int year,
int month,
int day
} CmpackDate;
year | year in 4-digit format |
month | month (1-12) |
day | day (1-31) |
Time in full format.
typedef struct _CmpackTime
{
int hour,
int minute,
int second,
int milisecond
} CmpackTime;
hour | hour (0-23) |
minute | minute (0-59) |
second | second (0-59) |
milisecond | milisecond (0-999) |
Date and time in full format.
typedef struct _CmpackDateTime
{
CmpackDate date,
CmpackTime time
} CmpackDateTime;
date | date, see CmpackDate structure |
time | time, see CmpackTime structure |
Border size.
typedef struct _CmpackBorder
{
int left,
int top,
int right,
int bottom
} CmpackBorder;
left | Left border. |
top | Top border. |
right | Right border. |
bottom | Bottom border. |
Open flags.
enum CmpackOpenMode
{
CMPACK_OPEN_READWRITE = 0x00,
CMPACK_OPEN_READONLY = 0x01,
CMPACK_OPEN_CREATE = 0x02,
CMPACK_OPEN_HEADONLY = 0x04
};
CMPACK_OPEN_READWRITE | The file allows modifications. |
CMPACK_OPEN_READONLY | The file does not allow modifications. |
CMPACK_OPEN_CREATE | Create a new file. |
CMPACK_OPEN_HEADONLY | Read only header. |
Load flags.
enum CmpackLoadMode
{
CMPACK_LOAD_DEFAULT = 0x00,
CMPACK_LOAD_HEADONLY = 0x04
};
CMPACK_LOAD_DEFAULT | Load entire file. |
CMPACK_LOAD_HEADONLY | Read only header. |
Image data types.
enum CmpackBitpix
{
CMPACK_BITPIX_UNKNOWN = 0,
CMPACK_BITPIX_SCHAR = 8,
CMPACK_BITPIX_UCHAR = 10,
CMPACK_BITPIX_SSHORT = 16,
CMPACK_BITPIX_USHORT = 20,
CMPACK_BITPIX_SLONG = 32,
CMPACK_BITPIX_ULONG = 40,
CMPACK_BITPIX_FLOAT = -32,
CMPACK_BITPIX_DOUBLE = -64
};
CMPACK_BITPIX_UNKNOWN | Unknown or invalid data format. |
CMPACK_BITPIX_SCHAR | Signed char (1 bytes). |
CMPACK_BITPIX_UCHAR | Unsigned char (1 bytes). |
CMPACK_BITPIX_SSHORT | Signed short (2 bytes). |
CMPACK_BITPIX_USHORT | Unsigned short (2 bytes). |
CMPACK_BITPIX_SLONG | Signed long (4 bytes). |
CMPACK_BITPIX_ULONG | Unsigned long (4 bytes). |
CMPACK_BITPIX_FLOAT | Single precision FP (4 bytes). |
CMPACK_BITPIX_DOUBLE | Double precision FP (8 bytes). |
Parameter identifiers.
enum CmpackParam
{
CMPACK_PARAM_JD_PRECISION = 0,
CMPACK_PARAM_POS_PRECISION = 1,
CMPACK_PARAM_EXP_PRECISION = 2,
CMPACK_PARAM_TEMP_PRECISION = 3,
CMPACK_PARAM_AMASS_PRECISION = 4,
CMPACK_PARAM_ALT_PRECISION = 5
};
CMPACK_PARAM_JD_PRECISION | Number of decimal places for Julian dates and heliocentric correction. |
CMPACK_PARAM_POS_PRECISION | Number of decimal places for position in pixels. |
CMPACK_PARAM_EXP_PRECISION | Number of decimal places for exposure duration in seconds. |
CMPACK_PARAM_TEMP_PRECISION | Number of decimal places for CCD temperature. |
CMPACK_PARAM_AMASS_PRECISION | Number of decimal places for air-mass coefficient. |
CMPACK_PARAM_ALT_PRECISION | Number of decimal places for altitude in degrees. |
Error codes.
enum CmpackError
{
CMPACK_ERR_OK = 0,
CMPACK_ERR_MEMORY = 1001,
CMPACK_ERR_KEY_NOT_FOUND = 1002,
CMPACK_ERR_COL_NOT_FOUND = 1003,
CMPACK_ERR_ROW_NOT_FOUND = 1004,
CMPACK_ERR_AP_NOT_FOUND = 1005,
CMPACK_ERR_READ_ONLY = 1006,
CMPACK_ERR_CLOSED_FILE = 1007,
CMPACK_ERR_OPEN_ERROR = 1008,
CMPACK_ERR_READ_ERROR = 1009,
CMPACK_ERR_WRITE_ERROR = 1010,
CMPACK_ERR_UNKNOWN_FORMAT = 1011,
CMPACK_ERR_BUFFER_TOO_SMALL = 1012,
CMPACK_ERR_INVALID_CONTEXT = 1013,
CMPACK_ERR_OUT_OF_RANGE = 1014,
CMPACK_ERR_UNDEF_VALUE = 1015,
CMPACK_ERR_MAG_NOT_FOUND = 1016,
CMPACK_ERR_STAR_NOT_FOUND = 1017,
CMPACK_ERR_NOT_IMPLEMENTED = 1018,
CMPACK_ERR_INVALID_SIZE = 1100,
CMPACK_ERR_INVALID_DATE = 1101,
CMPACK_ERR_INVALID_PAR = 1102,
CMPACK_ERR_INVALID_RA = 1103,
CMPACK_ERR_INVALID_DEC = 1104,
CMPACK_ERR_INVALID_EXPTIME = 1105,
CMPACK_ERR_INVALID_BITPIX = 1106,
CMPACK_ERR_INVALID_LON = 1107,
CMPACK_ERR_INVALID_LAT = 1108,
CMPACK_ERR_INVALID_JULDAT = 1109,
CMPACK_ERR_CANT_OPEN_SRC = 1200,
CMPACK_ERR_CANT_OPEN_OUT = 1201,
CMPACK_ERR_CANT_OPEN_BIAS = 1202,
CMPACK_ERR_CANT_OPEN_DARK = 1203,
CMPACK_ERR_CANT_OPEN_FLAT = 1204,
CMPACK_ERR_CANT_OPEN_REF = 1205,
CMPACK_ERR_CANT_OPEN_PHT = 1206,
CMPACK_ERR_DIFF_SIZE_SRC = 1300,
CMPACK_ERR_DIFF_SIZE_BIAS = 1301,
CMPACK_ERR_DIFF_SIZE_DARK = 1302,
CMPACK_ERR_DIFF_SIZE_FLAT = 1303,
CMPACK_ERR_DIFF_BITPIX_SRC = 1304,
CMPACK_ERR_NO_INPUT_FILES = 1400,
CMPACK_ERR_NO_BIAS_FRAME = 1401,
CMPACK_ERR_NO_DARK_FRAME = 1402,
CMPACK_ERR_NO_FLAT_FRAME = 1403,
CMPACK_ERR_NO_OBS_COORDS = 1404,
CMPACK_ERR_NO_OBJ_COORDS = 1405,
CMPACK_ERR_NO_OUTPUT_FILE = 1406,
CMPACK_ERR_NO_REF_FILE = 1407,
CMPACK_ERR_MEAN_ZERO = 1500,
CMPACK_ERR_REF_NOT_FOUND = 1501,
CMPACK_ERR_FEW_POINTS_REF = 1502,
CMPACK_ERR_FEW_POINTS_SRC = 1503,
CMPACK_ERR_MATCH_NOT_FOUND = 1504
};
CMPACK_ERR_OK | Operation finished successfully. |
CMPACK_ERR_MEMORY | Insufficient memory. |
CMPACK_ERR_KEY_NOT_FOUND | Key not found. |
CMPACK_ERR_COL_NOT_FOUND | Column not found. |
CMPACK_ERR_ROW_NOT_FOUND | Row not found. |
CMPACK_ERR_AP_NOT_FOUND | Aperture not found. |
CMPACK_ERR_READ_ONLY | File is open in read-only mode. |
CMPACK_ERR_CLOSED_FILE | Operation not allowed on closed file. |
CMPACK_ERR_OPEN_ERROR | Error while opening file. |
CMPACK_ERR_READ_ERROR | Error while reading file. |
CMPACK_ERR_WRITE_ERROR | Error while writing file. |
CMPACK_ERR_UNKNOWN_FORMAT | Unknown format of source file. |
CMPACK_ERR_BUFFER_TOO_SMALL | Buffer is too small. |
CMPACK_ERR_INVALID_CONTEXT | Invalid context. |
CMPACK_ERR_OUT_OF_RANGE | Index is out of range. |
CMPACK_ERR_UNDEF_VALUE | Undefined value. |
CMPACK_ERR_MAG_NOT_FOUND | Measurement not found. |
CMPACK_ERR_STAR_NOT_FOUND | Star not found. |
CMPACK_ERR_NOT_IMPLEMENTED | Unsupported operation. |
CMPACK_ERR_INVALID_SIZE | Invalid dimensions of image. |
CMPACK_ERR_INVALID_DATE | Invalid date/time format. |
CMPACK_ERR_INVALID_PAR | Invalid value of parameter. |
CMPACK_ERR_INVALID_RA | Invalid RA format. |
CMPACK_ERR_INVALID_DEC | Invalid DEC format. |
CMPACK_ERR_INVALID_EXPTIME | Invalid exposure duration. |
CMPACK_ERR_INVALID_BITPIX | Image image data format. |
CMPACK_ERR_INVALID_LON | Invalid format of longitude. |
CMPACK_ERR_INVALID_LAT | Invalid format of latitude. |
CMPACK_ERR_INVALID_JULDAT | Invalid date/time of observation. |
CMPACK_ERR_CANT_OPEN_SRC | Cannot open the source file. |
CMPACK_ERR_CANT_OPEN_OUT | Cannot open the destination file. |
CMPACK_ERR_CANT_OPEN_BIAS | Bias frame not found. |
CMPACK_ERR_CANT_OPEN_DARK | Dark frame not found. |
CMPACK_ERR_CANT_OPEN_FLAT | Flat frame not found. |
CMPACK_ERR_CANT_OPEN_REF | Reference file not found. |
CMPACK_ERR_CANT_OPEN_PHT | Cannot open photometry file. |
CMPACK_ERR_DIFF_SIZE_SRC | Input frames are not compatible (different sizes). |
CMPACK_ERR_DIFF_SIZE_BIAS | Bias frame is not compatible (different sizes). |
CMPACK_ERR_DIFF_SIZE_DARK | Dimensions of dark-frame and scientific image are different. |
CMPACK_ERR_DIFF_SIZE_FLAT | Dimensions of flat-frame and scientific image are different. |
CMPACK_ERR_DIFF_BITPIX_SRC | Input frames are not compatible (different image data type). |
CMPACK_ERR_NO_INPUT_FILES | No input files. |
CMPACK_ERR_NO_BIAS_FRAME | Missing bias frame. |
CMPACK_ERR_NO_DARK_FRAME | Missing dark frame. |
CMPACK_ERR_NO_FLAT_FRAME | Missing flat frame. |
CMPACK_ERR_NO_OBS_COORDS | Missing observer's coordinates. |
CMPACK_ERR_NO_OBJ_COORDS | Missing object's coordinates. |
CMPACK_ERR_NO_OUTPUT_FILE | Missing name of output frame. |
CMPACK_ERR_NO_REF_FILE | Missing name of reference frame. |
CMPACK_ERR_MEAN_ZERO | Mean value of flat frame is zero (can't divide by zero). |
CMPACK_ERR_REF_NOT_FOUND | Refererence star was not found. |
CMPACK_ERR_FEW_POINTS_REF | Too few stars in the reference file. |
CMPACK_ERR_FEW_POINTS_SRC | Too few stars in the source file. |
CMPACK_ERR_MATCH_NOT_FOUND | Coincidences not found. |
Mask flags (tells which fields are valid).
enum CmpackMask
{
CMPACK_MASK_CODE = 0x000001,
CMPACK_MASK_MAG = 0x000002,
CMPACK_MASK_ERR = 0x000004,
CMPACK_MASK_POS = 0x000008,
CMPACK_MASK_RA = 0x000010,
CMPACK_MASK_DEC = 0x000020,
CMPACK_MASK_LAT = 0x000040,
CMPACK_MASK_LON = 0x000080,
CMPACK_MASK_ID = 0x000100,
CMPACK_MASK_SEL_TYPE = 0x000800,
CMPACK_MASK_SEL_INDEX = 0x001000,
CMPACK_MASK_IMG_SIZE = 0x002000,
CMPACK_MASK_JD = 0x008000,
CMPACK_MASK_EXP_TIME = 0x010000,
CMPACK_MASK_CCD_TEMP = 0x020000,
CMPACK_MASK_FILTER = 0x040000,
CMPACK_MASK_OBJ_NAME = 0x080000,
CMPACK_MASK_RADIUS = 0x100000,
CMPACK_MASK_OBS_NAME = 0x200000
};
CMPACK_MASK_CODE | Result code. |
CMPACK_MASK_MAG | Magnitude. |
CMPACK_MASK_ERR | Error. |
CMPACK_MASK_POS | Position. |
CMPACK_MASK_RA | Right ascension. |
CMPACK_MASK_DEC | Declination. |
CMPACK_MASK_LAT | Latitude. |
CMPACK_MASK_LON | Longitude. |
CMPACK_MASK_ID | Identifier. |
CMPACK_MASK_SEL_TYPE | Selection type. |
CMPACK_MASK_SEL_INDEX | Selection index. |
CMPACK_MASK_IMG_SIZE | Image width. |
CMPACK_MASK_JD | Julian date of observation. |
CMPACK_MASK_EXP_TIME | Exposure duration. |
CMPACK_MASK_CCD_TEMP | CCD temperature. |
CMPACK_MASK_FILTER | Color filter designation. |
CMPACK_MASK_OBJ_NAME | Object's designation. |
CMPACK_MASK_RADIUS | Radius. |
CMPACK_MASK_OBS_NAME | Observer's name. |
Initialize library.
void cmpack_init (void)
Call this function in the main thread before any other function from the C-Munipack library is called.
Clean-up library.
void cmpack_cleanup (void)
Call this function in the main thread as the last of all functions from the C-Munipack library. When compiled with _DEBUG flag on, prints table of unreleased memory blocks to stderr.
Translates error code to its human readable representation.
char * cmpack_formaterror (int code)
The function returns pointer to allocated memory buffer. The caller is responsible to release it by calling cmpack_free() function.
code | [in] | error code |
pointer to allocated string or zero on failure.
Get C-Munipack library version.
const char * cmpack_versionid (void)
The version identifier consists of three part. The first one is major number which is incremented on major changes in the library. The second one is minor version incremented on changes in the library's interface. Even minor numbers indicates stable versions, odd minor numbers are reserved for development versions. The last part, the revision number, is incremented every time the package(s) are published.
pointer to allocated string or zero on failure.
Get major version number.
int cmpack_major_version (void)
This part is incremented on major changes in the library.
major version number
Get minor version number.
int cmpack_minor_version (void)
This part is incremented on changes in the library's interface. Even minor numbers indicates stable versions, odd minor numbers are reserved for development versions.
minor version number
Get revision number.
int cmpack_revision_number (void)
This part is incremented every time the package(s) are published.
revision number
Get C-Munipack package name.
const char * cmpack_packagename (void)
pointer to allocated string or zero on failure.
Fill date structure.
void cmpack_date_set (CmpackDate * date, int year, int month, int day)
date | [out] | date structure |
year | [in] | year in 4-digit format |
month | [in] | month (1-12) |
day | [in] | day (1-31) |
Fill time structure.
void cmpack_time_set (CmpackTime * time, int hour, int minute, int second, int milisecond)
time | [out] | time structure |
hour | [in] | hour (0-23) |
minute | [in] | minute (0-59) |
second | [in] | second (0-59) |
milisecond | [in] | milisecond (0-999) |
Fill date and time structure.
void cmpack_datetime_set (CmpackDateTime * datetime, int year, int month, int day, int hour, int minute, int second, int milisecond)
datetime | [out] | date and time structure |
year | [in] | year in 4-digit format |
month | [in] | month (1-12) |
day | [in] | day (1-31) |
hour | [in] | hour (0-23) |
minute | [in] | minute (0-59) |
second | [in] | second (0-59) |
milisecond | [in] | milisecond (0-999) |
Fill border structure.
void cmpack_border_set (CmpackBorder * border, int left, int top, int right, int bottom)
border | [out] | border structure |
left | [in] | left border |
top | [in] | top border |
right | [in] | right border |
bottom | [in] | bottom border |
Get configuration parameter.
long cmpack_get_param_long (CmpackParam param)
param | [in] | parameter identifier (see CMPACK_PARAM_xxx) |
parameter value or zero on failure
Allocate memory.
void * cmpack_malloc (size_t size)
The function allocates specified amount of memory on heap and returns pointer to the beginning of the memory block. All blocks allocated by means of this function must be released by calling the cmpack_free() function. The content of the memory block is undefined.
size | [in] | size in bytes |
pointer to the first byte of the memory block
Allocate and clear memory block.
void * cmpack_calloc (size_t num, size_t size)
The function allocates specified amount of memory on heap and returns pointer to the beginning of the memory block and sets the content to zeros. All blocks allocated by means of this function must be released by calling the cmpack_free() function.
num | [in] | number of items |
size | [in] | size of single item |
pointer to the first byte of the memory block
Change size of the memory block or make new one.
void * cmpack_realloc (void * ptr, size_t size)
When pointer to the existing memory block is NULL, it allocates new memory block of specified size. Otherwise, it resizes the memory block to specified size. All content of the old memory is preserved, but the content of new area is undefined.
ptr | [in] | pointer to existing block (or NULL) |
size | [in] | new size in bytes |
Makes copy of a null-terminated string.
char * cmpack_strdup (const char * src)
Returns pointer to newly allocated memory block. Use cmpack_free() function to release it. If the input string is NULL, it returns NULL. If the input string is empty, it returns empty string.
src | [in] | source string |
Updates a null-terminated string.
char * cmpack_strset (char * dst, const char * src)
First parameter can specify a pointer to an existing null-terminated string. If it's non-NULL, it's realocated to fit a new string and makes a copy of a string. Otherwise it allocates a new memory buffer and make a copy of a string. Old pointer may not be valid after that function and should not be used in following code, always use the result of the function.
dst | [in] | pointer to existing block (or NULL) |
src | [in] | source string |
Release allocated memory.
void cmpack_free (void * ptr)
Use this function to release the memory block allocated by the cmpack_malloc(), cmpack_malloc_dbg(), cmpack_calloc(), cmpack_calloc_dbg(), cmpack_realloc(), cmpack_realloc_dbg() functions or a other functions from the C-Munipack library.
ptr | [in] | pointer to memory |
Allocate memory (debug version).
void * cmpack_malloc_dbg (size_t size, const char * file, int line)
The function allocates specified amount of memory on heap and returns pointer to the beginning of the memory block. All blocks allocated by means of this function must be released by calling the cmpack_free() function. Unlike cmpack_malloc(), this function stores the given name of the source file and line number. The content of the memory block is undefined.
size | [in] | size in bytes |
file | [in] | source file name |
line | [in] | source line index |
pointer to the first byte of the memory block
Change size of the memory block or make new one.
void * cmpack_realloc_dbg (void * ptr, size_t size, const char * file, int line)
When pointer to the existing memory block is NULL, it allocates new memory block of specified size. Otherwise, it resizes the memory block to specified size. All content of the old memory is preserved, but the content of new area is undefined. Unline cmpack_realloc() this function stores the given name of the source file and line number.
ptr | [in] | pointer to existing block (or NULL) |
size | [in] | new size in bytes |
file | [in] | source file name |
line | [in] | source line index |
Allocate and clear memory block (debug version).
void * cmpack_calloc_dbg (size_t num, size_t size, const char * file, int line)
The function allocates specified amount of memory on heap and returns pointer to the beginning of the memory block and sets the content to zeros. All blocks allocated by means of this function must be released by calling the cmpack_free() function. Unlike cmpack_calloc(), this function stores the given name of the source file and line number.
num | [in] | number of items |
size | [in] | size of single item |
file | [in] | source file name |
line | [in] | source line index |
pointer to the first byte of the memory block
Makes copy of a null-terminated string.
char * cmpack_strdup_dbg (const char * src, const char * file, int line)
Returns pointer to newly allocated memory block. Use cmpack_free() function to release it. If the input string is NULL, it returns NULL. If the input string is empty, it returns empty string. Unline cmpack_realloc() this function stores the given name of the source file and line number.
src | [in] | source string |
file | [in] | source file name |
line | [in] | source line index |
Updates a null-terminated string.
char * cmpack_strset_dbg (char * dst, const char * src, const char * file, int line)
First parameter can specify a pointer to an existing null-terminated string. If it's non-NULL, it's realocated to fit a new string and makes a copy of a string. Otherwise it allocates a new memory buffer and make a copy of a string. Old pointer may not be valid after that function and should not be used in following code, always use the result of the function.
dst | [in] | pointer to existing block (or NULL) |
src | [in] | source string |
file | [in] | source file name |
line | [in] | source line index |
Increment reference counter.
void * cmpack_addref (void * ctx)
Call this function to make a persistent reference on a context. It ensures, that it won't be released until you call cmpack_unref() on it.
ctx | [in] | any context |
the same value as ctx
Decrement reference counter and when it is zero free the allocated memory.
void cmpack_unref (void * ctx)
Call this function on a context to release your persistent reference made by cmpack_addref() function.
ctx | [in] | any context |
Parse string and return parts of the date.
int cmpack_strtodate (const char * datestr, CmpackDate * date)
datestr | [in] | date string (YYYY-MM-DD) |
date | [out] | date parts |
zero on success or error code on failure
Parse string and return parts of the time.
int cmpack_strtotime (const char * timestr, CmpackTime * time)
timestr | [in] | time string (HH:MM:SS.SSS) |
time | [out] | time parts |
zero on success or error code on failure
Print date to the string.
int cmpack_datetostr (const CmpackDate * date, char * buf, int buflen)
date | [in] | date parts |
buf | [out] | output string |
buflen | [in] | size of buffer in chars |
zero on success or error code on failure.
Print time to the string.
int cmpack_timetostr (const CmpackTime * time, char * buf, int buflen)
time | [in] | time parts |
buf | [out] | output string |
buflen | [in] | size of buffer in chars |
zero on success or error code on failure.
Convert date and time parts to julian date.
double cmpack_encodejd (const CmpackDateTime * datetime)
datetime | [in] | date and time |
julian date on success or zero on failure
Convert julian date to parts of date and time.
int cmpack_decodejd (double jd, CmpackDateTime * datetime)
jd | [in] | julian date |
datetime | [out] | date and time |
zero on success or error code on failure.
Convert the string to R.A.
int cmpack_strtora (const char * buf, double * ra)
buf | [in] | input string |
ra | [out] | right ascension in hours (0..24) |
zero on success or error code on failure.
Converts the string to DEC.
int cmpack_strtodec (const char * buf, double * dec)
buf | [in] | input string |
dec | [out] | declination in degrees (-90..90) |
zero on success or error code on failure.
Converts the R.A.
int cmpack_ratostr (double ra, char * buf, int buflen)
value to the string (HH MM SS)
ra | [in] | right ascension in hours |
buf | [out] | output string |
buflen | [in] | size of buffer in chars |
zero on success or error code on failure.
Converts the DEC.
int cmpack_dectostr (double dec, char * buf, int buflen)
value to the string (+DDD MM SS)
dec | [in] | declination in degrees |
buf | [out] | output string |
buflen | [in] | size of buffer in chars |
pointer to allocated string or zero on failure
Converts string to latitude.
int cmpack_strtolat (const char * buf, double * lat)
buf | [in] | input string |
lat | [out] | latitude in degrees (-90..90) |
zero on success or error code on failure.
Converts string to longitude.
int cmpack_strtolon (const char * buf, double * lon)
buf | [in] | input string |
lon | [out] | longitude in degrees (-180..180) |
zero on success or error code on failure.
Converts the latitude to the string (N DDD MM SS).
int cmpack_lattostr (double lat, char * buf, int buflen)
The function returns pointer to allocated memory buffer. The caller is responsible to release it by calling cmpack_free() function.
lat | [in] | latitude in degrees |
buf | [out] | output string |
buflen | [in] | size of buffer in chars |
zero on success or error code on failure.
Converts the longitude to the string (E DDD MM SS).
int cmpack_lontostr (double lon, char * buf, int buflen)
The function returns pointer to allocated memory buffer. The caller is responsible to release it by calling cmpack_free() function.
lon | [in] | longitude in degrees |
buf | [out] | output string |
buflen | [in] | size of buffer in chars |
zero on success or error code on failure.
Computes Airmass coefficient.
double cmpack_airmass (double jd, double obj_ra, double obj_dec, double obs_lon, double obs_lat, double * alt)
jd | [in] | julian date (UT) |
obj_ra | [in] | right ascension of object in hours |
obj_dec | [in] | declination of object in degrees |
obs_lon | [in] | longitude of observer in degrees |
obs_lat | [in] | latitude of observer in degrees |
alt | [out] | altitude in degrees (optional) |
airmass coefficient (X=1 for object in zenith)
Computes heliocentric correction.
double cmpack_helcorr (double jd, double obj_ra, double obj_dec)
jd | [in] | julian date (UT) |
obj_ra | [in] | right ascension of object in hours |
obj_dec | [in] | declination of object in degrees |
heliocentric correction in days
Computes robust mean and standard deviation.
int cmpack_robustmean (int n, double * A, double * mean, double * sig)
This function is slower but more precise that cmpack_fastmean().
n | [in] | number of elements |
A | [in] | array of elements |
mean | [out] | robust mean |
sig | [out] | standard deviation |
Computes estimation of robust mean and standard deviation.
int cmpack_fastmean (int n, double * A, int nmax, double lobad, double hibad, double * skymed, double * skysig)
This function is much faster but less precise that cmpack_robustmean(). Unlike cmpack_robustmean(), this function estimates the mean value and standard deviation by computing robust mean using a subset of original data. At most nmax samples are taken in and all values <=lobad or >= hibad are ruled out.
n | [in] | number of elements |
A | [in] | array of elements |
nmax | [in] | max. number of samples in a subset |
lobad | [in] | low cutoff for sample value |
hibad | [in] | high cutoff for sample value |
skymed | [out] | robust mean |
skysig | [out] | standard deviation |