28 int calcrand_(
double* RAT,
double* LAM,
double* MRR,
double* MRI,
double*
EPS,
29 int*
NP,
double* DDELT,
int* NDGS,
int* NPNAX,
double* AXMAX,
double* B,
30 double* GAM,
int* NDISTR,
int* NKMAX,
int* NPNA,
int* NCOEFF,
31 double* REFF,
double* VEFF,
double* CEXTIN,
double* CSCAT,
double* WALB,
32 double* ASYMM,
double* ALPHA,
double* BETA,
double*
F,
double* SZ);
36 310.0, 315.0, 320.0, 325.0, 330.0, 335.0, 340.0, 345.0,
37 350.0, 355.0, 360.0, 365.0, 370.0, 375.0, 380.0, 385.0,
38 390.0, 395.0, 400.0, 405.0, 410.0, 415.0, 420.0, 425.0,
39 430.0, 435.0, 440.0, 445.0, 450.0, 455.0, 460.0, 465.0,
40 470.0, 475.0, 480.0, 485.0, 490.0, 495.0, 500.0, 505.0,
41 510.0, 515.0, 520.0, 525.0, 530.0, 535.0, 540.0, 545.0,
42 550.0, 555.0, 560.0, 565.0, 570.0, 575.0, 580.0, 585.0,
43 590.0, 595.0, 600.0, 605.0, 610.0, 615.0, 620.0, 625.0,
44 630.0, 635.0, 640.0, 645.0, 650.0, 655.0, 660.0, 665.0,
45 670.0, 675.0, 680.0, 685.0, 690.0, 695.0, 700.0, 705.0,
46 710.0, 715.0, 720.0, 725.0, 730.0, 735.0, 740.0, 745.0,
47 750.0, 755.0, 760.0, 765.0, 770.0, 775.0, 780.0, 785.0,
48 790.0, 795.0, 800.0, 805.0, 810.0, 815.0, 820.0, 825.0,
49 830.0, 835.0, 840.0, 845.0, 850.0, 855.0, 860.0, 865.0,
50 870.0, 875.0, 880.0, 885.0, 890.0, 895.0, 940.0, 1040.0,
51 1250.0, 1250.0, 1378.0, 1615.0, 1615.0, 2130.0, 2260.0
55 410.0, 490.0, 550.0, 670.0, 865.0, 1040.0,
56 1250.0, 1378.0, 1615.0, 1615.0, 2130.0, 2260.0
96 if (
str.empty() || (
str ==
"EQUAL_VOLUME")) {
97 tin_->rat = EQUAL_VOLUME;
98 }
else if (
str ==
"EQUAL_AREA") {
99 tin_->rat = EQUAL_AREA;
103 if (
str.empty() || (
str ==
"SPHEROID")) {
105 }
else if (
str ==
"CYLINDER") {
107 }
else if (
str ==
"CHEBYSHEV") {
108 tin_->np = CHEBYSHEV;
112 if (
str.empty() || (
str ==
"MODIFIED_GAMMA")) {
113 tin_->ndistr = MODIFIED_GAMMA;
114 }
else if (
str ==
"LOGNORMAL") {
115 tin_->ndistr = LOGNORMAL;
116 }
else if (
str ==
"POWERLAW") {
117 tin_->ndistr = POWERLAW;
118 }
else if (
str ==
"GAMMA") {
119 tin_->ndistr = GAMMA;
120 }
else if (
str ==
"MODIFIED_POWERLAW") {
121 tin_->ndistr = MODIFIED_POWERLAW;
145 int nwl = num_bands_;
146 int neps = tin_->eps_num;
147 int nmrr = tin_->mrr_num;
148 int nmri = tin_->mri_num;
149 int nb = tin_->b_num;
150 int npax = tin_->npnax;
151 int nang = tin_->npna;
153 tout_->wl.resize(boost::extents[nwl]);
154 tout_->eps.resize(boost::extents[neps]);
155 tout_->mrr.resize(boost::extents[nmrr]);
156 tout_->mri.resize(boost::extents[nmri]);
157 tout_->b.resize(boost::extents[
nb]);
158 tout_->a.resize(boost::extents[npax]);
159 tout_->angles.resize(boost::extents[nang]);
160 tout_->reff.resize(boost::extents[1][neps][nmrr][nmri][
nb][npax]);
161 tout_->veff.resize(boost::extents[1][neps][nmrr][nmri][
nb][npax]);
162 tout_->cext.resize(boost::extents[1][neps][nmrr][nmri][
nb][npax]);
163 tout_->cscat.resize(boost::extents[1][neps][nmrr][nmri][
nb][npax]);
164 tout_->walb.resize(boost::extents[1][neps][nmrr][nmri][
nb][npax]);
165 tout_->asymm.resize(boost::extents[1][neps][nmrr][nmri][
nb][npax]);
166 tout_->alpha.resize(boost::extents[neps][nmrr][nmri][
nb][npax][NPL][ALPHA_COEFF]);
167 tout_->beta.resize(boost::extents[neps][nmrr][nmri][
nb][npax][NPL][BETA_COEFF]);
169 boost::extents[1][neps][nmrr][nmri][
nb][npax][nang][STOKES6]);
171 for (
int iB = 0; iB < num_bands_; iB++) {
172 tout_->wl[iB] = tin_->lam[iB] *
MILLI;
174 if (tin_->eps_num < 2) {
175 tout_->eps[0] = tin_->eps_max;
176 tout_->eps[0] = (tout_->eps[0]==1.0) ? tout_->eps[0]+1.0e-6 : tout_->eps[0];
178 for (
int i = 0;
i < tin_->eps_num;
i++) {
179 tout_->eps[
i] = tin_->eps_min +
180 i*(tin_->eps_max - tin_->eps_min)/(tin_->eps_num-1);
181 tout_->eps[
i] = (tout_->eps[
i]==1.0) ? tout_->eps[
i]+1.0e-6 : tout_->eps[
i];
184 if (tin_->mrr_num < 2) {
185 tout_->mrr[0] = tin_->mrr_max;
187 for (
int i = 0;
i < tin_->mrr_num;
i++) {
188 tout_->mrr[
i] = tin_->mrr_min +
189 i*(tin_->mrr_max - tin_->mrr_min)/(tin_->mrr_num-1);
192 if (tin_->mri_num < 2) {
193 tout_->mri[0] = tin_->mri_max;
195 for (
int i = 0;
i < tin_->mri_num;
i++) {
196 tout_->mri[
i] = tin_->mri_min +
197 i*(tin_->mri_max - tin_->mri_min)/(tin_->mri_num-1);
200 if (tin_->b_num < 2) {
201 tout_->b[0] = tin_->b_max;
203 for (
int i = 0;
i < tin_->b_num;
i++) {
204 tout_->b[
i] = tin_->b_min +
205 i*(tin_->b_max - tin_->b_min)/(tin_->b_num-1);
208 if (tin_->npna < 2) {
209 tout_->angles[0] = 0.0;
211 for (
int i = 0;
i < tin_->npna;
i++) {
212 tout_->angles[
i] =
i*180.0/(tin_->npna-1);
231 for (
int iB = 0; iB < NUM_PACE_BANDS; iB++) {
236 &tin_->mrr_max, &tin_->mri_max,
237 &tin_->eps_max, &tin_->np,
238 &tin_->ddelt, &tin_->ndgs,
239 &tin_->npnax, &tin_->axmax,
240 &tin_->b_max, &tin_->gam,
241 &tin_->ndistr, &tin_->nkmax,
242 &tin_->npna, &tin_->ncoeff,
243 &tout_->reff[iB][0][0][0][0][0],
244 &tout_->veff[iB][0][0][0][0][0],
245 &tout_->cext[iB][0][0][0][0][0],
246 &tout_->cscat[iB][0][0][0][0][0],
247 &tout_->walb[iB][0][0][0][0][0],
248 &tout_->asymm[iB][0][0][0][0][0],
249 &tout_->alpha[0][0][0][0][0][0][0],
250 &tout_->beta[0][0][0][0][0][0][0],
251 &tout_->f[iB][0][0][0][0][0][0][0],
254 cout <<
"Wavelength = " << lam << endl;
270 for (
int iB = 0; iB < num_bands_; iB++) {
271 for (
int iE = 0; iE < tin_->eps_num; iE++) {
272 for (
int iR = 0; iR < tin_->mrr_num; iR++) {
273 for (
int iI = 0; iI < tin_->mri_num; iI++) {
274 for (
int iV = 0; iV < tin_->b_num; iV++) {
276 double ddelt = tin_->ddelt;
278 &tout_->mrr[iR], &tout_->mri[iI],
279 &tout_->eps[iE], &tin_->np,
281 &tin_->npnax, &tin_->axmax,
282 &tout_->b[iV], &tin_->gam,
283 &tin_->ndistr, &tin_->nkmax,
284 &tin_->npna, &tin_->ncoeff,
285 &tout_->reff[0][iE][iR][iI][iV][0],
286 &tout_->veff[0][iE][iR][iI][iV][0],
287 &tout_->cext[0][iE][iR][iI][iV][0],
288 &tout_->cscat[0][iE][iR][iI][iV][0],
289 &tout_->walb[0][iE][iR][iI][iV][0],
290 &tout_->asymm[0][iE][iR][iI][iV][0],
291 &tout_->alpha[iE][iR][iI][iV][0][0][0],
292 &tout_->beta[iE][iR][iI][iV][0][0][0],
293 &tout_->f[0][iE][iR][iI][iV][0][0][0],
297 for(
int iP=0; iP<tin_->npnax; iP++) {
298 tout_->reff[0][iE][iR][iI][iV][iP] = fillvalue;
299 tout_->veff[0][iE][iR][iI][iV][iP] = fillvalue;
300 tout_->cext[0][iE][iR][iI][iV][iP] = fillvalue;
301 tout_->cscat[0][iE][iR][iI][iV][iP] = fillvalue;
302 tout_->walb[0][iE][iR][iI][iV][iP] = fillvalue;
303 tout_->asymm[0][iE][iR][iI][iV][iP] = fillvalue;
304 for(
int iA=0; iA<tin_->npna; iA++) {
305 for(
int iS=0; iS<STOKES6; iS++) {
306 tout_->f[0][iE][iR][iI][iV][iP][iA][iS] = fillvalue;
310 cout <<
"\n Run failed for wl = " << tout_->wl[iB] <<
311 " axial ratio = " << tout_->eps[iE] <<
312 " mrr = " << tout_->mrr[iR] <<
313 " mri = " << tout_->mri[iI] <<
314 " var = " << tout_->b[iV] <<
315 " max_size = " << tin_->axmax <<
"\n" << endl;
317 cout <<
"\n Run complete for wl = " << tout_->wl[iB] <<
318 " axial ratio = " << tout_->eps[iE] <<
319 " mrr = " << tout_->mrr[iR] <<
320 " mri = " << tout_->mri[iI] <<
321 " var = " << tout_->b[iV] <<
322 " max_size = " << tin_->axmax <<
"\n" << endl;
328 status = write_wavelength(iB);
346 if (output_filepath_.empty()) {
347 cerr <<
"\nTmProcess:: Failure locating output file path.\n" << endl;
350 size_t pos = output_filepath_.rfind(
"/");
351 prod_name_ = output_filepath_.substr(
pos + 1);
354 nc_output =
new NcFile(output_filepath_, NcFile::replace);
355 }
catch (NcException& e) {
358 <<
"\nTmProcess:: Failure creating product file: "
359 + output_filepath_ +
"\n" << endl;
363 write_global_attributes(nc_output);
365 NcDim wave_dim = nc_output->addDim(
"dim_wavelength", num_bands_);
366 NcDim eps_dim = nc_output->addDim(
"dim_axial_ratio", tin_->eps_num);
367 NcDim mrr_dim = nc_output->addDim(
"dim_mrr", tin_->mrr_num);
368 NcDim mri_dim = nc_output->addDim(
"dim_mri", tin_->mri_num);
369 NcDim var_dim = nc_output->addDim(
"dim_variance", tin_->b_num);
370 NcDim size_dim = nc_output->addDim(
"dim_radius", tin_->npnax);
371 NcDim scat_dim = nc_output->addDim(
"dim_angles", tin_->npna);
372 NcDim stokes_dim = nc_output->addDim(
"dim_stokes", STOKES6);
373 vector<NcDim> scat_dims;
374 scat_dims.push_back(wave_dim);
375 scat_dims.push_back(eps_dim);
376 scat_dims.push_back(mrr_dim);
377 scat_dims.push_back(mri_dim);
378 scat_dims.push_back(var_dim);
379 scat_dims.push_back(size_dim);
380 scat_dims.push_back(scat_dim);
381 scat_dims.push_back(stokes_dim);
382 vector<NcDim> size_dims;
383 size_dims.push_back(wave_dim);
384 size_dims.push_back(eps_dim);
385 size_dims.push_back(mrr_dim);
386 size_dims.push_back(mri_dim);
387 size_dims.push_back(var_dim);
388 size_dims.push_back(size_dim);
392 var = nc_output->addVar(
"pts_wavelength", ncDouble, wave_dim);
393 var.putVar(&tout_->wl[0]);
394 var = nc_output->addVar(
"pts_axial_ratio", ncDouble, eps_dim);
395 var.putVar(&tout_->eps[0]);
396 var = nc_output->addVar(
"pts_mrr", ncDouble, mrr_dim);
397 var.putVar(&tout_->mrr[0]);
398 var = nc_output->addVar(
"pts_mri", ncDouble, mri_dim);
399 var.putVar(&tout_->mri[0]);
400 var = nc_output->addVar(
"pts_variance", ncDouble, var_dim);
401 var.putVar(&tout_->b[0]);
402 var = nc_output->addVar(
"pts_radius", ncDouble, size_dim);
403 var = nc_output->addVar(
"pts_angles", ncDouble, scat_dim);
404 var.putVar(&tout_->angles[0]);
405 var = nc_output->addVar(
"cext", ncDouble, size_dims);
406 var = nc_output->addVar(
"cscat", ncDouble, size_dims);
407 var = nc_output->addVar(
"walb", ncDouble, size_dims);
408 var = nc_output->addVar(
"asymmetry", ncDouble, size_dims);
409 var = nc_output->addVar(
"reff", ncDouble, size_dims);
410 var = nc_output->addVar(
"veff", ncDouble, size_dims);
411 var = nc_output->addVar(
"F", ncDouble, scat_dims);
412 var.putAtt(
"long_name",
"Single scattering matrix parameters (F11,F22,F33,F44,F12,F34)");
413 var.putAtt(
"dimensions",
"In order, wavelength, axial_ratio, ior_real, ior_imag, size_spread, size_radius, scattering_angles, scattering matrix parameters");
414 var.setFill(
true, -999.9);
432 if (output_filepath_.empty()) {
433 cerr <<
"\nTmProcess:: Failure locating output file path.\n" << endl;
436 size_t pos = output_filepath_.rfind(
"/");
437 prod_name_ = output_filepath_.substr(
pos + 1);
440 nc_output =
new NcFile(output_filepath_, NcFile::write);
441 }
catch (NcException& e) {
444 <<
"\nTmProcess:: Failure creating product file: "
445 + output_filepath_ +
"\n" << endl;
449 vector<size_t>
start;
456 vector<size_t>
count;
458 count.push_back(tin_->eps_num);
459 count.push_back(tin_->mrr_num);
460 count.push_back(tin_->mri_num);
461 count.push_back(tin_->b_num);
462 count.push_back(tin_->npnax);
464 NcVar var = nc_output->getVar(
"pts_radius");
465 var.putVar(&tout_->a[0]);
467 var = nc_output->getVar(
"cext");
468 var.putVar(
start,
count, &tout_->cext[0][0][0][0][0][0]);
470 var = nc_output->getVar(
"cscat");
471 var.putVar(
start,
count, &tout_->cscat[0][0][0][0][0][0]);
473 var = nc_output->getVar(
"walb");
474 var.putVar(
start,
count, &tout_->walb[0][0][0][0][0][0]);
476 var = nc_output->getVar(
"asymmetry");
477 var.putVar(
start,
count, &tout_->asymm[0][0][0][0][0][0]);
479 var = nc_output->getVar(
"reff");
480 var.putVar(
start,
count, &tout_->reff[0][0][0][0][0][0]);
482 var = nc_output->getVar(
"veff");
483 var.putVar(
start,
count, &tout_->veff[0][0][0][0][0][0]);
487 count.push_back(tin_->npna);
488 count.push_back(STOKES6);
489 var = nc_output->getVar(
"F");
490 var.putVar(
start,
count, &tout_->f[0][0][0][0][0][0][0][0]);
505 title_ =
"Particle Scattering Characteristics";
506 processing_version_ =
"v0.0.0";
507 Conventions_ =
"CF-1.6";
509 "NASA Goddard Space Flight Center, Ocean Biology Group";
511 "http://science.nasa.gov/earth-science/earth-science-data/data-information-policy/";
512 naming_authority_ =
"gov.nasa.gsfc";
515 struct tm * timeinfo;
518 timeinfo = localtime(&rawtime);
519 strftime(buffer, 80,
"%Y-%m-%dT%I:%M:%SZ", timeinfo);
520 date_created_ = (
string) buffer;
521 nc_output->putAtt(
"processing_version", processing_version_);
523 nc_output->putAtt(
"Conventions", Conventions_);
524 nc_output->putAtt(
"institution", institution_);
525 nc_output->putAtt(
"license", license_);
526 nc_output->putAtt(
"naming_authority", naming_authority_);
527 nc_output->putAtt(
"date_created", date_created_);
528 nc_output->putAtt(
"history", history_);
529 nc_output->putAtt(
"source", source_files_);
531 if (!versionid_.empty()) {
532 nc_output->putAtt(
"VersionId", versionid_);
535 nc_output->putAtt(
"title", title_);
536 nc_output->putAtt(
"product_name", prod_name_);
537 nc_output->putAtt(
"particle_shape", shape_);
538 nc_output->putAtt(
"size_distribution", distribution_);
539 nc_output->putAtt(
"radius_type", rad_type_);