I'm having some trouble replicating your problem from your 02/10 post below:
This range of this ndvi should be -1 to 1. However, you see that the range is off by an order of magnitude. However, if the image is displayed and the data values are probed, it looks like the data values in the display are correct.
Here's the script I'm running:
Code: Select all
parmsList=dict(
server='dcarchivex.ssec.wisc.edu',
dataset='GREX',
descriptor='FD',
band=1,
day='2016277',
time=('16:04', '16:09'),
position='ALL'
)
dateTimes=listADDEImageTimes(**parmsList)
if (len(dateTimes) >= 1):
#panel=buildWindow(height=900,width=900)[0]
for dateTime in dateTimes[::2]:
index=1
parms=dict(
server=parmsList['server'],
dataset=parmsList['dataset'],
descriptor='FD',
day=dateTime['day'],
time=dateTime['time'],
unit='ALB',
location=(0.1,-98.4),
coordinateSystem=LATLON,
place=ULEFT,
mag=(1,1)
)
rdata=loadADDEImage(band=2, size=(8,8), **parms)
gdata=loadADDEImage(band=3, size=(4,4), **parms)
bdata=loadADDEImage(band=4, size=(2,2), **parms)
rfield=getRangeType(rdata)
bfield=getRangeType(bdata)
gfield=getRangeType(gdata)
#rUnit=(rfield.defaultUnits)[0]
#bUnit=(bfield.defaultUnits)[0]
#nIRUnit=(nIRfield.defaultUnits)[0]
rUnit=whatType(rdata).toString().rstrip().splitlines()[-1].split('Unit: ',1)[1]
gUnit=whatType(gdata).toString().rstrip().splitlines()[-1].split('Unit: ',1)[1]
bUnit=whatType(bdata).toString().rstrip().splitlines()[-1].split('Unit: ',1)[1]
rdata=newUnit(rdata,rfield.toString(),None)
bdata=newUnit(bdata,bfield.toString(),None)
gdata=newUnit(gdata,gfield.toString(),None)
ndviDenom = sub(gdata,-rdata)
ndviNumer = sub(gdata,rdata)
ndviData = ndviNumer/ndviDenom
ndviLayer = activeDisplay().createLayer('Image Display',ndviData)
gridLayer = activeDisplay().createLayer('Grid Table', ndviData)
Notes:
- I changed nIRfield/nIRdata to 'gfield/gdata'.
- I hadn't used the bluefield/bluedata earlier on so I added them to this script, though I'm not actually using them in the NDVI calculation.
Once I'm done the script, the enhancement range in the Main Display goes from -1 to 0.13, which matches the Grid Table output. I also ran 'describe(ndviData)' which had these same min/max values. I'm wondering if you are doing something extra in your script than I am, which looks to be possible since you are working with the bfield/bdata objects in the bit of code from your last post.
Thanks -
Bob