main.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  1. /***************************************************************************
  2. atcorr - atmospheric correction for Grass GIS
  3. was
  4. 6s - Second Simulation of Satellite Signal in the Solar Spectrum.
  5. -------------------
  6. begin : Fri Jan 10 2003
  7. copyright : (C) 2003 by Christo Zietsman
  8. email : 13422863@sun.ac.za
  9. This program has been rewriten in C/C++ from the fortran source found
  10. on http://www.ltid.inpe.br/dsr/mauro/6s/index.html. This code is
  11. provided as is, with no implied warranty and under the conditions
  12. and restraint as placed on it by previous authors.
  13. atcorr is an atmospheric correction module for Grass GIS. Limited testing
  14. has been done and therefore it should not be assumed that it will work
  15. for all possible inputs.
  16. Care has been taken to test new functionality brought to the module by
  17. Grass such as the command-line options and flags. The extra feature of
  18. supplying an elevation map has not been run to completion, because it
  19. takes to long and no sensible data for the test data was at hand.
  20. Testing would be welcomed. :)
  21. **********
  22. * Code clean-up and port to GRASS 6.3, 15.12.2006:
  23. Yann Chemin, ychemin(at)gmail.com
  24. * Addition of IRS-1C LISS, Feb 2009: Markus Neteler
  25. * input elevation/visibility map: efficient cache with dynamic memory
  26. * allocation: Markus Metz, Apr 2011
  27. ***************************************************************************/
  28. #include <cstdlib>
  29. #include <map>
  30. extern "C"
  31. {
  32. #include <grass/gis.h>
  33. #include <grass/raster.h>
  34. #include <grass/glocale.h>
  35. #include <grass/rbtree.h>
  36. }
  37. #include "Transform.h"
  38. #include "6s.h"
  39. /* TICache: create 1 meter bins for altitude in km */
  40. /* 10m bins are also ok */
  41. /* BIN_ALT = 1000 / <bin size in meters> */
  42. #define BIN_ALT 1000.
  43. /* TICache: create 1 km bins for visibility */
  44. #define BIN_VIS 1.
  45. /* uncomment to disable cache usage */
  46. /* #define _NO_OPTIMIZE_ */
  47. /* Input options and flags */
  48. struct Options
  49. {
  50. /* options */
  51. struct Option *iimg; /* input satellite image */
  52. struct Option *iscl; /* input data is scaled to this range */
  53. struct Option *ialt; /* an input elevation map in meters used to increase */
  54. /* atmospheric correction accuracy, including this */
  55. /* will make computations take much, much longer */
  56. struct Option *ivis; /* an input visibility map in km (same purpose and effect as ialt) */
  57. struct Option *icnd; /* the input conditions file */
  58. struct Option *oimg; /* output image name */
  59. struct Option *oscl; /* scale the output data (reflectance values) to this range */
  60. /* flags */
  61. struct Flag *oint; /* output data as integer */
  62. struct Flag *irad; /* treat input values as reflectance instead of radiance values */
  63. struct Flag *etmafter; /* treat input data as a satelite image of type etm+ taken after July 1, 2000 */
  64. struct Flag *etmbefore; /* treat input data as a satelite image of type etm+ taken before July 1, 2000 */
  65. };
  66. struct ScaleRange
  67. {
  68. int min;
  69. int max;
  70. };
  71. struct RBitem
  72. {
  73. int alt; /* elevation */
  74. int vis; /* visibility */
  75. TransformInput ti; /* transformation parameters */
  76. };
  77. /* function prototypes */
  78. static void adjust_region(const char *);
  79. static CELL round_c(FCELL);
  80. static void write_fp_to_cell(int, FCELL *);
  81. static void process_raster(int, InputMask, ScaleRange, int, int, int, bool,
  82. ScaleRange);
  83. static void copy_colors(const char *, char *);
  84. static void define_module(void);
  85. static struct Options define_options(void);
  86. static void read_scale(Option *, ScaleRange &);
  87. /*
  88. Adjust the region to that of the input raster.
  89. Atmospheric corrections should be done on the whole
  90. satelite image, not just portions.
  91. */
  92. static void adjust_region(const char *name)
  93. {
  94. struct Cell_head iimg_head; /* the input image header file */
  95. Rast_get_cellhd(name, "", &iimg_head);
  96. Rast_set_window(&iimg_head);
  97. }
  98. /* Rounds a floating point cell value */
  99. static CELL round_c(FCELL x)
  100. {
  101. if (x >= 0.0)
  102. return (CELL) (x + .5);
  103. return (CELL) (-(-x + .5));
  104. }
  105. /* Converts the buffer to cell and write it to disk */
  106. static void write_fp_to_cell(int ofd, FCELL *buf)
  107. {
  108. CELL *cbuf;
  109. int col;
  110. cbuf = (CELL *) Rast_allocate_buf(CELL_TYPE);
  111. for (col = 0; col < Rast_window_cols(); col++)
  112. cbuf[col] = round_c(buf[col]);
  113. Rast_put_row(ofd, cbuf, CELL_TYPE);
  114. }
  115. /* compare function for RB tree */
  116. static int compare_hv(const void *ti_a, const void *ti_b)
  117. {
  118. struct RBitem *a, *b;
  119. a = (struct RBitem *)ti_a;
  120. b = (struct RBitem *)ti_b;
  121. /* check most common case first
  122. * also faster if either an altitude or a visibility map is given,
  123. * but not both */
  124. if (a->alt == b->alt) {
  125. if (a->vis == b->vis)
  126. return 0;
  127. if (a->vis > b->vis)
  128. return 1;
  129. else if (a->vis < b->vis)
  130. return -1;
  131. }
  132. else if (a->alt > b->alt)
  133. return 1;
  134. else if (a->alt < b->alt)
  135. return -1;
  136. /* should not be reached */
  137. return 0;
  138. }
  139. /* Cache for transformation input parameters */
  140. class TICache
  141. {
  142. struct RB_TREE *RBTree;
  143. unsigned int tree_size;
  144. private:
  145. struct RBitem set_alt_vis(float alt, float vis)
  146. {
  147. struct RBitem rbitem;
  148. /* although alt and vis are already rounded,
  149. * the + 0.5 is needed for fp representation errors */
  150. /* alt has been converted to kilometers */
  151. rbitem.alt = (int) (alt * BIN_ALT + 0.5);
  152. /* vis should be kilometers */
  153. rbitem.vis = (int) (vis + 0.5);
  154. return rbitem;
  155. }
  156. public:
  157. TICache()
  158. {
  159. RBTree = rbtree_create(compare_hv, sizeof(struct RBitem));
  160. tree_size = 0;
  161. }
  162. int search(float alt, float vis, TransformInput *ti)
  163. {
  164. struct RBitem search_ti = set_alt_vis(alt, vis);
  165. struct RBitem *found_ti;
  166. found_ti = (struct RBitem *)rbtree_find(RBTree, &search_ti);
  167. if (found_ti) {
  168. *ti = found_ti->ti;
  169. return 1;
  170. }
  171. else
  172. return 0;
  173. }
  174. void add(TransformInput ti, float alt, float vis)
  175. {
  176. struct RBitem insert_ti = set_alt_vis(alt, vis);
  177. /* add safety check here */
  178. tree_size++;
  179. insert_ti.ti = ti;
  180. rbtree_insert(RBTree, &insert_ti);
  181. }
  182. };
  183. /* Process the raster and do atmospheric corrections.
  184. Params:
  185. * INPUT FILE
  186. ifd: input file descriptor
  187. iref: input file has radiance values (default is reflectance) ?
  188. iscale: input file's range (default is min = 0, max = 255)
  189. ialt_fd: height map file descriptor, negative if global value is used
  190. ivis_fd: visibility map file descriptor, negative if global value is used
  191. * OUTPUT FILE
  192. ofd: output file descriptor
  193. oflt: if true use FCELL_TYPE for output
  194. oscale: output file's range (default is min = 0, max = 255)
  195. */
  196. static void process_raster(int ifd, InputMask imask, ScaleRange iscale,
  197. int ialt_fd, int ivis_fd, int ofd, bool oint,
  198. ScaleRange oscale)
  199. {
  200. FCELL *buf; /* buffer for the input values */
  201. FCELL *alt = NULL; /* buffer for the elevation values */
  202. FCELL *vis = NULL; /* buffer for the visibility values */
  203. FCELL prev_alt = -1.f;
  204. FCELL prev_vis = -1.f;
  205. int row, col, nrows, ncols;
  206. /* switch on optimization automatically if elevation and/or visibility map is given */
  207. bool optimize = (ialt_fd >= 0 || ivis_fd >= 0);
  208. #ifdef _NO_OPTIMIZE_
  209. optimize = false;
  210. #endif
  211. /* do initial computation with global elevation and visibility values */
  212. TransformInput ti;
  213. ti = compute();
  214. /* use a cache to increase computation speed when an elevation map
  215. * and/or a visibility map is given */
  216. TICache ticache;
  217. /* allocate memory for buffers */
  218. buf = (FCELL *) Rast_allocate_buf(FCELL_TYPE);
  219. if (ialt_fd >= 0)
  220. alt = (FCELL *) Rast_allocate_buf(FCELL_TYPE);
  221. if (ivis_fd >= 0)
  222. vis = (FCELL *) Rast_allocate_buf(FCELL_TYPE);
  223. nrows = Rast_window_rows();
  224. ncols = Rast_window_cols();
  225. for (row = 0; row < nrows; row++) {
  226. G_percent(row, nrows, 1); /* keep the user informed of our progress */
  227. /* read the next row */
  228. Rast_get_row(ifd, buf, row, FCELL_TYPE);
  229. /* read the next row of elevation values */
  230. if (ialt_fd >= 0)
  231. Rast_get_row(ialt_fd, alt, row, FCELL_TYPE);
  232. /* read the next row of elevation values */
  233. if (ivis_fd >= 0)
  234. Rast_get_row(ivis_fd, vis, row, FCELL_TYPE);
  235. /* loop over all the values in the row */
  236. for (col = 0; col < ncols; col++) {
  237. if ((vis && Rast_is_f_null_value(&vis[col])) ||
  238. (alt && Rast_is_f_null_value(&alt[col])) ||
  239. Rast_is_f_null_value(&buf[col])) {
  240. Rast_set_f_null_value(&buf[col], 1);
  241. continue;
  242. }
  243. if (ialt_fd >= 0) {
  244. if (alt[col] < 0)
  245. alt[col] = 0; /* on or below sea level, all the same for 6S */
  246. else
  247. alt[col] /= 1000.0f; /* converting to km from input which should be in meter */
  248. /* round to nearest altitude bin */
  249. /* rounding result: watch out for fp representation error */
  250. alt[col] = ((int) (alt[col] * BIN_ALT + 0.5)) / BIN_ALT;
  251. }
  252. if (ivis_fd >= 0) {
  253. if (vis[col] < 0)
  254. vis[col] = 0; /* negative visibility is invalid, print a WARNING ? */
  255. /* round to nearest visibility bin */
  256. /* rounding result: watch out for fp representation error */
  257. vis[col] = ((int) (vis[col] + 0.5));
  258. }
  259. /* check if both maps are active and if whether any value has changed */
  260. if ((ialt_fd >= 0) && (ivis_fd >= 0) &&
  261. ((prev_vis != vis[col]) || (prev_alt != alt[col]))) {
  262. prev_alt = alt[col]; /* update new values */
  263. prev_vis = vis[col];
  264. if (optimize) {
  265. int in_cache = ticache.search(alt[col], vis[col], &ti);
  266. if (!in_cache) {
  267. pre_compute_hv(alt[col], vis[col]); /* re-compute transformation inputs */
  268. ti = compute(); /* ... */
  269. ticache.add(ti, alt[col], vis[col]);
  270. }
  271. }
  272. else {
  273. pre_compute_hv(alt[col], vis[col]); /* re-compute transformation inputs */
  274. ti = compute(); /* ... */
  275. }
  276. }
  277. else { /* only one of the maps is being used */
  278. if ((ivis_fd >= 0) && (prev_vis != vis[col])) {
  279. prev_vis = vis[col]; /* keep track of previous visibility */
  280. if (optimize) {
  281. int in_cache = ticache.search(0, vis[col], &ti);
  282. if (!in_cache) {
  283. pre_compute_v(vis[col]); /* re-compute transformation inputs */
  284. ti = compute(); /* ... */
  285. ticache.add(ti, 0, vis[col]);
  286. }
  287. }
  288. else {
  289. pre_compute_v(vis[col]); /* re-compute transformation inputs */
  290. ti = compute(); /* ... */
  291. }
  292. }
  293. if ((ialt_fd >= 0) && (prev_alt != alt[col])) {
  294. prev_alt = alt[col]; /* keep track of previous altitude */
  295. if (optimize) {
  296. int in_cache = ticache.search(alt[col], 0, &ti);
  297. if (!in_cache) {
  298. pre_compute_h(alt[col]); /* re-compute transformation inputs */
  299. ti = compute(); /* ... */
  300. ticache.add(ti, alt[col], 0);
  301. }
  302. }
  303. else {
  304. pre_compute_h(alt[col]); /* re-compute transformation inputs */
  305. ti = compute(); /* ... */
  306. }
  307. }
  308. }
  309. G_debug(3, "Computed r%d (%d), c%d (%d)", row, nrows, col, ncols);
  310. /* transform from iscale.[min,max] to [0,1] */
  311. buf[col] =
  312. (buf[col] - iscale.min) / ((float)iscale.max -
  313. (float)iscale.min);
  314. buf[col] = transform(ti, imask, buf[col]);
  315. /* transform from [0,1] to oscale.[min,max] */
  316. buf[col] =
  317. buf[col] * ((float)oscale.max - (float)oscale.min) +
  318. oscale.min;
  319. if (oint && (buf[col] > (float)oscale.max))
  320. G_warning(_("The output data will overflow. Reflectance > 100%%"));
  321. }
  322. /* write output */
  323. if (oint)
  324. write_fp_to_cell(ofd, buf);
  325. else
  326. Rast_put_row(ofd, buf, FCELL_TYPE);
  327. }
  328. G_percent(1, 1, 1);
  329. /* free allocated memory */
  330. G_free(buf);
  331. if (ialt_fd >= 0)
  332. G_free(alt);
  333. if (ivis_fd >= 0)
  334. G_free(vis);
  335. }
  336. /* Copy the colors from map named iname to the map named oname */
  337. static void copy_colors(const char *iname, char *oname)
  338. {
  339. struct Colors colors;
  340. Rast_read_colors(iname, "", &colors);
  341. Rast_write_colors(oname, G_mapset(), &colors);
  342. }
  343. /* Define our module so that Grass can print it if the user wants to know more. */
  344. static void define_module(void)
  345. {
  346. struct GModule *module;
  347. module = G_define_module();
  348. module->label =
  349. _("Performs atmospheric correction using the 6S algorithm.");
  350. module->description =
  351. _("6S - Second Simulation of Satellite Signal in the Solar Spectrum.");
  352. G_add_keyword(_("imagery"));
  353. G_add_keyword(_("atmospheric correction"));
  354. /*
  355. " Incorporated into Grass by Christo A. Zietsman, January 2003.\n"
  356. " Converted from Fortran to C by Christo A. Zietsman, November 2002.\n\n"
  357. " Adapted by Mauro A. Homem Antunes for atmopheric corrections of\n"
  358. " remotely sensed images in raw format (.RAW) of 8 bits.\n"
  359. " April 4, 2001.\n\n"
  360. " Please refer to the following paper and acknowledge the authors of\n"
  361. " the model:\n"
  362. " Vermote, E.F., Tanre, D., Deuze, J.L., Herman, M., and Morcrette,\n"
  363. " J.J., (1997), Second simulation of the satellite signal in\n"
  364. " the solar spectrum, 6S: An overview., IEEE Trans. Geosc.\n"
  365. " and Remote Sens. 35(3):675-686.\n"
  366. " The code is provided as is and is not to be sold. See notes on\n"
  367. " http://loasys.univ-lille1.fr/informatique/sixs_gb.html\n"
  368. " http://www.ltid.inpe.br/dsr/mauro/6s/index.html\n"
  369. " and on http://www.cs.sun.ac.za/~caz/index.html\n"; */
  370. }
  371. /* Define the options and flags */
  372. static struct Options define_options(void)
  373. {
  374. struct Options opts;
  375. opts.iimg = G_define_standard_option(G_OPT_R_INPUT);
  376. opts.iscl = G_define_option();
  377. opts.iscl->key = "range";
  378. opts.iscl->type = TYPE_INTEGER;
  379. opts.iscl->key_desc = "min,max";
  380. opts.iscl->required = NO;
  381. opts.iscl->answer = "0,255";
  382. opts.iscl->description = _("Input range");
  383. opts.iscl->guisection = _("Input");
  384. opts.ialt = G_define_standard_option(G_OPT_R_ELEV);
  385. opts.ialt->required = NO;
  386. opts.ialt->description = _("Name of input elevation raster map (in m)");
  387. opts.ialt->guisection = _("Input");
  388. opts.ivis = G_define_standard_option(G_OPT_R_INPUT);
  389. opts.ivis->key = "visibility";
  390. opts.ivis->required = NO;
  391. opts.ivis->description = _("Name of input visibility raster map (in km)");
  392. opts.ivis->guisection = _("Input");
  393. opts.icnd = G_define_standard_option(G_OPT_F_INPUT);
  394. opts.icnd->key = "parameters";
  395. opts.icnd->required = YES;
  396. opts.icnd->description = _("Name of input text file with 6S parameters");
  397. opts.oimg = G_define_standard_option(G_OPT_R_OUTPUT);
  398. opts.oscl = G_define_option();
  399. opts.oscl->key = "rescale";
  400. opts.oscl->type = TYPE_INTEGER;
  401. opts.oscl->key_desc = "min,max";
  402. opts.oscl->answer = "0,255";
  403. opts.oscl->required = NO;
  404. opts.oscl->description = _("Rescale output raster map");
  405. opts.oscl->guisection = _("Output");
  406. opts.oint = G_define_flag();
  407. opts.oint->key = 'i';
  408. opts.oint->description = _("Output raster map as integer");
  409. opts.oint->guisection = _("Output");
  410. opts.irad = G_define_flag();
  411. opts.irad->key = 'r';
  412. opts.irad->description =
  413. _("Input raster map converted to reflectance (default is radiance)");
  414. opts.irad->guisection = _("Input");
  415. opts.etmafter = G_define_flag();
  416. opts.etmafter->key = 'a';
  417. opts.etmafter->description =
  418. _("Input from ETM+ image taken after July 1, 2000");
  419. opts.etmafter->guisection = _("Input");
  420. opts.etmbefore = G_define_flag();
  421. opts.etmbefore->key = 'b';
  422. opts.etmbefore->description =
  423. _("Input from ETM+ image taken before July 1, 2000");
  424. opts.etmbefore->guisection = _("Input");
  425. return opts;
  426. }
  427. /* Read the min and max values from the iscl and oscl options */
  428. void read_scale(Option * scl, ScaleRange & range)
  429. {
  430. /* set default values */
  431. range.min = 0;
  432. range.max = 255;
  433. if (scl->answer) {
  434. sscanf(scl->answers[0], "%d", &range.min);
  435. sscanf(scl->answers[1], "%d", &range.max);
  436. if (range.min == range.max) {
  437. G_warning(_("Scale range length should be > 0; Using default values: [0,255]"));
  438. range.min = 0;
  439. range.max = 255;
  440. }
  441. }
  442. /* swap values if max is smaller than min */
  443. if (range.max < range.min) {
  444. int temp;
  445. temp = range.max;
  446. range.max = range.min;
  447. range.min = temp;
  448. }
  449. }
  450. int main(int argc, char *argv[])
  451. {
  452. struct Options opts;
  453. struct ScaleRange iscale; /* input file's data is scaled to this interval */
  454. struct ScaleRange oscale; /* output file's scale */
  455. int iimg_fd; /* input image's file descriptor */
  456. int oimg_fd; /* output image's file descriptor */
  457. int ialt_fd = -1; /* input elevation map's file descriptor */
  458. int ivis_fd = -1; /* input visibility map's file descriptor */
  459. struct History hist;
  460. struct Cell_head orig_window;
  461. /* Define module */
  462. define_module();
  463. /* Define the different input options */
  464. opts = define_options();
  465. /**** Start ****/
  466. G_gisinit(argv[0]);
  467. if (G_parser(argc, argv) < 0)
  468. exit(EXIT_FAILURE);
  469. G_get_set_window(&orig_window);
  470. adjust_region(opts.iimg->answer);
  471. /* open input raster */
  472. if ((iimg_fd = Rast_open_old(opts.iimg->answer, "")) < 0)
  473. G_fatal_error(_("Unable to open raster map <%s>"), opts.iimg->answer);
  474. if (opts.ialt->answer) {
  475. if ((ialt_fd = Rast_open_old(opts.ialt->answer, "")) < 0)
  476. G_fatal_error(_("Unable to open raster map <%s>"),
  477. opts.ialt->answer);
  478. }
  479. if (opts.ivis->answer) {
  480. if ((ivis_fd = Rast_open_old(opts.ivis->answer, "")) < 0)
  481. G_fatal_error(_("Unable to open raster map <%s>"),
  482. opts.ivis->answer);
  483. }
  484. /* open a floating point raster or not? */
  485. if (opts.oint->answer) {
  486. if ((oimg_fd = Rast_open_new(opts.oimg->answer, CELL_TYPE)) < 0)
  487. G_fatal_error(_("Unable to create raster map <%s>"),
  488. opts.oimg->answer);
  489. }
  490. else {
  491. if ((oimg_fd = Rast_open_fp_new(opts.oimg->answer)) < 0)
  492. G_fatal_error(_("Unable to create raster map <%s>"),
  493. opts.oimg->answer);
  494. }
  495. /* read the scale parameters */
  496. read_scale(opts.iscl, iscale);
  497. read_scale(opts.oscl, oscale);
  498. /* initialize this 6s computation and parse the input conditions file */
  499. init_6S(opts.icnd->answer);
  500. InputMask imask = RADIANCE; /* the input mask tells us what transformations if any
  501. needs to be done to make our input values, reflectance
  502. values scaled between 0 and 1 */
  503. if (opts.irad->answer)
  504. imask = REFLECTANCE;
  505. if (opts.etmbefore->answer)
  506. imask = (InputMask) (imask | ETM_BEFORE);
  507. if (opts.etmafter->answer)
  508. imask = (InputMask) (imask | ETM_AFTER);
  509. /* process the input raster and produce our atmospheric corrected output raster. */
  510. G_message(_("Atmospheric correction..."));
  511. process_raster(iimg_fd, imask, iscale, ialt_fd, ivis_fd,
  512. oimg_fd, opts.oint->answer, oscale);
  513. /* Close the input and output file descriptors */
  514. Rast_short_history(opts.oimg->answer, "raster", &hist);
  515. Rast_close(iimg_fd);
  516. if (opts.ialt->answer)
  517. Rast_close(ialt_fd);
  518. if (opts.ivis->answer)
  519. Rast_close(ivis_fd);
  520. Rast_close(oimg_fd);
  521. Rast_command_history(&hist);
  522. Rast_write_history(opts.oimg->answer, &hist);
  523. /* Copy the colors of the input raster to the output raster.
  524. Scaling is ignored and color ranges might not be correct. */
  525. copy_colors(opts.iimg->answer, opts.oimg->answer);
  526. Rast_set_window(&orig_window);
  527. G_message(_("Atmospheric correction complete."));
  528. exit(EXIT_SUCCESS);
  529. }