A Space & astronomy forum. SpaceBanter.com

Go Back   Home » SpaceBanter.com forum » Astronomy and Astrophysics » Astronomy Misc
Site Map Home Authors List Search Today's Posts Mark Forums Read Web Partners

How To Decode The MER Image Filenames



 
 
Thread Tools Display Modes
  #1  
Old March 11th 04, 03:27 AM
Ron
external usenet poster
 
Posts: n/a
Default How To Decode The MER Image Filenames

http://marsrovers.jpl.nasa.gov/galle...ename_key.html

How To Decode The MER Image Filenames

File name code

Below is a chart that will help you decode the 27 character file
names associated with the Mars Exploration Rover mission.
There is enough info below to allow you to make
stereograms and construct color pictures and determine
when and where the raw images were taken. Enjoy!

----

Character Function

1 Spacecraft ID
1 = Opportunity
2 = Spirit

2 Camera
F = Forward HAZCAM
R = Rear HAZCAM
N = NAVCAM
P = PANCAM
M = Microscopic Imager
E - EDLcam (Descent Imager)

3 to 11 Spacecraft clock
This is the number of seconds since January 1, 2000
at 11:58:55.816 UTC.

12 to 14 Product type
Product types are differentiated as having camera-induced
distortion removed (geometrically "linearized") or not
removed (nominal), and, as being thumbnail-sized or not.
Four special flag characters follow:

a) Beginning E - Type of EDR, which are raw with no camera
model linearization or radiometric correction. If no
beginning E, then it is a Reduced Data Record (RDR).
b) Ending T - EDR or RDR that is Thumbnail -sized.
c) Ending L - If no beginning E , denotes an RDR that is
Linearized, except for Thumbnail sized RDRs.
d) Ending N - If no beginning E , denotes an RDR that is
ThumbNail-sized and Linearized .

Valid values for MER camera instrument input data products:
Data Product Identifier
-------------------- ----------
full frame EDR EFF
Sub-frame EDR ESF
Downsampled EDR EDN
Thumbnail EDR ETH
Row Summed EDR ERS
Column Summed EDR ECS
Reference Pixels EDR ERP
Histogram EDR EHG

15 to 16 Site number
Site location count (indicates rover's location).
Valid values: 00, 01, 02,...99, A0, A1,..., A9, AA, AB...etc.

17 to 18 Drive number
Position-within-Site count (indicates rover's position within site)
Valid values: 00, 01, 02,...99, A0, A1,..., A9, AA, AB...etc.

19 to 23 Command sequence number (one letter, 4 numbers)
Denotes a group of images that were all obtained within a
single command sequence.

Valid values for character (position 1) in field:
C - Cruise
D - IDD & RAT
E - Engineering
F - Flight Software (Seq rejected)
G - (spare)
K - (spare)
M - Master (Surface only)
N - In-Situ instr. (APXS, MB, MI)
P - PMA & Remote Sensing instr. (Pancam, Navcam, Hazcam, MI,
Mini-TES)
R - Rover Driving
S - Submaster
T - Test
W - Seq triggered by a Communications Window
X - Contingency
Y - (spare)
Z - SCM Seqs

Valid values for integers (positions 2 thru 5) in field:

0000 thru 4095 - Valid Sequence number, commanded by Ground

If P in character position 1:
0000 through 0499 - Misc. imaging setup/parm sequences
0500 through 0999 - Unallocated, for possible future use
1000 through 1499 - Hazcam sequences
1500 through 1999 - Navcam sequences
2000 through 2899 - Pancam sequences
2900 through 2999 - MI sequences
3000 through 3999 - Mini-TES sequences
4000 through 4095 - Misc. PMA actuation sequences (deploy, etc.)

24 Camera eye
R = Right
L = Left
M - Monoscopic (non-stereo camera)
N - Not Applicable

25 Camera Filter (PANCAM only, 0 otherwise)
LEFT CAMERA RIGHT CAMERA
1 = EMPTY (clear) 1 = 436nm (37nm Short-pass)
2 = 753nm (20nm bandpass) 2 = 754nm (20nm bandpass)
3 = 673nm (16nm bandpass) 3 = 803nm (20nm bandpass)
4 = 601nm (17nm bandpass) 4 = 864nm (17nm bandpass)
5 = 535nm (20nm bandpass) 5 = 904nm (26nm bandpass)
6 = 482nm (25nm bandpass) 6 = 934nm (25nm bandpass)
7 = 432nm (32nm Short-pass) 7 = 1009nm (38nm Long-pass)
8 = 440nm (20) Solar ND 5.0 8 = 880nm (20) Solar ND 5.0
See Filter Wheels on Pancam

Microscopic Imager "Filter" positions:

1. MI window/cover closed (500-700 nm response)
2. MI window/cover open (400-700 nm response)

26 Product producer
A - Arizona State University
C - Cornell University
F - USGS at Flagstaff
J - Johannes Gutenberg Univ. (Germany)
M - MIPL (OPGS) at JPL
N - NASA Ames Research (L. Edwards)
P - Max Plank Institute (Germany)
S - SOAS at JPL
U - University of Arizona
V - SSV Team (E. De Jong) at JPL
X - Other

27 Product version number
Version identifier providing uniqueness for book keeping.

Valid values: 1, 2, 3, ... 9, A, B, ... Z

Example:

A photo with the file name
2P126471340EDN0000P2303L5M1.JPG would be from
Spirit (2), taken by the left PANCAM through the
535nm (green) filter. By matching the spacecraft times
(in this case 126471340) with other pictures that have a
similar time, you can find sets that were taken at the same time
of the day. Use similar sets to build stereograms and color
composites. This picture was downsampled (EDN) at
site 0 (00) and position 0 (00) (On the lander in this case!)
It was taken with command sequence P2303 for MIPL
(OPGS) at JPL and is version 1.
  #4  
Old March 12th 04, 05:34 PM
Jan Panteltje
external usenet poster
 
Posts: n/a
Default How To Decode The MER Image Filenames

On a sunny day (Fri, 12 Mar 2004 02:58:46 GMT) it happened "Joe Knapp"
wrote in
m:


"Jan Panteltje" wrote in message
...
On a sunny day (10 Mar 2004 19:27:35 -0800) it happened


(Ron) wrote in :

A photo with the file name
2P126471340EDN0000P2303L5M1.JPG would be from
Spirit (2), taken by the left PANCAM through the
535nm (green) filter. By matching the spacecraft times
(in this case 126471340) with other pictures that have a
similar time, you can find sets that were taken at the same time
of the day. Use similar sets to build stereograms and color
composites. This picture was downsampled (EDN) at
site 0 (00) and position 0 (00) (On the lander in this case!)
It was taken with command sequence P2303 for MIPL
(OPGS) at JPL and is version 1.

Good stuff! Thank you :-)


Here's a small application to dump the image info:

http://www.copperas.com/astro/rawid.exe (Windows command-line executable)
http://www.copperas.com/astro/rawid (Linux command-line i386 executable)
http://www.copperas.com/astro/rawid.c (source code)

Joe

  #5  
Old March 12th 04, 08:01 PM
Jan Panteltje
external usenet poster
 
Posts: n/a
Default How To Decode The MER Image Filenames

On a sunny day (Fri, 12 Mar 2004 02:58:46 GMT) it happened "Joe Knapp"
wrote in
m:

Here's a small application to dump the image info:

http://www.copperas.com/astro/rawid.exe (Windows command-line executable)
http://www.copperas.com/astro/rawid (Linux command-line i386 executable)
http://www.copperas.com/astro/rawid.c (source code)

Joe

That compiles fine on Linux,

rawid ./
works OPK,
but
rawid 1M131649564EFF0544P2933M2M1.JPG
does nothing.
I looked at the code, in line 93 you do if(! isdr(filename) ) gotit is not etc...

The problem is in the routine isdr()
You do
if (fname[i] == '.')
fname[i] = '\0' ;

That basically already cuts of .JPG when you do a:
if (!isdr(fname))
{

/* here already it is 1M131649564EFF0544P2933M2M1 */
long patlen, gotit, gotone ;
char pat[MAXFN] ;

Beautiful site, I hear big ben?
Mars-birds?
JP
  #6  
Old March 12th 04, 09:11 PM
Joe Knapp
external usenet poster
 
Posts: n/a
Default How To Decode The MER Image Filenames


"Jan Panteltje" wrote
Here's a small application to dump the image info:

[snip]
That compiles fine on Linux,

rawid ./
works OPK,
but
rawid 1M131649564EFF0544P2933M2M1.JPG
does nothing.


Thanks Jan. I fixed the bug & updated the files:

http://www.copperas.com/astro/rawid.exe (Windows command-line executable)
http://www.copperas.com/astro/rawid (Linux command-line i386 executable)
http://www.copperas.com/astro/rawid.c (source code)

Joe


  #7  
Old March 13th 04, 01:18 AM
Jan Panteltje
external usenet poster
 
Posts: n/a
Default How To Decode The MER Image Filenames

On a sunny day (Fri, 12 Mar 2004 21:11:39 GMT) it happened "Joe Knapp"
wrote in
m:


"Jan Panteltje" wrote
Here's a small application to dump the image info:

[snip]
That compiles fine on Linux,

rawid ./
works OPK,
but
rawid 1M131649564EFF0544P2933M2M1.JPG
does nothing.


Thanks Jan. I fixed the bug & updated the files:

http://www.copperas.com/astro/rawid.exe (Windows command-line executable)
http://www.copperas.com/astro/rawid (Linux command-line i386 executable)
http://www.copperas.com/astro/rawid.c (source code)

Joe

I still got the same C file, here is what I did (tossed MS windows):

// Program by Joe Knapp March 11, 2004
#define MAXFN 1200
#define FNLEN 27
#define OPPORTUNITY '1'
#define SPIRIT '2'
#define SCID 0
#define CAMERAID 1
#define SCCLK_START 2
#define SCCLK_END 10
#define SCCLK_LEN (SCCLK_END - SCCLK_START + 1)
#define PRODTYPE 11
#define SITENO 14
#define DRIVENO 16
#define CMDSEQNO 18
#define CAMEYE 23
#define CAMFILT 24
#define PRODUCER 25
#define VERSION 26
#define UNIX 1
#define MER2UTIME 946727273
#define SECSPERSOL 88775.244
#define OPP_SOL1 128228618
#define SPR_SOL1 126408373
#define CWD "."
#include stdio.h
#include string.h
#include sys/types.h
#include sys/stat.h
#include stdlib.h
#include time.h

#if UNIX
#include dirent.h
#include libgen.h
#include unistd.h
#else
#include windows.h
#include io.h
#endif
char * d2hms(double) ;
int isdr(char *) ;
int dumpinfo(char *) ;
char * bname(char *) ;
char * dname(char *) ;
int main(int, char**) ;
int main(int argc, char *argv[])
{
char fname[MAXFN] ;
int i ;
DIR * cwd ;
struct dirent *dent ;

char datadir[MAXFN] ;
static struct
{
char type[80] ;
} lfilts[8] =
{
"EMPTY (clear)",
"753 nm (20 nm bp) infrared",
"673 nm (16 nm bp) red",
"601 nm (17 nm bp) orange",
"535 nm (20 nm bp) green",
"482 nm (25 nm bp) cyan",
"432 nm (32 nm shortpass) blue",
"440 nm solar ND"
} ;

static struct
{
char type[80] ;
} rfilts[8] = {
"436 nm (37 nm sp) blue",
"754 nm (20 nm bp) infrared",
"803 nm (20 nm bp) infrared",
"864 nm (17 nm bp) infrared",
"904 nm (26 nm bp) infrared",
"934 nm (25 nm bp) infrared",
"1009 nm (38 nm lp) infrared",
"880 nm solar ND"
} ;

if (argc != 2)
{
fprintf(stderr,"usage: %s MER raw image path\n",argv[0]) ;
fprintf(stderr," or %s partial MER raw image path\n",argv[0]) ;
fprintf(stderr," e.g., %s 1F132089069EDN05A6P1141R0M1.jpg\n",argv[0]) ;
fprintf(stderr," %s R0\n",argv[0]) ;
fprintf(stderr," %s images/dir/1F132089069EDN05A6P1141R0M1.jpg\n",argv[0]) ;
fprintf(stderr," %s images/dir/R0\n",argv[0]) ;
exit(1) ;
}

strncpy(fname, bname(argv[1]), MAXFN) ;
strncpy(datadir, dname(argv[1]), MAXFN) ;

fname[MAXFN] = '\0' ;
datadir[MAXFN] = '\0' ;

if (!isdr(fname))
{
long patlen, gotit, gotone ;
char pat[MAXFN] ;

strncpy(pat,fname,MAXFN) ;

patlen = strlen(pat) ;
gotone = 0 ;
gotit = 0 ;

cwd = opendir(datadir) ;
while(dent = readdir(cwd))
{
if (isdr(dent-d_name))
{
gotit = 0 ;
printf("%s %d %s\n",pat,patlen,dent-d_name) ;

for (i = 0 ; i FNLEN ; i++)
if (!strncmp(dent-d_name+i,pat,patlen))
{
gotit = 1 ;
gotone = 1 ;
}

if (gotit)
{
strncpy(fname,dent-d_name,FNLEN) ;
fname[FNLEN] = '\0' ;
printf("-----------------------------------------------------------------------\n") ;
dumpinfo(fname) ;
}
}
}

if (!gotone)
{
fprintf(stderr,"ERROR: could not find MER data file matching %s in directory %s\n",fname,datadir) ;
exit(1) ;
}
else printf("-----------------------------------------------------------------------\n") ;
}
else
{
dumpinfo(fname);
}

return(0) ;
}


int dumpinfo(char *fname)
{
char scclk[SCCLK_LEN+1] ;
long mertime ;
char siteno[3] ;
char driveno[3] ;
char cmdseqno[6] ;
int icmdseqno ;
int filtno ;
time_t unixtime ;
time_t umertime ;
double sols, csols, edays ;
int isols, icsols, iedays ;
int i,len ;
char pl[2] ;
static struct {
char type[80] ;
} lfilts[8] = {
"EMPTY (clear)",
"753 nm (20 nm bp) infrared",
"673 nm (16 nm bp) red",
"601 nm (17 nm bp) orange",
"535 nm (20 nm bp) green",
"482 nm (25 nm bp) cyan",
"432 nm (32 nm shortpass) blue",
"440 nm solar ND"
} ;
static struct {
char type[80] ;
} rfilts[8] = {
"436 nm (37 nm sp) blue",
"754 nm (20 nm bp) infrared",
"803 nm (20 nm bp) infrared",
"864 nm (17 nm bp) infrared",
"904 nm (26 nm bp) infrared",
"934 nm (25 nm bp) infrared",
"1009 nm (38 nm lp) infrared",
"880 nm solar ND"
} ;
i = 0 ;
len = strlen(fname) ;
while (i len) {
if (fname[i] == '.')
fname[i] = '\0' ;
i++ ;
}
if (strlen(fname) != FNLEN) {
fprintf(stderr,"ERROR: %s is not a valid MER data file name\n",fname) ;
return(0) ;
}
printf("Image info for: %s\n",fname) ;
if (fname[SCID] == OPPORTUNITY)
printf("Spacecraft: OPPORTUNITY\n") ;
else if (fname[SCID] == SPIRIT)
printf("Spacecraft: SPIRIT\n") ;
else {
fprintf(stderr,"ERROR: spacecraft ID %c in position %d unknown\n",fname[SCID],SCID+1) ;
return(0) ;
}
switch(fname[CAMERAID]) {
case 'F':
printf("Camera: Forward HAZCAM") ;
break ;
case 'R':
printf("Camera: Rear HAZCAM") ;
break ;
case 'N':
printf("Camera: NAVCAM") ;
break ;
case 'P':
printf("Camera: PANCAM") ;
break ;
case 'M':
printf("Camera: Microscopic Imager") ;
break ;
case 'E':
printf("EDLCAM") ;
break ;
default:
fprintf(stderr,"\nERROR: Camera ID %c in position %d unknown\n",fname[CAMERAID],CAMERAID+1) ;
return(0) ;
}
if (fname[CAMEYE] == 'L')
printf(", left") ;
else if (fname[CAMEYE] == 'R')
printf(", right") ;
if (fname[CAMFILT] != '0') {
if (fname[CAMEYE] == 'L') {
printf(", filter %c",fname[CAMFILT]) ;
filtno = (int)fname[CAMFILT] - (int)'0' - 1;
printf(", %s\n",lfilts[filtno].type) ;
}
else if (fname[CAMEYE] == 'R') {
printf(", filter %c",fname[CAMFILT]) ;
filtno = (int)fname[CAMFILT] - (int)'0' - 1;
printf(", %s\n",rfilts[filtno].type) ;
}
else if (fname[CAMEYE] == 'M') {
if (fname[CAMFILT] == '1')
printf(", dust cover CLOSED\n") ;
else if (fname[CAMFILT] == '2')
printf(", dust cover OPEN\n") ;
else
printf("\n") ;
}
}
else
printf("\n") ;
strncpy(scclk,fname+SCCLK_START,SCCLK_LEN) ;
mertime = atol(scclk) ;
printf("Spacecraft clock: %d (seconds since January 1, 2000, 11:58:55.816 UTC)\n",mertime) ;
printf("Product type: ") ;
if (fname[PRODTYPE] == 'E') {
char pid[3] ;
printf("EDR") ;
strncpy(pid,fname+PRODTYPE+1,2) ;
pid[2] = '\0' ;
if (!strcmp(pid,"FF"))
printf(" full frame") ;
else if (!strcmp(pid,"SF"))
printf(" sub-frame") ;
else if (!strcmp(pid,"DN"))
printf(" downsampled") ;
else if (!strcmp(pid,"TH"))
printf(" thumbnail") ;
else if (!strcmp(pid,"RS"))
printf(" row-summed") ;
else if (!strcmp(pid,"CS"))
printf(" column-summed") ;
else if (!strcmp(pid,"RP"))
printf(" reference pixels") ;
else if (!strcmp(pid,"HG"))
printf(" histogram") ;
else {
fprintf(stderr,"\nERROR: Unknown EDR type %s\n",pid) ;
return(0) ;
}
}
else
printf("RDR") ;
printf("\n") ;
strncpy(siteno,fname+SITENO,2) ;
siteno[2] = '\0' ;
printf("Site number: %s\n",siteno) ;
strncpy(driveno,fname+DRIVENO,2) ;
driveno[2] = '\0' ;
printf("Drive number: %s\n",driveno) ;
strncpy(cmdseqno,fname+CMDSEQNO,5) ;
cmdseqno[5] = '\0' ;
printf("Command sequence number: %s ",cmdseqno) ;
switch(fname[CMDSEQNO]) {
case 'C':
printf("(cruise)") ;
break ;
case 'D':
printf("(IDD & RAT)") ;
break ;
case 'E':
printf("(engineering)") ;
break ;
case 'F':
printf("(flight software seq rejected)") ;
break ;
case 'G':
printf("(spare)") ;
break ;
case 'K':
printf("(spare)") ;
break ;
case 'M':
printf("(master)") ;
break ;
case 'N':
printf("(in-situ instrument)") ;
break ;
case 'P':
printf("(PMA or remote sensing instrument)") ;
break ;
case 'R':
printf("(rover driving)") ;
break ;
case 'S':
printf("(submaster)") ;
break ;
case 'T':
printf("(test)") ;
break ;
case 'W':
printf("(seq triggered by comm window)") ;
break ;
case 'X':
printf("(contingency)") ;
break ;
case 'Y':
printf("(spare)") ;
break ;
case 'Z':
printf("(SCM seqs)") ;
break ;
default:
break ;
}
icmdseqno = atoi(cmdseqno+1) ;
if ((icmdseqno 4096) || (icmdseqno 0)) {
fprintf(stderr,"ERROR: invalid command sequence number %d\n",icmdseqno) ;
return(0) ;
}
if (icmdseqno 500)
printf(" misc. imaging") ;
else if (icmdseqno 1000)
printf(" unallocated") ;
else if (icmdseqno 1500)
printf(" HAZCAM") ;
else if (icmdseqno 2000)
printf(" NAVCAM") ;
else if (icmdseqno 2900)
printf(" PANCAM") ;
else if (icmdseqno 3000)
printf(" MI") ;
else if (icmdseqno 4000)
printf(" Mini-TES") ;
else if (icmdseqno 4096)
printf(" misc. PMA") ;
printf("\n") ;
printf("Producer: ") ;
switch(fname[PRODUCER]) {
case 'A':
printf("Arizona State University") ;
break ;
case 'C':
printf("Cornell University") ;
break ;
case 'F':
printf("USGS") ;
break ;
case 'J':
printf("Johannes Gutenberg University") ;
break ;
case 'M':
printf("MIPL/JPL") ;
break ;
case 'N':
printf("NASA Ames Research") ;
break ;
case 'P':
printf("Max Plank Institute") ;
break ;
case 'S':
printf("SOAS/JPL") ;
break ;
case 'U':
printf("University of Arizona") ;
break ;
case 'V':
printf("SSV/JPL") ;
break ;
case 'X':
printf("OTHER") ;
break ;
default:
fprintf(stderr,"ERROR; unknown data producer %c\n",fname[PRODUCER]) ;
return(0) ;
}
printf("\n") ;
time(&unixtime) ;
//printf("Unix time: %ld\n",(long)unixtime) ;
umertime = mertime + MER2UTIME ;
printf("Acquisition time (Earth): %s",ctime(&umertime)) ;
printf("Time zone: %s\n",tzname[0]) ;
if (fname[SCID] == OPPORTUNITY)
sols = 1.0 + (double)(mertime - OPP_SOL1)/SECSPERSOL ;
else
sols = 1.0 + (double)(mertime - SPR_SOL1)/SECSPERSOL ;
isols = (int)sols ;
printf("Acquisition time (Mars): Sol %d %s\n",isols,d2hms((double)(sols - isols))) ;
printf("Current local time (Earth): %s",ctime(&unixtime)) ;
if (fname[SCID] == OPPORTUNITY)
csols = 1.0 + (double)(unixtime - (OPP_SOL1 + MER2UTIME))/SECSPERSOL ;
else
csols = 1.0 + (double)(unixtime - (SPR_SOL1 + MER2UTIME))/SECSPERSOL ;
icsols = (int)csols ;
printf("Current local time (Mars): Sol %d %s\n",icsols,d2hms((double)(csols - icsols))) ;

edays = (unixtime - umertime)/86400. ;
iedays = (int)edays ;
if (iedays == 1)
strcpy(pl,"") ;
else
strcpy(pl,"s") ;
printf("Elapsed time since acquisition: %d day%s, %s\n",iedays,pl,d2hms((double)(edays - iedays))) ;
return(1) ;
}


char * d2hms(double d)
{
int h, m, s ;
static char hms[80] ;

s = (int)(d*84600) ;
h = s/3600 ;
m = (s - h*3600)/60 ;
s %= 60 ;
sprintf(hms,"%02d:%02d:%02d",h,m,s) ;
return (hms) ;
}


// return true if fname is valid data record name
// modifies fname if it has an extension
int isdr(char *fname)
{
int i, len ;
i = 0 ;
len = strlen(fname) ;
while (i len) {
if (fname[i] == '.')
fname[i] = '\0' ;
i++ ;
}
if (strlen(fname) != FNLEN)
return(0) ;

if ((fname[SCID] != OPPORTUNITY) && (fname[SCID] != SPIRIT))
return(0) ;
return(1) ; // close enough for govt work
}


char *bname(char *path)
{
static char basename[MAXFN] ;

int i, len ;

len = strlen(path) ;

i = len - 1 ;
while (i 0) {
if ((path[i] == '/') || (path[i] == '\\'))
break ;
i-- ;
}
if (i == 0)
strncpy(basename,path,MAXFN) ;
else
strncpy(basename,path+i+1,MAXFN) ;

return(basename) ;
}


char *dname(char *path)
{
static char dirname[MAXFN] ;

int i, len ;

len = strlen(path) ;

i = len - 1 ;
while (i 0) {
if ((path[i] == '/') || (path[i] == '\\'))
break ;
i-- ;
}
if (i == 0)
strcpy(dirname,".") ;
else
strncpy(dirname,path,i) ;

return(dirname) ;
}

  #8  
Old March 13th 04, 01:21 AM
Jan Panteltje
external usenet poster
 
Posts: n/a
Default How To Decode The MER Image Filenames

On a sunny day (Fri, 12 Mar 2004 21:11:39 GMT) it happened "Joe Knapp"
wrote in
m:


"Jan Panteltje" wrote
Here's a small application to dump the image info:

[snip]
That compiles fine on Linux,

rawid ./
works OPK,
but
rawid 1M131649564EFF0544P2933M2M1.JPG
does nothing.


Thanks Jan. I fixed the bug & updated the files:

http://www.copperas.com/astro/rawid.exe (Windows command-line executable)
http://www.copperas.com/astro/rawid (Linux command-line i386 executable)
http://www.copperas.com/astro/rawid.c (source code)

Joe

I still got the same C file, here is what I did (tossed MS windows):

// Program by Joe Knapp March 11, 2004
#define MAXFN 1200
#define FNLEN 27
#define OPPORTUNITY '1'
#define SPIRIT '2'
#define SCID 0
#define CAMERAID 1
#define SCCLK_START 2
#define SCCLK_END 10
#define SCCLK_LEN (SCCLK_END - SCCLK_START + 1)
#define PRODTYPE 11
#define SITENO 14
#define DRIVENO 16
#define CMDSEQNO 18
#define CAMEYE 23
#define CAMFILT 24
#define PRODUCER 25
#define VERSION 26
#define UNIX 1
#define MER2UTIME 946727273
#define SECSPERSOL 88775.244
#define OPP_SOL1 128228618
#define SPR_SOL1 126408373
#define CWD "."
#include stdio.h
#include string.h
#include sys/types.h
#include sys/stat.h
#include stdlib.h
#include time.h

#if UNIX
#include dirent.h
#include libgen.h
#include unistd.h
#else
#include windows.h
#include io.h
#endif
char * d2hms(double) ;
int isdr(char *) ;
int dumpinfo(char *) ;
char * bname(char *) ;
char * dname(char *) ;
int main(int, char**) ;
int main(int argc, char *argv[])
{
char fname[MAXFN] ;
int i ;
DIR * cwd ;
struct dirent *dent ;

char datadir[MAXFN] ;
static struct
{
char type[80] ;
} lfilts[8] =
{
"EMPTY (clear)",
"753 nm (20 nm bp) infrared",
"673 nm (16 nm bp) red",
"601 nm (17 nm bp) orange",
"535 nm (20 nm bp) green",
"482 nm (25 nm bp) cyan",
"432 nm (32 nm shortpass) blue",
"440 nm solar ND"
} ;

static struct
{
char type[80] ;
} rfilts[8] = {
"436 nm (37 nm sp) blue",
"754 nm (20 nm bp) infrared",
"803 nm (20 nm bp) infrared",
"864 nm (17 nm bp) infrared",
"904 nm (26 nm bp) infrared",
"934 nm (25 nm bp) infrared",
"1009 nm (38 nm lp) infrared",
"880 nm solar ND"
} ;

if (argc != 2)
{
fprintf(stderr,"usage: %s MER raw image path\n",argv[0]) ;
fprintf(stderr," or %s partial MER raw image path\n",argv[0]) ;
fprintf(stderr," e.g., %s 1F132089069EDN05A6P1141R0M1.jpg\n",argv[0]) ;
fprintf(stderr," %s R0\n",argv[0]) ;
fprintf(stderr," %s images/dir/1F132089069EDN05A6P1141R0M1.jpg\n",argv[0]) ;
fprintf(stderr," %s images/dir/R0\n",argv[0]) ;
exit(1) ;
}

strncpy(fname, bname(argv[1]), MAXFN) ;
strncpy(datadir, dname(argv[1]), MAXFN) ;

fname[MAXFN] = '\0' ;
datadir[MAXFN] = '\0' ;

if (!isdr(fname))
{
long patlen, gotit, gotone ;
char pat[MAXFN] ;

strncpy(pat,fname,MAXFN) ;

patlen = strlen(pat) ;
gotone = 0 ;
gotit = 0 ;

cwd = opendir(datadir) ;
while(dent = readdir(cwd))
{
if (isdr(dent-d_name))
{
gotit = 0 ;
printf("%s %d %s\n",pat,patlen,dent-d_name) ;

for (i = 0 ; i FNLEN ; i++)
if (!strncmp(dent-d_name+i,pat,patlen))
{
gotit = 1 ;
gotone = 1 ;
}

if (gotit)
{
strncpy(fname,dent-d_name,FNLEN) ;
fname[FNLEN] = '\0' ;
printf("-----------------------------------------------------------------------\n") ;
dumpinfo(fname) ;
}
}
}

if (!gotone)
{
fprintf(stderr,"ERROR: could not find MER data file matching %s in directory %s\n",fname,datadir) ;
exit(1) ;
}
else printf("-----------------------------------------------------------------------\n") ;
}
else
{
dumpinfo(fname);
}

return(0) ;
}


int dumpinfo(char *fname)
{
char scclk[SCCLK_LEN+1] ;
long mertime ;
char siteno[3] ;
char driveno[3] ;
char cmdseqno[6] ;
int icmdseqno ;
int filtno ;
time_t unixtime ;
time_t umertime ;
double sols, csols, edays ;
int isols, icsols, iedays ;
int i,len ;
char pl[2] ;
static struct {
char type[80] ;
} lfilts[8] = {
"EMPTY (clear)",
"753 nm (20 nm bp) infrared",
"673 nm (16 nm bp) red",
"601 nm (17 nm bp) orange",
"535 nm (20 nm bp) green",
"482 nm (25 nm bp) cyan",
"432 nm (32 nm shortpass) blue",
"440 nm solar ND"
} ;
static struct {
char type[80] ;
} rfilts[8] = {
"436 nm (37 nm sp) blue",
"754 nm (20 nm bp) infrared",
"803 nm (20 nm bp) infrared",
"864 nm (17 nm bp) infrared",
"904 nm (26 nm bp) infrared",
"934 nm (25 nm bp) infrared",
"1009 nm (38 nm lp) infrared",
"880 nm solar ND"
} ;
i = 0 ;
len = strlen(fname) ;
while (i len) {
if (fname[i] == '.')
fname[i] = '\0' ;
i++ ;
}
if (strlen(fname) != FNLEN) {
fprintf(stderr,"ERROR: %s is not a valid MER data file name\n",fname) ;
return(0) ;
}
printf("Image info for: %s\n",fname) ;
if (fname[SCID] == OPPORTUNITY)
printf("Spacecraft: OPPORTUNITY\n") ;
else if (fname[SCID] == SPIRIT)
printf("Spacecraft: SPIRIT\n") ;
else {
fprintf(stderr,"ERROR: spacecraft ID %c in position %d unknown\n",fname[SCID],SCID+1) ;
return(0) ;
}
switch(fname[CAMERAID]) {
case 'F':
printf("Camera: Forward HAZCAM") ;
break ;
case 'R':
printf("Camera: Rear HAZCAM") ;
break ;
case 'N':
printf("Camera: NAVCAM") ;
break ;
case 'P':
printf("Camera: PANCAM") ;
break ;
case 'M':
printf("Camera: Microscopic Imager") ;
break ;
case 'E':
printf("EDLCAM") ;
break ;
default:
fprintf(stderr,"\nERROR: Camera ID %c in position %d unknown\n",fname[CAMERAID],CAMERAID+1) ;
return(0) ;
}
if (fname[CAMEYE] == 'L')
printf(", left") ;
else if (fname[CAMEYE] == 'R')
printf(", right") ;
if (fname[CAMFILT] != '0') {
if (fname[CAMEYE] == 'L') {
printf(", filter %c",fname[CAMFILT]) ;
filtno = (int)fname[CAMFILT] - (int)'0' - 1;
printf(", %s\n",lfilts[filtno].type) ;
}
else if (fname[CAMEYE] == 'R') {
printf(", filter %c",fname[CAMFILT]) ;
filtno = (int)fname[CAMFILT] - (int)'0' - 1;
printf(", %s\n",rfilts[filtno].type) ;
}
else if (fname[CAMEYE] == 'M') {
if (fname[CAMFILT] == '1')
printf(", dust cover CLOSED\n") ;
else if (fname[CAMFILT] == '2')
printf(", dust cover OPEN\n") ;
else
printf("\n") ;
}
}
else
printf("\n") ;
strncpy(scclk,fname+SCCLK_START,SCCLK_LEN) ;
mertime = atol(scclk) ;
printf("Spacecraft clock: %d (seconds since January 1, 2000, 11:58:55.816 UTC)\n",mertime) ;
printf("Product type: ") ;
if (fname[PRODTYPE] == 'E') {
char pid[3] ;
printf("EDR") ;
strncpy(pid,fname+PRODTYPE+1,2) ;
pid[2] = '\0' ;
if (!strcmp(pid,"FF"))
printf(" full frame") ;
else if (!strcmp(pid,"SF"))
printf(" sub-frame") ;
else if (!strcmp(pid,"DN"))
printf(" downsampled") ;
else if (!strcmp(pid,"TH"))
printf(" thumbnail") ;
else if (!strcmp(pid,"RS"))
printf(" row-summed") ;
else if (!strcmp(pid,"CS"))
printf(" column-summed") ;
else if (!strcmp(pid,"RP"))
printf(" reference pixels") ;
else if (!strcmp(pid,"HG"))
printf(" histogram") ;
else {
fprintf(stderr,"\nERROR: Unknown EDR type %s\n",pid) ;
return(0) ;
}
}
else
printf("RDR") ;
printf("\n") ;
strncpy(siteno,fname+SITENO,2) ;
siteno[2] = '\0' ;
printf("Site number: %s\n",siteno) ;
strncpy(driveno,fname+DRIVENO,2) ;
driveno[2] = '\0' ;
printf("Drive number: %s\n",driveno) ;
strncpy(cmdseqno,fname+CMDSEQNO,5) ;
cmdseqno[5] = '\0' ;
printf("Command sequence number: %s ",cmdseqno) ;
switch(fname[CMDSEQNO]) {
case 'C':
printf("(cruise)") ;
break ;
case 'D':
printf("(IDD & RAT)") ;
break ;
case 'E':
printf("(engineering)") ;
break ;
case 'F':
printf("(flight software seq rejected)") ;
break ;
case 'G':
printf("(spare)") ;
break ;
case 'K':
printf("(spare)") ;
break ;
case 'M':
printf("(master)") ;
break ;
case 'N':
printf("(in-situ instrument)") ;
break ;
case 'P':
printf("(PMA or remote sensing instrument)") ;
break ;
case 'R':
printf("(rover driving)") ;
break ;
case 'S':
printf("(submaster)") ;
break ;
case 'T':
printf("(test)") ;
break ;
case 'W':
printf("(seq triggered by comm window)") ;
break ;
case 'X':
printf("(contingency)") ;
break ;
case 'Y':
printf("(spare)") ;
break ;
case 'Z':
printf("(SCM seqs)") ;
break ;
default:
break ;
}
icmdseqno = atoi(cmdseqno+1) ;
if ((icmdseqno 4096) || (icmdseqno 0)) {
fprintf(stderr,"ERROR: invalid command sequence number %d\n",icmdseqno) ;
return(0) ;
}
if (icmdseqno 500)
printf(" misc. imaging") ;
else if (icmdseqno 1000)
printf(" unallocated") ;
else if (icmdseqno 1500)
printf(" HAZCAM") ;
else if (icmdseqno 2000)
printf(" NAVCAM") ;
else if (icmdseqno 2900)
printf(" PANCAM") ;
else if (icmdseqno 3000)
printf(" MI") ;
else if (icmdseqno 4000)
printf(" Mini-TES") ;
else if (icmdseqno 4096)
printf(" misc. PMA") ;
printf("\n") ;
printf("Producer: ") ;
switch(fname[PRODUCER]) {
case 'A':
printf("Arizona State University") ;
break ;
case 'C':
printf("Cornell University") ;
break ;
case 'F':
printf("USGS") ;
break ;
case 'J':
printf("Johannes Gutenberg University") ;
break ;
case 'M':
printf("MIPL/JPL") ;
break ;
case 'N':
printf("NASA Ames Research") ;
break ;
case 'P':
printf("Max Plank Institute") ;
break ;
case 'S':
printf("SOAS/JPL") ;
break ;
case 'U':
printf("University of Arizona") ;
break ;
case 'V':
printf("SSV/JPL") ;
break ;
case 'X':
printf("OTHER") ;
break ;
default:
fprintf(stderr,"ERROR; unknown data producer %c\n",fname[PRODUCER]) ;
return(0) ;
}
printf("\n") ;
time(&unixtime) ;
//printf("Unix time: %ld\n",(long)unixtime) ;
umertime = mertime + MER2UTIME ;
printf("Acquisition time (Earth): %s",ctime(&umertime)) ;
printf("Time zone: %s\n",tzname[0]) ;
if (fname[SCID] == OPPORTUNITY)
sols = 1.0 + (double)(mertime - OPP_SOL1)/SECSPERSOL ;
else
sols = 1.0 + (double)(mertime - SPR_SOL1)/SECSPERSOL ;
isols = (int)sols ;
printf("Acquisition time (Mars): Sol %d %s\n",isols,d2hms((double)(sols - isols))) ;
printf("Current local time (Earth): %s",ctime(&unixtime)) ;
if (fname[SCID] == OPPORTUNITY)
csols = 1.0 + (double)(unixtime - (OPP_SOL1 + MER2UTIME))/SECSPERSOL ;
else
csols = 1.0 + (double)(unixtime - (SPR_SOL1 + MER2UTIME))/SECSPERSOL ;
icsols = (int)csols ;
printf("Current local time (Mars): Sol %d %s\n",icsols,d2hms((double)(csols - icsols))) ;

edays = (unixtime - umertime)/86400. ;
iedays = (int)edays ;
if (iedays == 1)
strcpy(pl,"") ;
else
strcpy(pl,"s") ;
printf("Elapsed time since acquisition: %d day%s, %s\n",iedays,pl,d2hms((double)(edays - iedays))) ;
return(1) ;
}


char * d2hms(double d)
{
int h, m, s ;
static char hms[80] ;

s = (int)(d*84600) ;
h = s/3600 ;
m = (s - h*3600)/60 ;
s %= 60 ;
sprintf(hms,"%02d:%02d:%02d",h,m,s) ;
return (hms) ;
}


// return true if fname is valid data record name
// modifies fname if it has an extension
int isdr(char *fname)
{
int i, len ;
i = 0 ;
len = strlen(fname) ;
while (i len) {
if (fname[i] == '.')
fname[i] = '\0' ;
i++ ;
}
if (strlen(fname) != FNLEN)
return(0) ;

if ((fname[SCID] != OPPORTUNITY) && (fname[SCID] != SPIRIT))
return(0) ;
return(1) ; // close enough for govt work
}


char *bname(char *path)
{
static char basename[MAXFN] ;

int i, len ;

len = strlen(path) ;

i = len - 1 ;
while (i 0) {
if ((path[i] == '/') || (path[i] == '\\'))
break ;
i-- ;
}
if (i == 0)
strncpy(basename,path,MAXFN) ;
else
strncpy(basename,path+i+1,MAXFN) ;

return(basename) ;
}


char *dname(char *path)
{
static char dirname[MAXFN] ;

int i, len ;

len = strlen(path) ;

i = len - 1 ;
while (i 0) {
if ((path[i] == '/') || (path[i] == '\\'))
break ;
i-- ;
}
if (i == 0)
strcpy(dirname,".") ;
else
strncpy(dirname,path,i) ;

return(dirname) ;
}

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Information blackout (mars rover) jimmydevice Policy 24 February 4th 04 06:38 PM
U.Hawaii Astronomers Release First Image from Gigantic New InfraredCamera (Forwarded) Andrew Yee Astronomy Misc 0 November 14th 03 08:31 PM
New Image of Comet Halley in the Cold Ron Baalke Science 0 September 2nd 03 04:31 PM
Is a Correct Image Finder Really Correct? Alan French Amateur Astronomy 0 August 1st 03 04:10 AM
Your opinions, please... LarryG Amateur Astronomy 23 July 28th 03 04:30 AM


All times are GMT +1. The time now is 12:39 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 SpaceBanter.com.
The comments are property of their posters.