From d741eef52179d16077f7915851a1965b4118a073 Mon Sep 17 00:00:00 2001 From: 7andahalf Date: Tue, 19 Jun 2018 18:16:01 +0530 Subject: [PATCH] Make generated map point north Make generated map point north --- directdemod/decode_noaa.py | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/directdemod/decode_noaa.py b/directdemod/decode_noaa.py index dc73fef..05fe27b 100644 --- a/directdemod/decode_noaa.py +++ b/directdemod/decode_noaa.py @@ -183,17 +183,20 @@ def angleFromCoordinate(lat1, long1, lat2, long2): plt.savefig(destFileRot, bbox_inches='tight', dpi=1000) img = misc.imread(destFileRot) - img = img[100:-100,100:-100,:] - img = ndimage.rotate(img, -1 * (rot%180)) - + img = img[109:-109,109:-109,:] img = misc.imresize(img, rimg.shape) - rf = int((img.shape[0]/2) - ((img.shape[0] * oim.shape[0] / rimg.shape[0])/2)) - re = int((img.shape[0]/2) + ((img.shape[0] * oim.shape[0] / rimg.shape[0])/2)) - cf = int((img.shape[1]/2) - ((img.shape[1] * oim.shape[1] / rimg.shape[1])/2)) - ce = int((img.shape[1]/2) + ((img.shape[1] * oim.shape[1] / rimg.shape[1])/2)) + if 90 < (rot%360) < 270: + img = ndimage.rotate(img, -1 * (rot%180)) + else: + img = ndimage.rotate(img, -1 * rot) + + rf = int((img.shape[0]/2) - oim.shape[0]/2) + re = int((img.shape[0]/2) + oim.shape[0]/2) + cf = int((img.shape[1]/2) - oim.shape[1]/2) + ce = int((img.shape[1]/2) + oim.shape[1]/2) img = img[rf:re,cf:ce] - img = Image.fromarray(img[97:-97,97:-97]) + img = Image.fromarray(img) try: img.save(destFileNoRot) @@ -229,17 +232,20 @@ def add_m(center, dx, dy): plt.savefig(destFileRot, bbox_inches='tight', dpi=1000) img = misc.imread(destFileRot) - img = img[100:-100,100:-100,:] - img = ndimage.rotate(img, -1 * (rot%180)) - + img = img[109:-109,109:-109,:] img = misc.imresize(img, rimg.shape) - rf = int((img.shape[0]/2) - ((img.shape[0] * oim.shape[0] / rimg.shape[0])/2)) - re = int((img.shape[0]/2) + ((img.shape[0] * oim.shape[0] / rimg.shape[0])/2)) - cf = int((img.shape[1]/2) - ((img.shape[1] * oim.shape[1] / rimg.shape[1])/2)) - ce = int((img.shape[1]/2) + ((img.shape[1] * oim.shape[1] / rimg.shape[1])/2)) + if 90 < (rot%360) < 270: + img = ndimage.rotate(img, -1 * (rot%180)) + else: + img = ndimage.rotate(img, -1 * rot) + + rf = int((img.shape[0]/2) - oim.shape[0]/2) + re = int((img.shape[0]/2) + oim.shape[0]/2) + cf = int((img.shape[1]/2) - oim.shape[1]/2) + ce = int((img.shape[1]/2) + oim.shape[1]/2) img = img[rf:re,cf:ce] - img = Image.fromarray(img[97:-97,97:-97]) + img = Image.fromarray(img) try: img.save(destFileNoRot) except: