Changeset 33614
- Timestamp:
- Sep 30, 2008, 4:56:02 AM (16 years ago)
- Location:
- grass/trunk/imagery/i.albedo
- Files:
-
- 2 edited
-
i.albedo.html (modified) (3 diffs)
-
main.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
grass/trunk/imagery/i.albedo/i.albedo.html
r33565 r33614 1 1 <H2>DESCRIPTION</H2> 2 2 3 <EM>i.albedo</EM> calculates the Albedo, that is the Shortwave surface reflectance in the range of 0.3-3 micro-meters. 4 It takes input of individual bands of surface reflectance from Modis, AVHRR, Landsat or Aster and calculates the Albedo for those. 5 This is an precursor to r.sun and any Energy-Balance processing. 3 <EM>i.albedo</EM> calculates the Albedo, that is the Shortwave surface 4 reflectance in the range of 0.3-3 micro-meters. It takes input of 5 individual bands of surface reflectance from Modis, AVHRR, Landsat or 6 Aster and calculates the Albedo for those. This is an precursor to 7 r.sun and any Energy-Balance processing. 8 6 9 <H2>NOTES</H2> 7 10 It assumes MODIS product surface reflectance in [0;10000] 11 8 12 <H2>TODO</H2> 9 13 Maybe change input requirement of MODIS to [0.0-1.0]? … … 12 16 13 17 <em> 14 <A HREF="r.sun.html">r.sun</A><br> 18 <a href="r.sun.html">r.sun</a>, 19 <a href="i.vi.html">i.vi</a> 15 20 </em> 16 21 … … 18 23 <H2>AUTHORS</H2> 19 24 20 Yann Chemin, International Rice Research Institute, The Philippines<BR> 21 25 Yann Chemin, International Rice Research Institute, The Philippines 22 26 23 27 <p> -
grass/trunk/imagery/i.albedo/main.c
r33582 r33614 54 54 char **names; 55 55 char **ptr; 56 int i = 0 , j = 0;56 int i = 0; 57 57 int modis = 0, aster = 0, avhrr = 0, landsat = 0; 58 58 void *inrast[MAXFILES]; 59 59 unsigned char *outrast; 60 int data_format; /* 0=double 1=float 2=32bit signed int 5=8bit unsigned int (ie text) */ 60 61 61 RASTER_MAP_TYPE in_data_type[MAXFILES]; /* 0=numbers 1=text */ 62 62 RASTER_MAP_TYPE out_data_type = DCELL_TYPE; … … 84 84 85 85 module = G_define_module(); 86 module->keywords = _("Albedo,surface reflectance,r.sun"); 87 module->description = 88 _("Broad Band Albedo from Surface Reflectance.\n NOAA AVHRR(n), Modis(m), Landsat(l), Aster(a)\n"); 86 module->keywords = _("imagery, albedo, surface reflectance"); 87 module->description = _("Broad Band Albedo from Surface Reflectance."); 89 88 90 89 /* Define the different options */ … … 92 91 input = G_define_standard_option(G_OPT_R_INPUT); 93 92 input->multiple = YES; 94 input->description = _("Names of surface reflectance layers");95 93 96 94 output = G_define_standard_option(G_OPT_R_OUTPUT); 97 output->description = _("Name of the BB_Albedo layer");98 95 99 96 /* Define the different flags */ … … 117 114 flag5 = G_define_flag(); 118 115 flag5->key = 'c'; 116 flag5->label = _("Agressive mode (Landsat)"); 119 117 flag5->description = 120 _("Albedo dry run to calculate some water to beach/sand/desert stretching, a kind of simple atmospheric correction. Agressive mode (Landsat)."); 118 _("Albedo dry run to calculate some water to beach/sand/desert stretching, " 119 "a kind of simple atmospheric correction"); 121 120 122 121 flag6 = G_define_flag(); 123 122 flag6->key = 'd'; 123 flag6->label = _("Soft mode (Modis)"); 124 124 flag6->description = 125 _("Albedo dry run to calculate some water to beach/sand/desert stretching, a kind of simple atmospheric correction. Soft mode (Modis)."); 125 _("Albedo dry run to calculate some water to beach/sand/desert stretching, " 126 "a kind of simple atmospheric correction"); 126 127 127 128 /* FMEO init nfiles */ … … 129 130 130 131 if (G_parser(argc, argv)) 131 exit( -1);132 exit(EXIT_FAILURE); 132 133 133 134 names = input->answers; … … 141 142 aster = (flag4->answer); 142 143 143 if (G_legal_filename(result) < 0)144 G_fatal_error(_("[%s] is an illegal name"), result);145 146 144 for (; *ptr != NULL; ptr++) { 147 145 if (nfiles >= MAXFILES) 148 G_fatal_error(_("Too many input files. Only %d allowed"), MAXFILES);146 G_fatal_error(_("Too many input maps. Only %d allowed."), MAXFILES); 149 147 name = *ptr; 150 148 151 149 infd[nfiles] = G_open_cell_old(name, ""); 152 150 if (infd[nfiles] < 0) … … 156 154 in_data_type[nfiles] = G_raster_map_type(name, ""); 157 155 if ((infd[nfiles] = G_open_cell_old(name, "")) < 0) 158 G_fatal_error(_(" Cannot open cell file [%s]"), name);156 G_fatal_error(_("Unable to open raster map <%s>"), name); 159 157 160 158 if ((G_get_cellhd(name, "", &cellhd)) < 0) 161 G_fatal_error(_(" Cannot read file header of [%s]"), name);159 G_fatal_error(_("Unable to read header of raster map <%s>"), name); 162 160 163 161 inrast[nfiles] = G_allocate_raster_buf(in_data_type[nfiles]); … … 166 164 nfiles--; 167 165 if (nfiles <= 1) 168 G_fatal_error(_(" The min specified input map is two (that is NOAA AVHRR)"));166 G_fatal_error(_("At least two raster maps are required")); 169 167 170 168 /* Allocate output buffer, use input map data_type */ … … 175 173 /* Create New raster files */ 176 174 if ((outfd = G_open_raster_new(result, 1)) < 0) 177 G_fatal_error(_(" Could not open<%s>"), result);175 G_fatal_error(_("Unable to create raster map <%s>"), result); 178 176 179 177 /*START ALBEDO HISTOGRAM STRETCH */ … … 194 192 if ((G_get_raster_row( 195 193 infd[i], inrast[i], row, in_data_type[i])) < 0) 196 G_fatal_error(_("Could not read from <%s>"), name); 194 G_fatal_error(_("Unable to read raster map <%s> row %d >"), 195 name, row); 197 196 } 198 197 /*process the data */ … … 237 236 } 238 237 } 239 G_message("Histogram of Albedo\n"); 238 239 G_message("Calculating histogram of albedo"); 240 240 241 241 peak1 = 0; … … 324 324 } 325 325 if (flag5->answer) { 326 G_message("peak1 %d %d \n", peak1, i_peak1);327 G_message("bottom2b= %d %d \n", bottom2b, i_bottom2b);326 G_message("peak1 %d %d", peak1, i_peak1); 327 G_message("bottom2b= %d %d", bottom2b, i_bottom2b); 328 328 a = (0.36 - 0.05) / (i_bottom2b / 100.0 - i_peak1 / 100.0); 329 329 b = 0.05 - a * (i_peak1 / 100.0); 330 G_message("a= %f\tb= %f \n", a, b);330 G_message("a= %f\tb= %f", a, b); 331 331 } 332 332 if (flag6->answer) { 333 G_message("bottom1a %d %d \n", bottom1a, i_bottom1a);334 G_message("bottom2b= %d %d \n", bottom2b, i_bottom2b);333 G_message("bottom1a %d %d", bottom1a, i_bottom1a); 334 G_message("bottom2b= %d %d", bottom2b, i_bottom2b); 335 335 a = (0.36 - 0.05) / (i_bottom2b / 100.0 - i_bottom1a / 100.0); 336 336 b = 0.05 - a * (i_bottom1a / 100.0); 337 G_message("a= %f\tb= %f \n", a, b);337 G_message("a= %f\tb= %f", a, b); 338 338 } 339 339 } /*END OF FLAG1 */ … … 350 350 if ((G_get_raster_row( 351 351 infd[i], inrast[i], row, in_data_type[i])) < 0) 352 G_fatal_error(_("Could not read from <%s>"), name); 352 G_fatal_error(_("Unable to read raster map <%s> row %d"), 353 name, row); 353 354 } 354 355 /*process the data */ … … 386 387 } 387 388 if (G_put_raster_row(outfd, outrast, out_data_type) < 0) 388 G_fatal_error(_("Cannot write to <%s>"), result); 389 G_fatal_error(_("Failed writing raster map <%s> row %d"), 390 result, row); 389 391 } 390 392 for (i = 1; i <= nfiles; i++) {
Note:
See TracChangeset
for help on using the changeset viewer.
