1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492
|
/*-----------------------------------------------------------------*/
/*!
\file inspector.c
\brief display details about the ephemeris file.
\author M. Gastineau
Astronomie et Systemes Dynamiques, IMCCE, CNRS, Observatoire de
Paris.
Copyright, 2011-2024, CNRS
email of the author : Mickael.Gastineau@obspm.fr
History:
*/
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
/* License of this file :
This file is "triple-licensed", you have to choose one of the three licenses
below to apply on this file.
CeCILL-C
The CeCILL-C license is close to the GNU LGPL.
( http://www.cecill.info/licences/Licence_CeCILL-C_V1-en.html )
or CeCILL-B
The CeCILL-B license is close to the BSD.
(http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
or CeCILL v2.1
The CeCILL license is compatible with the GNU GPL.
( http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.html )
This library is governed by the CeCILL-C, CeCILL-B or the CeCILL license under
French law and abiding by the rules of distribution of free software.
You can use, modify and/ or redistribute the software under the terms
of the CeCILL-C,CeCILL-B or CeCILL license as circulated by CEA, CNRS and INRIA
at the following URL "http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited
liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL-C,CeCILL-B or CeCILL license and that you accept its
terms.
*/
/*-----------------------------------------------------------------*/
#include "calcephconfig.h"
#if HAVE_STDIO_H
#include <stdio.h>
#endif
#if HAVE_STDLIB_H
#include <stdlib.h>
#endif
#if HAVE_STRING_H
#include <string.h>
#endif
#if HAVE_ERRNO_H
#include <errno.h>
#endif
#if HAVE_MATH_H
#include <math.h>
#endif
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifndef __cplusplus
#if HAVE_STDBOOL_H
#include <stdbool.h>
#endif
#endif /*__cplusplus */
#include "real.h"
#include "calceph.h"
#include "calcephinternal.h"
#include "util.h"
int main(int argc, char *argv[])
{
t_calcephbin *peph;
const char *filename;
struct calcephbin_inpop *pinpop;
struct calcephbin_spice *pspice;
struct SPICEkernel *pkernel;
struct SPKfile *pspk;
struct TXTPCKfile *ptxtpck;
struct TXTPCKconstant *listconstant;
struct TXTFKfile *ptxtfk;
struct TXTFKframe *listframe;
struct SPKSegmentList *listseg;
char nameconstant[CALCEPH_MAX_CONSTANTNAME];
double valueconstant;
char fileversion[CALCEPH_MAX_CONSTANTVALUE];
int j;
int timescale;
double firsttime, lasttime;
int continuous;
int countposrecord;
int countorirecord;
int target, center, frame;
if (argc != 2)
{
printf("Usage : calceph_inspector filename\n");
printf(" filename : binary ephemeris file name\n\n");
printf("e.g. : calceph_inspector inpop08a_m100_p100_littleendian.dat\n\n");
return 1;
}
printf("calceph_inspector - CALCEPH version %d.%d.%d\n\n", CALCEPH_VERSION_MAJOR,
CALCEPH_VERSION_MINOR, CALCEPH_VERSION_PATCH);
filename = argv[1];
peph = calceph_open(filename);
if (peph)
{
if (calceph_getfileversion(peph, fileversion))
{
printf("Ephemeris file version : '%s'\n", fileversion);
}
else
{
printf("Ephemeris file version : unknown\n");
}
timescale = calceph_gettimescale(peph);
printf("timescale : ");
switch (timescale)
{
case 1:
printf("TDB\n");
break;
case 2:
printf("TCB\n");
break;
default:
printf("unknown\n");
break;
}
countposrecord = calceph_getpositionrecordcount(peph);
printf("Number of position's record : %d\n", countposrecord);
countorirecord = calceph_getorientrecordcount(peph);
printf("Number of orientation's record : %d\n", countorirecord);
switch (peph->etype)
{
case CALCEPH_espice:
printf("SPICE file format\n");
pspice = &peph->data.spkernel;
/*if (pspice==NULL) printf("peph->data.spkernel is NULL\n"); */
pkernel = pspice->list;
while (pkernel != NULL)
{
switch (pkernel->filetype)
{
case DAF_SPK:
printf("SPK file\n");
pspk = &pkernel->filedata.spk;
printf("Binary file format ID : '%.*s'\n", IFNAME_LEN, pspk->header.bff);
printf("body center start time (JD) end time (JD) "
"frame data type data information\n");
printf("-------------------------------------------------------------"
"-----------------------------------------\n");
for (listseg = pspk->list_seg; listseg != NULL; listseg = listseg->next)
{
for (j = 0; j < listseg->array_seg.count; j++)
{
struct SPKSegmentHeader *seg = listseg->array_seg.array + j;
printf("%-12d %-12d%-16.2f%-16.2f %-10d%-12d", seg->body, seg->center,
seg->T_begin / 86400E0 + 2.451545E+06, seg->T_end / 86400E0 + 2.451545E+06,
seg->refframe, seg->datatype);
switch (seg->datatype)
{
case SPK_SEGTYPE1:
printf("MDA number of records : %6d TDB\n",
seg->seginfo.data1.count_record);
break;
case SPK_SEGTYPE3:
case SPK_SEGTYPE2:
printf("Time span per record: %4.2g (day)\tnumber of records : "
"%6d TDB\n",
seg->seginfo.data2.T_len / 86400E0, seg->seginfo.data2.count_record);
break;
case SPK_SEGTYPE103:
case SPK_SEGTYPE102:
printf("Time span per record: %4.2g (day)\tnumber of records : "
"%6d TCB\n",
seg->seginfo.data2.T_len / 86400E0, seg->seginfo.data2.count_record);
break;
case SPK_SEGTYPE5:
printf
("Discrete states (two body propagation) number of records : %6d GM: %g "
"TDB\n", seg->seginfo.data5.count_record, seg->seginfo.data5.GM);
break;
case SPK_SEGTYPE8:
printf("Time span per record: %4.2g (day)\tnumber of records : "
"%6d\tLagrange Interpolation of degree %d - Equal Time "
"Steps TDB\n",
seg->seginfo.data12.step_size / 86400E0,
seg->seginfo.data12.count_record, seg->seginfo.data12.degree);
break;
case SPK_SEGTYPE9:
printf("number of records : %6d\tLagrange Interpolation of "
"degree %d - Unequal Time Steps TDB\n",
seg->seginfo.data13.count_record, seg->seginfo.data13.degree);
break;
case SPK_SEGTYPE12:
printf("Time span per record: %4.2g (day)\tnumber of records : "
"%6d\tHermite Interpolation of degree %d - Equal Time "
"Steps TDB\n",
seg->seginfo.data12.step_size / 86400E0,
seg->seginfo.data12.count_record, seg->seginfo.data12.degree);
break;
case SPK_SEGTYPE13:
printf("number of records : %6d\tHermite Interpolation of "
"degree %d - Unequal Time Steps TDB\n",
seg->seginfo.data13.count_record, seg->seginfo.data13.degree);
break;
case SPK_SEGTYPE14:
printf("number of packets : %6d\tChebychev of "
"degree %d - Unequal Time Steps TDB\n",
seg->seginfo.data14.count_packets, seg->seginfo.data14.degree);
break;
case SPK_SEGTYPE17:
printf("Equinoctial Elements : epoch=%g TDB\n", seg->seginfo.data17.epoch);
break;
case SPK_SEGTYPE18:
printf("number of records : %6d\tESOC/DDID %s Interpolation of "
"degree %d - Window's size %d - Unequal Time Steps TDB\n",
seg->seginfo.data18.count_record,
seg->seginfo.data18.subtype == 0 ? "Hermite" : "Lagrange",
seg->seginfo.data18.degree, seg->seginfo.data18.window_size);
break;
case SPK_SEGTYPE19:
printf("number of records : %6d\tESOC/DDID Piecewise Interpolation "
"- boundary flag %d - TDB\n",
seg->seginfo.data19.number_intervals,
seg->seginfo.data19.boundary_choice_flag);
break;
case SPK_SEGTYPE20:
printf("Time span per record: %4.2g (day)\tnumber of records : "
"%6d TDB Dscale=%g Tscale=%g\n",
seg->seginfo.data20.T_len / 86400E0,
seg->seginfo.data20.count_record, seg->seginfo.data20.dscale,
seg->seginfo.data20.tscale);
break;
case SPK_SEGTYPE21:
printf("Extended MDA number of records : %6d dlsize=%6d TDB\n",
seg->seginfo.data21.count_record, seg->seginfo.data21.dlsize);
break;
case SPK_SEGTYPE120:
printf("Time span per record: %4.2g (day)\tnumber of records : "
"%6d TCB Dscale=%g Tscale=%g\n",
seg->seginfo.data20.T_len / 86400E0,
seg->seginfo.data20.count_record, seg->seginfo.data20.dscale,
seg->seginfo.data20.tscale);
break;
default:
printf("Unsupported segment (type=%d).", (int) seg->datatype);
break;
}
}
printf("\n");
}
break;
case TXT_PCK:
printf("text PCK file\n");
ptxtpck = &pkernel->filedata.txtpck;
printf("list of constant of the text PCK file : \n");
for (listconstant = ptxtpck->listconstant; listconstant != NULL;
listconstant = listconstant->next)
{
struct TXTPCKvalue *listvalue;
printf("'%s' = ( ", listconstant->name);
for (listvalue = listconstant->value; listvalue != NULL; listvalue = listvalue->next)
{
printf("%.*s", (int) (listvalue->loclast - listvalue->locfirst),
ptxtpck->buffer + listvalue->locfirst);
if (listvalue->next != NULL)
printf(" , ");
}
printf(" ) \n");
}
break;
case DAF_PCK:
printf("binary PCK file\n");
pspk = &pkernel->filedata.spk;
printf("Binary file format ID : '%.*s'\n", IFNAME_LEN, pspk->header.bff);
printf("body start time (JD) end time (JD) frame data type "
" data information\n");
printf("-------------------------------------------------------------"
"------------------------\n");
for (listseg = pspk->list_seg; listseg != NULL; listseg = listseg->next)
{
for (j = 0; j < listseg->array_seg.count; j++)
{
struct SPKSegmentHeader *seg = listseg->array_seg.array + j;
printf("%-8d %-16.2f %-16.2f %-7d%-12d", seg->body,
seg->T_begin / 86400E0 + 2.451545E+06, seg->T_end / 86400E0 + 2.451545E+06,
seg->refframe, seg->datatype);
switch (seg->datatype)
{
case SPK_SEGTYPE3:
case SPK_SEGTYPE2:
printf("Time span per record: %4.2g (day) number of records : "
"%6d TDB\n",
seg->seginfo.data2.T_len / 86400E0, seg->seginfo.data2.count_record);
break;
case SPK_SEGTYPE103:
case SPK_SEGTYPE102:
printf("Time span per record: %4.2g (day) number of records : "
"%6d TCB\n",
seg->seginfo.data2.T_len / 86400E0, seg->seginfo.data2.count_record);
break;
case SPK_SEGTYPE20:
printf("Time span per record: %4.2g (day)\tnumber of records : "
"%6d TDB Dscale=%g Tscale=%g\n",
seg->seginfo.data20.T_len /*/ 86400E0 */ ,
seg->seginfo.data20.count_record,
seg->seginfo.data20.dscale, seg->seginfo.data20.tscale);
break;
case SPK_SEGTYPE120:
printf("Time span per record: %4.2g (day)\tnumber of records : "
"%6d TCB Dscale=%g Tscale=%g\n",
seg->seginfo.data20.T_len /*/ 86400E0 */ ,
seg->seginfo.data20.count_record,
seg->seginfo.data20.dscale, seg->seginfo.data20.tscale);
break;
default:
printf("Unsupported segment (type=%d).", (int) seg->datatype);
break;
}
}
printf("\n");
}
break;
case TXT_FK:
printf("text FK file\n");
ptxtfk = &pkernel->filedata.txtfk;
printf("list of frame of the text FK file : \n");
for (listframe = ptxtfk->listframe; listframe != NULL; listframe = listframe->next)
{
printf("'%s' = ( %d, class=%2d, classid=%8d, center = %8d ", listframe->name,
listframe->frame_id, listframe->classtype, listframe->class_id,
listframe->center);
printf(" ) \n");
}
printf("list of constant of the text FK file : \n");
for (listconstant = ptxtfk->txtpckfile.listconstant; listconstant != NULL;
listconstant = listconstant->next)
{
struct TXTPCKvalue *listvalue;
printf("'%s' = ( ", listconstant->name);
for (listvalue = listconstant->value; listvalue != NULL; listvalue = listvalue->next)
{
printf("%.*s", (int) (listvalue->loclast - listvalue->locfirst),
ptxtfk->txtpckfile.buffer + listvalue->locfirst);
if (listvalue->next != NULL)
printf(" , ");
}
printf(" ) \n");
}
break;
default:
printf("Unknown SPICE type in %d\n", (int) pkernel->filetype);
return 2;
break;
}
pkernel = pkernel->next;
}
break;
case CALCEPH_ebinary:
printf("INPOP or original DE file format\n");
pinpop = &peph->data.binary;
printf("Ephemerides number : %d\n", pinpop->H1.DENUM);
calceph_gettimespan(peph, &firsttime, &lasttime, &continuous);
printf("Start time : %23.16e\n", firsttime);
printf("End time : %23.16e\n", lasttime);
printf("Time Span : %23.16e\n", pinpop->H1.timeData[2]);
printf("Data available on continuous time : %d\n", continuous);
printf("1980 IAU nutation angles : %s\n", pinpop->haveNutation ? "available" : "not available");
printf("TT-TDB : %s\n", pinpop->haveTTmTDB ? "available" : "not available");
printf("Lunar angular velocity : %s\n",
pinpop->haveLunarAngularVelocity ? "available" : "not available");
printf("\nNumber of constants : %d\n", calceph_getconstantcount(peph));
printf("list of constants :\n");
for (j = 1; j <= calceph_getconstantcount(peph); j++)
{
calceph_getconstantindex(peph, j, nameconstant, &valueconstant);
printf("'%s'\t= %23.16E\n", nameconstant, valueconstant);
}
if (countposrecord)
{
printf("position's records :\n");
printf("body center start time (JD) end time (JD) " " frame \n");
printf("---------------------------------------------------------------"
"----------------------\n");
for (j = 1; j <= countposrecord; j++)
{
calceph_getpositionrecordindex(peph, j, &target, ¢er, &firsttime, &lasttime, &frame);
printf("%8d %8d %23.16E %23.16E %4d\n", target, center, firsttime, lasttime, frame);
}
}
if (countorirecord)
{
printf("orientation's records :\n");
printf("body start time (JD) end time (JD) frame " "\n");
printf("---------------------------------------------------------------"
"----------------------\n");
for (j = 1; j <= countorirecord; j++)
{
calceph_getorientrecordindex(peph, j, &target, &firsttime, &lasttime, &frame);
printf("%8d %23.16E %23.16E %4d\n", target, firsttime, lasttime, frame);
}
}
break;
default:
printf("Unknown ephemeris type in calceph_getconstant\n");
return 1;
break;
}
calceph_close(peph);
}
return 0;
}
|