[GRASS-user] g.mlist: order of numbers

hello,

I have a script which creates so far n rasters with an analysis on different
spatial scales.
Now I want to apply r.series for an analysis of their trend but doing it fails
because I haven't figured out, how to add all new images (name.1, name.2,
name.3,...., up to name.n ) to a r.series command in the correct order.

Theoreticall I can merge r.series and g.mlist as shown in the help pages but
when I run g.mlist the order is: name.1, name.11, name.12,....

It would be no problem adding $GIS_OPT_output.1, $GIS_OPT_output.2, ... by
hand, but because the number of scales differ I had to adept it every time
again.

any hint is appreciated, TIA, Martin

Martin Wegmann wrote on 07/23/2007 11:57 AM:

hello,

I have a script which creates so far n rasters with an analysis on different
spatial scales.
Now I want to apply r.series for an analysis of their trend but doing it fails
because I haven't figured out, how to add all new images (name.1, name.2,
name.3,...., up to name.n ) to a r.series command in the correct order.

Theoreticall I can merge r.series and g.mlist as shown in the help pages but
when I run g.mlist the order is: name.1, name.11, name.12,....

It would be no problem adding $GIS_OPT_output.1, $GIS_OPT_output.2, ... by
hand, but because the number of scales differ I had to adept it every time
again.

any hint is appreciated, TIA,

Martin

probably you have to fill with 0 to get the numbers right, using
something like

echo "1" | awk '{printf "%03d\n", $1}'
001

Markus

------------------
ITC -> dall'1 marzo 2007 Fondazione Bruno Kessler
ITC -> since 1 March 2007 Fondazione Bruno Kessler
------------------

On Monday 23 July 2007 13:45:06 Markus Neteler wrote:

Martin Wegmann wrote on 07/23/2007 11:57 AM:
> hello,
>
> I have a script which creates so far n rasters with an analysis on
> different spatial scales.
> Now I want to apply r.series for an analysis of their trend but doing it
> fails because I haven't figured out, how to add all new images (name.1,
> name.2, name.3,...., up to name.n ) to a r.series command in the correct
> order.
>
> Theoreticall I can merge r.series and g.mlist as shown in the help pages
> but when I run g.mlist the order is: name.1, name.11, name.12,....
>
> It would be no problem adding $GIS_OPT_output.1, $GIS_OPT_output.2, ...
> by hand, but because the number of scales differ I had to adept it every
> time again.
>
> any hint is appreciated, TIA,

Martin

probably you have to fill with 0 to get the numbers right, using
something like

echo "1" | awk '{printf "%03d\n", $1}'
001

I added .00 to the numbers but unfortunately that did not work, I get:

g.mlist type=rast pattern=$GIS_OPT_output*

test.001
test.0010
test.002
test.003
test.004
test.005
test.006
test.007
test.008
test.009

Martin

Markus

------------------
ITC -> dall'1 marzo 2007 Fondazione Bruno Kessler
ITC -> since 1 March 2007 Fondazione Bruno Kessler
------------------

_______________________________________________
grassuser mailing list
grassuser@grass.itc.it
http://grass.itc.it/mailman/listinfo/grassuser

On Monday 23 July 2007 17:03:51 Martin Wegmann wrote:

On Monday 23 July 2007 13:45:06 Markus Neteler wrote:
> Martin Wegmann wrote on 07/23/2007 11:57 AM:
> > hello,
> >
> > I have a script which creates so far n rasters with an analysis on
> > different spatial scales.
> > Now I want to apply r.series for an analysis of their trend but doing
> > it fails because I haven't figured out, how to add all new images
> > (name.1, name.2, name.3,...., up to name.n ) to a r.series command in
> > the correct order.
> >
> > Theoreticall I can merge r.series and g.mlist as shown in the help
> > pages but when I run g.mlist the order is: name.1, name.11,
> > name.12,....
> >
> > It would be no problem adding $GIS_OPT_output.1, $GIS_OPT_output.2, ...
> > by hand, but because the number of scales differ I had to adept it
> > every time again.
> >
> > any hint is appreciated, TIA,
>
> Martin
>
> probably you have to fill with 0 to get the numbers right, using
> something like
>
> echo "1" | awk '{printf "%03d\n", $1}'
> 001

I added .00 to the numbers but unfortunately that did not work, I get:

g.mlist type=rast pattern=$GIS_OPT_output*

test.001
test.0010
test.002
test.003
test.004
test.005
test.006
test.007
test.008
test.009

ah, sorry, just realized that I have:

test.0010
instead of
test.010

renaming test.0010 to .010 gives the correct order.

but I did not manage to get your example running, Markus.

echo "1" | awk '{printf "%03d\n", $1}'

my test.001 is "$1$, isn't it? So I have to replace $1 with my filename?

sorry, not a lot of experiences with awk.

Martin

Martin

> Markus
>
> ------------------
> ITC -> dall'1 marzo 2007 Fondazione Bruno Kessler
> ITC -> since 1 March 2007 Fondazione Bruno Kessler
> ------------------
>
> _______________________________________________
> grassuser mailing list
> grassuser@grass.itc.it
> http://grass.itc.it/mailman/listinfo/grassuser

_______________________________________________
grassuser mailing list
grassuser@grass.itc.it
http://grass.itc.it/mailman/listinfo/grassuser

Hi,

this is really *ugly* hack,

g.mlist rast pat=name*
name.1
name.11
name.110
name.2

->

g.mlist rast pat=name* | awk -F. '{print $2,$1}' | sort -n | awk
'{printf $2"."$1","}'
name.1,name.2,name.11,name.110,

->

r.series in=`g.mlist rast pat=name* | awk -F. '{print $2,$1}' | sort
-n | awk '{printf $2"."$1","}'` out=series method=average

?

would be better to write script for renaming maps

name.1 -> name.001, etc.

Martin

2007/7/23, Martin Wegmann <wegmann@biozentrum.uni-wuerzburg.de>:

On Monday 23 July 2007 13:45:06 Markus Neteler wrote:
> Martin Wegmann wrote on 07/23/2007 11:57 AM:
> > hello,
> >
> > I have a script which creates so far n rasters with an analysis on
> > different spatial scales.
> > Now I want to apply r.series for an analysis of their trend but doing it
> > fails because I haven't figured out, how to add all new images (name.1,
> > name.2, name.3,...., up to name.n ) to a r.series command in the correct
> > order.
> >
> > Theoreticall I can merge r.series and g.mlist as shown in the help pages
> > but when I run g.mlist the order is: name.1, name.11, name.12,....
> >
> > It would be no problem adding $GIS_OPT_output.1, $GIS_OPT_output.2, ...
> > by hand, but because the number of scales differ I had to adept it every
> > time again.
> >
> > any hint is appreciated, TIA,
>
> Martin
>
> probably you have to fill with 0 to get the numbers right, using
> something like
>
> echo "1" | awk '{printf "%03d\n", $1}'
> 001

I added .00 to the numbers but unfortunately that did not work, I get:

g.mlist type=rast pattern=$GIS_OPT_output*

test.001
test.0010
test.002
test.003
test.004
test.005
test.006
test.007
test.008
test.009

Martin

>
> Markus
>
> ------------------
> ITC -> dall'1 marzo 2007 Fondazione Bruno Kessler
> ITC -> since 1 March 2007 Fondazione Bruno Kessler
> ------------------
>
> _______________________________________________
> grassuser mailing list
> grassuser@grass.itc.it
> http://grass.itc.it/mailman/listinfo/grassuser

_______________________________________________
grassuser mailing list
grassuser@grass.itc.it
http://grass.itc.it/mailman/listinfo/grassuser

--
Martin Landa <landa.martin@gmail.com> * http://gama.fsv.cvut.cz/~landa *

> > Martin Wegmann wrote:
> > > I have a script which creates so far n rasters with an analysis
> > > on different spatial scales.
> > > Now I want to apply r.series for an analysis of their trend but
> > > doing it fails because I haven't figured out, how to add all new
> > > images (name.1, name.2, name.3,...., up to name.n ) to a
> > > r.series command in the correct order.
> > >
> > > Theoreticall I can merge r.series and g.mlist as shown in the
> > > help pages but when I run g.mlist the order is: name.1, name.11,
> > > name.12,....
> > >
> > > It would be no problem adding $GIS_OPT_output.1,
> > > $GIS_OPT_output.2, ... by hand, but because the number of scales
> > > differ I had to adept it every time again.
> > > any hint is appreciated, TIA,

Markus:

> > probably you have to fill with 0 to get the numbers right, using
> > something like
> >
> > echo "1" | awk '{printf "%03d\n", $1}'
> > 001

Martin Landa wrote:

would be better to write script for renaming maps

name.1 -> name.001, etc.

see this post from last week for exactly that:
  http://grass.itc.it/pipermail/grassuser/2007-July/040423.html

Hamish

On Monday 23 July 2007 17:33:10 Martin Landa wrote:

r.series in=`g.mlist rast pat=name* | awk -F. '{print $2,$1}' | sort
-n | awk '{printf $2"."$1","}'` out=series method=average

works fine even when having
test.001, test.002, ...., test.0010
or
test.1, test.2, ...., test.10

thanks, Martin

BTW would it be possible to add such a sorting method to g.mlist natively? Or
adding it the g.mlist/r.series man-pages?