[GRASS-dev] [GRASS GIS] #3891: t.rast.algebra: if clause with two conditions does not work properly

GRASS GIS trac at osgeo.org
Thu Aug 15 05:56:17 PDT 2019


#3891: t.rast.algebra: if clause with two conditions does not work properly
---------------------------------------+-------------------------
 Reporter:  veroandreo                 |      Owner:  grass-dev@…
     Type:  defect                     |     Status:  new
 Priority:  normal                     |  Milestone:  7.8.0
Component:  Temporal                   |    Version:  unspecified
 Keywords:  t.rast.algebra, r.mapcalc  |        CPU:  Unspecified
 Platform:  Unspecified                |
---------------------------------------+-------------------------
 I have a daily lst time series that I converted to celsius degrees. I want
 to count how many days per year have LST >= 20 and <= 30. So, I first do
 the following:

 {{{
 t.rast.algebra expression="tmean_higher20_lower30 = if(lst_daily_celsius
 >= 20.0 && lst_daily_celsius <= 30.0, lst_daily_celsius, null())"
 basename=tmean_higher20_lower30 suffix=gran nprocs=7
 }}}

 with the intention of using t.rast.aggregate afterwards.

 However, without any error, the `t.rast.algebra` command produces either
 an empty STRDS or one full of null maps if I use the -n flag.

 If I run the corresponding `r.mapcalc` command for a single date, it works
 as expected. Region is properly set, input maps have values in the proper
 range. No idea what's wrong. I have used this command before and it worked
 just fine. It is indeed something very simple for t.rast.algebra.

 The only odd thing I see when I do a dry run is how it builds the
 r.mapcalc command, that in the second part of the condition it puts
 parenthesis, but I don't know much python as to judge that.

 {{{
 ['EQUAL'] False False False True && & False False False
 lst_2014_01_01 at italy_LST_1km_daily_reconstructed_daily >=
 20.0&&(lst_2014_01_01 at italy_LST_1km_daily_reconstructed_daily <= 30.0)
 lst_2014_01_02 at italy_LST_1km_daily_reconstructed_daily >=
 20.0&&(lst_2014_01_02 at italy_LST_1km_daily_reconstructed_daily <= 30.0)

 [rest skipped]

 lst_2018_12_31 at italy_LST_1km_daily_reconstructed_daily >=
 20.0&&(lst_2018_12_31 at italy_LST_1km_daily_reconstructed_daily <= 30.0)
 build_condition_cmd_list ['EQUAL']
 ['EQUAL'] False False False False None None False False False
 {'STDS': {'name': 'tmean_higher20_lower30',
           'stdstype': 'strds',
           'temporal_type': 'absolute'},
  'processes': [{'flags': ['overwrite'],
                 'inputs': [('expression',
 'tmean_higher20_lower30_2014_01_01=if(lst_2014_01_01 at italy_LST_1km_daily_reconstructed_daily
 '
                             '>= '
 '20.0&&(lst_2014_01_01 at italy_LST_1km_daily_reconstructed_daily '
                             '<= 30.0), '
 'lst_2014_01_01 at italy_LST_1km_daily_reconstructed_daily, '
                             'null())'),
                            ('region', 'current')],
                 'name': 'r.mapcalc',
                 'outputs': []},

 [rest skipped]

  'register': [('tmean_higher20_lower30_2014_01_01',
                '2014-01-01 00:00:00',
                '2014-01-02 00:00:00'),
               ('tmean_higher20_lower30_2014_01_02',
                '2014-01-02 00:00:00',
                '2014-01-03 00:00:00'),

 [rest skipped]

               ('tmean_higher20_lower30_2018_12_31',
                '2018-12-31 00:00:00',
                '2019-01-01 00:00:00')],
  'remove': []}
 }}}

 I attach the full output of the dry run.

 I tested with python2 and python3, same behavior. I use grass-dev in
 Fedora 30.

-- 
Ticket URL: <https://trac.osgeo.org/grass/ticket/3891>
GRASS GIS <https://grass.osgeo.org>



More information about the grass-dev mailing list