OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
swh.c
Go to the documentation of this file.
1 #include <stdint.h>
2 #include <string.h>
3 #include "hdf5.h"
4 
5 // wget http://nomads.ncep.noaa.gov/pub/data/nccf/com/wave/prod/wave.yyyymmdd/nww3.t00z.grib.grib2
6 // wgrib2 -match HTSGW:surface:anl nww3.t00z.grib.grib2 -bin swh.dat
7 // swh swh.dat Nyyyydoyhr_SWH_NCEP_6h.h5
8 
9 int main(int argc, char *argv[]) {
10  hsize_t dimsf[2]; /* dataset dimensions */
11 
12  /*
13  * Data and output buffer initialization.
14  */
15  hid_t file, dataset; /* handles */
16  hid_t dataspace;
17 
18  float swh[157 * 288], buf[288];
19 
20  int i, j;
21  uint32_t hdr;
22 
23  FILE *fp;
24 
25  // Read in binary swh
26  fp = fopen(argv[1], "rb");
27  fread(&hdr, sizeof (uint32_t), 1, fp);
28  fread(swh, 157 * 288 * sizeof (float), 1, fp);
29  fclose(fp);
30 
31  for (i = 0; i < 157 * 288; i++) if (swh[i] > 1e20) swh[i] = -999.;
32 
33  // Flip about equator (if not already flipped) JMG 03/18/14
34  if (swh[39] == -999) {
35  for (i = 0; i < 157 / 2; i++) {
36  memcpy(buf, &swh[288 * i], 288 * sizeof (float));
37  memcpy(&swh[288 * i], &swh[288 * (156 - i)], 288 * sizeof (float));
38  memcpy(&swh[288 * (156 - i)], buf, 288 * sizeof (float));
39  }
40  }
41 
42  file = H5Fcreate(argv[2], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
43 
44  dimsf[0] = 157;
45  dimsf[1] = 288;
46  dataspace = H5Screate_simple(2, dimsf, NULL);
47 
48  /*
49  * Create a new dataset within the file using defined dataspace and
50  * default dataset creation properties.
51  */
52  dataset = H5Dcreate1(file, "significant wave height", H5T_NATIVE_FLOAT,
53  dataspace, H5P_DEFAULT);
54 
55  /*
56  * Write the data to the dataset using default transfer properties.
57  */
58  H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL,
59  H5P_DEFAULT, swh);
60 
61  /*
62  * Close/release resources.
63  */
64  H5Sclose(dataspace);
65  H5Dclose(dataset);
66  H5Fclose(file);
67 
68  return 0;
69 }
int j
Definition: decode_rs.h:73
#define NULL
Definition: decode_rs.h:63
int main(int argc, char *argv[])
Definition: swh.c:9
no change in intended resolving MODur00064 Corrected handling of bad ephemeris attitude resolving resolving GSFcd00179 Corrected handling of fill values for[Sensor|Solar][Zenith|Azimuth] resolving MODxl01751 Changed to validate LUT version against a value retrieved from the resolving MODxl02056 Changed to calculate Solar Diffuser angles without adjustment for estimated post launch changes in the MODIS orientation relative to incidentally resolving defects MODxl01766 Also resolves MODxl01947 Changed to ignore fill values in SCI_ABNORM and SCI_STATE rather than treating them as resolving MODxl01780 Changed to use spacecraft ancillary data to recognise when the mirror encoder data is being set by side A or side B and to change calculations accordingly This removes the need for seperate LUTs for Side A and Side B data it makes the new LUTs incompatible with older versions of the and vice versa Also resolves MODxl01685 A more robust GRing algorithm is being which will create a non default GRing anytime there s even a single geolocated pixel in a granule Removed obsolete messages from seed file
Definition: HISTORY.txt:413
but the philosophy of the MODIS L1 routines is that the output granule must be if it contains even a single packet of useable data Some of the spacecraft ancillary data in L0 datasets is available only on a cycle that repeates every seconds MOD_PR01 therefore looks backwards up to for such packets If the seconds preceeding the start of an MOD_PR01 run are covered by a different L0 dataset
Definition: MOD_PR01_pr.txt:33
int i
Definition: decode_rs.h:71