[GRASS-dev] Re: [GRASS GIS] #1109: g.mlist functionality extension:
return e.g. $prefix.001 to $prefix.031 out of $prefix.365 maps
GRASS GIS
trac at osgeo.org
Mon Jul 19 03:49:52 EDT 2010
#1109: g.mlist functionality extension: return e.g. $prefix.001 to $prefix.031 out
of $prefix.365 maps
-------------------------------+--------------------------------------------
Reporter: nikos | Owner: grass-dev@…
Type: enhancement | Status: new
Priority: minor | Milestone:
Component: default | Version: unspecified
Keywords: g.mlist, pattern, | Platform: Unspecified
Cpu: Unspecified |
-------------------------------+--------------------------------------------
Comment(by nikos):
Thank you Hamish. I'll have to try that one. I found my way around as
follows:
{{{
# julian days of months
for DAYS in "1 31 jan" "32 59 feb" "60 90 mar" \
"91 120 apr" "121 151 may" "152 181 jun" \
"182 212 jul" "213 243 aug" "244 273 sep" \
"274 304 oct" "305 334 nov" "335 365 dec"
# parse "${DAYS}" and set positional parameters
do
set -- $DAYS ; echo $1 $2 $3
# loop over asked period of days
for DAY in `seq $1 $STEP $2` ; do
# print leading 0's
DAY_STR=`echo $DAY | awk '{printf("%.03d", $1)}'`
echo "${DAY_STR}"
# separate map names of interest with $SEP
DAY_STR2=`g.mlist rast pat="$PREFIX${DAY_STR}" sep="$SEP"`
echo "${DAY_STR2}"
# store in a list
echo "${DAY_STR2}" | tr '\n' "," >> "${PREFIX}${3}.TEMP.LIST"
done
# remove last "orphan" separator
cat "${PREFIX}${3}.TEMP.LIST" | \
sed 's/.$//' >> "${PREFIX}${3}.LIST"
# remove temp file
rm "${PREFIX}${3}.TEMP.LIST"
# average per month
r.series input=`cat "${PREFIX}${3}.LIST"` \
out="${PREFIX}${3}" method=average
# remove lists
rm "${PREFIX}${3}.LIST"
done
}}}
(
on-sight: what do you think about the above? drawbacks?
)
--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1109#comment:4>
GRASS GIS <http://grass.osgeo.org>
More information about the grass-dev
mailing list