OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
solar_xray.c
Go to the documentation of this file.
1 /*****************************************************************
2  * File: solar_xray.c
3  *
4  * Modification history:
5  *****************************************************************/
6 #include <stdio.h>
7 #include <stdint.h>
8 #include <stdlib.h>
9 #include <string.h>
10 #include <libgen.h>
11 #include "hdf5.h"
12 
13 double ymds2unix(short year, short month, short day, double secs);
14 void unix2yds(double usec, short *year, short *day, double *secs);
15 
16 int main(int argc, char *argv[]) {
17 
18  int32_t i, j, k;
19 
20  int16_t yr, mon, dy, doy;
21  double secs;
22  float flux[288 * 5];
23  char junk[120], outfile[80], buffer[80];
24  FILE *fp;
25 
26  hsize_t dimsf[1]; /* dataset dimensions */
27 
28  /*
29  * Data and output buffer initialization.
30  */
31  hid_t file, dataset; /* handles */
32  hid_t dataspace;
33 
34  strcpy(junk, basename(argv[1]));
35 
36  memcpy(buffer, &junk[0], 4);
37  buffer[4] = 0;
38  yr = (int16_t) atoi(buffer);
39 
40  memcpy(buffer, &junk[4], 2);
41  buffer[2] = 0;
42  mon = (int16_t) atoi(buffer);
43 
44  memcpy(buffer, &junk[6], 2);
45  buffer[2] = 0;
46  dy = (int16_t) atoi(buffer);
47 
48  unix2yds(ymds2unix(yr, mon, dy, 0.0), &yr, &doy, &secs);
49 
50  sprintf(outfile, "%s%d%03d%s", "N", yr, doy, "00_XRAY_GOES_24h.h5");
51 
52  printf("Creating: %s\n", outfile);
53 
54  file = H5Fcreate(outfile, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
55 
56  dimsf[0] = 288 * 5;
57  dataspace = H5Screate_simple(1, dimsf, NULL);
58 
59 
60  fp = fopen(argv[1], "r");
61  for (i = 0; i < 19; i++) fgets(junk, 120, fp);
62 
63  for (i = 0; i < 288 * 5; i++) {
64  fgets(junk, 120, fp);
65  memcpy(buffer, &junk[45], 15);
66  buffer[15] = 0;
67  flux[i] = (float) atof(buffer);
68  }
69 
70 
71  /*
72  * Create a new dataset within the file using defined dataspace and
73  * default dataset creation properties.
74  */
75  dataset = H5Dcreate1(file, "1min_xray_irradiance", H5T_NATIVE_FLOAT,
76  dataspace, H5P_DEFAULT);
77 
78  /*
79  * Write the data to the dataset using default transfer properties.
80  */
81  H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL,
82  H5P_DEFAULT, flux);
83 
84 
85  /*
86  * Close/release resources.
87  */
88  H5Sclose(dataspace);
89  H5Dclose(dataset);
90  H5Fclose(file);
91 
92 
93  return 0;
94 }
int j
Definition: decode_rs.h:73
int32_t day
#define NULL
Definition: decode_rs.h:63
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
void unix2yds(double usec, short *year, short *day, double *secs)
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
#define basename(s)
Definition: l0chunk_modis.c:29
double ymds2unix(short year, short month, short day, double secs)
int i
Definition: decode_rs.h:71
How many dimensions is the output array Default is Not sure if anything above will work correctly strcpy(l2prod->title, "no title yet")
int main(int argc, char *argv[])
Definition: solar_xray.c:16
int k
Definition: decode_rs.h:73