27 days = timediff / 86400.;
30 nday = floor(days * 24.) + 1;
31 sprintf(
period,
"%d-hour", nday);
33 }
else if (days >= 0.75 && days < 1.5) {
35 }
else if (days >= 1.5 && days < 27.5) {
37 sprintf(
period,
"%d-day", nday);
39 }
else if (days >= 27.5 && days < 31.5) {
41 }
else if (days > 31.5 && days < 32.75) {
44 }
else if (days >= 32.75 && days < 364) {
45 nday = round(days / 30.);
46 sprintf(
period,
"%d-month", nday);
48 }
else if (days > 364 && days < 367) {
50 }
else if (days >= 367) {
51 nday = round(days / 365.);
52 sprintf(
period,
"%d-year", nday);
65 SDsetattr(sd_id,
"Product Name", DFNT_CHAR, strlen(buf) + 1, buf);
68 strcat(buf,
" Level-3 Binned Data");
69 SDsetattr(sd_id,
"Title", DFNT_CHAR, strlen(buf) + 1, buf);
72 SDsetattr(sd_id,
"Sensor Name", DFNT_CHAR, strlen(buf) + 1, buf);
75 SDsetattr(sd_id,
"Mission", DFNT_CHAR, strlen(buf) + 1, buf);
79 SDsetattr(sd_id,
"Product Type", DFNT_CHAR, strlen(buf) + 1, buf);
82 SDsetattr(sd_id,
"Processing Version", DFNT_CHAR, strlen(buf) + 1, buf);
85 SDsetattr(sd_id,
"Software Name", DFNT_CHAR, strlen(buf) + 1, buf);
88 SDsetattr(sd_id,
"Software Version", DFNT_CHAR, strlen(buf) + 1, buf);
94 SDsetattr(sd_id,
"Processing Time", DFNT_CHAR, strlen(buf) + 1, buf);
97 SDsetattr(sd_id,
"Processing Control", DFNT_CHAR, strlen(buf) + 1, buf);
100 SDsetattr(sd_id,
"Input Parameters", DFNT_CHAR, strlen(buf) + 1, buf);
103 SDsetattr(sd_id,
"Input Files", DFNT_CHAR, strlen(buf) + 1, buf);
106 SDsetattr(sd_id,
"L2 Flag Names", DFNT_CHAR, strlen(buf) + 1, buf);
129 SDsetattr(sd_id,
"Start Time", DFNT_CHAR, strlen(buf) + 1, buf);
132 SDsetattr(sd_id,
"End Time", DFNT_CHAR, strlen(buf) + 1, buf);
141 strcpy(buf,
"degrees North");
142 SDsetattr(sd_id,
"Latitude Units", DFNT_CHAR, strlen(buf) + 1, buf);
143 strcpy(buf,
"degrees East");
144 SDsetattr(sd_id,
"Longitude Units", DFNT_CHAR, strlen(buf) + 1, buf);
148 SDsetattr(sd_id,
"Easternmost Longitude",
DFNT_FLOAT32, 1, &meta_l3b->
east);
149 SDsetattr(sd_id,
"Westernmost Longitude",
DFNT_FLOAT32, 1, &meta_l3b->
west);
152 SDsetattr(sd_id,
"Data Bins",
DFNT_INT32, 1, &tmpInt);
157 SDsetattr(sd_id,
"Units", DFNT_CHAR, strlen(buf) + 1, buf);
159 SDsetattr(sd_id,
"Bin Resolution", DFNT_CHAR, strlen(buf) + 1, buf);
170 setAttr(ds_id,
"product_name", NC_CHAR, strlen(buf) + 1, buf);
173 strcat(buf,
" Level-3 Binned Data");
174 setAttr(ds_id,
"title", NC_CHAR, strlen(buf) + 1, buf);
177 setAttr(ds_id,
"instrument", NC_CHAR, strlen(buf) + 1, buf);
180 if (strcmp(meta_l3b->
mission,
"") != 0)
181 setAttr(ds_id,
"platform", NC_CHAR, strlen(buf) + 1, buf);
185 setAttr(ds_id,
"temporal_range", NC_CHAR, strlen(buf) + 1, buf);
188 setAttr(ds_id,
"end_orbit_number", NC_INT, 1, &meta_l3b->
end_orb);
191 setAttr(ds_id,
"date_created", NC_CHAR, strlen(buf) + 1, buf);
194 setAttr(ds_id,
"processing_version", NC_CHAR, strlen(buf) + 1, buf);
196 strcpy(buf,
"satellite observations from ");
197 strncat(buf, meta_l3b->
sensor,
sizeof(buf) - strlen(meta_l3b->
sensor) - 1);
198 if (strcmp(meta_l3b->
mission,
"") != 0){
199 strncat(buf,
"-",
sizeof(buf));
200 strncat(buf, meta_l3b->
mission,
sizeof(buf) - strlen(meta_l3b->
mission) - 1);
202 setAttr(ds_id,
"source", NC_CHAR, strlen(buf) + 1, buf);
205 setAttr(ds_id,
"history", NC_CHAR, strlen(buf) + 1, buf);
208 setAttr(ds_id,
"time_coverage_start", NC_CHAR, strlen(buf) + 1, buf);
211 setAttr(ds_id,
"time_coverage_end", NC_CHAR, strlen(buf) + 1, buf);
213 setAttr(ds_id,
"northernmost_latitude", NC_FLOAT, 1,
214 (VOIDP) & meta_l3b->
north);
215 setAttr(ds_id,
"southernmost_latitude", NC_FLOAT, 1,
216 (VOIDP) & meta_l3b->
south);
217 setAttr(ds_id,
"easternmost_longitude", NC_FLOAT, 1,
218 (VOIDP) & meta_l3b->
east);
219 setAttr(ds_id,
"westernmost_longitude", NC_FLOAT, 1,
220 (VOIDP) & meta_l3b->
west);
222 setAttr(ds_id,
"geospatial_lat_max", NC_DOUBLE, 1, (VOIDP) &
val);
224 setAttr(ds_id,
"geospatial_lat_min", NC_DOUBLE, 1, (VOIDP) &
val);
226 setAttr(ds_id,
"geospatial_lon_max", NC_DOUBLE, 1, (VOIDP) &
val);
228 setAttr(ds_id,
"geospatial_lon_min", NC_DOUBLE, 1, (VOIDP) &
val);
230 strcpy(buf,
"degrees_north");
231 setAttr(ds_id,
"geospatial_lat_units", NC_CHAR, strlen(buf) + 1, buf);
233 strcpy(buf,
"degrees_east");
234 setAttr(ds_id,
"geospatial_lon_units", NC_CHAR, strlen(buf) + 1, buf);
236 int len = strlen(resString) + 1;
237 setAttr(ds_id,
"geospatial_lat_resolution", NC_CHAR, len , (VOIDP)resString);
238 setAttr(ds_id,
"geospatial_lon_resolution", NC_CHAR, len , (VOIDP)resString);
239 setAttr(ds_id,
"spatialResolution", NC_CHAR, len , (VOIDP)resString);
245 setAttr(ds_id,
"data_bins", NC_INT, 1, (VOIDP) &tmpInt);
248 setAttr(ds_id,
"percent_data_bins", NC_FLOAT, 1,
252 setAttr(ds_id,
"units", NC_CHAR, strlen(buf) + 1, buf);
255 setAttr(ds_id,
"binning_scheme", NC_CHAR, strlen(buf) + 1, buf);
257 strcpy(buf,
"Ocean Biology Processing Group (NASA/GSFC/OBPG)");
258 setAttr(ds_id,
"project", NC_CHAR, strlen(buf) + 1, buf);
261 "NASA Goddard Space Flight Center, Ocean Ecology Laboratory, Ocean Biology Processing Group");
262 setAttr(ds_id,
"institution", NC_CHAR, strlen(buf) + 1, buf);
264 strcpy(buf,
"CF Standard Name Table v36");
265 setAttr(ds_id,
"standard_name_vocabulary", NC_CHAR, strlen(buf) + 1, buf);
267 strcpy(buf,
"CF-1.6 ACDD-1.3");
268 setAttr(ds_id,
"Conventions", NC_CHAR, strlen(buf) + 1, buf);
270 char const *naming_authority =
"gov.nasa.gsfc.sci.oceandata";
271 strcpy(buf, naming_authority);
272 setAttr(ds_id,
"naming_authority", NC_CHAR, strlen(buf) + 1, buf);
275 if (strcmp(meta_l3b->
pversion,
"Unspecified") != 0) {
283 setAttr(ds_id,
"id", NC_CHAR, strlen(buf) + 1, buf);
285 char const *license =
286 "https://science.nasa.gov/earth-science/earth-science-data/data-information-policy/";
288 setAttr(ds_id,
"license", NC_CHAR, strlen(buf) + 1, buf);
290 strcpy(buf,
"NASA/GSFC/OBPG");
291 setAttr(ds_id,
"creator_name", NC_CHAR, strlen(buf) + 1, buf);
292 setAttr(ds_id,
"publisher_name", NC_CHAR, strlen(buf) + 1, buf);
294 strcpy(buf,
"data@oceancolor.gsfc.nasa.gov");
295 setAttr(ds_id,
"creator_email", NC_CHAR, strlen(buf) + 1, buf);
296 setAttr(ds_id,
"publisher_email", NC_CHAR, strlen(buf) + 1, buf);
298 strcpy(buf,
"https://oceandata.sci.gsfc.nasa.gov");
299 setAttr(ds_id,
"creator_url", NC_CHAR, strlen(buf) + 1, buf);
300 setAttr(ds_id,
"publisher_url", NC_CHAR, strlen(buf) + 1, buf);
303 setAttr(ds_id,
"processing_level", NC_CHAR, strlen(buf) + 1, buf);
306 setAttr(ds_id,
"cdm_data_type", NC_CHAR, strlen(buf) + 1, buf);
308 if(meta_l3b->
doi[0]) {
309 strcpy(buf,
"https://dx.doi.org");
310 setAttr(ds_id,
"identifier_product_doi_authority",
311 NC_CHAR, strlen(buf) + 1, buf);
312 setAttr(ds_id,
"identifier_product_doi", NC_CHAR, strlen(meta_l3b->
doi) + 1, meta_l3b->
doi);
316 strcpy(buf,
"NASA Global Change Master Directory (GCMD) Science Keywords");
317 setAttr(ds_id,
"keywords_vocabulary", NC_CHAR, strlen(buf) + 1, buf);
321 nc_def_grp(ds_id.
fid,
"processing_control", &ds_id.
fid);
324 setAttr(ds_id,
"software_name", NC_CHAR, strlen(buf) + 1, buf);
327 setAttr(ds_id,
"software_version", NC_CHAR, strlen(buf) + 1, buf);
330 setAttr(ds_id,
"input_sources", NC_CHAR, strlen(buf) + 1, buf);
333 setAttr(ds_id,
"l2_flag_names", NC_CHAR, strlen(buf) + 1, buf);
335 nc_def_grp(ds_id.
fid,
"input_parameters", &ds_id.
fid);
338 char *token = strtok_r(cleanInputParams,
"\n", &end_str);
340 while (token !=
NULL) {
343 char *
name = strtok_r(token,
"=", &end_token);
345 strcpy(tmp_buf, strtok_r(
NULL,
"\n", &end_token));
349 token = strtok_r(
NULL,
"\n", &end_str);
351 free(cleanInputParams);