Skip to content

Commit

Permalink
False color corrected
Browse files Browse the repository at this point in the history
False color corrected
  • Loading branch information
7andahalf committed Jun 6, 2018
1 parent 98ccd1d commit 6410637
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
22 changes: 13 additions & 9 deletions directdemod/decode_noaa.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import logging, colorsys
import scipy.signal as signal
from scipy import stats
import scipy.ndimage

'''
Object to decode NOAA APT
Expand Down Expand Up @@ -118,7 +119,7 @@ def getImage(self):
anchor = 0
c = modeSyncDIff
while(validSyncs[anchor] + c < amSig.length):
if (anchor + 1) < len(validSyncs) and abs(validSyncs[anchor + 1] - c - validSyncs[anchor]) < wiggleRoom:
if (anchor + 1) < len(validSyncs) and (abs(validSyncs[anchor + 1] - c - validSyncs[anchor]) < wiggleRoom or c + validSyncs[anchor] > validSyncs[anchor + 1]):
anchor += 1
c = modeSyncDIff
else:
Expand Down Expand Up @@ -294,34 +295,37 @@ def getColor(self):

imageA = self.getImageA
imageB = self.getImageB
imageAb = scipy.ndimage.uniform_filter(self.getImageA, size=(3, 3))
imageBb = scipy.ndimage.uniform_filter(self.getImageB, size=(3, 3))

# constants
tempLimit = 155.0
seaLimit = 30.0
tempLimit = 147.0
seaLimit = 25.0
landLimit = 90.0

colorImg = []
for r in range(len(imageA)):
colorRow = []
for c in range(1040):
v, t = imageA[r,c], imageB[r,c]
vb, tb = imageAb[r,c], imageBb[r,c]
maxColor, minColor = None, None
scaleVisible, scaleTemp = None, None

if t < tempLimit:
if tb > tempLimit:
# clouds
maxColor, minColor = [230, 0.2, 0.3], [230, 0.0, 1.0]
minColor, maxColor = [230/360.0, 0.2, 0.3], [230/360.0, 0.0, 1.0]
scaleVisible = v / 256.0
scaleTemp = (256.0 - t) / 256.0
else:
if v < seaLimit:
if vb < seaLimit:
# sea
maxColor, minColor = [200.0, 0.7, 0.6], [240.0, 0.6, 0.4]
minColor, maxColor = [200.0/360.0, 0.7, 0.6], [240.0/360.0, 0.6, 0.4]
scaleVisible = v / seaLimit
scaleTemp = (256.0-t) / (256.0 - tempLimit)
else:
# ground
maxColor, minColor = [60.0, 0.6, 0.2], [100.0, 0.0, 0.5]
minColor, maxColor = [60.0/360.0, 0.6, 0.2], [100.0/360.0, 0.0, 0.5]
scaleVisible = (v - seaLimit) / (landLimit - seaLimit)
scaleTemp = (256.0 - t) / (256.0 - tempLimit);

Expand All @@ -332,7 +336,7 @@ def getColor(self):
colorRow.append(pix)

colorImg.append(colorRow)
self.__color = np.uint8(np.array(colorImg))
self.__color = np.uint8(np.array(colorImg))

return self.__color

Expand Down
6 changes: 5 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,15 @@ def usage(err = ""):

# get the image if -noimage is not present
if calculateImage:
# get the audio
#audioOut = noaaObj.getAudio
#sink.wavFile(audFileName, audioOut).write

imageMatrix = noaaObj.getImage
sink.image(imgFileName, imageMatrix).write.show

# Experimental
#sink.image(colorimgFileName, noaaObj.getColor).write.show
sink.image(colorimgFileName, noaaObj.getColor).write.show

# calculate sync is -sync flag is set
if calculateSync:
Expand Down

0 comments on commit 6410637

Please sign in to comment.