Go to the documentation of this file.
22 where: filename is the full path to a SeaWiFS level-2 file that contains\n\
23 computed depth data.\n\
24 This program maps SeaWiFS level-2 depth data to bins of a Plate Carree\n\
25 projection that extends from 35 North to 35 South and from 180 West\n\
26 to 180 East. The results are written to standard output as a series\n\
27 of ASCII text records. Each output record contains a bin number and\n\
28 pixel value separated by whitespace. Each bin represents one 0.01 by\n\
29 0.01 degree subregion of the aforementioned area. Bins are numbered\n\
30 from 0 to 251,999,999. Depths are expressed in meters.\n"
32 #define FILENAME argv[1]
33 #define LAC_PIXEL_INSET 200
36 #define READ_GLBL_ATTR(nam,ptr) { \
37 if(SDreadattr(sd_id,SDfindattr(sd_id,(nam)),(VOIDP)(ptr))){ \
39 "-E- %s line %d: Could not get global attribute, %s, from file, %s.\n", \
40 __FILE__,__LINE__,(nam),FILENAME); \
41 return(EXIT_FAILURE); \
45 #define MALLOC(ptr,typ,num) { \
46 (ptr) = (typ *)malloc((num) * sizeof(typ)); \
48 fprintf(stderr,"-E- %s line %d: Memory allocation failure.\n", \
54 #define READ_SDS(nam,ptr,s0,s1,s2,e0,e1,e2) { \
55 int32 start[3],edge[3]; \
56 edge[0]=(e0); edge[1]=(e1); edge[2]=(e2); \
57 start[0]=(s0); start[1]=(s1); start[2]=(s2); \
58 if(SDreaddata(SDselect(sd_id, SDnametoindex(sd_id, (nam))), \
59 start, NULL, edge, (VOIDP)(ptr)) == FAIL){ \
60 fprintf(stderr,"-E- %s line %d: Could not read SDS, %s.\n", \
61 __FILE__,__LINE__,(nam)); \
70 int main(
int argc,
char *argv[]) {
72 int32
npix, nscans, num_cntl_pts, lacstart, lacsub;
81 return (EXIT_FAILURE);
85 sd_id = SDstart(
FILENAME, DFACC_RDONLY);
87 fprintf(
stderr,
"-E- %s line %d: SDstart failed for file, %s.\n",
89 return (EXIT_FAILURE);
102 "-E- %s line %d: Input pixels are too close to the edge of the swath.\n",
104 return (EXIT_FAILURE);
108 }
else if (lacsub == 4) {
112 "-E- %s line %d: Input pixels are too close to the edge of the swath.\n",
114 return (EXIT_FAILURE);
119 fprintf(
stderr,
"-E- %s line %d: ", __FILE__, __LINE__);
121 "Unexpected number of pixels per scanline (%d) in file, %s.\n",
123 return (EXIT_FAILURE);
125 if (pix_0 < 0) pix_0 = 0;
126 if (pix_n >=
npix) pix_n =
npix - 1;
129 "-E- %s line %d: Bad scene dimension: nscans=%d in file, %s.\n",
130 __FILE__, __LINE__, nscans,
FILENAME);
131 return (EXIT_FAILURE);
138 for (
s = 0;
s < nscans;
s++) {
146 READ_SDS(
"nflag", nflag,
s, 0, 0, 1, 8, 1);
147 if (nflag[0] == 1)
continue;
148 if (nflag[6] == 2)
continue;
155 for (
p = pix_0;
p <= pix_n;
p++) {
158 if (
lat[
p] > 35 ||
lat[
p] <= -35)
continue;
168 printf(
"%d %g\n", bin,
data[
p]);
177 if (SDend(sd_id) ==
FAIL) {
178 fprintf(
stderr,
"-W- %s line %d: SDend failed for file, %s.\n",
193 static float32 *cntl_pts, *spl2nderiv;
208 int32
p, *cntl_pt_cols;
209 MALLOC(cntl_pt_cols, int32, nc);
210 READ_SDS(
"cntl_pt_cols", cntl_pt_cols, 0, 0, 0, nc, 0, 0);
211 MALLOC(cntl_pts, float32, nc);
212 for (
p = 0;
p < nc;
p++) {
213 cntl_pts[
p] = (float32) cntl_pt_cols[
p];
216 MALLOC(spl2nderiv, float32, nc);
217 MALLOC(lati, float32, np);
218 MALLOC(longi, float32, np);
234 for (
p = 1;
p < nc;
p++) {
247 for (
p = 0;
p < np;
p++) {
251 for (
p = 0;
p < np;
p++) {
254 while (longi[
p] >= 180) longi[
p] -= 360;
255 while (longi[
p] < -180) longi[
p] += 360;
void get_scan_coords(int32, int32, int32, float32 **, float32 **)
real(single), dimension(:,:), allocatable longitude
real(single), dimension(:,:), allocatable latitude
subroutine spline(s, x, y, n, in, t, il, iu, vl, vu, e, u)
#define MALLOC(ptr, typ, num)
no change in intended resolving MODur00064 Corrected handling of bad ephemeris attitude data
subroutine splint(xa, ya, y2a, n, x, y)
#define READ_SDS(nam, ptr, s0, s1, s2, e0, e1, e2)
int main(int argc, char *argv[])
#define READ_GLBL_ATTR(nam, ptr)