wiki:Winter2014/yusra/measureCcdConfigs
Last modified 5 years ago Last modified on 02/06/2014 10:07:07 PM

This page contains some preliminary plots of modelMags from meas_multifit running in single-epoch mode (measureCcd.py).

Please click on the plots for full size. These are the starting point for developing some quantitative metrics to test configs.

These are from an i-band test in the HST ACS CLASH cluster RXJ2129+0005 region.

RUN 4 (luvMags): likelihood.usePixelWeights=False + bugfix: compute geometric means with logs

runOrca.py -p lsst -c "measureCcd.py /lsst8/yusra/W14/test_meas/calexp_dir_72
 --output /lsst8/yusra/W14/test_meas/measureCcdOutputRX2129Deblend 
 --config tag=usePixelWeightsFalse_lux --configfile /lsst8/yusra/W14/test_meas/measureCcd_config.py" 
-i /lsst8/yusra/W14/test_meas/rawInputs_i_uniq.dat -e $LSST_HOME -n 1 -N tmp

#where measureCcd_config.py contains:
root.model['fixed-sersic'].profile='luv'
root.fitter.doRecordHistory=True 
root.likelihood.usePixelWeights=False

'fixed-sersic' luv mags from meas_multifit/measureCcd.py vs. SDSS dev mags

By run. The luvMags in this run overestimate the flux in galaxies: http://content.screencast.com/users/YusraAlSayyad/folders/Default/media/a6ca6450-b3bb-47a9-ba48-807c4a9c7af9/devr3.png

Now all runs that have a mean zeropoint offset < 0.03. Right plot is zoomed in version of left plot.
http://content.screencast.com/users/YusraAlSayyad/folders/Default/media/6621c30b-62b9-4a40-90cc-ab11676e45bd/allLuvr3.png http://content.screencast.com/users/YusraAlSayyad/folders/Default/media/10e2195f-894c-4a64-9f04-c37c060a7b20/allLuvZoomedr3.png

What do the sources with overestimated fluxes (devMag-luvMag > 0.5 and devMag < 20) look like?
http://content.screencast.com/users/YusraAlSayyad/folders/Default/media/11bb17af-5dfc-4605-94d7-8a569839847c/weirdLuv2_020614.jpeg http://content.screencast.com/users/YusraAlSayyad/folders/Default/media/2a678c19-d73e-427c-a439-95164b1bf0eb/weirdLuv1_020614.jpeg

RUN 3 (luxMags: likelihood.usePixelWeights=False + bugfix: compute geometric means with logs

runOrca.py -p lsst -c "measureCcd.py /lsst8/yusra/W14/test_meas/calexp_dir_72
 --output /lsst8/yusra/W14/test_meas/measureCcdOutputRX2129Deblend 
 --config tag=usePixelWeightsFalse_luv --configfile /lsst8/yusra/W14/test_meas/measureCcd_config.py" 
-i /lsst8/yusra/W14/test_meas/rawInputs_i_uniq.dat -e $LSST_HOME -n 1 -N tmp

'fixed-sersic' lux mags from meas_multifit/measureCcd.py vs. SDSS exp mags

First, the run by run flux comparisons. The cloud of underestimated luxMags went away!:
http://content.screencast.com/users/YusraAlSayyad/folders/Default/media/c6b31899-5959-41be-8bfe-ae18bb049dce/luxr3.png

We can zoom in now to take a closer look at the compact sources. Black points show the SDSS psfMag vs. the W14 psfMag, which are only here to show the ZEROPOINT OFFSET. Teal and red points show the same as above, just zoomed.
http://content.screencast.com/users/YusraAlSayyad/folders/Default/media/76356ceb-7a76-417b-9700-4bda612c55f4/luxZoomedr3.png

Now all runs that have a mean zeropoint offset < 0.03. Right plot is zoomed in version of left plot.
http://content.screencast.com/users/YusraAlSayyad/folders/Default/media/f690b830-b554-4791-8e82-a0248962c216/Allr3.png http://content.screencast.com/users/YusraAlSayyad/folders/Default/media/57245630-d96b-4cb9-9a9c-318cac5d2600/AllZoomedr3.png

By "luxMags match the SDSS psfMags" I mean this.

http://content.screencast.com/users/YusraAlSayyad/folders/Default/media/725184c7-a91c-4e63-aa43-266c9ad87c9d/strangeExpMags2.gif ^^ Thumbnails of the ~1000 sources in black rectangle above. Most are stars. There are some bright galaxies:
http://content.screencast.com/users/YusraAlSayyad/folders/Default/media/7c46a468-7375-4aa6-8b6d-da35b5b12d80/constExp1.jpeg http://content.screencast.com/users/YusraAlSayyad/folders/Default/media/43238417-3875-40a4-834b-58398278746b/constExp2.jpeg

Repeatibiility

Lines show median and errorbars show the IQR.
http://content.screencast.com/users/YusraAlSayyad/folders/Default/media/4fe9887a-7737-4d08-a9e5-f9522887a824/repeatr3.png

RUN 2: likelihood.usePixelWeights=False

PLEASE NOTE: As of ctrl_execute 7.3.0.0, in the runOrca.py command the -j option has changed to -n. The -n option has changed to -N. The command line options listed below refer to a previous release of ctrl_execute.

runOrca.py -p lsst -c "measureCcd.py /lsst8/yusra/RX2129/calexp_dir 
--output /lsst8/yusra/W14/test_meas/measureCcdOutputRX2129 --config tag=defaults 
--config fitter.doRecordHistory=True likelihood.usePixelWeights=False" 
-i /lsst8/yusra/W14/test_meas/rawInputs_i_uniq.dat -e $LSST_HOME -j 1 -n tmp

The configs are identical to the defaults except for the one change.

S13 multishapelet_combo_mags vs. SDSS model mags (baseline)

The following SDSS vs LSST plots have been changed from the default plots: they compare the model mags for stars AND galaxies

http://content.screencast.com/users/YusraAlSayyad/folders/Default/media/65d2a5d5-4d32-443a-812d-813544284967/multishapeletv2.png

'fixed-sersic' lux mags from meas_multifit/measureCcd.py vs. SDSS exp mags

http://content.screencast.com/users/YusraAlSayyad/folders/Default/media/9bae153d-1662-4caf-a246-c271ecf1e885/luxMagv2.png

Repeatibiility

Lines show median and errorbars show the IQR.

http://content.screencast.com/users/YusraAlSayyad/folders/Default/media/f977038f-db05-4e55-8832-b82d1afc3205/repeatabilityv2.png

modelMags vs. SDSS psfMags

http://content.screencast.com/users/YusraAlSayyad/folders/Default/media/e5fc297c-b928-4752-a2cf-b703a4293256/sepMultishapeletv2.png http://content.screencast.com/users/YusraAlSayyad/folders/Default/media/7130f2a8-ff33-4ce3-bbef-8d90a15363f0/sepLuxMagv2.png http://content.screencast.com/users/YusraAlSayyad/folders/Default/media/e3f2d4a0-67b6-47dc-8e0d-cfb6d13e4804/sepSDSSv2.png

Run 1: Default Configs

runOrca.py -p lsst -c "measureCcd.py /lsst8/yusra/RX2129/calexp_dir 
--output /lsst8/yusra/W14/test_meas/measureCcdOutputRX2129 --config tag=defaults 
--config fitter.doRecordHistory=True" 
-i /lsst8/yusra/W14/test_meas/rawInputs_i_uniq.dat -e $LSST_HOME -j 1 -n tmp

measureCcdOutputRX2129/config/measureCcd/defaults.py:

import lsst.meas.multifit.measureCcd
assert type(root)==lsst.meas.multifit.measureCcd.MeasureCcdConfig, 'config is of type %s.%s instead of lsst.meas.multifit.measureCcd.MeasureCcdConfig' % (type(root).__module__, type(root).__name__)
root.minInitialRadius=0.1
root.fitRegion.nGrow=0
root.fitRegion.growIsotropic=True
root.prior['mixture'].filename='s13-v2-disk-08.fits'
root.prior.name='mixture'
root.fitter.gradientThreshold=1e-05
root.fitter.trustRegionShrinkReductionRatio=0.25
root.fitter.trustRegionGrowFactor=2.0
root.fitter.trustRegionGrowStepFraction=0.8
root.fitter.doSaveIterations=False
root.fitter.trustRegionGrowReductionRatio=0.75
root.fitter.trustRegionShrinkFactor=0.3333333333333333
root.fitter.stepAcceptThreshold=0.0
root.fitter.trustRegionInitialSize=1.0
root.fitter.doRecordDerivatives=True
root.fitter.numDiffRelStep=0.0
root.fitter.numDiffTrustRadiusStep=0.1
root.fitter.maxOuterIterations=500
root.fitter.skipSR1UpdateThreshold=1e-08
root.fitter.noSR1Term=False
root.fitter.numDiffAbsStep=0.0
root.fitter.maxInnerIterations=20
root.fitter.minTrustRadiusThreshold=1e-05
root.fitter.trustRegionSolverTolerance=1e-08
root.fitter.doRecordHistory=True
root.doRaise=False
root.psf.innerOrder=2
root.psf.initialRadius=1.5
root.psf.priority=2.0
root.psf.minRadius=0.1
root.psf.radiusRatio=2.0
root.psf.minAxisRatio=0.1
root.psf.peakRatio=0.1
root.psf.outerOrder=2
root.psf.useApproximateExp=False
root.progressChunk=100
root.prepOnly=False
root.doApplyUberCal=False
root.tag='defaults'
root.maxObjects=None
root.model['bulge+disk'].bulge.profile='luv'
root.model['bulge+disk'].bulge.nComponents=8
root.model['bulge+disk'].bulge.maxRadius=None
root.model['bulge+disk'].fixCenter=True
root.model['bulge+disk'].bulgeRadius=0.6
root.model['bulge+disk'].disk.profile='lux'
root.model['bulge+disk'].disk.nComponents=8
root.model['bulge+disk'].disk.maxRadius=None
root.model['gaussian'].fixCenter=True
root.model['gaussian'].radius=1.0
root.model['fixed-sersic'].profile='lux'
root.model['fixed-sersic'].nComponents=8
root.model['fixed-sersic'].fixCenter=True
root.model['fixed-sersic'].maxRadius=None
root.model.name='fixed-sersic'
root.likelihood.usePixelWeights=True
root.likelihood.useApproximateExp=False
root.previous=None

S13 multishapelet_combo_mags vs. SDSS model mags (baseline)

This plots are being shown only for comparison purposes. Runs are separated into panels, so that zeropoint scaling differences are clear. Each panel may consist of up to 3 separate fields which are scaled separately. Note that the S13 multishapelet mags are relatively well calibrated with no slope.

For point sources (blue): differences in LSST and SDSS psfMags are shown as a reference to the zp scaling. For extended sources (red): differences in modelMags are show.

The star/galaxy designation is taken from SDSS skyserver. Objects with NaN measurements or any of the LSST flags set were removed.

http://content.screencast.com/users/YusraAlSayyad/folders/Default/media/9bad53a7-129b-48fc-b2ce-1b095baf4508/multishape1.png http://content.screencast.com/users/YusraAlSayyad/folders/Default/media/fb270aa7-2bd9-42d8-b030-36e507a506c5/multishape2.png

default meas_multifit/measureCcd.py vs. SDSS model mags

http://content.screencast.com/users/YusraAlSayyad/folders/Default/media/666e6dfe-823a-4680-8824-f07aa9d27987/defaultsPerRun.png http://content.screencast.com/users/YusraAlSayyad/folders/Default/media/7821cf59-7515-45ab-b72b-67c148239936/defaultsPerRun2.png

Repeatibiility

http://content.screencast.com/users/YusraAlSayyad/folders/Default/media/1a8be5e6-fefd-44b0-8197-76c6b3c7f168/Repeatability.png

modelMags vs. SDSS psfMags

http://content.screencast.com/users/YusraAlSayyad/folders/Default/media/72803e52-eced-45eb-b8b3-fdd4e17de73b/lsstSGSep.png http://content.screencast.com/users/YusraAlSayyad/folders/Default/media/7f58e067-2850-4ec5-90f1-77752d2b1c0e/sdssSGSep.png http://content.screencast.com/users/YusraAlSayyad/folders/Default/media/a822c6e7-2d13-46d6-bdd8-0a597923c8d1/lsst-lsstSGSep.png

Hack to print multifit outputs to csv

WARNING: JUST A HACK THAT WILL PRINT OUTPUT FROM A TICKET VERSION OF MEASURE_CCD. THIS WILL CHANGE AND IS NOT A PERMANENT SOLUTION AS MAPPERS NEED TO BE UPDATED

import numpy as np
import lsst.meas.multifit #you need branch /u/bosch/w14 which is in active development
import lsst.afw.image as afwImage
import lsst.afw.table as afwTable
import lsst.daf.persistence
import os
import signal

from  lsst.meas.multifit.measureCcd import MeasureCcdTask
TaskClass = MeasureCcdTask
configName = "measureCcd_config"
butler = lsst.daf.persistence.Butler('/lsst8/yusra/W14/test_meas/measureCcdOutputRX2129/')
config = butler.get(configName, tag='defaults', immediate=True)


#You can get a single record from the butler like:
butler.get('modelfits', tag='defaults', run=6425, camcol=4, field=171, filter='r')
#However, .subset isn't setup up with the tags columns, so .subset doesn't work for me


#please forgive the direct file access:
modelfitdir =  '/lsst8/yusra/W14/test_meas/measureCcdOutputRX2129/modelfits/defaults/'
fileList = os.listdir(modelfitdir)
task = TaskClass(config=config, butler=butler)
interp = task.fitter.interpreter

def printCatToFile(catalog, Handle):
    for i, c in enumerate(catalog):
        outputList = [c.get('id'), c.get('coord').getRa().asDegrees(),c.get('coord').getDec().asDegrees(), 
        c.get('snr'), 
        c.get('sys.position').getRa().asDegrees(),  c.get('sys.position').getDec().asDegrees(), 
        c.get('sys.mag'), ', '.join([str(item) for item in c.get('fit.nonlinear')]), 
        c.get('fit.amplitudes')[0], '%d'%(c.get('fit.flags')), c.get('fit.state'), c.get('objective'),]
        if np.isnan(c.get('objective')):  #Jim points out that it's better to check the flags. 
            print c['id'], " mag/flux/time calc failed"
        else:     
            try:
                unitsys = task.getUnitSystem(c)
            except:
                print i, c['id'], "unitsys" 
                continue
            try:
                mag =  unitsys.calib.getMagnitude(interp.computeAmplitudeMean(c))[0]
                flux = unitsys.calib.getFlux(interp.computeAmplitudeMean(c))[0]
                time = unitsys.calib.getMidTime().mjd()
            except:
                print c['id'], " mag/flux/time calc failed"
                continue
            outputList.append(mag)
            outputList.append(flux)
            outputList.append(time)
            print >>Handle, ', '.join([str(o) for o in outputList])

handleRX = open('RXDefault_2.dat', 'wb')
for i, f in enumerate(fileList):
    if '-i' in f: #I only wanted i-band for now
        print "%s of %s"%(i, len(fileList)), f
        path = os.path.join(modelfitdir,f)
        try:
            catalog1 = lsst.meas.multifit.ModelFitCatalog.readFits(path)
        except:
            print "...didnt open"
            continue
        printCatToFile(catalog1,handleRX)
        handleRX.flush()
handleRX.close()