Created
January 25, 2014 19:31
-
-
Save danclewley/8622087 to your computer and use it in GitHub Desktop.
Calibrate PALSAR data to dB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A script to convert PALSAR data to dB using the RIOS applier. | |
# Dan Clewley (daniel.clewley@gmail.com) - 05/02/2013 | |
import sys | |
from rios import applier | |
from rios import cuiprogress | |
import numpy as np | |
def converttodB(info, inputs, outputs): | |
""" | |
Converts to dB using: | |
10*log10(b1) | |
""" | |
dn=inputs.inimage.astype(np.float32) | |
# Only run for pixels greater than 0 | |
outputs.outimage = np.where(inputs.inimage > 0,(10 * np.log10(dn^2))-83.0 ,0) | |
if len(sys.argv) == 3: | |
inImage = sys.argv[1] | |
outImage = sys.argv[2] | |
else: | |
print('''Not enough parameters provided. | |
Usage: | |
convert2dB.py inImage outImage | |
''') | |
exit() | |
infiles = applier.FilenameAssociations() | |
infiles.inimage = inImage | |
outfiles = applier.FilenameAssociations() | |
outfiles.outimage = outImage | |
controls = applier.ApplierControls() | |
controls.progress = cuiprogress.CUIProgressBar() | |
controls.setCalcStats(True) | |
applier.apply(converttodB, infiles, outfiles, controls=controls) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment