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
34
35DAS_API extern const char* UNIT_US2000;
36DAS_API extern const char* UNIT_MJ1958;
37DAS_API extern const char* UNIT_T2000;
38DAS_API extern const char* UNIT_T1970;
39DAS_API extern const char* UNIT_NS1970;
40DAS_API extern const char* UNIT_UTC;
46DAS_API extern const char* UNIT_TT2000;
47
51DAS_API extern const char* UNIT_ET2000;
52
53/* Other common units */
54DAS_API extern const char* UNIT_SECONDS;
55DAS_API extern const char* UNIT_HOURS;
56DAS_API extern const char* UNIT_DAYS;
57DAS_API extern const char* UNIT_MILLISECONDS;
58DAS_API extern const char* UNIT_MICROSECONDS;
59DAS_API extern const char* UNIT_NANOSECONDS;
61DAS_API extern const char* UNIT_HERTZ;
62DAS_API extern const char* UNIT_KILO_HERTZ;
63DAS_API extern const char* UNIT_MEGA_HERTZ;
64DAS_API extern const char* UNIT_GIGA_HERTZ;
65DAS_API extern const char* UNIT_E_SPECDENS;
66DAS_API extern const char* UNIT_B_SPECDENS;
67DAS_API extern const char* UNIT_NT;
69DAS_API extern const char* UNIT_NUMBER_DENS;
71DAS_API extern const char* UNIT_DB;
73DAS_API extern const char* UNIT_KM;
75DAS_API extern const char* UNIT_EV;
77DAS_API extern const char* UNIT_DEGREES;
78DAS_API extern const char* UNIT_DIMENSIONLESS;
80/* color: Color should be handled as as vector, we don't have
81 * support for vectors at this time. Also a datatype of
82 * byte is needed for small values
83 */
84/* extern const char* UNIT_RGB; */
85
86
87
141typedef const char* das_units;
142
155DAS_API das_units Units_fromStr(const char* string);
156
157
164DAS_API const char* Units_toStr(das_units unit);
165
166
189DAS_API char* Units_toLabel(das_units unit, char* sBuf, size_t uLen);
190
191
217
218
234
248
249
264DAS_API das_units Units_power(das_units unit, int power);
265
266
279DAS_API das_units Units_root(das_units unit, int root );
280
281
297
298
319DAS_API das_units Units_reduce(das_units orig, double* pFactor);
320
331DAS_API bool Units_canConvert(das_units fromUnits , das_units toUnits);
332
333
346DAS_API double Units_convertTo( das_units toUnits, double rVal, das_units fromUnits );
347
348
365DAS_API bool Units_haveCalRep(das_units unit);
366
367
378DAS_API DasErrCode Units_convertToDt(das_time* pDt, double value, das_units epoch_units);
379
387DAS_API double Units_convertFromDt(das_units epoch_units, const das_time* pDt);
388
394DAS_API double Units_secondsSinceMidnight( double rVal, das_units epoch_units );
395
396
397/* Get the Julian day for the Datum (double,unit) */
398DAS_API int Units_getJulianDay( double timeDouble, das_units epoch_units );
399
407DAS_API bool Units_canMerge(das_units left, int op, das_units right);
408
409#ifdef __cplusplus
410}
411#endif
412
413#endif /* _das_units_h_ */
int DasErrCode
return code type 0 indicates success, negative integer indicates failure
Definition defs.h:189
const char * das_units
Handle SI and other units, with accommodations for Epoch systems, from units.h.
Definition units.h:141
Basic date-time structure used throughout the Das1 & Das2 utilities.
Definition time.h:43
Das Time Utilities.
DAS_API double Units_convertTo(das_units toUnits, double rVal, das_units fromUnits)
Generic unit conversion utility.
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.
DAS_API const char * UNIT_EV
SI kilometers.
DAS_API const char * UNIT_MEGA_HERTZ
Units of 1/milliseconds.
DAS_API const char * UNIT_GIGA_HERTZ
Units of 1/microseconds.
DAS_API const char * UNIT_DIMENSIONLESS
degrees, 360 of them in a circle
DAS_API const char * UNIT_NANOSECONDS
Units of SI microseconds.
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.
DAS_API const char * UNIT_NT
nanoTesla squared per hertz
DAS_API das_units Units_root(das_units unit, int root)
Reduce units to a root.
DAS_API const char * UNIT_DAYS
Units of 3600 seconds.
DAS_API const char * UNIT_T2000
Units of days since midnight, Jan 1, 1958.
DAS_API const char * UNIT_KILO_HERTZ
Units of 1/seconds.
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.
DAS_API const char * UNIT_B_SPECDENS
Volts squared per meter squared per hertz.
DAS_API char * Units_toLabel(das_units unit, char *sBuf, size_t uLen)
Get label string representation das_units.
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.
DAS_API const char * UNIT_MJ1958
Units of microseconds since midnight, Jan 1, 2000.
DAS_API das_units Units_power(das_units unit, int power)
Raise units to a power.
DAS_API const char * UNIT_TT2000
Time strings on the Gregorian Calendar.
DAS_API const char * UNIT_T1970
Units of seconds since midnight, Jan 1, 2000.
DAS_API const char * UNIT_KM
decibels (a ratio unit)
DAS_API const char * UNIT_MILLISECONDS
Units of 86400 seconds.
DAS_API const char * UNIT_E_SPECDENS
Units of 1/nanoseconds.
DAS_API const char * UNIT_NUMBER_DENS
SI nanoTesla.
DAS_API const char * UNIT_DB
Number of items per centimeter cubed.
DAS_API const char * UNIT_NS1970
Units of seconds since midnight, Jan 1, 1970.
DAS_API const char * UNIT_HERTZ
Units of SI nanoseconds.
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 const char * UNIT_ET2000
SPICE ephem time, constant seconds for Solar Sys Center in J2000 epoch This is the same UTC epoch as ...
DAS_API const char * UNIT_UTC
Units of nanoseconds since midnight, Jan 1, 1970.
DAS_API const char * UNIT_DEGREES
electron volts
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.
DAS_API const char * UNIT_HOURS
Units of SI Seconds.
DAS_API double Units_secondsSinceMidnight(double rVal, das_units epoch_units)
Get seconds since midnight for some value of an epoch time unit.
DAS_API const char * UNIT_MICROSECONDS
Units of SI milliseconds.