das2C
das core C utilities (v3)
Loading...
Searching...
No Matches
units.h
Go to the documentation of this file.
1/* Copyright (C) 2004-2017 Chris Piker <chris-piker@uiowa.edu>
2 * Jeremy Faden <jeremy-faden@uiowa.edu>
3 *
4 * This file is part of das2C, the Core Das2 C Library.
5 *
6 * Das2C is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Lesser General Public License version 2.1 as published
8 * by the Free Software Foundation.
9 *
10 * Das2C is distributed in the hope that it will be useful, but WITHOUT ANY
11 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * version 2.1 along with das2C; if not, see <http://www.gnu.org/licenses/>.
17 */
18
19
24#ifndef _das_units_h_
25#define _das_units_h_
26
27#include <stdbool.h>
28#include <das3/time.h>
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34bool units_init(const char* sProgName);
35
36#ifndef _das_units_c_
37
38extern const char* UNIT_US2000;
39extern const char* UNIT_MJ1958;
40extern const char* UNIT_T2000;
41extern const char* UNIT_T1970;
42extern const char* UNIT_NS1970;
43extern const char* UNIT_UTC;
49extern const char* UNIT_TT2000;
50
54extern const char* UNIT_ET2000;
55
56/* Other common units */
57extern const char* UNIT_SECONDS;
58extern const char* UNIT_HOURS;
59extern const char* UNIT_DAYS;
60extern const char* UNIT_MILLISECONDS;
61extern const char* UNIT_MICROSECONDS;
62extern const char* UNIT_NANOSECONDS;
64extern const char* UNIT_HERTZ;
65extern const char* UNIT_KILO_HERTZ;
66extern const char* UNIT_MEGA_HERTZ;
67extern const char* UNIT_E_SPECDENS;
68extern const char* UNIT_B_SPECDENS;
69extern const char* UNIT_NT;
71extern const char* UNIT_NUMBER_DENS;
73extern const char* UNIT_DB;
75extern const char* UNIT_KM;
77extern const char* UNIT_EV;
79extern const char* UNIT_DEGREES;
80extern const char* UNIT_DIMENSIONLESS;
82/* color: Color should be handled as as vector, we don't have
83 * support for vectors at this time. Also a datatype of
84 * byte is needed for small values
85 */
86/* extern const char* UNIT_RGB; */
87
88
89#endif
90
144typedef const char* das_units;
145
158DAS_API das_units Units_fromStr(const char* string);
159
160
167DAS_API const char* Units_toStr(das_units unit);
168
169
191DAS_API char* Units_toLabel(das_units unit, char* sBuf, int nLen);
192
193
219
220
236
250
251
266DAS_API das_units Units_power(das_units unit, int power);
267
268
281DAS_API das_units Units_root(das_units unit, int root );
282
283
299
300
321DAS_API das_units Units_reduce(das_units orig, double* pFactor);
322
333DAS_API bool Units_canConvert(das_units fromUnits , das_units toUnits);
334
335
348DAS_API double Units_convertTo( das_units toUnits, double rVal, das_units fromUnits );
349
350
367DAS_API bool Units_haveCalRep(das_units unit);
368
369
380DAS_API DasErrCode Units_convertToDt(das_time* pDt, double value, das_units epoch_units);
381
389DAS_API double Units_convertFromDt(das_units epoch_units, const das_time* pDt);
390
396DAS_API double Units_secondsSinceMidnight( double rVal, das_units epoch_units );
397
398
399/* Get the Julian day for the Datum (double,unit) */
400DAS_API int Units_getJulianDay( double timeDouble, das_units epoch_units );
401
409DAS_API bool Units_canMerge(das_units left, int op, das_units right);
410
411#ifdef __cplusplus
412}
413#endif
414
415#endif /* _das_units_h_ */
int DasErrCode
return code type 0 indicates success, negative integer indicates failure
Definition defs.h:184
const char * das_units
Handle SI and other units, with accommodations for Epoch systems, from units.h.
Definition units.h:144
Basic date-time structure used throughout the Das1 & Das2 utilities.
Definition time.h:43
Das Time Utilities.
const char * UNIT_E_SPECDENS
Units of 1/microseconds.
const char * UNIT_DEGREES
electron volts
DAS_API double Units_convertTo(das_units toUnits, double rVal, das_units fromUnits)
Generic unit conversion utility.
const char * UNIT_DIMENSIONLESS
degrees, 360 of them in a circle
const char * UNIT_MEGA_HERTZ
Units of 1/milliseconds.
DAS_API das_units Units_invert(das_units unit)
Invert the units, most commonly used for Fourier transform results.
DAS_API das_units Units_reduce(das_units orig, double *pFactor)
Reduce arbitrary units to the most basic know representation.
const char * UNIT_T1970
Units of seconds since midnight, Jan 1, 2000.
const char * UNIT_NT
nanoTesla squared per hertz
DAS_API double Units_convertFromDt(das_units epoch_units, const das_time *pDt)
Convert a calendar representation of a time to value in time offset units.
const char * UNIT_TT2000
Time strings on the Gregorian Calendar.
DAS_API das_units Units_root(das_units unit, int root)
Reduce units to a root.
DAS_API bool Units_canConvert(das_units fromUnits, das_units toUnits)
Determine if given units are interchangeable Though not as good a solution as using UDUNITS2 works fo...
DAS_API das_units Units_divide(das_units a, das_units b)
Combine units via division.
DAS_API bool Units_haveCalRep(das_units unit)
Determine if the units in question can be converted to date-times.
const char * UNIT_KM
decibels (a ratio unit)
const char * UNIT_NANOSECONDS
Units of SI microseconds.
const char * UNIT_B_SPECDENS
Volts squared per meter squared per hertz.
const char * UNIT_HOURS
Units of SI Seconds.
DAS_API bool Units_canMerge(das_units left, int op, das_units right)
Determine if the units of values in a binary expression are compatible.
const char * UNIT_MJ1958
Units of microseconds since midnight, Jan 1, 2000.
const char * UNIT_KILO_HERTZ
Units of 1/seconds.
const char * UNIT_UTC
Units of nanoseconds since midnight, Jan 1, 1970.
DAS_API das_units Units_power(das_units unit, int power)
Raise units to a power.
const char * UNIT_MILLISECONDS
Units of 86400 seconds.
const char * UNIT_T2000
Units of days since midnight, Jan 1, 1958.
const char * UNIT_NS1970
Units of seconds since midnight, Jan 1, 1970.
const char * UNIT_NUMBER_DENS
SI nanoTesla.
const char * UNIT_MICROSECONDS
Units of SI milliseconds.
DAS_API das_units Units_interval(das_units unit)
Get the unit type for intervals between data points of a given unit type.
DAS_API das_units Units_multiply(das_units ut1, das_units ut2)
Combine units via multiplication.
DAS_API DasErrCode Units_convertToDt(das_time *pDt, double value, das_units epoch_units)
Convert a value in time offset units to a calendar representation.
const char * UNIT_ET2000
SPICE ephem time, constant seconds for Solar Sys Center in J2000 epoch This is the same UTC epoch as ...
const char * UNIT_DB
Number of items per centimeter cubed.
const char * UNIT_DAYS
Units of 3600 seconds.
const char * UNIT_EV
SI kilometers.
DAS_API char * Units_toLabel(das_units unit, char *sBuf, int nLen)
Get label string representation das_units.
DAS_API double Units_secondsSinceMidnight(double rVal, das_units epoch_units)
Get seconds since midnight for some value of an epoch time unit.
const char * UNIT_HERTZ
Units of SI nanoseconds.