00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include "drms.h"
00035 #include "math.h"
00036
00037 extern ModuleArgs_t *gModArgs;
00038 extern CmdParams_t cmdparams;
00039
00040 int check_and_set_key_short (DRMS_Record_t *new, const char *key, short val) {
00041 DRMS_Keyword_t *keywd;
00042 short vreq;
00043 int status;
00044
00045 if (!(keywd = drms_keyword_lookup (new, key, 1))) return 0;
00046 if (keywd->info->recscope != 1) {
00047
00048 drms_setkey_short (new, key, val);
00049 return 0;
00050 }
00051 vreq = drms_getkey_short (new, key, &status);
00052 if (status) {
00053 fprintf (stderr, "Error retrieving value for constant keyword %s\n", key);
00054 return 1;
00055 }
00056 if (vreq != val) {
00057 char format[256];
00058 sprintf (format,
00059 "Error: parameter value %s for keyword %%s\n differs from required value %s\n",
00060 keywd->info->format, keywd->info->format);
00061 fprintf (stderr, format, val, key, vreq);
00062 return 1;
00063 }
00064 return 0;
00065 }
00066
00067 int check_and_set_key_int (DRMS_Record_t *new, const char *key, int val) {
00068 DRMS_Keyword_t *keywd;
00069 int vreq;
00070 int status;
00071
00072 if (!(keywd = drms_keyword_lookup (new, key, 1))) return 0;
00073 if (keywd->info->recscope != 1) {
00074
00075 drms_setkey_int (new, key, val);
00076 return 0;
00077 }
00078 vreq = drms_getkey_int (new, key, &status);
00079 if (status) {
00080 fprintf (stderr, "Error retrieving value for constant keyword %s\n", key);
00081 return 1;
00082 }
00083 if (vreq != val) {
00084 char format[256];
00085 sprintf (format,
00086 "Error: parameter value %s for keyword %%s\n differs from required value %s\n",
00087 keywd->info->format, keywd->info->format);
00088 fprintf (stderr, format, val, key, vreq);
00089 return 1;
00090 }
00091 return 0;
00092 }
00093
00094 int check_and_set_key_longlong (DRMS_Record_t *new, const char *key,
00095 long long val) {
00096 DRMS_Keyword_t *keywd;
00097 long long vreq;
00098 int status;
00099
00100 if (!(keywd = drms_keyword_lookup (new, key, 1))) return 0;
00101 if (keywd->info->recscope != 1) {
00102
00103 drms_setkey_longlong (new, key, val);
00104 return 0;
00105 }
00106 vreq = drms_getkey_longlong (new, key, &status);
00107 if (status) {
00108 fprintf (stderr, "Error retrieving value for constant keyword %s\n", key);
00109 return 1;
00110 }
00111 if (vreq != val) {
00112 char format[256];
00113 sprintf (format,
00114 "Error: parameter value %s for keyword %%s\n differs from required value %s\n",
00115 keywd->info->format, keywd->info->format);
00116 fprintf (stderr, format, val, key, vreq);
00117 return 1;
00118 }
00119 return 0;
00120 }
00121
00122 int check_and_set_key_float (DRMS_Record_t *new, const char *key, float val) {
00123 DRMS_Keyword_t *keywd;
00124 float vreq;
00125 int status;
00126 char sreq[128], sval[128];
00127
00128 if (!(keywd = drms_keyword_lookup (new, key, 1))) return 0;
00129 if (keywd->info->recscope != 1) {
00130
00131 drms_setkey_float (new, key, val);
00132 return 0;
00133 }
00134 vreq = drms_getkey_float (new, key, &status);
00135 if (status) {
00136 fprintf (stderr, "Error retrieving value for constant keyword %s\n", key);
00137 return 1;
00138 }
00139 sprintf (sreq, keywd->info->format, vreq);
00140 sprintf (sval, keywd->info->format, val);
00141 if (strcmp (sreq, sval)) {
00142 char format[256];
00143 sprintf (format,
00144 "Error: parameter value %s for keyword %%s\n differs from required value %s\n",
00145 keywd->info->format, keywd->info->format);
00146 fprintf (stderr, format, val, key, vreq);
00147 return 1;
00148 }
00149 return 0;
00150 }
00151
00152 int check_and_set_key_double (DRMS_Record_t *new, const char *key, double val) {
00153 DRMS_Keyword_t *keywd;
00154 double vreq;
00155 int status;
00156 char sreq[128], sval[128];
00157
00158 if (!(keywd = drms_keyword_lookup (new, key, 1))) return 0;
00159 if (keywd->info->recscope != 1) {
00160
00161 drms_setkey_double (new, key, val);
00162 return 0;
00163 }
00164 vreq = drms_getkey_double (new, key, &status);
00165 if (status) {
00166 fprintf (stderr, "Error retrieving value for constant keyword %s\n", key);
00167 return 1;
00168 }
00169 sprintf (sreq, keywd->info->format, vreq);
00170 sprintf (sval, keywd->info->format, val);
00171 if (strcmp (sreq, sval)) {
00172 char format[256];
00173 sprintf (format,
00174 "Error: parameter value %s for keyword %%s\n differs from required value %s\n",
00175 keywd->info->format, keywd->info->format);
00176 fprintf (stderr, format, val, key, vreq);
00177 return 1;
00178 }
00179 return 0;
00180 }
00181
00182 int check_and_set_key_str (DRMS_Record_t *new, const char *key, char *val) {
00183 DRMS_Keyword_t *keywd;
00184 char *vreq;
00185 int status;
00186
00187 if (!(keywd = drms_keyword_lookup (new, key, 1))) return 0;
00188 if (keywd->info->recscope != 1) {
00189
00190 drms_setkey_string (new, key, val);
00191 return 0;
00192 }
00193 vreq = drms_getkey_string (new, key, &status);
00194 if (status) {
00195 fprintf (stderr, "Error retrieving value for constant keyword %s\n", key);
00196 return 1;
00197 }
00198 if (strcmp (vreq, val)) {
00199 char format[256];
00200 sprintf (format,
00201 "Error: parameter value \"%s\" for keyword %%s\n differs from required value \"%s\"\n",
00202 keywd->info->format, keywd->info->format);
00203 fprintf (stderr, format, val, key, vreq);
00204 return 1;
00205 }
00206 return 0;
00207 }
00208
00209 int check_and_set_key_time (DRMS_Record_t *new, const char *key, TIME tval) {
00210 DRMS_Keyword_t *keywd;
00211 TIME treq;
00212 int status;
00213 char sreq[64], sval[64];
00214
00215 if (!(keywd = drms_keyword_lookup (new, key, 1))) return 0;
00216 if (keywd->info->recscope != 1) {
00217
00218 drms_setkey_time (new, key, tval);
00219 return 0;
00220 }
00221 treq = drms_getkey_time (new, key, &status);
00222 if (status) {
00223 fprintf (stderr, "Error retrieving value for constant keyword %s\n", key);
00224 return 1;
00225 }
00226 sprint_time (sreq, treq, keywd->info->unit, atoi (keywd->info->format));
00227 sprint_time (sval, tval, keywd->info->unit, atoi (keywd->info->format));
00228 if (strcmp (sval, sreq)) {
00229 fprintf (stderr, "Error: parameter value %s for keyword %s\n", sval, key);
00230 fprintf (stderr, " differs from required value %s\n", sreq);
00231 return 1;
00232 }
00233 return 0;
00234 }
00235
00236 int check_and_copy_key (DRMS_Record_t *new, DRMS_Record_t *old,
00237 const char *key) {
00238 DRMS_Keyword_t *oldkey, *newkey, *pkey;
00239 DRMS_Type_t *type;
00240 DRMS_Type_Value_t *value;
00241 int n, status;
00242
00243 if (!(oldkey = drms_keyword_lookup (old, key, 1))) return 0;
00244 if (newkey = drms_keyword_lookup (new, key, 0)) {
00245
00246 if (newkey->info->islink) {
00247 int pkeyct = old->seriesinfo->pidx_num;
00248 type = (DRMS_Type_t *)malloc (pkeyct * sizeof (DRMS_Type_t));
00249 value = (DRMS_Type_Value_t *)malloc (pkeyct * sizeof (DRMS_Type_Value_t));
00250 for (n = 0; n < pkeyct; n++) {
00251 pkey = old->seriesinfo->pidx_keywords[n];
00252 value[n] = drms_getkey (old, pkey->info->name, &type[n], NULL);
00253 }
00254
00255 drms_setlink_dynamic (new, newkey->info->linkname, type, value);
00256 free (type);
00257 free (value);
00258 return 0;
00259 }
00260 } else {
00261 return 0;
00262 }
00263
00264 if (oldkey->info->type != newkey->info->type) {
00265
00266
00267
00268
00269 ;
00270
00271
00272
00273 }
00274 if (newkey->info->recscope != 1) {
00275
00276
00277 drms_copykey (new, old, key);
00278 return 0;
00279 }
00280 switch (newkey->info->type) {
00281
00282
00283
00284
00285
00286 case DRMS_TYPE_SHORT:
00287 return check_and_set_key_short (new, key,
00288 drms_getkey_short (old, key, &status));
00289 case DRMS_TYPE_INT:
00290 return check_and_set_key_int (new, key,
00291 drms_getkey_int (old, key, &status));
00292
00293
00294
00295
00296
00297 case DRMS_TYPE_FLOAT:
00298 return check_and_set_key_float (new, key,
00299 drms_getkey_float (old, key, &status));
00300 case DRMS_TYPE_DOUBLE:
00301 return check_and_set_key_double (new, key,
00302 drms_getkey_double (old, key, &status));
00303 case DRMS_TYPE_TIME:
00304 return check_and_set_key_time (new, key,
00305 drms_getkey_time (old, key, &status));
00306 case DRMS_TYPE_STRING:
00307 return check_and_set_key_str (new, key,
00308 drms_getkey_string (old, key, &status));
00309 default:
00310 fprintf (stderr,
00311 "Error in check_and_copy_key(): Unknown type %s for keyword %s\n",
00312 drms_type2str (newkey->info->type), key);
00313 return 1;
00314 }
00315 }
00316
00317 int drms_appendstr_tokey (DRMS_Record_t *rec, const char *key, const char *str,
00318 int addline) {
00319
00320
00321
00322
00323 DRMS_Keyword_t *keyword = NULL;
00324 int rv;
00325
00326 if (!rec || !str) return DRMS_ERROR_INVALIDDATA;
00327 if (!strlen (str)) return 0;
00328 keyword = drms_keyword_lookup (rec, key, 0);
00329 if (!keyword) return DRMS_ERROR_UNKNOWNKEYWORD;
00330 if (keyword->info->islink || drms_keyword_isconstant (keyword) ||
00331 drms_keyword_isslotted (keyword))
00332 return DRMS_ERROR_KEYWORDREADONLY;
00333 if (keyword->info->type != DRMS_TYPE_STRING) return DRMS_ERROR_INVALIDDATA;
00334
00335 if (keyword->value.string_val) {
00336 char *tmp = NULL;
00337 if (strlen (keyword->value.string_val)) {
00338 size_t strsz = strlen (keyword->value.string_val) + strlen (str) + 2;
00339 tmp = malloc(strsz);
00340 if (addline)
00341 snprintf (tmp, strsz, "%s\n%s", keyword->value.string_val, str);
00342 else
00343 snprintf (tmp, strsz, "%s%s", keyword->value.string_val, str);
00344 } else tmp = strdup (str);
00345 free (keyword->value.string_val);
00346 keyword->value.string_val = tmp;
00347 } else keyword->value.string_val = strdup (str);
00348 return 0;
00349 }
00350
00351 void append_args_tokey (DRMS_Record_t *rec, const char *key) {
00352
00353
00354
00355
00356 ModuleArgs_t *arg = gModArgs;
00357 CmdParams_t *params = &cmdparams;
00358 int flagct = 0;
00359 char *strval;
00360 char flaglist[72];
00361
00362 drms_appendstr_tokey (rec, key, "Module called with following arguments:", 1);
00363 while (arg->type != ARG_END) {
00364 if (arg->type == ARG_FLAG) {
00365 if (params_isflagset (params, arg->name)) {
00366 if (!flagct) sprintf (flaglist, "with flags -");
00367 strcat (flaglist, arg->name);
00368 flagct++;
00369 }
00370 } else {
00371 drms_appendstr_tokey (rec, key, arg->name, 1);
00372 drms_appendstr_tokey (rec, key, "= ", 0);
00373 strval = strdup (params_get_str (params, arg->name));
00374 drms_appendstr_tokey (rec, key, strval, 0);
00375 }
00376 arg++;
00377 }
00378 if (flagct) drms_appendstr_tokey (rec, key, flaglist, 1);
00379 return;
00380 }
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390 int construct_stringlist (const char *request, char token, char ***stringlist) {
00391 int keyct = 1;
00392 int m, n;
00393 char *req, *req0 = strdup (request);
00394 char c;
00395
00396 req = req0;
00397 while (c = *req) {
00398 if (c == token) {
00399 *req = '\0';
00400 keyct++;
00401 }
00402 req++;
00403 }
00404 *stringlist = (char **)malloc (keyct * sizeof (char **));
00405 req = req0;
00406 for (n = 0; n < keyct; n++) {
00407 (*stringlist)[n] = strdup (req);
00408 req += strlen (req) + 1;
00409 }
00410 for (n = 0; n < keyct; n++) {
00411 char *subs = (*stringlist)[n];
00412
00413 while (isspace (c = *subs)) subs++;
00414 (*stringlist)[n] = subs;
00415
00416 if (strlen (subs)) {
00417 subs += strlen (subs) - 1;
00418 while (isspace (c = *subs)) {
00419 *subs = '\0';
00420 subs--;
00421 }
00422 }
00423 }
00424
00425 for (n = 0; n < keyct; n++) {
00426 if (!strlen ((*stringlist)[n])) {
00427 for (m = n; m < keyct - 1; m++)
00428 (*stringlist)[m] = (*stringlist)[m + 1];
00429 keyct--;
00430 }
00431 }
00432 free (req0);
00433 return keyct;
00434 }
00435
00436 int copy_prime_keys (DRMS_Record_t *new, DRMS_Record_t *old) {
00437
00438
00439
00440
00441 DRMS_Keyword_t *pkey;
00442 int n, kstat = 0;
00443 char *key, *pkeyindex;
00444 int pkeyct = new->seriesinfo->pidx_num;
00445
00446 for (n = 0; n < pkeyct; n++) {
00447 pkey = new->seriesinfo->pidx_keywords[n];
00448 key = strdup (pkey->info->name);
00449
00450 if (pkeyindex = strstr (key, "_index")) *pkeyindex = '\0';
00451 if (!drms_keyword_lookup (old, key, 1)) continue;
00452 kstat += check_and_copy_key (new, old, key);
00453 }
00454 return kstat;
00455 }
00456
00457 void string_insert_escape_char (char **str, const char esc) {
00458 int i, n, ct = 0, len;
00459
00460 len = strlen (*str);
00461 for (n = 0; n < len; n++) if ((*str)[n] == esc) ct++;
00462 if (ct) {
00463 *str = realloc (*str, 2*len);
00464 for (n = len; n < 2*len; n++) (*str)[n] = '\0';
00465 }
00466 for (n = 0; n < len; n++) {
00467 if ((*str)[n] == esc) {
00468 for (i = len; i > n; i--) (*str)[i] = (*str)[i-1];
00469 (*str)[n] = '\\';
00470 len++;
00471 n++;
00472 }
00473 }
00474 }
00475
00476 int append_keyval_to_primekeyval (char **pkey, DRMS_Record_t *rec,
00477 const char *key) {
00478 DRMS_Keyword_t *keywd;
00479 int size;
00480 static int curlen;
00481 char **buf;
00482 int buflen = 256;
00483
00484 if (!*pkey) {
00485 *pkey = calloc (buflen, sizeof (char));
00486 curlen = buflen;
00487 }
00488 size = strlen (*pkey);
00489 if (size) {
00490
00491 size++;
00492 if (size >= curlen) {
00493 char *tmp = calloc (curlen, sizeof (char));
00494 strcpy (tmp, *pkey);
00495 curlen += buflen;
00496 *pkey = realloc (*pkey, curlen);
00497 bzero (*pkey, curlen);
00498 strcpy (*pkey, tmp);
00499 free (tmp);
00500 }
00501 strcat (*pkey, "|");
00502 }
00503 if (!(keywd = drms_keyword_lookup (rec, key, 1))) {
00504 fprintf (stderr, "create_primekey_from_keylist(): %s not found\n", key);
00505 if (*pkey) free (*pkey);
00506 *pkey = NULL;
00507 return 1;
00508 }
00509 buf = malloc (sizeof (char **));
00510 *buf = malloc (DRMS_DEFVAL_MAXLEN * sizeof (char *));
00511 drms_keyword_snprintfval (keywd, *buf, DRMS_DEFVAL_MAXLEN);
00512 if (keywd->info->type == DRMS_TYPE_STRING ||
00513 keywd->info->type == DRMS_TYPE_TIME) {
00514 string_insert_escape_char (buf, '|');
00515 }
00516 size += strlen (*buf);
00517 if (size >= curlen) {
00518 curlen += buflen;
00519 *pkey = realloc (*pkey, curlen);
00520 }
00521 strncat (*pkey, *buf, strlen (*buf));
00522 free (*buf);
00523 free (buf);
00524 return 0;
00525 }
00526
00527 char *create_primekey_from_keylist (DRMS_Record_t *rec, char **keylist,
00528 int keyct) {
00529 char *pkey = NULL;
00530 int n;
00531 for (n = 0; n < keyct; n++)
00532 if (append_keyval_to_primekeyval (&pkey, rec, keylist[n])) break;
00533
00534 return pkey;
00535 }
00536
00537 int propagate_keys (DRMS_Record_t *to, DRMS_Record_t *from, char **keylist,
00538 int keyct) {
00539 int n, status = 0;
00540 for (n = 0; n < keyct; n++)
00541 status += check_and_copy_key (to, from, keylist[n]);
00542 return status;
00543 }
00544
00545 char *iau_units_parse_unit (char *unit, double *scale) {
00546 char prefix = unit[0];
00547
00548 *scale = 1.0;
00549 switch (prefix) {
00550 case ('y'):
00551 if (strcmp (unit, "yr")) {
00552 *scale = 1.0e24;
00553 return &unit[1];
00554 } else return unit;
00555 case ('z'): *scale = 1.0e21; return &unit[1];
00556 case ('a'):
00557 if (strlen (unit) == 1) return unit;
00558 if (strcmp (unit, "arcmin") && strcmp (unit, "arcsec") &&
00559 strcmp (unit, "adu")) {
00560 *scale = 1.0e18;
00561 return &unit[1];
00562 } else return unit;
00563 case ('f'): *scale = 1.0e15; return &unit[1];
00564 case ('p'):
00565 if (strcmp (unit, "pc") && strcmp (unit, "ph") && strcmp (unit, "photon")
00566 && strcmp (unit, "pix") && strcmp (unit, "pixel") ) {
00567 *scale = 1.0e12;
00568 return &unit[1];
00569 } else return unit;
00570 case ('n'): *scale = 1.0e9; return &unit[1];
00571 case ('u'): *scale = 1.0e6; return &unit[1];
00572 case ('m'):
00573 if (strlen (unit) == 1) return unit;
00574 if (strcmp (unit, "mol") && strcmp (unit, "mas") && strcmp (unit, "min")
00575 && strcmp (unit, "mag")) {
00576 *scale = 1.0e3;
00577 return &unit[1];
00578 } else return unit;
00579 case ('c'):
00580 if (strcmp (unit, "cd") && strcmp (unit, "count") && strcmp (unit, "ct")
00581 && strcmp (unit, "chan")) {
00582 *scale = 1.0e2;
00583 return &unit[1];
00584 } else return unit;
00585 case ('d'):
00586 if (strlen (unit) == 1) return unit;
00587 if (strcmp (unit, "deg")) {
00588 *scale = 1.0e1;
00589 return &unit[1];
00590 } else return unit;
00591 case ('h'):
00592 if (strlen (unit) == 1) return unit;
00593 else {
00594 *scale = 1.0e-2;
00595 return &unit[1];
00596 }
00597 case ('k'):
00598 if (strcmp (unit, "kg") && strcmp (unit, "count") && strcmp (unit, "ct")
00599 && strcmp (unit, "chan")) {
00600 *scale = 1.0e-3;
00601 return &unit[1];
00602 } else return unit;
00603 case ('M'): *scale = 1.0e-6; return &unit[1];
00604 case ('G'):
00605 if (strlen (unit) == 1) return unit;
00606 else {
00607 *scale = 1.0e-9;
00608 return &unit[1];
00609 }
00610 case ('T'):
00611 if (strlen (unit) == 1) return unit;
00612 else {
00613 *scale = 1.0e-12;
00614 return &unit[1];
00615 }
00616 case ('P'):
00617 if (strcmp (unit, "PA")) {
00618 *scale = 1.0e-15;
00619 return &unit[1];
00620 } else return unit;
00621 case ('E'): *scale = 1.0e-18; return &unit[1];
00622 case ('Z'): *scale = 1.0e-21; return &unit[1];
00623 case ('Y'): *scale = 1.0e-24; return &unit[1];
00624 default: return unit;
00625 }
00626 }
00627
00628 int drms_iau_units_scale (char *unit, double *scale) {
00629 if (!(strcmp (unit, "rad"))) *scale = 1.0;
00630 else return -1;
00631 return 0;
00632 }
00633
00634 int drms_wcs_timestep (DRMS_Record_t *rec, int axis, double *tstep) {
00635 double dval;
00636 int status;
00637 char *sval;
00638 char delta[9], unit[9];
00639
00640 *tstep = 1.0 / 0.0;
00641 sprintf (delta, "CDELT%d", axis);
00642 sprintf (unit, "CUNIT%d", axis);
00643 dval = drms_getkey_double (rec, delta, &status);
00644 if (status || isnan (dval)) return 1;
00645 *tstep = dval;
00646 sval = drms_getkey_string (rec, unit, &status);
00647
00648 if (status || !sval) {
00649 fprintf (stderr, "Warning: no keyword %s: \"s\" assumed\n", unit);
00650 return 0;
00651 }
00652 if (!strcmp (sval, "s")) return 0;
00653 if (!strcmp (sval, "min")) {
00654 *tstep *= 60.0;
00655 return 0;
00656 }
00657 if (!strcmp (sval, "h")) {
00658 *tstep *= 3600.0;
00659 return 0;
00660 }
00661 if (!strcmp (sval, "d")) {
00662 *tstep *= 86400.0;
00663 return 0;
00664 }
00665 if (!strcmp (sval, "a") || !strcmp (sval, "yr")) {
00666 *tstep *= 31557600.0;
00667 return 0;
00668 }
00669
00670 if (!strcmp (sval, "ns")) {
00671 *tstep *= 1.0e-9;
00672 return 0;
00673 }
00674 if (!strcmp (sval, "us")) {
00675 *tstep *= 1.0e-6;
00676 return 0;
00677 }
00678 if (!strcmp (sval, "ms")) {
00679 *tstep *= 0.001;
00680 return 0;
00681 }
00682 if (!strcmp (sval, "cs")) {
00683 *tstep *= 0.01;
00684 return 0;
00685 }
00686 if (!strcmp (sval, "ds")) {
00687 *tstep *= 0.1;
00688 return 0;
00689 }
00690 if (!strcmp (sval, "das")) {
00691 *tstep *= 10.0;
00692 return 0;
00693 }
00694 if (!strcmp (sval, "hs")) {
00695 *tstep *= 100.0;
00696 return 0;
00697 }
00698 if (!strcmp (sval, "ks")) {
00699 *tstep *= 1000.0;
00700 return 0;
00701 }
00702 if (!strcmp (sval, "Ms")) {
00703 *tstep *= 1.0e6;
00704 return 0;
00705 }
00706 if (!strcmp (sval, "gs")) {
00707 *tstep *= 1.0e9;
00708 return 0;
00709 }
00710
00711 if (!strcmp (sval, "nmin")) {
00712 *tstep *= 6.0e-8;
00713 return 0;
00714 }
00715 if (!strcmp (sval, "umin")) {
00716 *tstep *= 6.0e-5;
00717 return 0;
00718 }
00719 if (!strcmp (sval, "mmin")) {
00720 *tstep *= 0.06;
00721 return 0;
00722 }
00723 if (!strcmp (sval, "cmin")) {
00724 *tstep *= 0.6;
00725 return 0;
00726 }
00727 if (!strcmp (sval, "dmin")) {
00728 *tstep *= 6.0;
00729 return 0;
00730 }
00731 if (!strcmp (sval, "damin")) {
00732 *tstep *= 600.0;
00733 return 0;
00734 }
00735 if (!strcmp (sval, "hmin")) {
00736 *tstep *= 6000.0;
00737 return 0;
00738 }
00739 if (!strcmp (sval, "kmin")) {
00740 *tstep *= 60000.0;
00741 return 0;
00742 }
00743 if (!strcmp (sval, "Mmin")) {
00744 *tstep *= 6.0e7;
00745 return 0;
00746 }
00747 if (!strcmp (sval, "gmin")) {
00748 *tstep *= 6.0e10;
00749 return 0;
00750 }
00751
00752 if (!strcmp (sval, "nh")) {
00753 *tstep *= 3.6e-6;
00754 return 0;
00755 }
00756 if (!strcmp (sval, "uh")) {
00757 *tstep *= 3.6e-3;
00758 return 0;
00759 }
00760 if (!strcmp (sval, "mh")) {
00761 *tstep *= 0.36;
00762 return 0;
00763 }
00764 if (!strcmp (sval, "ch")) {
00765 *tstep *= 3.6;
00766 return 0;
00767 }
00768 if (!strcmp (sval, "dh")) {
00769 *tstep *= 360.0;
00770 return 0;
00771 }
00772 if (!strcmp (sval, "dah")) {
00773 *tstep *= 3.6e4;
00774 return 0;
00775 }
00776 if (!strcmp (sval, "hh")) {
00777 *tstep *= 3.6e5;
00778 return 0;
00779 }
00780 if (!strcmp (sval, "kh")) {
00781 *tstep *= 3.6e6;
00782 return 0;
00783 }
00784 if (!strcmp (sval, "Mh")) {
00785 *tstep *= 3.6e9;
00786 return 0;
00787 }
00788 if (!strcmp (sval, "gh")) {
00789 *tstep *= 3.6e12;
00790 return 0;
00791 }
00792
00793 if (!strcmp (sval, "nd")) {
00794 *tstep *= 8.64e-5;
00795 return 0;
00796 }
00797 if (!strcmp (sval, "ud")) {
00798 *tstep *= 8.64-2;
00799 return 0;
00800 }
00801 if (!strcmp (sval, "md")) {
00802 *tstep *= 86.4;
00803 return 0;
00804 }
00805 if (!strcmp (sval, "cd")) {
00806 *tstep *= 864.0;
00807 return 0;
00808 }
00809 if (!strcmp (sval, "dd")) {
00810 *tstep *= 8640.0;
00811 return 0;
00812 }
00813 if (!strcmp (sval, "dad")) {
00814 *tstep *= 8.64e5;
00815 return 0;
00816 }
00817 if (!strcmp (sval, "hd")) {
00818 *tstep *= 8.64e6;
00819 return 0;
00820 }
00821 if (!strcmp (sval, "kd")) {
00822 *tstep *= 8.64e7;
00823 return 0;
00824 }
00825 if (!strcmp (sval, "Md")) {
00826 *tstep *= 8.64e10;
00827 return 0;
00828 }
00829 if (!strcmp (sval, "gd")) {
00830 *tstep *= 8.64e13;
00831 return 0;
00832 }
00833
00834 fprintf (stderr, "Error: %s type of %s unrecognized by drms_wcs_timestep()\n",
00835 unit, sval);
00836 return 1;
00837 }
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854