Datasets can contain values in various formats or units.
The functions in this section are defined to facilitate the easy conversion between them and are declared in `units.h`.
If there are certain conversions that are useful for your work, please get in touch.

- Function:

`int`

**gal_units_extract_decimal**`(char`

¶`*convert`

, const char`*delimiter`

, double`*args`

, size_t`n`

) Parse the input

`convert`

string with a certain delimiter (for example,`01:23:45`

, where the delimiter is`":"`

) as multiple numbers (for example, 1,23,45) and write them as an array in the space that`args`

is pointing to. The expected number of values in the string is specified by the`n`

argument (3 in the example above).If the function succeeds, it will return 1, otherwise it will return 0 and the values may not be fully written into

`args`

. If the number of values parsed in the string is different from`n`

, this function will fail.

- Function:

`double`

**gal_units_ra_to_degree**`(char`

¶`*convert`

) -
Convert the input Right Ascension (RA) string (in the format of hours, minutes and seconds either as

`_h_m_s`

or`_:_:_`

) to degrees (a single floating point number).

- Function:

`double`

**gal_units_dec_to_degree**`(char`

¶`*convert`

) -
Convert the input Declination (Dec) string (in the format of degrees, arc-minutes and arc-seconds either as

`_d_m_s`

or`_:_:_`

) to degrees (a single floating point number).

- Function:

`char *`

**gal_units_degree_to_ra**`(double`

¶`decimal`

, int`usecolon`

) -
Convert the input Right Ascension (RA) degree (a single floating point number) to old/standard notation (in the format of hours, minutes and seconds of

`_h_m_s`

). If`usecolon!=0`

, then the delimiters between the components will be colons:`_:_:_`

.

- Function:

`char *`

**gal_units_degree_to_dec**`(double`

¶`decimal`

, int`usecolon`

) -
Convert the input Declination (Dec) degree (a single floating point number) to old/standard notation (in the format of degrees, arc-minutes and arc-seconds of

`_d_m_s`

). If`usecolon!=0`

, then the delimiters between the components will be colons:`_:_:_`

.

- Function:

`double`

**gal_units_counts_to_mag**`(double`

¶`counts`

, double`zeropoint`

) -
Convert counts to magnitudes through the given zero point. For more on the equation, see Brightness, Flux, Magnitude and Surface brightness.

- Function:

`double`

**gal_units_mag_to_counts**`(double`

¶`mag`

, double`zeropoint`

) -
Convert magnitudes to counts through the given zero point. For more on the equation, see Brightness, Flux, Magnitude and Surface brightness.

- Function:

`double`

**gal_units_mag_to_sb**`(double`

¶`mag`

, double`area_arcsec2`

) -
Calculate the surface brightness of a given magnitude, over a certain area in units of arcsec\(^2\). For more on the equation, see Brightness, Flux, Magnitude and Surface brightness.

- Function:

`double`

**gal_units_sb_to_mag**`(double`

¶`sb`

, double`area_arcsec2`

) Calculate the magnitude of a given surface brightness, over a certain area in units of arcsec\(^2\). For more on the equation, see Brightness, Flux, Magnitude and Surface brightness.

- Function:

`double`

**gal_units_counts_to_sb**`(double`

¶`counts`

, double`zeropoint_ab`

, double`area_arcsec2`

) Calculate the surface brightness of a given count level, over a certain area in units of arcsec\(^2\), assuming a certain AB zero point. For more on the equation, see Brightness, Flux, Magnitude and Surface brightness.

- Function:

`double`

**gal_units_sb_to_counts**`(double`

¶`sb`

, double`zeropoint_ab`

, double`area_arcsec2`

) Calculate the counts corresponding to a given surface brightness, over a certain area in units of arcsec\(^2\). For more on the equation, see Brightness, Flux, Magnitude and Surface brightness.

- Function:

`double`

**gal_units_counts_to_jy**`(double`

¶`counts`

, double`zeropoint_ab`

) -
Convert counts to Janskys through an AB magnitude-based zero point. For more on the equation, see Brightness, Flux, Magnitude and Surface brightness.

- Function:

`double`

**gal_units_au_to_pc**`(double`

¶`au`

) -
Convert the input value (assumed to be in Astronomical Units) to Parsecs. For the conversion equation, see the description of

`au-to-pc`

operator in Arithmetic operators.

- Function:

`double`

**gal_units_counts_to_nanomaggy**`(double`

¶`counts`

, double`zeropoint_ab`

) -
Convert counts to Nanomaggy (with fixed zero point of 22.5) through an AB magnitude-based zero point.

- Function:

`double`

**gal_units_nanomaggy_to_counts**`(double`

¶`counts`

, double`zeropoint_ab`

) Convert Nanomaggy (with fixed zero point of 22.5) to counts through an AB magnitude-based zero point.

- Function:

`double`

**gal_units_pc_to_au**`(double`

¶`pc`

) Convert the input value (assumed to be in Parsecs) to Astronomical Units (AUs). For the conversion equation, see the description of

`au-to-pc`

operator in Arithmetic operators.

- Function:

`double`

**gal_units_ly_to_pc**`(double`

¶`ly`

) -
Convert the input value (assumed to be in Light-years) to Parsecs. For the conversion equation, see the description of

`ly-to-pc`

operator in Arithmetic operators.

- Function:

`double`

**gal_units_pc_to_ly**`(double`

¶`pc`

) Convert the input value (assumed to be in Parsecs) to Light-years. For the conversion equation, see the description of

`ly-to-pc`

operator in Arithmetic operators.

- Function:

`double`

**gal_units_ly_to_au**`(double`

¶`ly`

) Convert the input value (assumed to be in Light-years) to Astronomical Units. For the conversion equation, see the description of

`ly-to-pc`

operator in Arithmetic operators.

- Function:

`double`

**gal_units_au_to_ly**`(double`

¶`au`

) Convert the input value (assumed to be in Astronomical Units) to Light-years. For the conversion equation, see the description of

`ly-to-pc`

operator in Arithmetic operators.

JavaScript license information

GNU Astronomy Utilities 0.22 manual, February 2024.