C-Munipack 1.2 / Application programming interface / API reference
C-Munipack 1.2 / Application programming interface / API reference
CmpackPhtMeasurement | Measurement stored in photometry file. |
CmpackPhtFile | Photometry file context. |
CmpackPhtAperture | Aperture definition in photometry file. |
CmpackPhtStar | Star definition in photometry file. |
cmpack_pht_init | Create new photometry file context. |
cmpack_pht_load | Load a photometry file. |
cmpack_pht_save | Save data from memory to a photometry file. |
cmpack_pht_copy | Copy a file. |
cmpack_pht_clear | Clear all data. |
cmpack_pht_test | Test if given file seems to be a photometry file. |
cmpack_pht_test_buffer | Test if the content of the buffer might be a photometry file. |
cmpack_pht_get_size | Get frame size in pixels. |
cmpack_pht_get_jd | Get julian date of observation. |
cmpack_pht_get_exptime | Get exposure duration. |
cmpack_pht_get_filter | Get optical filter name. |
cmpack_pht_get_offset | Get frame size in pixels. |
cmpack_pht_pkys | Set parameter value in file header (string). |
cmpack_pht_pkyi | Set parameter value in file header (integer). |
cmpack_pht_pkyd | Set parameter value in file header (double). |
cmpack_pht_gkys | Get value of parameter in file header (string). |
cmpack_pht_gkyi | Get value of parameter in file header (integer number). |
cmpack_pht_gkyd | Get value of parameter in file header (real number). |
cmpack_pht_gkyc | Get comment text of parameter in file header. |
cmpack_pht_nkey | Get number of parameters in header section. |
cmpack_pht_gkyn | Get the parameter from header section by its index. |
cmpack_pht_dkey | Delete parameter from header section. |
cmpack_pht_naper | Get number of apertures stored in a photometry file. |
cmpack_pht_get_aperture | Get aperture context by the index. |
cmpack_pht_find_aperture | Get aperture context by the identifier. |
cmpack_pht_add_aperture | Add new aperture to a file. |
cmpack_pht_aperture_new | Create a new aperture definition. |
cmpack_pht_aperture_get_id | Get identifier of an aperture. |
cmpack_pht_aperture_set_radius | Set aperture radius. |
cmpack_pht_aperture_get_radius | Get radius of an aperture. |
cmpack_pht_nstar | Get number of stars stored in a photometry file. |
cmpack_pht_add_star | Add new star to a file. |
cmpack_pht_get_star | Get star context by the index. |
cmpack_pht_find_star | Get star context by its identifier. |
cmpack_pht_find_star_by_refid | Get star context by its reference identifier. |
cmpack_pht_star_new | Create a new star context. |
cmpack_pht_star_get_id | Get position of a center of a star. |
cmpack_pht_star_set_center | Set position of a center of a star. |
cmpack_pht_star_get_center | Get position of a center of a star. |
cmpack_pht_star_set_refid | Set reference id of a star. |
cmpack_pht_star_get_refid | Get reference id of a star. |
cmpack_pht_star_clear_measurements | Clear all measurements for specified star. |
cmpack_pht_star_set_measurement | Set a measurement for specified star and aperture. |
cmpack_pht_star_get_measurement | Set a measurement for specified star and aperture. |
Photometry files contain photometry result for a single CCD frame. The file is valid standalone XML document. This format was introduced in the version 1.2
Photometry file context.
typedef struct _CmpackPhtFile CmpackPhtFile
This private structure holds the content of the read-all file.
Aperture definition in photometry file.
typedef struct _CmpackPhtAperture CmpackPhtAperture
This structure is used to access an aperture definitions in photometry files.
Star definition in photometry file.
typedef struct _CmpackPhtStar CmpackPhtStar
This structure is used to access a star definitions in photometry files.
Measurement stored in photometry file.
typedef struct _CmpackPhtMeasurement
{
int mask,
int code,
double magnitude,
double error
} CmpackPhtMeasurement;
mask | Bitmask of valid fields (combination of CMPACK_MASK_xxx values). |
code | Result of photometry. |
magnitude | Instrumental mahnitude. |
error | Error estimation of instrumental magnitude. |
Create new photometry file context.
CmpackPhtFile * cmpack_pht_init (void)
pointer to a new instance
Load a photometry file.
int cmpack_pht_load (CmpackPhtFile ** file, const char * filename, CmpackLoadMode flags)
file | [out] | new file context |
filename | [in] | path + file name |
flags | [in] | flags (see CMPACK_LOAD_xxx constants) |
zero on success, error code on failure
Save data from memory to a photometry file.
int cmpack_pht_save (CmpackPhtFile * file, const char * filename)
file | [in] | file context |
filename | [in] | path + file name |
zero on success, error code on failure
Copy a file.
void cmpack_pht_copy (CmpackPhtFile * dstfile, CmpackPhtFile * srcfile)
Makes a copy of source file to the destination file. All content of the destination file will be deleted.
dstfile | [in] | destination file context |
srcfile | [in] | source file context |
Clear all data.
void cmpack_pht_clear (CmpackPhtFile * file)
file | [in] | file context |
Test if given file seems to be a photometry file.
int cmpack_pht_test (const char * filename)
nonzero if the file is a photometry file, zero otherwise
Test if the content of the buffer might be a photometry file.
int cmpack_pht_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 photometry file. This function is used for file format autodetection.
nonzero if the file is a photometry file, zero otherwise
Get frame size in pixels.
int cmpack_pht_get_size (CmpackPhtFile * file, int * width, int * height)
file | [in] | file context |
width | [out] | frame width in pixels (0 = not available) |
height | [out] | frame height in pixels (0 = not available) |
nonzero on success, zero on failure
Get julian date of observation.
double cmpack_pht_get_jd (CmpackPhtFile * fc)
fc | [in] | file context |
Julian date or zero on failure
Get exposure duration.
double cmpack_pht_get_exptime (CmpackPhtFile * fc)
fc | [in] | file context |
Exposure duration in seconds or zero on failure
Get optical filter name.
const char * cmpack_pht_get_filter (CmpackPhtFile * fc)
The function returns pointer to the internal buffer. You must not free or modify it.
fc | [in] | file context |
Filter name, null terminated string
Get frame size in pixels.
int cmpack_pht_get_offset (CmpackPhtFile * file, double * offsetx, double * offsety)
file | [in] | file context |
offsetx | [out] | frame offset in x axis in pixels |
offsety | [out] | frame offset in y axis in pixels |
nonzero on success, zero on failure
Set parameter value in file header (string).
void cmpack_pht_pkys (CmpackPhtFile * file, const char * key, const char * val, const char * com)
If the parameter does not exist, it makes new entry in the file header. Otherwise, its content is changed. Keys are case sensitive.
file | [in] | file context |
key | [in] | parameter name |
val | [in] | parameter value |
com | [in] | comment text (can be NULL) |
Set parameter value in file header (integer).
void cmpack_pht_pkyi (CmpackPhtFile * file, const char * key, int val, const char * com)
If the parameter does not exist, it makes new entry in the file header. Otherwise, its content is changed. Keys are case sensitive.
file | [in] | file context |
key | [in] | parameter name |
val | [in] | parameter value |
com | [in] | comment text (can be NULL) |
Set parameter value in file header (double).
void cmpack_pht_pkyd (CmpackPhtFile * file, const char * key, double val, int prec, const char * com)
If the parameter does not exist, it makes new entry in the file header. Otherwise, its content is changed. Keys are case sensitive.
file | [in] | file context |
key | [in] | parameter name |
val | [in] | parameter value |
prec | [in] | number of decimal places |
com | [in] | comment text (can be NULL) |
Get value of parameter in file header (string).
const char * cmpack_pht_gkys (CmpackPhtFile * file, const char * key)
Keys are case sensitive. The function returns pointer to the internal buffer. You must not free or modify it.
file | [in] | file context |
key | [in] | parameter name |
parameter value, null terminated string
Get value of parameter in file header (integer number).
int cmpack_pht_gkyi (CmpackPhtFile * file, const char * key, int defval)
Keys are case sensitive. If the parameter is not defined, returns the default value.
file | [in] | file context |
key | [in] | parameter name |
defval | [in] | default value |
parameter value or default value if it is not defined
Get value of parameter in file header (real number).
double cmpack_pht_gkyd (CmpackPhtFile * file, const char * key, double defval)
Keys are case sensitive. If the parameter is not defined, returns the default value.
file | [in] | file context |
key | [in] | parameter name |
defval | [in] | default value |
parameter value or default value if it is not defined
Get comment text of parameter in file header.
const char * cmpack_pht_gkyc (CmpackPhtFile * file, const char * key)
Keys are case sensitive. The function returns pointer to the internal buffer. You must not free or modify it.
file | [in] | file context |
key | [in] | parameter name |
comment text, null terminated string
Get number of parameters in header section.
int cmpack_pht_nkey (CmpackPhtFile * file)
file | [in] | file context |
number of parameter or zero if the file is not a valid context or if the file header is empty.
Get the parameter from header section by its index.
int cmpack_pht_gkyn (CmpackPhtFile * file, int index, const char ** key, const char ** val, const char ** com)
Index of the first parameter is zero. The output parameters receive the pointers to internal memory buffers. You must not free or modify it!
file | [in] | file context |
index | [in] | parameter index (starting by zero) |
key | [out] | parameter name |
val | [out] | parameter value |
com | [out] | comment text |
nonzero on success, zero on failure
Delete parameter from header section.
void cmpack_pht_dkey (CmpackPhtFile * file, const char * key)
Keys are case sensitive.
file | [in] | file context |
key | [in] | parameter name |
Get number of apertures stored in a photometry file.
int cmpack_pht_naper (CmpackPhtFile * file)
file | [in] | file context |
number of apertures or negative value on failure
Get aperture context by the index.
CmpackPhtAperture * cmpack_pht_get_aperture (CmpackPhtFile * file, int index)
Index of the first aperture is zero. The function increments aperture's reference counter, the caller is responsible to call the cmpack_unref() function when the context is no longer needed.
file | [in] | file context |
index | [in] | aperture index (starting by 0) |
pointer to context or zero on failure.
Get aperture context by the identifier.
CmpackPhtAperture * cmpack_pht_find_aperture (CmpackPhtFile * file, int aperid)
The function increments aperture's reference counter, the caller is responsible to call the cmpack_unref() function when the context is no longer needed.
file | [in] | file context |
aperid | [in] | aperture identifider |
aperture index or negative value on failure
Add new aperture to a file.
void cmpack_pht_add_aperture (CmpackPhtFile * file, CmpackPhtAperture * aper)
The function steals the aperture's reference, so the caller dont need to decrement the aperture's reference counter.
file | [in] | file context |
aper | [in] | aperture context |
Create a new aperture definition.
CmpackPhtAperture * cmpack_pht_aperture_new (int id)
The function makes a new aperture definition and returns a new reference to it.
id | [in] | aperture identifider |
pointer to the new reference
Get identifier of an aperture.
int cmpack_pht_aperture_get_id (CmpackPhtAperture * aper)
aper | [in] | aperture context |
returns aperture id or zero on failure
Set aperture radius.
void cmpack_pht_aperture_set_radius (CmpackPhtAperture * aper, double radius)
aper | [in] | aperture context |
radius | [in] | radius in pixels |
zero on success, error code on failure
Get radius of an aperture.
double cmpack_pht_aperture_get_radius (CmpackPhtAperture * aper)
aper | [in] | aperture context |
aperture radius in pixels or zero on failure
Get number of stars stored in a photometry file.
int cmpack_pht_nstar (CmpackPhtFile * file)
file | [in] | file context |
zero on success, error code on failure
Add new star to a file.
void cmpack_pht_add_star (CmpackPhtFile * file, CmpackPhtStar * star)
The function steals the reference to the star.
file | [in] | file context |
star | [in] | star context |
Get star context by the index.
CmpackPhtStar * cmpack_pht_get_star (CmpackPhtFile * file, int index)
Index of the first star is zero. The function increments star's reference counter, the caller is responsible to call the cmpack_unref() function when the context is no longer needed.
file | [in] | file context |
index | [in] | star index (starting by 0) |
pointer to context or zero on failure.
Get star context by its identifier.
CmpackPhtStar * cmpack_pht_find_star (CmpackPhtFile * file, int starid)
The function increments star's reference counter, the caller is responsible to call the cmpack_unref() function when the context is no longer needed.
file | [in] | file context |
starid | [in] | star identifier |
pointer to context or zero on failure.
Get star context by its reference identifier.
CmpackPhtStar * cmpack_pht_find_star_by_refid (CmpackPhtFile * file, int refid)
The function increments star's reference counter, the caller is responsible to call the cmpack_unref() function when the context is no longer needed.
file | [in] | file context |
refid | [in] | reference identifier |
pointer to context or zero on failure.
Create a new star context.
CmpackPhtStar * cmpack_pht_star_new (int id)
id | [in] | star identifier |
Zero on success or error code on failure
Get position of a center of a star.
int cmpack_pht_star_get_id (CmpackPhtStar * star)
star | [in] | star context |
Star identifier or negative value on failure
Set position of a center of a star.
void cmpack_pht_star_set_center (CmpackPhtStar * star, double x, double y)
star | [in] | star context |
x | [in] | x position in pixels |
y | [in] | y position in pixels |
Get position of a center of a star.
int cmpack_pht_star_get_center (CmpackPhtStar * star, double * x, double * y)
star | [in] | star context |
x | [out] | x position in pixels |
y | [out] | y position in pixels |
nonzero on success or zero on failure
Set reference id of a star.
void cmpack_pht_star_set_refid (CmpackPhtStar * star, int refid)
star | [in] | star context |
refid | [in] | reference star identifier |
Get reference id of a star.
int cmpack_pht_star_get_refid (CmpackPhtStar * star)
star | [in] | star context |
Reference id or negative value on failure
Clear all measurements for specified star.
void cmpack_pht_star_clear_measurements (CmpackPhtStar * star)
star | [in] | star context |
Set a measurement for specified star and aperture.
void cmpack_pht_star_set_measurement (CmpackPhtStar * star, int aperture, const CmpackPhtMeasurement * data)
star | [in] | star context |
aperture | [in] | aperture identifier |
data | [in] | measurement data |
Set a measurement for specified star and aperture.
int cmpack_pht_star_get_measurement (CmpackPhtStar * star, int aperture, CmpackPhtMeasurement * data)
star | [in] | star context |
aperture | [in] | aperture identifier |
data | [out] | measurement data |
Zero on success or error code on failure