[GRASS-SVN] r47684 - in grass-addons/grass7/raster/r.modis:
libmodis r.modis.import
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Aug 17 01:40:24 EDT 2011
Author: lucadelu
Date: 2011-08-16 22:40:24 -0700 (Tue, 16 Aug 2011)
New Revision: 47684
Modified:
grass-addons/grass7/raster/r.modis/libmodis/rmodislib.py
grass-addons/grass7/raster/r.modis/r.modis.import/r.modis.import.py
Log:
using r.bitpattern to find the good pixel
Modified: grass-addons/grass7/raster/r.modis/libmodis/rmodislib.py
===================================================================
--- grass-addons/grass7/raster/r.modis/libmodis/rmodislib.py 2011-08-16 18:44:00 UTC (rev 47683)
+++ grass-addons/grass7/raster/r.modis/libmodis/rmodislib.py 2011-08-17 05:40:24 UTC (rev 47684)
@@ -50,12 +50,13 @@
lst_spec = '( 1 0 0 0 1 0 0 0 0 0 0 0 )'
lst_specqa = '( 1 1 0 0 1 1 0 0 0 0 0 0 )'
lstvi_specall = '( 1 1 1 1 1 1 1 1 1 1 1 1)'
- lst_patt = [ " == 2", " == 3", " >= 81" ]
+ lst_patt = {3 : [2, 3], 128 : [81, 85], 255 : [129, 133, 145, 149]}
lst_suff = {'.LST_Day_1km':'.QC_Day','.LST_Night_1km':'.QC_Night'}
lst_color = ['modis_lst']
vi_spec = '( 1 1 0 0 0 0 0 0 0 0 0 )'
vi_specqa = '( 1 1 1 0 0 0 0 0 0 0 0 )'
- vi_patt = []
+ vi_patt = {3 : [2, 3], 63 : [13, 14, 15], 128 : [3], 1024 : [1],
+ 8192 : [0, 6, 7], 16384 : [1], 32768 : [1]}
vi_color = ['ndvi','evi']
vi_suff = {'.250m_16_days_NDVI.tif' : '250m_16_days_VI_Quality.tif',
'.250m_16_days_EVI.tif' : '250m_16_days_VI_Quality.tif'}
Modified: grass-addons/grass7/raster/r.modis/r.modis.import/r.modis.import.py
===================================================================
--- grass-addons/grass7/raster/r.modis/r.modis.import/r.modis.import.py 2011-08-16 18:44:00 UTC (rev 47683)
+++ grass-addons/grass7/raster/r.modis/r.modis.import/r.modis.import.py 2011-08-17 05:40:24 UTC (rev 47684)
@@ -180,7 +180,7 @@
else:
return None
-def import_tif(out, basedir, rem, target=False):
+def import_tif(out, basedir, rem, target=None):
"""Import TIF files"""
# list of tif files
tifiles = glob.glob1(basedir, out + "*.tif")
@@ -204,8 +204,9 @@
grass.fatal(_('Error during import'))
if rem:
os.remove(name)
- if target != basedir:
- shutil.move(name,target)
+ if target:
+ if target != basedir:
+ shutil.move(name,target)
return outfile
def findfile(pref, suff):
@@ -249,8 +250,14 @@
qaname = qa[n]['name']
qafull = qa[n]['fullname']
grass.run_command('r.null', map = valfull)
- mapc = "%s.2 = (%s * 0.0200) - 273.15" % (valname, valfull)
- grass.mapcalc(mapc)
+ if string.find(cod,'13Q1') or string.find(cod,'13A2'):
+ mapc = "%s.2 = %s / 10000" % (valname, valfull)
+ grass.mapcalc(mapc)
+ elif string.find(cod,'11A1') or string.find(cod,'11A2') or string.find(cod,'11B1'):
+ mapc = "%s.2 = (%s * 0.0200) - 273.15" % (valname, valfull)
+ grass.mapcalc(mapc)
+ else:
+ grass.run_command('g.copy', rast = (valfull,valname + '.2'))
if an == 'noqa':
grass.run_command('g.remove', rast = valfull)
grass.run_command('g.rename', rast= (valname + '.2', valfull))
@@ -259,17 +266,22 @@
#metadata(parse, qafull, 'byr')
if an == 'all':
- qamapcal = "%s.badpixels = if( " % qaname
- for p in pat:
- qamapcal += "%s%s || " % (qaname, p)
- qamapcal.strip(' || ')
- qamapcal += "1, null() )"
- grass.mapcalc(qamapcal)
- finalmap = "%s.3=if( isnull(%s.badpixels), %s.2, null())" % (
- valname, qaname, valname)
+ finalmap = "%s.3=if(" % valname
+ for key,value in prod['pattern'].iteritems():
+ for v in value:
+ outpat = "%s.%i.%i" % (qaname, key, v)
+ grass.run_command('r.bitpattern', quiet=True, input = qafull,
+ output = outpat, pattern = key, patval= v)
+ finalmap += "%s == 0 && " % outpat
+ if string.find(cod,'13Q1') or string.find(cod,'13A2'):
+ finalmap += "%s.2 <= 1.000" % valname
+ else:
+ finalmap.rstrip(' && ')
+ finalmap += ",%s.2, null() )" % valname
+ import pdb; pdb.set_trace()
grass.mapcalc(finalmap)
- grass.run_command('g.remove', rast=(qaname + '.badpixels', valname,
- valname + '.2'))
+ grass.run_command('g.remove', rast=(valname, valname + '.2'))
+ grass.run_command('g.mremove', flag="f", rast = ("%s.*" % qaname)
grass.run_command('g.rename', rast=(valname + '.3', valname))
#TODO check in modis.py to adjust the xml file of mosaic
#metadata(parse, valfull, col)
More information about the grass-commit
mailing list