Giter VIP home page Giter VIP logo

ugali's Introduction

Build PyPI Release License Github Downloads

Overview

The ultra-faint galaxy likelihood (ugali) toolkit provides a set of python modules developed for maximum-likelihood-based studies of resolved satellite galaxies. The primary inputs are stellar object catalogs derived from optical photometric surveys and the coverage masks of those surveys. In addition, ugali ships with a set of synthetic isochrone libraries and catalogs of known resolved stellar systems.

Authors: Keith Bechtol & Alex Drlica-Wagner

Installation

There are several ways to install ugali.

The most robust way is to follow the installation procedure for the automated GitHub Actions build documented in python-package.yml. This installation creates a conda environment with the necessary dependencies and installs ugali.

# Create and activate conda environment
conda create -n ugali-env numpy scipy matplotlib astropy healpy pyyaml emcee nose fitsio corner -c conda-forge -c kadrlica
source activate ugali-env

# Clone source code from the parent repository
git clone https://github.com/DarkEnergySurvey/ugali.git && cd ugali

# Install just the python source code
python setup.py install 

# Install source code with a minimal set of isochrone and catalog libraries
python setup.py install --isochrones --catalogs

In theory, the easiest way to get a stable release of ugali is through PyPi using pip:

# Install just the source code
pip install ugali

# Install source code with a minimal set of isochrone and catalog libraries
pip install ugali --install-option "--isochrones" --install-option "--catalogs"

By default, the minimal isochrone and catalog libraries are installed into the directory specified by the $UGALIDIR environment variable (default: $HOME/.ugali). The download and unpacking of the isochrone and catalog files might make it appear that your pip installation has stalled. Unfortunately, pip may not display a progress bar during this delay.

Auxiliary Libraries

The ugali source code is distributed with several auxiliary libraries for isochrone generation and catalog matching. These libraries can be downloaded directly from the releases page, and unpacked in your $UGALIDIR. For example, to install the Bressan et al. 2012 isochrones for the DES survey:

cd $UGALIDIR
wget https://github.com/DarkEnergySurvey/ugali/releases/download/v1.8.0/ugali-des-bressan2012.tar.gz
tar -xzf ugali-des-bressan2012.tar.gz

The UGALIDIR environment variable is used to point to the isochrone and catalog libraries. If you install the isochrones in a non-standard location be sure to set UGALIDIR so ugali can find them:

export UGALIDIR=<PATH>

An experimental interface for downloading the isochrone and catalog libraries also exists through setup.py:

# To install the Bressan+ 2012 isochrones for the DES survey
python setup.py isochrones --survey des --model bressan2012

# If you have isochrones already installed, you may need to force
python setup.py isochrones --survey des --model bressan2012 --force

# To install all available DES isochrones
python setup.py isochrones --survey des

# To install all available Bressan+ 2012 isochrones
python setup.py isochrones --model bressan2012

# To install the catalog libraries
python setup.py catalogs

Usage Examples

Several examples can be found as jupyter notebooks in the notebooks directory.

Additional Information

Dependencies

These should mostly be taken care of by PyPi with a pip install.

Isochrones

The isochrones used by ugali come dominantly from:

More information can be found in the isochrone module.

Abbreviations

  • CMD: color-magnitude diagram
  • ROI: region of interest
  • PDF: probability distribution function
  • LKHD: likelihood
  • IMF: initial mass function
  • LUT: look-up table

ugali's People

Contributors

bechtol avatar johannct avatar kadrlica avatar mcnanna avatar sidneymau avatar willcerny avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ugali's Issues

Add more nearby galaxies?

We could add a more complete and modern galaxy sample from HyperLeda. This is a continuation of the RC3 catalog of bright galaxies. I haven't noticed any major issues with incompleteness in the catalogs we have ingested (NGC, IC, and UGC), but I am continually paranoid about missing something.

Large and small kernels

Check for numerical issues with very small Plummer radii, sampling kernel (at the very least add a warning). Investigate large kernel fitting accuracy, what is largest size?

Re-integrate simulation tools

@bechtol has been developing simulation tools under the scratch directory. Once development slows it would be good to re-integrate these into the simulation module.

Create a github organization?

Now that we are using ugali across surveys it probably makes sense to start moving the package to a github organization. This would also allow us to host dependent tools such as the simple_binner, dsphsim, and a future "pysochrone" module.

Add background density to results

It would be nice to add the background density to the results file. This is a bit complicated, because we are actually calculating the background model as a 2D probability distribution in color magnitude space, but maybe we could do something like sum loglike.b values for stars in the interior region?

This feature was requested by @scantu and @sidneymau in order to better plot radial profiles including the background density.

Non-uniform background

Residual maps / how to deal with gradients in background (important mainly for LMC region)

Isochrone storage format

Distributing the isochrones is a headache. Might we want to compress isochrone data to easy distribution and allow for more extensive isochrone set? This is connected to #21.

Loading config in mcmc

Working on MCMC analysis with ugali and tyring to use g-i bands has shown that ugali.analysis.source seems to create a g-r isochrone even when the relevant config files specify band_1 = g and band_2 = i. This behavior has been evidenced in ugali/pipeline/run_05.0_followup.py and ugali/analysis/mcmc.py, but may be elsewhere.

Deal with objects outside of ROI

Be careful with spatialBin function when objects fall outside of ROI. This may actually be throwing an error now (which is not terrible). Need to look into more deeply.

Fix IAU name generation

We changed the default coordinate system to equatorial, but this didn't fully propagate to the results file. In particular, we are mis-reporting the glon,glat values and the iau name. Taking into account the correlated uncertainties between ra,dec and glon,glat is most easily done at the level of estimating parameters from the chains.

Isochrones updates and distribution

This is a moving target since new isochrones come out all the time. It's also a pain because of the way we distribute the isochrone files. We might want to think about a standalone isochrone package (certainly a lot of work to be done there). We might also want to think about a deeper integration of the code to download isochrones from the web.

Add Martin surface brightness to results

@willcerny tracking this as a separate issue since #78 is closed. It should be pretty easy to calculated surface brightness from the Martin mag if it exists and output it as an additional results field. Basically add something like this inside the if martin block:

mu = surfaceBrightness(Mv, rsize, dist) ##updated from size-->rsize
results['surface_brightness'] = ugali.utils.stats.interval(mu,np.nan,np.nan)

Precompute HEALPix pixel for each object

Precompute HEALPix pixel for each object and avoid creating full HEALPix maps. I'm not really sure what this means any more, but I think it would involve some pre-processing before catalog creation.

Typo in DECam mesa isochrone IO

The column for log_lum should be 6 (as opposed to 8) for DECam based on an example isochrone from MIST.

The line to change is here:

(8, ('log_lum',float)),

Columns from the isochrone file:

#   1                               2                               3                               4                               5                               6                               7                               8                   9                  10                  11                  12                  13                  14                  15                  16
# EEP          log10_isochrone_age_yr                    initial_mass                       star_mass                        log_Teff                           log_g                           log_L                     [Fe/H]_init              [Fe/H]             DECam_u             DECam_g             DECam_r             DECam_i             DECam_z             DECam_Y               phase

bug in plotMembership in ugali.utils.plotting

In Line 1219 and 1220 of ugali.utils.plotting.py, an error is returned in calls to plotMembership because of a reference to self.isochrone.band_1 and self.isochrone.band_2. The "self" should be removed in both cases.

Also, the axes labels are swapped - line 1219 should be set_xlabel and 1220 should be set_ylabel

rec_append_fields deprecation

Matplotlib b2.2 has started warning that mlab.rec_append_fields is deprecated. There is a drop-in replacement in numpy.lib.recfunctions; however, it is a factor of 5x slower...

Make celestial coordinates the default

We made the unfortunate (though physically motivated) decision to use Galactic coordinates as the default. We need to change this to Celestial, and make sure that the infrastructure for changing coordinate systems actually works.

Sparse HEALPix file format

This is a great space saver, but uses a non-standard file format. We should investigate whether healpy has evolved to have a sparse file format.

Fix histogram binning

We are currently inconsistently defining whether our histograms are defined with hist.shape == (len(xbins),len(ybins)) or hist.shape == (len(xbins)-1,len(ybins)-1). The second defines the bin value at the center of the bin and is the convention followed by numpy.

Add catalog for diffuse structures

It would be useful to define a catalog for diffuse structures (streams & clouds) that can be potentially confused with satellite candidates. I think the preliminary list would consist of:

  • ATLAS stream (particularly the over dense "progenitor")
  • Phoenix stream (particularly around over densities)
  • SMCNOD
  • LMC tidal tail from Mackey

ugali.stats.peak_interval appears to be calculating the interval incorrectly

We are sometimes seeing that the peak interval does not contain the peak (kde peak)
I think this has to do with lines 99 and 100, which currently read:
lo = x[min_idx]
hi = x[min_idx+window]

and should probably be changed to something along the lines of
lo = starts[select][min_idx]
hi = ends[select][min_idx]

Change coordinate name to equatorial

We currently track two coordinate systems: Galactic (gal) and celestial (cel). Celestial just means "sky" and doesn't actually contain information about coordinate frame. The actual system is the equatorial coordinate system, so we should update instances of cel to equ. This is a trivial change, but permeates the codebase.

Update isochrone download scripts

The isochrone download scripts have become out of date as we've moved the server query functionality into the isochrone classes. We should update these scripts to use the current configuration in the isochrone classes.

Pinging @mcnanna to keep an eye on this for his LSST work.

Default configuration

Merge config file with default config or store defaults in objects (probably the latter)?

Absolute magnitude from generic isochrone color

@sidneymau ran into the problem that the absolute magnitude calculation requires that the isochrone uses g and r band magnitudes assuming the DES system. We can work around either by having transformation equations for other bands, or by accessing the g and r magnitudes directly from the isochrone. The use of sample makes this a bit more complicated, so maybe we need to make a copy of the isochrone with band_1 = g and band_2 = r.

Move to fitsio

I've found fitsio to be superior to pyfits. In addition, astropy has taken over pyfits, which is now accessed as astropy.io.fits. I'd like to switch to fitsio, or abstract the interface to the fits reader so the user can use whatever is available on their system (fitsio > astropy.io.fits > pyfits).

Output Galactic coordinates with uncertainties

We implemented the ability to output the Galactic coordinates with the "correct" coordinate uncertainties by directly converting the mcmc chains. However, this never propagated through to the results file. In fact, the gal values in the results file have been incorrect.

Generalized bands in plot output

Generalize bands in plot output, i.e.

plt.xlabel(r'$g - r$')
plt.ylabel(r'$g$')

Examples:

Pythonic style string formatting

plt.xlabel(r'${} - {}$'.format(self.isochrone.band_1, self.isochrone.band_2)
plt.ylabel(r'${}$'.format(self.isochrone.band_1))

C style string formatting

plt.xlabel(r'$%s - %s$' % (self.isochrone.band_1, self.isochrone.band_2))
plt.ylabel(r'$%s$' % self.isochrone.band_1)

User age/metallicity bounds not respected

The isochrone constructor currently disregards user-specified bounds on age/metallicity and sets them to the range of the isochrone grid (see here). Possible improvements:

  1. Continue this behavior but warn the user
  2. Respect the user's bounds when they are within the isochrone grid; when outside warn the user and set to the isochrone grid bounds.
  3. Respect the user's bounds and throw and exception when they are outside the allowed grid bounds.

For both 2. and 3. above, the default isochrone grid consists of age = [10, 12] and z = [0.0001,0.0002], so the default bounds should be similarly constrained.

Tighter link between isochrone and data selections

There is a fragility in the connection between the selection applied to the isochrones and the selection applied to the data. We want to connect isochrone.observableFraction and mask.restrictCatalogToObservableSpace better.

Include completeness in mask

Compute observable fraction including photometric errors and detection completeness. Currently only using the magnitude limit. Fully incorporate completeness in isochrone fitting and simulation.

Update ugali dwarf catalogs

A few issues with the catalogs:
Laevens 1 is listed in the ExtraClusters catalog, but the ra, dec, and reference are all for Laevnes 2/Triangulum II. Triangulum II already exists in the ExtraDwarfs catalog. I think the solution is to change the ra, dec, and reference for Laevens 1 to actually be for Laevens 1.

Aquarius II is not in any catalog. It probably belongs in ExtraDwarfs.

McConnachie15 has an object named "Indus I ?", which is actually Indus II.

Python3 ...

Ugh, but LSST is moving this way so we better too.

Surface intensity for small kernels

Calculating the per pixel surface intensity for small kernels has been a continual issue. The basic problem is that when the pixel size becomes comparable to the kernel size, the location of the kernel centroid within a pixel can have a large effect on the surface intensity calculated within that pixel. This leads to an unnormalized surface intensity and a mis-estimation of the richness and other source parameters.

One possible solution would be to subsample the surface intensity within each pixel (or just the central pixels). Whether this is technically and computationally feasible needs to be investigated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.