static char rcsid[]="$Id: testedf.c,v 1.0 1992/07/28 23:07:53 maurer $"; /*********************************************************************** testedf.c Function: program illustrates how to read EDF emissivity file This file is part of the STARLab Magellan Altimeter Data Processing Software. Joe Twicken, June 1992. ***********************************************************************/ /* $Log: testedf.c,v $ * Revision 1.0 1992/07/28 23:07:53 maurer * Initial revision * */ #include #include "scvdr.h" #include "scvparse.h" #include "scvparse.i" #include "scv_rdr.i" #define RECNUM 10 /* Number data recs to read at once */ int main(argc,argv) int argc; /* Number of program arguments */ char *argv[]; /* Argument strings */ { sfdu sf1; /* CCSDS header SFDU label */ sfdu sf2; /* Keyword/value SFDU label */ sfdu sf3; /* Emissivity header SFDU label */ sfdu sf4; /* Aggr start marker SFDU label */ keyval_t *kv2; /* Catalog keyword/value list */ keyval_t *kv4; /* Aggr smarker keyword/value list */ eh_rec eh; /* Emissivity header record */ er_rec er[RECNUM]; /* Emissivity data records */ int orb,ver; /* Orbit and version */ int nrec; /* Number of data records remaining */ int nread; /* Number of data records to read */ int nfoot; /* Footprint number */ float Trcv; /* Receiver physical temperature */ char product_file_name[80];/* Product file name */ FILE *f_edf; /* EDF file pointer */ /* Check usage */ if (argc != 2) { fprintf(stderr,"usage: testedf edf_file\n"); exit(1); } /* Open the EDF file for reading */ if ((f_edf = fopen(argv[1],"r")) == NULL) { fprintf(stderr, "testedf: [main] can't open %s\n",argv[1]); exit(2); } /* Read the 4 header SFDU's. Remember to free the keyword/value list pointers with free_catalog() when they are no longer needed */ if (hdr_read(f_edf,&sf1,&sf2,&kv2,&sf3,&eh,&sf4,&kv4)) { fprintf(stderr, "testedf: [main] can't read edf header\n"); exit(3); } /* Do something with the header values. The example here shows how to get the orbit, version, record number and product file name */ orb = eh.eh_orb; ver = eh.eh_ver; nrec = eh.eh_nrec; strncpy(product_file_name,kv2[0].val,sizeof(product_file_name)); /* Read emissivity data records, 10 at a time */ while (nrec > 0) { /* Read the data records 10 at a time. Note that edf_readn() returns the number of records successfully read */ nread = (nrec > RECNUM) ? RECNUM : nrec; if (edf_readn(f_edf,er,nread) != nread) { fprintf(stderr, "testedf: [main] can't read edf data recs\n"); exit(4); } nrec -= nread; /* Do somethings with the data values. The example here shows how to read the footprint number and the receiver physical temperature for the first data record */ nfoot = er[0].er_nfoot; Trcv = er[0].er_Trcv; } /* Free the header keyword/value lists */ free_catalog(kv2); free_catalog(kv4); /* Close the EDF file */ fclose(f_edf); return(0); }