Changeset 33614


Ignore:
Timestamp:
Sep 30, 2008, 4:56:02 AM (16 years ago)
Author:
martinl
Message:

i.albedo: follow GRASS coding rules

Location:
grass/trunk/imagery/i.albedo
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • grass/trunk/imagery/i.albedo/i.albedo.html

    r33565 r33614  
    11<H2>DESCRIPTION</H2>
    22
    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
     4reflectance in the range of 0.3-3 micro-meters.  It takes input of
     5individual bands of surface reflectance from Modis, AVHRR, Landsat or
     6Aster and calculates the Albedo for those.  This is an precursor to
     7r.sun and any Energy-Balance processing.
     8
    69<H2>NOTES</H2>
    710It assumes MODIS product surface reflectance in [0;10000]
     11
    812<H2>TODO</H2>
    913Maybe change input requirement of MODIS to [0.0-1.0]?
     
    1216
    1317<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>
    1520</em>
    1621
     
    1823<H2>AUTHORS</H2>
    1924
    20 Yann Chemin, International Rice Research Institute, The Philippines<BR>
    21 
     25Yann Chemin, International Rice Research Institute, The Philippines
    2226
    2327<p>
  • grass/trunk/imagery/i.albedo/main.c

    r33582 r33614  
    5454    char **names;
    5555    char **ptr;
    56     int i = 0, j = 0;
     56    int i = 0;
    5757    int modis = 0, aster = 0, avhrr = 0, landsat = 0;
    5858    void *inrast[MAXFILES];
    5959    unsigned char *outrast;
    60     int data_format;            /* 0=double  1=float  2=32bit signed int  5=8bit unsigned int (ie text) */
     60
    6161    RASTER_MAP_TYPE in_data_type[MAXFILES];     /* 0=numbers  1=text */
    6262    RASTER_MAP_TYPE out_data_type = DCELL_TYPE;
     
    8484
    8585    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.");
    8988
    9089    /* Define the different options */
     
    9291    input = G_define_standard_option(G_OPT_R_INPUT);
    9392    input->multiple = YES;
    94     input->description = _("Names of surface reflectance layers");
    9593
    9694    output = G_define_standard_option(G_OPT_R_OUTPUT);
    97     output->description = _("Name of the BB_Albedo layer");
    9895
    9996    /* Define the different flags */
     
    117114    flag5 = G_define_flag();
    118115    flag5->key = 'c';
     116    flag5->label = _("Agressive mode (Landsat)");
    119117    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");
    121120
    122121    flag6 = G_define_flag();
    123122    flag6->key = 'd';
     123    flag6->label = _("Soft mode (Modis)");
    124124    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");
    126127
    127128    /* FMEO init nfiles */
     
    129130
    130131    if (G_parser(argc, argv))
    131         exit(-1);
     132        exit(EXIT_FAILURE);
    132133
    133134    names = input->answers;
     
    141142    aster = (flag4->answer);
    142143
    143     if (G_legal_filename(result) < 0)
    144         G_fatal_error(_("[%s] is an illegal name"), result);
    145 
    146144    for (; *ptr != NULL; ptr++) {
    147145        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);
    149147        name = *ptr;
    150 
     148       
    151149        infd[nfiles] = G_open_cell_old(name, "");
    152150        if (infd[nfiles] < 0)
     
    156154        in_data_type[nfiles] = G_raster_map_type(name, "");
    157155        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);
    159157
    160158        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);
    162160
    163161        inrast[nfiles] = G_allocate_raster_buf(in_data_type[nfiles]);
     
    166164    nfiles--;
    167165    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"));
    169167
    170168    /* Allocate output buffer, use input map data_type */
     
    175173    /* Create New raster files */
    176174    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);
    178176
    179177    /*START ALBEDO HISTOGRAM STRETCH */
     
    194192                if ((G_get_raster_row(
    195193                         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);
    197196            }
    198197            /*process the data */
     
    237236            }
    238237        }
    239         G_message("Histogram of Albedo\n");
     238
     239        G_message("Calculating histogram of albedo");
    240240
    241241        peak1 = 0;
     
    324324        }
    325325        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);
    328328            a = (0.36 - 0.05) / (i_bottom2b / 100.0 - i_peak1 / 100.0);
    329329            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);
    331331        }
    332332        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);
    335335            a = (0.36 - 0.05) / (i_bottom2b / 100.0 - i_bottom1a / 100.0);
    336336            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);
    338338        }
    339339    }                           /*END OF FLAG1 */
     
    350350            if ((G_get_raster_row(
    351351                     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);
    353354        }
    354355        /*process the data */
     
    386387        }
    387388        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);
    389391    }
    390392    for (i = 1; i <= nfiles; i++) {
Note: See TracChangeset for help on using the changeset viewer.