From 9bd3ca63d42ea89e03e93563b67344211e6472de Mon Sep 17 00:00:00 2001
From: Leo Singer <leo.singer@ligo.org>
Date: Thu, 18 Aug 2011 02:17:30 -0700
Subject: [PATCH] Defined the inverse transform for Mollweide projection

---
 lib/matplotlib/projections/geo.py |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/matplotlib/projections/geo.py b/lib/matplotlib/projections/geo.py
index 8a20f5c..9d24e96 100644
--- a/lib/matplotlib/projections/geo.py
+++ b/lib/matplotlib/projections/geo.py
@@ -481,8 +481,15 @@ class MollweideAxes(GeoAxes):
             self._resolution = resolution
 
         def transform(self, xy):
-            # MGDTODO: Math is hard ;(
-            return xy
+            x = xy[:, 0:1]
+            y = xy[:, 1:2]
+
+            sqrt2 = np.sqrt(2)
+            sintheta = y / sqrt2
+            costheta = np.sqrt(1. - 0.5 * y * y)
+            longitude = 0.25 * sqrt2 * np.pi * x / costheta
+            latitude = np.arcsin(2 / np.pi * (np.arcsin(sintheta) + sintheta * costheta))
+            return np.concatenate((longitude, latitude), 1)
         transform.__doc__ = Transform.transform.__doc__
 
         def inverted(self):
-- 
1.7.5

