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