[GRASS-user] Practical examples for t.select

Dears, are there real-world examples that show-case t.select?

I cannot select maps from an absolute raster space-time dataset (in a local Mapset)
that have the same starting dates (only, not time) as maps in another raster space-time
dataset (stored however in the PERMANENT Mapset).

Is the different Mapset a problem?
I can't make it work, however, for space-time dataset within the same Mapset.

Shouldn't the expression

t.select -d expression="D = if(start_date(A) == start_date(B), A)"

work?

I.e., I want to select maps from `milano_mod09gq_qc_250m@modis`

→ trl milano_mod09gq_qc_250m@modis |head
name|mapset|start_time|end_time
milano_mod09gq_QC_250m_1_doy2019001|modis|2019-01-01 10:30:00|None
milano_mod09gq_QC_250m_1_doy2019002|modis|2019-01-02 10:30:00|None
milano_mod09gq_QC_250m_1_doy2019003|modis|2019-01-03 10:30:00|None
milano_mod09gq_QC_250m_1_doy2019004|modis|2019-01-04 10:30:00|None
milano_mod09gq_QC_250m_1_doy2019005|modis|2019-01-05 10:30:00|None
milano_mod09gq_QC_250m_1_doy2019006|modis|2019-01-06 10:30:00|None
milano_mod09gq_QC_250m_1_doy2019007|modis|2019-01-07 10:30:00|None
milano_mod09gq_QC_250m_1_doy2019008|modis|2019-01-08 10:30:00|None
milano_mod09gq_QC_250m_1_doy2019009|modis|2019-01-09 10:30:00|None

whose starting dates (only, not time) coincide with maps from `test_myd11a2_emissivity_average`

→ trl test_myd11a2_emissivity_average@PERMANENT |head
name|mapset|start_time|end_time
test_myd11a2_emissivity_average_2019_01_01T00_00_00|PERMANENT|2019-01-01 00:00:00|None
test_myd11a2_emissivity_average_2019_01_09T00_00_00|PERMANENT|2019-01-09 00:00:00|None
test_myd11a2_emissivity_average_2019_01_17T00_00_00|PERMANENT|2019-01-17 00:00:00|None
test_myd11a2_emissivity_average_2019_01_25T00_00_00|PERMANENT|2019-01-25 00:00:00|None
test_myd11a2_emissivity_average_2019_02_02T00_00_00|PERMANENT|2019-02-02 00:00:00|None
test_myd11a2_emissivity_average_2019_02_10T00_00_00|PERMANENT|2019-02-10 00:00:00|None
test_myd11a2_emissivity_average_2019_02_18T00_00_00|PERMANENT|2019-02-18 00:00:00|None
test_myd11a2_emissivity_average_2019_02_26T00_00_00|PERMANENT|2019-02-26 00:00:00|None
test_myd11a2_emissivity_average_2019_03_06T00_00_00|PERMANENT|2019-03-06 00:00:00|None

Given the selection works, and for the maps listed above (just an example, notice the `|head`),
I would expect the maps

milano_mod09gq_QC_250m_1_doy2019001|modis|2019-01-01 10:30:00|None
milano_mod09gq_QC_250m_1_doy2019009|modis|2019-01-09 10:30:00|None

to be picked-up.

I can't work this out. Example:

t.select -d expression="C = if( start_date(milano_mod09gq_surface_reflectance_1) == start_date(myd21a1_emissivity_29_best_above_09_low_zenith@PERMANENT, milano_mod09gq_surface_reflectance_1)"

gives an error.

Any concrete examples?
The manual covers in theory all cases.
In practice however and in this case, I don't find it easy to follow.

Thanks, Nikos

Dear all,

would anyone be so kind to provide a simple example with a `t.rast.algebra` expression that involves

- the if() conditional call and the inverse selection operator, ie.: {!:,equal}
- if() and {!:,equal,r}

I cannot find a way to build a valid expression that includes both of these.

The following works:

t.rast.algebra expression='test = if({equal}, A1 >= -30, A2)' base=test nprocs=40

However, adding the inverse selection operator, won't do:

t.rast.algebra expression='test = if({!:,equal}, A1 >= -30, A2)' base=test3 nprocs=40 --o
Traceback (most recent call last):
   File "/osgeo/grass/dist.x86_64-pc-linux-gnu/scripts/t.rast.algebra", line 132, in <module>
     sys.exit(main())
   File "/osgeo/grass/dist.x86_64-pc-linux-gnu/scripts/t.rast.algebra", line 124, in main
     pc = p.parse(expression, basename, grass.script.overwrite())
   File "/osgeo/grass/dist.x86_64-pc-linux-gnu/etc/python/grass/temporal/temporal_raster_algebra.py", line 110, in parse
     self.parser.parse(expression)
   File "/home/nik/code/miniconda3/envs/py385/lib/python3.8/site-packages/ply/yacc.py", line 333, in parse
     return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
   File "/home/nik/code/miniconda3/envs/py385/lib/python3.8/site-packages/ply/yacc.py", line 1201, in parseopt_notrack
     tok = call_errorfunc(self.errorfunc, errtoken, self)
   File "/home/nik/code/miniconda3/envs/py385/lib/python3.8/site-packages/ply/yacc.py", line 192, in call_errorfunc
     r = errorfunc(token)
   File "/osgeo/grass/dist.x86_64-pc-linux-gnu/etc/python/grass/temporal/temporal_algebra.py", line 3042, in p_error
     raise SyntaxError("syntax error on line %d, position %i token %s near '%s' expression '%s'" %
SyntaxError: syntax error on line 1, position 11 token T_SELECT_OPERATOR near '{!:,equal}' expression 'test = if({!:,equal}, A1 >= -30, A2)'

Even the theoretically equivalent expression (to the first one) won't do:

→ t.rast.algebra expression='test = if({:,equal}, A1 >= -30, A2)' --o base=test3 nprocs=40
Traceback (most recent call last):
   File "/osgeo/grass/dist.x86_64-pc-linux-gnu/scripts/t.rast.algebra", line 132, in <module>
     sys.exit(main())
   File "/osgeo/grass/dist.x86_64-pc-linux-gnu/scripts/t.rast.algebra", line 124, in main
     pc = p.parse(expression, basename, grass.script.overwrite())
   File "/osgeo/grass/dist.x86_64-pc-linux-gnu/etc/python/grass/temporal/temporal_raster_algebra.py", line 110, in parse
     self.parser.parse(expression)
   File "/home/nik/code/miniconda3/envs/py385/lib/python3.8/site-packages/ply/yacc.py", line 333, in parse
     return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
   File "/home/nik/code/miniconda3/envs/py385/lib/python3.8/site-packages/ply/yacc.py", line 1201, in parseopt_notrack
     tok = call_errorfunc(self.errorfunc, errtoken, self)
   File "/home/nik/code/miniconda3/envs/py385/lib/python3.8/site-packages/ply/yacc.py", line 192, in call_errorfunc
     r = errorfunc(token)
   File "/osgeo/grass/dist.x86_64-pc-linux-gnu/etc/python/grass/temporal/temporal_algebra.py", line 3042, in p_error
     raise SyntaxError("syntax error on line %d, position %i token %s near '%s' expression '%s'" %
SyntaxError: syntax error on line 1, position 11 token T_SELECT_OPERATOR near '{:,equal}' expression 'test3 = if({:,equal}, A1 >= -30, A2)'

Nikos:

Even the theoretically equivalent expression (to the first one) won't do:

...
    raise SyntaxError("syntax error on line %d, position %i token %s
near '%s' expression '%s'" %
SyntaxError: syntax error on line 1, position 11 token
T_SELECT_OPERATOR near '{:,equal}' expression 'test3 = if({:,equal},
A1 >= -30, A2)'

This is actually

>     raise SyntaxError("syntax error on line %d, position %i token %s
> near '%s' expression '%s'" %
> SyntaxError: syntax error on line 1, position 11 token
> T_SELECT_OPERATOR near '{:,equal}' expression 'test = if({:,equal},
> A1 >= -30, A2)'
> ```

\(\`test\` and not \`test3\` \-\- manually edited the name before\)