File: SubsetPoint.c

package info (click to toggle)
hdf-eos4 3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,960 kB
  • sloc: ansic: 43,570; sh: 11,324; fortran: 9,649; makefile: 261
file content (120 lines) | stat: -rw-r--r-- 2,632 bytes parent folder | download | duplicates (5)
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
#include "hdf.h"


main()
{

    intn            i, status;
    
    int32           ptfid, PTid, regionID, periodID, size;
    int32           level;
    
    float64         cornerlon[2], cornerlat[2], starttime, stoptime;
    float64        *datbuf;
    


    /*
     * Open the HDF point file, "PointFile.hdf".
     */

    ptfid = PTopen("PointFile_created_with_hadeos_sample_file_writer_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_RDWR);
    if(ptfid == -1)
      {
	printf("\t\tError: Unable to open file PointFile.hdf\n");
	return -1;
       }


    if (ptfid != -1)
    {

	PTid = PTattach(ptfid, "FloatBuoy Point");
	if (PTid == -1)
	  {
	    printf("\t\tError: Cannot attach point \"FloatBuoy Point\"\n");
	    return -1;
	  }
	
	if (PTid != -1)
	{
	    cornerlon[0] = -145.;
	    cornerlat[0] = -15.;
	    cornerlon[1] = -135;
	    cornerlat[1] = -8.;

	    regionID = PTdefboxregion(PTid, cornerlon, cornerlat);
	    if (regionID == -1)
	      {
		printf("\t\tError: Cannot define subsetting region for point \"FloatBuoy Point\"\n");
		return -1;
	      }
	    level = 1;
	    status = PTregioninfo(PTid, regionID, level, 
				  "Longitude,Latitude", &size);
	    if (status == -1)
	      {
		printf("\t\tError: Cannot get region info for point \"FloatBuoy Point\"\n");
		return -1;
	      }
	    datbuf = (float64 *) malloc(size);

	    status = PTextractregion(PTid, regionID, level, 
				  "Longitude,Latitude", (char *) datbuf);
	    if (status == -1)
	      {
		printf("\t\tError: Cannot extract region for point \"FloatBuoy Point\"\n");
		return -1;
	      }
	    for (i=0; i<size/16; i++)
	    {
		printf("%d %lf %lf\n", i, datbuf[2*i], datbuf[2*i+1]);
	    }
	    
	    free(datbuf);


	    starttime = 35208757.6;
	    stoptime = 35984639.2;
	    
	    periodID = PTdeftimeperiod(PTid, starttime, stoptime);
	    if (periodID == -1)
	    {
	      printf("\t\tError: Cannot define time period for point \"FloatBuoy Point\"\n");
	      return -1;
	    }
	    level = 1;
	    status = PTperiodinfo(PTid, periodID, level, 
				  "Time", &size);
	    if (status == -1)
	      {
		printf("\t\tError: Cannot get period info for point \"FloatBuoy Point\"\n");
		return -1;
	      }
	    datbuf = (float64 *) malloc(size);

	    status = PTextractperiod(PTid, periodID, level, 
				  "Time", datbuf);

	    if (status == -1)
	      {
		printf("\t\tError: Cannot extract period for point \"FloatBuoy Point\"\n");
		return -1;
	      }
	    for (i=0; i<size/8; i++)
	    {
		printf("%d %lf\n", i, datbuf[i]);
	    }

	    free(datbuf);
	    


	}
    }

    PTdetach(PTid);
    PTclose(ptfid);

    return 0;
}