C-Munipack 1.2 / Application programming interface / API reference

Miscellaneous data types, definitions, functions, &c.

cmpack_common.h

Data structures

CmpackDateDate in full format.
CmpackTimeTime in full format.
CmpackDateTimeDate and time in full format.
CmpackBorderBorder size.

Defines

CMPACK_BITPIX_AUTO

Enumerations

CmpackOpenModeOpen flags.
CmpackLoadModeLoad flags.
CmpackBitpixImage data types.
CmpackParamParameter identifiers.
CmpackErrorError codes.
CmpackMaskMask flags (tells which fields are valid).

Functions

cmpack_initInitialize library.
cmpack_cleanupClean-up library.
cmpack_formaterrorTranslates error code to its human readable representation.
cmpack_versionidGet C-Munipack library version.
cmpack_major_versionGet major version number.
cmpack_minor_versionGet minor version number.
cmpack_revision_numberGet revision number.
cmpack_packagenameGet C-Munipack package name.
cmpack_date_setFill date structure.
cmpack_time_setFill time structure.
cmpack_datetime_setFill date and time structure.
cmpack_border_setFill border structure.
cmpack_get_param_longGet configuration parameter.
cmpack_mallocAllocate memory.
cmpack_callocAllocate and clear memory block.
cmpack_reallocChange size of the memory block or make new one.
cmpack_strdupMakes copy of a null-terminated string.
cmpack_strsetUpdates a null-terminated string.
cmpack_freeRelease allocated memory.
cmpack_malloc_dbgAllocate memory (debug version).
cmpack_realloc_dbgChange size of the memory block or make new one.
cmpack_calloc_dbgAllocate and clear memory block (debug version).
cmpack_strdup_dbgMakes copy of a null-terminated string.
cmpack_strset_dbgUpdates a null-terminated string.
cmpack_addrefIncrement reference counter.
cmpack_unrefDecrement reference counter and when it is zero free the allocated memory.
cmpack_strtodateParse string and return parts of the date.
cmpack_strtotimeParse string and return parts of the time.
cmpack_datetostrPrint date to the string.
cmpack_timetostrPrint time to the string.
cmpack_encodejdConvert date and time parts to julian date.
cmpack_decodejdConvert julian date to parts of date and time.
cmpack_strtoraConvert the string to R.A.
cmpack_strtodecConverts the string to DEC.
cmpack_ratostrConverts the R.A.
cmpack_dectostrConverts the DEC.
cmpack_strtolatConverts string to latitude.
cmpack_strtolonConverts string to longitude.
cmpack_lattostrConverts the latitude to the string (N DDD MM SS).
cmpack_lontostrConverts the longitude to the string (E DDD MM SS).
cmpack_airmassComputes Airmass coefficient.
cmpack_helcorrComputes heliocentric correction.
cmpack_robustmeanComputes robust mean and standard deviation.
cmpack_fastmeanComputes estimation of robust mean and standard deviation.

Description

Set of functions, data types for general use.

CmpackDate (data structure)

Date in full format.

Synopsis

typedef struct _CmpackDate
{
     int year,
     int month,
     int day
} CmpackDate;

Members

yearyear in 4-digit format
monthmonth (1-12)
dayday (1-31)

CmpackTime (data structure)

Time in full format.

Synopsis

typedef struct _CmpackTime
{
     int hour,
     int minute,
     int second,
     int milisecond
} CmpackTime;

Members

hourhour (0-23)
minuteminute (0-59)
secondsecond (0-59)
milisecondmilisecond (0-999)

CmpackDateTime (data structure)

Date and time in full format.

Synopsis

typedef struct _CmpackDateTime
{
     CmpackDate date,
     CmpackTime time
} CmpackDateTime;

Members

datedate, see CmpackDate structure
timetime, see CmpackTime structure

CmpackBorder (data structure)

Border size.

Synopsis

typedef struct _CmpackBorder
{
     int left,
     int top,
     int right,
     int bottom
} CmpackBorder;

Members

leftLeft border.
topTop border.
rightRight border.
bottomBottom border.

CmpackOpenMode (enumeration)

Open flags.

Synopsis

enum CmpackOpenMode
{
     CMPACK_OPEN_READWRITE = 0x00,
     CMPACK_OPEN_READONLY = 0x01,
     CMPACK_OPEN_CREATE = 0x02,
     CMPACK_OPEN_HEADONLY = 0x04
};

Enumerators

CMPACK_OPEN_READWRITEThe file allows modifications.
CMPACK_OPEN_READONLYThe file does not allow modifications.
CMPACK_OPEN_CREATECreate a new file.
CMPACK_OPEN_HEADONLYRead only header.

CmpackLoadMode (enumeration)

Load flags.

Synopsis

enum CmpackLoadMode
{
     CMPACK_LOAD_DEFAULT = 0x00,
     CMPACK_LOAD_HEADONLY = 0x04
};

Enumerators

CMPACK_LOAD_DEFAULTLoad entire file.
CMPACK_LOAD_HEADONLYRead only header.

CmpackBitpix (enumeration)

Image data types.

Synopsis

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
};

Enumerators

CMPACK_BITPIX_UNKNOWNUnknown or invalid data format.
CMPACK_BITPIX_SCHARSigned char (1 bytes).
CMPACK_BITPIX_UCHARUnsigned char (1 bytes).
CMPACK_BITPIX_SSHORTSigned short (2 bytes).
CMPACK_BITPIX_USHORTUnsigned short (2 bytes).
CMPACK_BITPIX_SLONGSigned long (4 bytes).
CMPACK_BITPIX_ULONGUnsigned long (4 bytes).
CMPACK_BITPIX_FLOATSingle precision FP (4 bytes).
CMPACK_BITPIX_DOUBLEDouble precision FP (8 bytes).

CmpackParam (enumeration)

Parameter identifiers.

Synopsis

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
};

Enumerators

CMPACK_PARAM_JD_PRECISIONNumber of decimal places for Julian dates and heliocentric correction.
CMPACK_PARAM_POS_PRECISIONNumber of decimal places for position in pixels.
CMPACK_PARAM_EXP_PRECISIONNumber of decimal places for exposure duration in seconds.
CMPACK_PARAM_TEMP_PRECISIONNumber of decimal places for CCD temperature.
CMPACK_PARAM_AMASS_PRECISIONNumber of decimal places for air-mass coefficient.
CMPACK_PARAM_ALT_PRECISIONNumber of decimal places for altitude in degrees.

CmpackError (enumeration)

Error codes.

Synopsis

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
};

Enumerators

CMPACK_ERR_OKOperation finished successfully.
CMPACK_ERR_MEMORYInsufficient memory.
CMPACK_ERR_KEY_NOT_FOUNDKey not found.
CMPACK_ERR_COL_NOT_FOUNDColumn not found.
CMPACK_ERR_ROW_NOT_FOUNDRow not found.
CMPACK_ERR_AP_NOT_FOUNDAperture not found.
CMPACK_ERR_READ_ONLYFile is open in read-only mode.
CMPACK_ERR_CLOSED_FILEOperation not allowed on closed file.
CMPACK_ERR_OPEN_ERRORError while opening file.
CMPACK_ERR_READ_ERRORError while reading file.
CMPACK_ERR_WRITE_ERRORError while writing file.
CMPACK_ERR_UNKNOWN_FORMATUnknown format of source file.
CMPACK_ERR_BUFFER_TOO_SMALLBuffer is too small.
CMPACK_ERR_INVALID_CONTEXTInvalid context.
CMPACK_ERR_OUT_OF_RANGEIndex is out of range.
CMPACK_ERR_UNDEF_VALUEUndefined value.
CMPACK_ERR_MAG_NOT_FOUNDMeasurement not found.
CMPACK_ERR_STAR_NOT_FOUNDStar not found.
CMPACK_ERR_NOT_IMPLEMENTEDUnsupported operation.
CMPACK_ERR_INVALID_SIZEInvalid dimensions of image.
CMPACK_ERR_INVALID_DATEInvalid date/time format.
CMPACK_ERR_INVALID_PARInvalid value of parameter.
CMPACK_ERR_INVALID_RAInvalid RA format.
CMPACK_ERR_INVALID_DECInvalid DEC format.
CMPACK_ERR_INVALID_EXPTIMEInvalid exposure duration.
CMPACK_ERR_INVALID_BITPIXImage image data format.
CMPACK_ERR_INVALID_LONInvalid format of longitude.
CMPACK_ERR_INVALID_LATInvalid format of latitude.
CMPACK_ERR_INVALID_JULDATInvalid date/time of observation.
CMPACK_ERR_CANT_OPEN_SRCCannot open the source file.
CMPACK_ERR_CANT_OPEN_OUTCannot open the destination file.
CMPACK_ERR_CANT_OPEN_BIASBias frame not found.
CMPACK_ERR_CANT_OPEN_DARKDark frame not found.
CMPACK_ERR_CANT_OPEN_FLATFlat frame not found.
CMPACK_ERR_CANT_OPEN_REFReference file not found.
CMPACK_ERR_CANT_OPEN_PHTCannot open photometry file.
CMPACK_ERR_DIFF_SIZE_SRCInput frames are not compatible (different sizes).
CMPACK_ERR_DIFF_SIZE_BIASBias frame is not compatible (different sizes).
CMPACK_ERR_DIFF_SIZE_DARKDimensions of dark-frame and scientific image are different.
CMPACK_ERR_DIFF_SIZE_FLATDimensions of flat-frame and scientific image are different.
CMPACK_ERR_DIFF_BITPIX_SRCInput frames are not compatible (different image data type).
CMPACK_ERR_NO_INPUT_FILESNo input files.
CMPACK_ERR_NO_BIAS_FRAMEMissing bias frame.
CMPACK_ERR_NO_DARK_FRAMEMissing dark frame.
CMPACK_ERR_NO_FLAT_FRAMEMissing flat frame.
CMPACK_ERR_NO_OBS_COORDSMissing observer's coordinates.
CMPACK_ERR_NO_OBJ_COORDSMissing object's coordinates.
CMPACK_ERR_NO_OUTPUT_FILEMissing name of output frame.
CMPACK_ERR_NO_REF_FILEMissing name of reference frame.
CMPACK_ERR_MEAN_ZEROMean value of flat frame is zero (can't divide by zero).
CMPACK_ERR_REF_NOT_FOUNDRefererence star was not found.
CMPACK_ERR_FEW_POINTS_REFToo few stars in the reference file.
CMPACK_ERR_FEW_POINTS_SRCToo few stars in the source file.
CMPACK_ERR_MATCH_NOT_FOUNDCoincidences not found.

CmpackMask (enumeration)

Mask flags (tells which fields are valid).

Synopsis

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
};

Enumerators

CMPACK_MASK_CODEResult code.
CMPACK_MASK_MAGMagnitude.
CMPACK_MASK_ERRError.
CMPACK_MASK_POSPosition.
CMPACK_MASK_RARight ascension.
CMPACK_MASK_DECDeclination.
CMPACK_MASK_LATLatitude.
CMPACK_MASK_LONLongitude.
CMPACK_MASK_IDIdentifier.
CMPACK_MASK_SEL_TYPESelection type.
CMPACK_MASK_SEL_INDEXSelection index.
CMPACK_MASK_IMG_SIZEImage width.
CMPACK_MASK_JDJulian date of observation.
CMPACK_MASK_EXP_TIMEExposure duration.
CMPACK_MASK_CCD_TEMPCCD temperature.
CMPACK_MASK_FILTERColor filter designation.
CMPACK_MASK_OBJ_NAMEObject's designation.
CMPACK_MASK_RADIUSRadius.
CMPACK_MASK_OBS_NAMEObserver's name.

cmpack_init (function)

Initialize library.

Synopsis

void cmpack_init (void)

Description

Call this function in the main thread before any other function from the C-Munipack library is called.

cmpack_cleanup (function)

Clean-up library.

Synopsis

void cmpack_cleanup (void)

Description

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.

cmpack_formaterror (function)

Translates error code to its human readable representation.

Synopsis

char * cmpack_formaterror (int code)

Description

The function returns pointer to allocated memory buffer. The caller is responsible to release it by calling cmpack_free() function.

Parameters

code[in] error code

Return value

pointer to allocated string or zero on failure.

cmpack_versionid (function)

Get C-Munipack library version.

Synopsis

const char * cmpack_versionid (void)

Description

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.

Return value

pointer to allocated string or zero on failure.

cmpack_major_version (function)

Get major version number.

Synopsis

int cmpack_major_version (void)

Description

This part is incremented on major changes in the library.

Return value

major version number

cmpack_minor_version (function)

Get minor version number.

Synopsis

int cmpack_minor_version (void)

Description

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.

Return value

minor version number

cmpack_revision_number (function)

Get revision number.

Synopsis

int cmpack_revision_number (void)

Description

This part is incremented every time the package(s) are published.

Return value

revision number

cmpack_packagename (function)

Get C-Munipack package name.

Synopsis

const char * cmpack_packagename (void)

Return value

pointer to allocated string or zero on failure.

cmpack_date_set (function)

Fill date structure.

Synopsis

void cmpack_date_set (CmpackDate * date, int year, int month, int day)

Parameters

date[out] date structure
year[in] year in 4-digit format
month[in] month (1-12)
day[in] day (1-31)

cmpack_time_set (function)

Fill time structure.

Synopsis

void cmpack_time_set (CmpackTime * time, int hour, int minute, int second, int milisecond)

Parameters

time[out] time structure
hour[in] hour (0-23)
minute[in] minute (0-59)
second[in] second (0-59)
milisecond[in] milisecond (0-999)

cmpack_datetime_set (function)

Fill date and time structure.

Synopsis

void cmpack_datetime_set (CmpackDateTime * datetime, int year, int month, int day, int hour, int minute, int second, int milisecond)

Parameters

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)

cmpack_border_set (function)

Fill border structure.

Synopsis

void cmpack_border_set (CmpackBorder * border, int left, int top, int right, int bottom)

Parameters

border[out] border structure
left[in] left border
top[in] top border
right[in] right border
bottom[in] bottom border

cmpack_get_param_long (function)

Get configuration parameter.

Synopsis

long cmpack_get_param_long (CmpackParam param)

Parameters

param[in] parameter identifier (see CMPACK_PARAM_xxx)

Return value

parameter value or zero on failure

cmpack_malloc (function)

Allocate memory.

Synopsis

void * cmpack_malloc (size_t size)

Description

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.

Parameters

size[in] size in bytes

Return value

pointer to the first byte of the memory block

cmpack_calloc (function)

Allocate and clear memory block.

Synopsis

void * cmpack_calloc (size_t num, size_t size)

Description

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.

Parameters

num[in] number of items
size[in] size of single item

Return value

pointer to the first byte of the memory block

cmpack_realloc (function)

Change size of the memory block or make new one.

Synopsis

void * cmpack_realloc (void * ptr, size_t size)

Description

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.

Parameters

ptr[in] pointer to existing block (or NULL)
size[in] new size in bytes

cmpack_strdup (function)

Makes copy of a null-terminated string.

Synopsis

char * cmpack_strdup (const char * src)

Description

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.

Parameters

src[in] source string

cmpack_strset (function)

Updates a null-terminated string.

Synopsis

char * cmpack_strset (char * dst, const char * src)

Description

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.

Parameters

dst[in] pointer to existing block (or NULL)
src[in] source string

cmpack_free (function)

Release allocated memory.

Synopsis

void cmpack_free (void * ptr)

Description

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.

Parameters

ptr[in] pointer to memory

cmpack_malloc_dbg (function)

Allocate memory (debug version).

Synopsis

void * cmpack_malloc_dbg (size_t size, const char * file, int line)

Description

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.

Parameters

size[in] size in bytes
file[in] source file name
line[in] source line index

Return value

pointer to the first byte of the memory block

cmpack_realloc_dbg (function)

Change size of the memory block or make new one.

Synopsis

void * cmpack_realloc_dbg (void * ptr, size_t size, const char * file, int line)

Description

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.

Parameters

ptr[in] pointer to existing block (or NULL)
size[in] new size in bytes
file[in] source file name
line[in] source line index

cmpack_calloc_dbg (function)

Allocate and clear memory block (debug version).

Synopsis

void * cmpack_calloc_dbg (size_t num, size_t size, const char * file, int line)

Description

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.

Parameters

num[in] number of items
size[in] size of single item
file[in] source file name
line[in] source line index

Return value

pointer to the first byte of the memory block

cmpack_strdup_dbg (function)

Makes copy of a null-terminated string.

Synopsis

char * cmpack_strdup_dbg (const char * src, const char * file, int line)

Description

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.

Parameters

src[in] source string
file[in] source file name
line[in] source line index

cmpack_strset_dbg (function)

Updates a null-terminated string.

Synopsis

char * cmpack_strset_dbg (char * dst, const char * src, const char * file, int line)

Description

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.

Parameters

dst[in] pointer to existing block (or NULL)
src[in] source string
file[in] source file name
line[in] source line index

cmpack_addref (function)

Increment reference counter.

Synopsis

void * cmpack_addref (void * ctx)

Description

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.

Parameters

ctx[in] any context

Return value

the same value as ctx

cmpack_unref (function)

Decrement reference counter and when it is zero free the allocated memory.

Synopsis

void cmpack_unref (void * ctx)

Description

Call this function on a context to release your persistent reference made by cmpack_addref() function.

Parameters

ctx[in] any context

cmpack_strtodate (function)

Parse string and return parts of the date.

Synopsis

int cmpack_strtodate (const char * datestr, CmpackDate * date)

Parameters

datestr[in] date string (YYYY-MM-DD)
date[out] date parts

Return value

zero on success or error code on failure

cmpack_strtotime (function)

Parse string and return parts of the time.

Synopsis

int cmpack_strtotime (const char * timestr, CmpackTime * time)

Parameters

timestr[in] time string (HH:MM:SS.SSS)
time[out] time parts

Return value

zero on success or error code on failure

cmpack_datetostr (function)

Print date to the string.

Synopsis

int cmpack_datetostr (const CmpackDate * date, char * buf, int buflen)

Parameters

date[in] date parts
buf[out] output string
buflen[in] size of buffer in chars

Return value

zero on success or error code on failure.

cmpack_timetostr (function)

Print time to the string.

Synopsis

int cmpack_timetostr (const CmpackTime * time, char * buf, int buflen)

Parameters

time[in] time parts
buf[out] output string
buflen[in] size of buffer in chars

Return value

zero on success or error code on failure.

cmpack_encodejd (function)

Convert date and time parts to julian date.

Synopsis

double cmpack_encodejd (const CmpackDateTime * datetime)

Parameters

datetime[in] date and time

Return value

julian date on success or zero on failure

cmpack_decodejd (function)

Convert julian date to parts of date and time.

Synopsis

int cmpack_decodejd (double jd, CmpackDateTime * datetime)

Parameters

jd[in] julian date
datetime[out] date and time

Return value

zero on success or error code on failure.

cmpack_strtora (function)

Convert the string to R.A.

Synopsis

int cmpack_strtora (const char * buf, double * ra)

Parameters

buf[in] input string
ra[out] right ascension in hours (0..24)

Return value

zero on success or error code on failure.

cmpack_strtodec (function)

Converts the string to DEC.

Synopsis

int cmpack_strtodec (const char * buf, double * dec)

Parameters

buf[in] input string
dec[out] declination in degrees (-90..90)

Return value

zero on success or error code on failure.

cmpack_ratostr (function)

Converts the R.A.

Synopsis

int cmpack_ratostr (double ra, char * buf, int buflen)

Description

value to the string (HH MM SS)

Parameters

ra[in] right ascension in hours
buf[out] output string
buflen[in] size of buffer in chars

Return value

zero on success or error code on failure.

cmpack_dectostr (function)

Converts the DEC.

Synopsis

int cmpack_dectostr (double dec, char * buf, int buflen)

Description

value to the string (+DDD MM SS)

Parameters

dec[in] declination in degrees
buf[out] output string
buflen[in] size of buffer in chars

Return value

pointer to allocated string or zero on failure

cmpack_strtolat (function)

Converts string to latitude.

Synopsis

int cmpack_strtolat (const char * buf, double * lat)

Parameters

buf[in] input string
lat[out] latitude in degrees (-90..90)

Return value

zero on success or error code on failure.

cmpack_strtolon (function)

Converts string to longitude.

Synopsis

int cmpack_strtolon (const char * buf, double * lon)

Parameters

buf[in] input string
lon[out] longitude in degrees (-180..180)

Return value

zero on success or error code on failure.

cmpack_lattostr (function)

Converts the latitude to the string (N DDD MM SS).

Synopsis

int cmpack_lattostr (double lat, char * buf, int buflen)

Description

The function returns pointer to allocated memory buffer. The caller is responsible to release it by calling cmpack_free() function.

Parameters

lat[in] latitude in degrees
buf[out] output string
buflen[in] size of buffer in chars

Return value

zero on success or error code on failure.

cmpack_lontostr (function)

Converts the longitude to the string (E DDD MM SS).

Synopsis

int cmpack_lontostr (double lon, char * buf, int buflen)

Description

The function returns pointer to allocated memory buffer. The caller is responsible to release it by calling cmpack_free() function.

Parameters

lon[in] longitude in degrees
buf[out] output string
buflen[in] size of buffer in chars

Return value

zero on success or error code on failure.

cmpack_airmass (function)

Computes Airmass coefficient.

Synopsis

double cmpack_airmass (double jd, double obj_ra, double obj_dec, double obs_lon, double obs_lat, double * alt)

Parameters

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)

Return value

airmass coefficient (X=1 for object in zenith)

cmpack_helcorr (function)

Computes heliocentric correction.

Synopsis

double cmpack_helcorr (double jd, double obj_ra, double obj_dec)

Parameters

jd[in] julian date (UT)
obj_ra[in] right ascension of object in hours
obj_dec[in] declination of object in degrees

Return value

heliocentric correction in days

cmpack_robustmean (function)

Computes robust mean and standard deviation.

Synopsis

int cmpack_robustmean (int n, double * A, double * mean, double * sig)

Description

This function is slower but more precise that cmpack_fastmean().

Parameters

n[in] number of elements
A[in] array of elements
mean[out] robust mean
sig[out] standard deviation

cmpack_fastmean (function)

Computes estimation of robust mean and standard deviation.

Synopsis

int cmpack_fastmean (int n, double * A, int nmax, double lobad, double hibad, double * skymed, double * skysig)

Description

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.

Parameters

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