diff --git a/doc/PatatTwi/fitPat.py b/doc/PatatTwi/fitPat.py index ca6e9dd..9ffe0d9 100644 --- a/doc/PatatTwi/fitPat.py +++ b/doc/PatatTwi/fitPat.py @@ -3,6 +3,9 @@ from scipy.optimize import curve_fit ## Fit a simple exponential + constant to the twilight data scrapped from Patat et al 2006 +plt.rcParams.update({'axes.labelsize': 'x-large'}) +plt.rcParams.update({'axes.titlesize': 'x-large'}) +plt.rcParams.update({'xtick.labelsize': 'large', 'ytick.labelsize': 'large'}) diff --git a/examples/mag_range.ipynb b/examples/mag_range.ipynb new file mode 100644 index 0000000..dbde07f --- /dev/null +++ b/examples/mag_range.ipynb @@ -0,0 +1,163 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Let's see how much the zenith sky brightess changes with lunar phase." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/yoachim/lsst/DarwinX86/anaconda/2.2.0/lib/python2.7/site-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.\n", + " warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')\n" + ] + } + ], + "source": [ + "%matplotlib inline\n", + "import numpy as np\n", + "import lsst.sims.skybrightness as sb" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "sm = sb.SkyModel(observatory='LSST', mags=True)\n", + "mjds = np.arange(50000,50000+30, 0.1)\n", + "allMags = []" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/yoachim/lsst/DarwinX86/healpy/1.8.1-2-gd4cac0b+1/lib/python/healpy-1.8.1-py2.7-macosx-10.5-x86_64.egg/healpy/pixelfunc.py:1045: FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.\n", + " if phi == None:\n" + ] + } + ], + "source": [ + "for mjd in mjds:\n", + " sm.setRaDecMjd([0.],[90.], mjd, degrees=True, azAlt=True)\n", + " if sm.sunAlt < np.radians(-12.):\n", + " allMags.append(sm.returnMags())" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "ack = np.array(allMags)" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "u 18.5890711916 22.8640055314 4.27493433984\n", + "g 17.9738140641 22.3603513644 4.38653730032\n", + "r 18.0580876027 21.3426629588 3.28457535604\n", + "i 18.2802410183 20.4205108755 2.14026985722\n", + "z 17.8716216489 19.4447736244 1.57315197551\n", + "y 16.8408159122 18.2377162092 1.39690029706\n" + ] + } + ], + "source": [ + "\n", + "for filterName in ack.dtype.names:\n", + " print filterName, ack[filterName].min(), ack[filterName].max(), ack[filterName].max()-ack[filterName].min()" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'u'" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n" + ] + } + ], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.11" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/examples/validate.py b/examples/validate.py index 466fa2c..9ec21b4 100644 --- a/examples/validate.py +++ b/examples/validate.py @@ -1,7 +1,7 @@ import numpy as np import lsst.sims.skybrightness as sb from scipy.stats import binned_statistic_2d -from lsst.sims.utils import _altAzPaFromRaDec, _raDecFromAltAz, haversine, healbin +from lsst.sims.utils import _altAzPaFromRaDec, _raDecFromAltAz, haversine, healbin, Site, ObservationMetaData from lsst.sims.maf.utils.telescopeInfo import TelescopeInfo import healpy as hp import os @@ -199,18 +199,19 @@ def healpixels2dist(nside, hp1,hp2): darkTimeMedianResid[np.where(darkTimeMedianResid == 0)] = hp.UNSEEN hp.mollview(darkTimeMedianResid, fig=1, unit=r'Median model-sky (mags/sq$^{\prime\prime}$)', - rot=(0,90), max=0.5, min=-0.5, cmap=myCmap, cbar=False, + rot=(0,90), max=0.5, min=-0.5, cmap=myCmap, cbar=True, title='Dark Time, %s' % filterName) - ax = plt.gca() - im = ax.get_images()[0] - cb = plt.colorbar(im, shrink=0.75, aspect=25, orientation='horizontal', - extend='both', extendrect=True, format=None) - cb.set_label(r'Median model-sky (mags/sq$^{\prime\prime}$)') - cb.solids.set_edgecolor("face") + #ax = plt.gca() + #im = ax.get_images()[0] + #cb = plt.colorbar(im, shrink=0.75, aspect=25, orientation='horizontal', + # extend='both', extendrect=True, format=None) + #cb.set_label(r'Median model-sky (mags/sq$^{\prime\prime}$)') + #cb.solids.set_edgecolor("face") - import pdb ; pdb.set_trace() + #import pdb ; pdb.set_trace() - fig.savefig('Plots/medianResidMap_%s.pdf' % filterName) + # XXX--WTF + #fig.savefig('Plots/medianResidMap_%s.pdf' % filterName) plt.close(fig) @@ -228,7 +229,8 @@ def healpixels2dist(nside, hp1,hp2): cb.set_label(r'RMS model-sky (mags/sq$^{\prime\prime}$)') cb.solids.set_edgecolor("face") - fig.savefig('Plots/stdResidMap_%s.pdf' % filterName) + # XXX-WTF + # fig.savefig('Plots/stdResidMap_%s.pdf' % filterName) plt.close(fig) @@ -470,6 +472,9 @@ def healpixels2dist(nside, hp1,hp2): dateIDs = [2844,40290,17449,22010] filterName = 'R' + + telescope = Site('LSST') + for i,dID in enumerate(dateIDs): fig = plt.figure(1, figsize=(11,2.8)) figCounter = 0 @@ -477,7 +482,7 @@ def healpixels2dist(nside, hp1,hp2): airmass = 1./np.cos(np.radians(90.-skydata['alt'])) skydata = skydata[np.where((airmass < amMax) & (airmass >= 1.))] alt,az,pa = _altAzPaFromRaDec(np.radians(skydata['ra']), np.radians(skydata['dec']), - telescope.lon, telescope.lat, mjd) + ObservationMetaData(mjd=mjd, site=telescope)) skyhp = healbin(az,alt, skydata['sky'], nside=nside) skyhp[np.isnan(skyhp)] = hp.UNSEEN