Skip to content

Commit

Permalink
Make generated map point north
Browse files Browse the repository at this point in the history
Make generated map point north
  • Loading branch information
7andahalf committed Jun 19, 2018
1 parent ea2770e commit d741eef
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions directdemod/decode_noaa.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit d741eef

Please sign in to comment.