CR2RE Pipeline Reference Manual 1.6.7
Functions
General Utility Functions

Functions

const char * hdrl_get_license (void)
 Get the pipeline copyright and license.
 
cpl_table * hdrl_eop_data_totable (const char *eop_data, cpl_size data_length)
 Export a raw string buffer containing EOP data to a CPL table.
 
hdrl_parameter * hdrl_rect_region_parameter_create (cpl_size llx, cpl_size lly, cpl_size urx, cpl_size ury)
 Creates Rect Region Parameters object.
 
cpl_error_code hdrl_rect_region_parameter_update (hdrl_parameter *rect_region, cpl_size llx, cpl_size lly, cpl_size urx, cpl_size ury)
 Update Rect Region Parameters object.
 
cpl_boolean hdrl_rect_region_parameter_check (const hdrl_parameter *self)
 Check that the parameter is hdrl_rect_region parameter.
 
cpl_size hdrl_rect_region_get_llx (const hdrl_parameter *p)
 get lower left x coordinate of rectangual region
 
cpl_size hdrl_rect_region_get_lly (const hdrl_parameter *p)
 get lower left y coordinate of rectangual region
 
cpl_size hdrl_rect_region_get_urx (const hdrl_parameter *p)
 get upper right x coordinate of rectangular region
 
cpl_size hdrl_rect_region_get_ury (const hdrl_parameter *p)
 get upper right y coordinate of rectangual region
 
cpl_error_code hdrl_rect_region_parameter_verify (const hdrl_parameter *param, const cpl_size max_x, const cpl_size max_y)
 Verify basic correctness of the parameters.
 
cpl_parameterlist * hdrl_rect_region_parameter_create_parlist (const char *base_context, const char *prefix, const char *name_prefix, const hdrl_parameter *defaults)
 Create parameter list for hdrl_rect_region.
 
hdrl_parameter * hdrl_rect_region_parameter_parse_parlist (const cpl_parameterlist *parlist, const char *base_context, const char *name_prefix)
 parse parameterlist for rectangle parameters
 
cpl_error_code hdrl_rect_region_fix_negatives (hdrl_parameter *rect_region, const cpl_size nx, const cpl_size ny)
 wrap negative or zero coordinates around full image size
 
cpl_boolean hdrl_is_strictly_monotonic_increasing (const double *x, cpl_size l)
 returns CPL_TRUE if x is strictly monotonic increasing
 
void hdrl_sort_on_x (double *x, double *y1, double *y2, const cpl_size sample_len, const cpl_boolean sort_decreasing)
 sort in increasing or decreasing order x. Keep aligned with y1 and y2.
 
char * hdrl_join_string (const char *sep_, int n,...)
 join strings together
 
hdrl_value hdrl_utils_airmass (hdrl_value aRA, hdrl_value aDEC, hdrl_value aLST, hdrl_value aExptime, hdrl_value aLatitude, hdrl_airmass_approx type)
 Compute the effective airmass of an observation. Takes in count the error propagation if you enter the relative error of the input parameters in a hdrl_value structure {data,error}.
 

Detailed Description

This module contain various utilities functions that might be used in several of the HDRL modules.

Function Documentation

◆ hdrl_eop_data_totable()

cpl_table * hdrl_eop_data_totable ( const char *  eop_data,
cpl_size  data_length 
)

Export a raw string buffer containing EOP data to a CPL table.

Parameters
eop_dataThe string buffer with the data
data_lengthThe total size of the data buffer
Returns
A string buffer with the full contents of the data

This function convert the ascii file retrieve from the internet and convert it to a CPL table.

Possible cpl-error-code set in this function:

  • CPL_ERROR_NULL_INPUT if eop_data is NULL
  • CPL_ERROR_NULL_INPUT if data_length doesn't correspond with the expected EOP records length

Definition at line 112 of file hdrl_utils.c.

◆ hdrl_get_license()

const char * hdrl_get_license ( void  )

Get the pipeline copyright and license.

Returns
The copyright and license string

The function returns a pointer to the statically allocated license string. This string should not be modified using the returned pointer.

Definition at line 68 of file hdrl_utils.c.

◆ hdrl_is_strictly_monotonic_increasing()

cpl_boolean hdrl_is_strictly_monotonic_increasing ( const double *  x,
cpl_size  l 
)

returns CPL_TRUE if x is strictly monotonic increasing

Parameters
xarray to check for being strictly monotonic increasing
llength of the array
Returns
CPL_TRUE if x is strictly monotonic increasing, CPL_FALSE otherwise

Definition at line 745 of file hdrl_utils.c.

◆ hdrl_join_string()

char * hdrl_join_string ( const char *  sep_,
int  n,
  ... 
)

◆ hdrl_rect_region_fix_negatives()

cpl_error_code hdrl_rect_region_fix_negatives ( hdrl_parameter *  rect_region,
const cpl_size  nx,
const cpl_size  ny 
)

wrap negative or zero coordinates around full image size

Parameters
rect_regionrect region to wrap
nximage size in x, nx is added to entries < 1
nyimage size in y, ny is added to entries < 1
Returns
cpl_error_code

allows reverse indexing: 0 would be nx, -2 would be nx - 2 etc Wrapping is based in FITS convention: 1 first pixel, nx last pixel inclusive

Definition at line 715 of file hdrl_utils.c.

References hdrl_rect_region_parameter_check(), and hdrl_rect_region_parameter_verify().

◆ hdrl_rect_region_parameter_check()

cpl_boolean hdrl_rect_region_parameter_check ( const hdrl_parameter *  self)

Check that the parameter is hdrl_rect_region parameter.

Returns
the parameter to check

Definition at line 506 of file hdrl_utils.c.

Referenced by hdrl_overscan_parameter_create_parlist(), hdrl_rect_region_fix_negatives(), hdrl_rect_region_parameter_create_parlist(), and hdrl_rect_region_parameter_verify().

◆ hdrl_rect_region_parameter_create()

hdrl_parameter * hdrl_rect_region_parameter_create ( cpl_size  llx,
cpl_size  lly,
cpl_size  urx,
cpl_size  ury 
)

Creates Rect Region Parameters object.

Parameters
llx
lly
urx
ury
Returns
the Rect Region parameters

Definition at line 459 of file hdrl_utils.c.

Referenced by hdrl_rect_region_parameter_parse_parlist().

◆ hdrl_rect_region_parameter_create_parlist()

cpl_parameterlist * hdrl_rect_region_parameter_create_parlist ( const char *  base_context,
const char *  prefix,
const char *  name_prefix,
const hdrl_parameter *  defaults 
)

Create parameter list for hdrl_rect_region.

Parameters
base_contextbase context of parameter (e.g. recipe name)
prefixprefix of parameter, may be empty string
name_prefixprefix for the parameter names, may be empty string
defaultsdefault parameters values
Returns
cpl_parameterlist Creates a parameterlist containing base_context.prefix.name-prefixllx base_context.prefix.name-prefixlly base_context.prefix.name-prefixurx base_context.prefix.name-prefixury The CLI aliases omit the base_context.

Definition at line 615 of file hdrl_utils.c.

References hdrl_rect_region_get_llx(), hdrl_rect_region_get_lly(), hdrl_rect_region_get_urx(), hdrl_rect_region_get_ury(), and hdrl_rect_region_parameter_check().

Referenced by hdrl_overscan_parameter_create_parlist().

◆ hdrl_rect_region_parameter_parse_parlist()

hdrl_parameter * hdrl_rect_region_parameter_parse_parlist ( const cpl_parameterlist *  parlist,
const char *  base_context,
const char *  name_prefix 
)

parse parameterlist for rectangle parameters

Parameters
parlistparameter list to parse
base_contextprefix of parameter
name_prefixprefix of parameter name, may be empty string
See also
hdrl_rect_get_parlist()
Returns
A newly allocated hdrl_rect_region parameter or NULL in error case

The returned object must be deallocated with hdrl_parameter_delete() parameterlist should have been created with hdrl_rect_get_parlist or have the same name hierachy

Definition at line 674 of file hdrl_utils.c.

References hdrl_rect_region_parameter_create().

Referenced by hdrl_overscan_parameter_parse_parlist().

◆ hdrl_rect_region_parameter_update()

cpl_error_code hdrl_rect_region_parameter_update ( hdrl_parameter *  rect_region,
cpl_size  llx,
cpl_size  lly,
cpl_size  urx,
cpl_size  ury 
)

Update Rect Region Parameters object.

Parameters
rect_regionThe region to update
llx
lly
urx
ury
Returns
the error code in case of error or CPL_ERROR_NONE

Definition at line 485 of file hdrl_utils.c.

References hdrl_rect_region_parameter_verify().

◆ hdrl_rect_region_parameter_verify()

cpl_error_code hdrl_rect_region_parameter_verify ( const hdrl_parameter *  param,
const cpl_size  max_x,
const cpl_size  max_y 
)

Verify basic correctness of the parameters.

Parameters
paramrect region parameters
max_xmax value for upper x bound, set to < 0 to skip check
max_ymax value for upper y bound, set to < 0 to skip check
Returns
CPL_ERROR_NONE if everything is ok, an error code otherwise

Definition at line 560 of file hdrl_utils.c.

References hdrl_rect_region_parameter_check().

Referenced by hdrl_overscan_correct(), hdrl_overscan_parameter_verify(), hdrl_rect_region_fix_negatives(), and hdrl_rect_region_parameter_update().

◆ hdrl_sort_on_x()

void hdrl_sort_on_x ( double *  x,
double *  y1,
double *  y2,
const cpl_size  sample_len,
const cpl_boolean  sort_decreasing 
)

sort in increasing or decreasing order x. Keep aligned with y1 and y2.

Parameters
xx array
y1y1 array
y2y2 array
sample_lenlength of the arrays
sort_decreasingif CPL_TRUE sort as decreasing, otherwise increasing
Returns
nothing

Definition at line 767 of file hdrl_utils.c.

◆ hdrl_utils_airmass()

hdrl_value hdrl_utils_airmass ( hdrl_value  aRA,
hdrl_value  aDEC,
hdrl_value  aLST,
hdrl_value  aExptime,
hdrl_value  aLatitude,
hdrl_airmass_approx  type 
)

Compute the effective airmass of an observation. Takes in count the error propagation if you enter the relative error of the input parameters in a hdrl_value structure {data,error}.

The function calculates the average airmass for the line of sight given by the right ascension (ra) and the declination (dec). The latitude (geolat) in degrees of the observatory site and the local siderial time (lst) at observation start has to be given, as well as the duration of the observation, i.e. the exposure time (exptime). If the exposure time is zero then only one value of airmass is computed, instead of weighting beginning, middle, and end of exposure according to Stetson (Stetson P., 1987, PASP 99, 191).

Parameters
aRAright ascension in degrees
aDECdeclination in degrees
aLSTlocal sideral time (s.) elapsed since siderial midnight
aExptimeintegration time in seconds
aLatitudelatitude of the observatory site in degrees
typekind of approximation (see hdrl_airmass_approx enumtype)
Returns
The computed average airmass or {-1,0.} on error.
Note
This function can be calcule different kinds of approximation specified in the hdrl_airmass_approx enum type, explain as follow. 1) The formula given by Hardie (Hardie 1962, In: "Astronomical Techniques", ed. Hiltner, p. 184) to compute the airmass as a function of zenith distance. 2) The formula of Young and Irvine (Young A. T., Irvine W. M., 1967, Astron. J. 72, 945). The range of trustworthy airmass outputs is only between 1 and 4. 3) The formula of Young (Young A. T., 1994 ApOpt, 33, 1108).
You can to find in Interpolative formulas an interesting collection of approximations.

Definition at line 2069 of file hdrl_utils.c.