C-Munipack 1.2 / Application programming interface / API reference
C-Munipack 1.2 / Application programming interface / API reference
CmpackTableType | Table type identifiers. |
CmpackColumnType | Column type identifier. |
CmpackTable | Table context. |
CmpackTabColumn | Table column context. |
cmpack_tab_init | Create a new table context. |
cmpack_tab_load | Load a table from a file. |
cmpack_tab_save | Save a table to a file. |
cmpack_tab_clear | Clear table definition, header and data. |
cmpack_tab_copy | Copy a table. |
cmpack_tab_set_type | Set table type. |
cmpack_tab_get_type | Get table type. |
cmpack_tab_test | Check if the file is a table. |
cmpack_tab_test_buffer | Test if the content of the buffer might be a table. |
cmpack_tab_pkys | Set parameter value in file header (string). |
cmpack_tab_pkyi | Set parameter value in file header (integer). |
cmpack_tab_pkyd | Set parameter value in file header (integer). |
cmpack_tab_gkys | Get value of parameter in file header (string). |
cmpack_tab_gkyi | Get value of parameter in file header (integer). |
cmpack_tab_gkyd | Get value of parameter in file header (double). |
cmpack_tab_nkey | Get number of parameters in file header. |
cmpack_tab_gkyn | Get the parameter from file header by its index. |
cmpack_tab_dkey | Delete parameter from file header. |
cmpack_tab_ncolumns | Get number of columns. |
cmpack_tab_add_column | Append new column to the table. |
cmpack_tab_get_column | Get column by its index. |
cmpack_tab_find_column | Find column by its name. |
cmpack_tab_column_set_name | Set column name. |
cmpack_tab_column_get_name | Get column name. |
cmpack_tab_nrows | Get number of rows in the table. |
cmpack_tab_add_row | Append a new row to the table. |
cmpack_tab_ptds | Set table data (string). |
cmpack_tab_ptdi | Set table data (integer). |
cmpack_tab_ptdd | Set table data (real number). |
cmpack_tab_gtds | Get table data (string). |
cmpack_tab_gtdi | Get table data (integer). |
cmpack_tab_gtdd | Get table data (double). |
Output data files contain data in form of table. It is used for storing light curves, track lists, etc.
Use cmpack-list object to process a set of photometry files and make output data. This format was inherited from original Munipack, but it's been extended to support saving a set of parameters (file header).
Table context.
typedef struct _CmpackTable CmpackTable
This private structure holds the table header and data
Table column context.
typedef struct _CmpackTabColumn CmpackTabColumn
This private structure holds the information about table column
Table type identifiers.
enum CmpackTableType
{
CMPACK_TABLE_UNSPECIFIED,
CMPACK_TABLE_LIGHTCURVE,
CMPACK_TABLE_MUNIFIND,
CMPACK_TABLE_TRACKLIST,
CMPACK_TABLE_APERTURES,
CMPACK_TABLE_AIRMASS
};
CMPACK_TABLE_UNSPECIFIED | Unspecified type. |
CMPACK_TABLE_LIGHTCURVE | Light curve. |
CMPACK_TABLE_MUNIFIND | Mag-dev graph, result of the Munifind tool. |
CMPACK_TABLE_TRACKLIST | Track-list, frame offsets. |
CMPACK_TABLE_APERTURES | Apertures and standard deviations. |
CMPACK_TABLE_AIRMASS | Air-mass coefficients. |
Column type identifier.
enum CmpackColumnType
{
CMPACK_COLUMN_STRING,
CMPACK_COLUMN_INTEGER,
CMPACK_COLUMN_DOUBLE
};
CMPACK_COLUMN_STRING | Unspecified type. |
CMPACK_COLUMN_INTEGER | Identifier of a star, an aperture, . |
CMPACK_COLUMN_DOUBLE | Julian date. |
Create a new table context.
CmpackTable * cmpack_tab_init (CmpackTableType type)
This function makes an empty table
new reference to a table context
Load a table from a file.
int cmpack_tab_load (CmpackTable ** tab, const char * filename, CmpackLoadMode flags)
tab | [out] | new table context |
filename | [in] | path + file name |
flags | [in] | flags (see CMPACK_LOAD_xxx constants) |
zero on success, error code on failure
Save a table to a file.
int cmpack_tab_save (CmpackTable * tab, const char * filename)
tab | [in] | table context |
filename | [in] | path + file name |
zero on success, error code on failure
Clear table definition, header and data.
void cmpack_tab_clear (CmpackTable * tab)
Deletes all information stored in a table context
tab | [in] | table context |
Copy a table.
void cmpack_tab_copy (CmpackTable * dsttab, const CmpackTable * srctab)
Makes a copy of source table to the destination table. All content of the destination table will be deleted.
dsttab | [in] | destination table context |
srctab | [in] | source table context |
Set table type.
void cmpack_tab_set_type (CmpackTable * tab, CmpackTableType type)
tab | [in] | table context |
type | [in] | table type identifier |
Get table type.
CmpackTableType cmpack_tab_get_type (CmpackTable * tab)
This function returns the type of the table
the integer value that represents the type of the table
Check if the file is a table.
int cmpack_tab_test (const char * filename)
filename | [in] | path + file name |
nonzero if the file is a table, zero otherwise
Test if the content of the buffer might be a table.
int cmpack_tab_test_buffer (const char * buffer, int buflen, int filesize)
The function checks the data in the buffer and returns nonzero, when the buffer contain first 'buflen' bytes from a table. This function is used for file format autodetection.
nonzero if the file is a photometry file, zero otherwise
Set parameter value in file header (string).
void cmpack_tab_pkys (CmpackTable * tab, const char * key, const char * val)
If the parameter does not exist, it makes new entry in the file header. If the parameter exists, its content is changed. Keys are case sensitive.
tab | [in] | table context |
key | [in] | parameter name |
val | [in] | parameter value |
zero on success, error code on failure
Set parameter value in file header (integer).
void cmpack_tab_pkyi (CmpackTable * tab, const char * key, int val)
If the parameter does not exist, it makes new entry in the file header. If the parameter exists, its content is changed. Keys are case sensitive.
tab | [in] | table context |
key | [in] | parameter name |
val | [in] | parameter value |
zero on success, error code on failure
Set parameter value in file header (integer).
void cmpack_tab_pkyd (CmpackTable * tab, const char * key, double val, int prec)
If the parameter does not exist, it makes new entry in the file header. If the parameter exists, its content is changed. Keys are case sensitive.
tab | [in] | table context |
key | [in] | parameter name |
val | [in] | parameter value |
prec | [in] | number of decimal places |
zero on success, error code on failure
Get value of parameter in file header (string).
const char * cmpack_tab_gkys (CmpackTable * tab, const char * key)
The val parameters receives the pointer to newly allocated memory buffer. The caller is responsible to free it by calling of cmpack_free() function. Keys are case sensitive. You can set the output parameter to NULL if you want to test the value only.
tab | [in] | table context |
key | [in] | parameter name |
pointer to internal buffer or NULL on failure
Get value of parameter in file header (integer).
int cmpack_tab_gkyi (CmpackTable * tab, const char * key, int defval)
Keys are case sensitive.
tab | [in] | table context |
key | [in] | parameter name |
defval | [in] | default value |
parameter value on success, default value on failure
Get value of parameter in file header (double).
double cmpack_tab_gkyd (CmpackTable * tab, const char * key, double defval)
Keys are case sensitive.
tab | [in] | table context |
key | [in] | parameter name |
defval | [in] | default value |
zero on success, error code on failure
Get number of parameters in file header.
int cmpack_tab_nkey (CmpackTable * tab)
tab | [in] | table context |
number of parameter or zero if the file is not valid context or if the header is empty.
Get the parameter from file header by its index.
int cmpack_tab_gkyn (CmpackTable * tab, int index, const char ** key, const char ** val)
Index of the first parameter is zero. The output parameters receive the pointers to newly allocated memory buffers. The caller is responsible to free it by calling of cmpack_free() function. You can set the value of output parameter to NULL if you do not need to read it.
tab | [in] | table context |
index | [in] | parameter index (starting by zero) |
key | [out] | parameter name (can be NULL) |
val | [out] | parameter value (can be NULL) |
zero on success, error code on failure
Delete parameter from file header.
void cmpack_tab_dkey (CmpackTable * tab, const char * key)
Keys are case sensitive.
tab | [in] | table context |
key | [in] | parameter name |
Get number of columns.
int cmpack_tab_ncolumns (CmpackTable * tab)
tab | [in] | table context |
number of columns or zero if the table is not valid context or if it is empty.
Append new column to the table.
int cmpack_tab_add_column (CmpackTable * tab, const char * name, CmpackColumnType type, int prec)
tab | [in] | table context |
name | [in] | column name |
type | [in] | data type |
prec | [in] | number of places after the decimal point |
index of new column or negative value on failure
Get column by its index.
CmpackTabColumn * cmpack_tab_get_column (CmpackTable * tab, int index)
tab | [in] | table context |
index | [in] | column index |
new reference to table column
Find column by its name.
int cmpack_tab_find_column (CmpackTable * tab, const char * name)
tab | [in] | table context |
name | [in] | column name |
index of table column or negative value on failure
Set column name.
void cmpack_tab_column_set_name (CmpackTabColumn * col, const char * name)
The function returns pointer to the internal structure. You must not call the cmpack_free() function to it.
col | [in] | column context |
name | [in] | new column name |
Get column name.
const char * cmpack_tab_column_get_name (CmpackTabColumn * col)
The function returns pointer to the internal structure. You must not call the cmpack_free() function to it.
col | [in] | column context |
pointer to the column name
Get number of rows in the table.
int cmpack_tab_nrows (CmpackTable * tab)
tab | [in] | table context |
If context is not valid or contains no data, returns zero
Append a new row to the table.
int cmpack_tab_add_row (CmpackTable * tab)
The function appends a new row to the end of the table
tab | [in] | table context |
index of new row or negative number on failure
Set table data (string).
void cmpack_tab_ptds (CmpackTable * tab, int row, int col, const char * val)
The function modifies table data in specified row and column.
tab | [in] | table context |
row | [in] | row index |
col | [in] | column index |
val | [in] | new value |
zero on success, error code on failure.
Set table data (integer).
void cmpack_tab_ptdi (CmpackTable * tab, int row, int col, int val)
The function modifies table data in specified row and column.
tab | [in] | table context |
row | [in] | row index |
col | [in] | column index |
val | [in] | new value |
zero on success, error code on failure.
Set table data (real number).
void cmpack_tab_ptdd (CmpackTable * tab, int row, int col, double val)
The function modifies table data in specified row and column.
tab | [in] | table context |
row | [in] | row index |
col | [in] | column index |
val | [in] | new value |
zero on success, error code on failure.
Get table data (string).
int cmpack_tab_gtds (CmpackTable * tab, int row, int col, char ** val)
tab | [in] | table context |
row | [in] | row index |
col | [in] | column index |
val | [out] | pointer to internal buffer |
nonzero on success, zero on failure
Get table data (integer).
int cmpack_tab_gtdi (CmpackTable * tab, int row, int col, int * val)
tab | [in] | table context |
row | [in] | row index |
col | [in] | column index |
val | [out] | value |
nonzero on success, zero on failure
Get table data (double).
int cmpack_tab_gtdd (CmpackTable * tab, int row, int col, double * val)
tab | [in] | table context |
row | [in] | row index |
col | [in] | column index |
val | [out] | value |
nonzero on success, zero on failure