Skip to content

Instantly share code, notes, and snippets.

@danclewley
Created January 25, 2014 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save danclewley/8622087 to your computer and use it in GitHub Desktop.
Save danclewley/8622087 to your computer and use it in GitHub Desktop.
Calibrate PALSAR data to dB
# 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