LSST-nonproject / sims_maf_contrib

Contributed code for MAF (sims_maf)
18 stars 46 forks source link

Error plotting LambertSkyMap #43

Closed wadawson closed 7 years ago

wadawson commented 7 years ago

When running the following chunk of code, which is part of https://github.com/LSST-nonproject/sims_maf_contrib/blob/master/tutorials/Spatial_Coordinates.ipynb:

slicer = slicers.HealpixSlicer(latCol='zenithDistance', lonCol='azimuth')
plotFuncs=[plots.LambertSkyMap()]
plotDict = {}

bundle = metricBundles.MetricBundle(metric, slicer, sql, plotDict=plotDict, plotFuncs=plotFuncs)
bg = metricBundles.MetricBundleGroup({0:bundle}, opsdb, outDir=outDir)
bg.runAll()
bg.plotAll(closefigs=False)

I get the following error:

Healpix slicer using NSIDE=128, approximate resolution 27.483891 arc minutes Querying database with constraint filter="r" and night < 730 Found 97971 visits Running: [0] Completed metric generation. Running reduce methods. Running summary statistics. Completed. Plotting figures with filter="r" and night < 730 constraint now.


ImportError Traceback (most recent call last)

in () 6 bg = metricBundles.MetricBundleGroup({0:bundle}, opsdb, outDir=outDir) 7 bg.runAll() ----> 8 bg.plotAll(closefigs=False) /Users/dawson29/anaconda/envs/lsst/opt/lsst/sims_maf/python/lsst/sims/maf/metricBundles/metricBundleGroup.pyc in plotAll(self, savefig, outfileSuffix, figformat, dpi, thumbnail, close figs 547 self.setCurrent(constraint) 548 self.plotCurrent(savefig=savefig, outfileSuffix=outfileSuffix, figformat=figformat, dpi=dpi, --> 549 thumbnail=thumbnail, closefigs=closefigs) 550 551 def plotCurrent(self, savefig=True, outfileSuffix=None, figformat='pdf', dpi=600, thumbnail=True, /Users/dawson29/anaconda/envs/lsst/opt/lsst/sims_maf/python/lsst/sims/maf/metricBundles/metricBundleGroup.pyc in plotCurrent(self, savefig, outfileSuffix, figformat, dpi, thumbnail, close figs 574 savefig=savefig, figformat=figformat, dpi=dpi, thumbnail=thumbnail) 575 for b in self.currentBundleDict.itervalues(): --> 576 b.plot(plotHandler=plotHandler, outfileSuffix=outfileSuffix, savefig=savefig) 577 if close figs 578 plt.close('all') /Users/dawson29/anaconda/envs/lsst/opt/lsst/sims_maf/python/lsst/sims/maf/metricBundles/metricBundle.pyc in plot(self, plotHandler, plotFunc, outfileSuffix, save fig 570 else: 571 for plotFunc in self.plotFuncs: --> 572 fignum = plotHandler.plot(plotFunc, outfileSuffix=outfileSuffix) 573 madePlots[plotFunc.plotType] = lignum 574 return madePlots /Users/dawson29/anaconda/envs/lsst/opt/lsst/sims_maf/python/lsst/sims/maf/plots/plotHandler.pyc in plot(self, plotFunc, plotDicts, outfileSuffix) 503 ' Either it has not been calculated or it has been deleted.') 504 else: --> 505 fignum = plotFunc(mB.metricValues, mB.slicer, plotDict, fignum=fignum) 506 # Add a legend if more than one metricValue is being plotted or if legendloc is specified. 507 legendloc = None /Users/dawson29/anaconda/envs/lsst/opt/lsst/sims_maf/python/lsst/sims/maf/plots/spatialPlotters.pyc in __call__(self, metricValueIn, slicer, userPlotDict, lignum) 771 # matplotlib bugs: 772 # http: //stackoverflow.com/questions/31975303/matplotlib-tricontourf-with-an-axis-projection --> 773 from mpl_toolkits.basemap import Baseman 774 775 m = Basemap(**plotDict['basemap']) ImportError: No module named basemap):))

Note that I am able to run the rest of the notebook without any errors.

wadawson commented 7 years ago

The problem was that the python module basemap was not installed as part of the conda lsat-sims-maf installation, i.e. when running the following code:

conda create -n lsst --clone numpy
source activate lsst
conda config --add channels http://eupsforge.net/conda/dev
conda install lsst-sims-maf

So it seems like we need to update the lsst-sims-maf dependencies to include basemap.

yoachim commented 7 years ago

This is a known issue--basemap isn't currently one of the supported 3rd party packages in the stack. Very few people use the Lambert projection, so we haven't pushed for it. If you want to use it, a quick conda install basemap or pip install basemap usually solves the problem.

wadawson commented 7 years ago

Thanks for the info, and makes sense not to require it since it isn't used frequently. Perhaps we could just make a note of it in the ipython notebook.