Skip to content

Instantly share code, notes, and snippets.

View demitri's full-sized avatar

Demitri Muna demitri

View GitHub Profile
@demitri
demitri / 3d_sphere.tex
Last active April 20, 2020 23:32
Demo of drawing a 3D sphere using native ra,dec coordinates in LaTeX using the TikZ package.
% This is a demo of drawing a 3D sphere using native ra,dec coordinates in LaTeX using the TikZ package.
% It's based on this fantastic StackExchange answer:
% https://tex.stackexchange.com/questions/537573/how-can-i-draw-great-circles-on-a-diagram-using-specific-coordinates-with-arbitr
\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{fpu}
\usepackage{tikz-3dplot-circleofsphere}
\makeatletter
# Since Contents/Resources/createinstallmedia command doesn't work, we need to manually create an disk image.
# Mount InstallESD.dmg
hdiutil mount /Applications/Install\ OS\ X\ 10.10\ Developer\ Preview.app/Contents/SharedSupport/InstallESD.dmg
# Create a temporary writable BaseSystem image.
hdiutil convert /Volumes/OS\ X\ Install\ ESD/BaseSystem.dmg -format UDRW -o rw.dmg
# Get required sectors for packages.
# You'll get these numbers.
@demitri
demitri / fits_column_read.py
Last active May 9, 2017 20:04
Different ways to read a single column from a FITS file.
#!/usr/bin/env python
from astropy.table import Table
import fitsio
import time
import astropy.io.fits as fits
__author__ = "Demitri Muna"
__date__ = "2017.05.09"
## 5.4G survey-dr3-specObj-dr13.fits
@demitri
demitri / fits_histogram.R
Created January 26, 2016 21:35
Creating a histogram of pixel values of an image from a FITS file in R.
library(FITSio)
hdu1 = readFITS(file="myfile.fits", hdu=1)
image = hdu1$imDat
hist(image)
@demitri
demitri / Muna_MOC_2015-10-30.md
Last active October 30, 2015 11:52
Demitri Muna’s suggestions for HiPS/MOC survey footprints, 30 October 2015

Notes on HiPS

HiPS is a useful iteration on top of Healpix, however, it is missing a few things that could make it useful in production pipeline code (and other uses). Of particular note, it has a notable functional overlap with mangle (http://space.mit.edu/~molly/mangle/), a tool for creating polygons on a sphere. Mangle is used extensively in SDSS and DES.

These are the area that I feel HiPS could be improved upon.

  1. HiPS should have "memory" of the individual files that comprise the survey footprint. Given an ra/dec position, one should be able to query the MOC and have returned all of the files that contain that position. Take for example SDSS. Nearly every image frame (if not all) overlap at least a little, and in many cases (such as Stripe 82) many times, with other images. A much more useful footprint survey map will contain a) the overlap information and b) the name (or some unique identifier) of the file of each "tile". In fact, ESA Sky requires this information, but it was pointed out to me by T
@demitri
demitri / install_postgresql.md
Created July 21, 2015 15:47
Installing PostgreSQL from source

These are directions written a few years ago to help SciCoder students install PostgreSQL from source. It might be a little out of date, but could still be useful. And the Markdown needs updating.

The following instructions will show you how to install PostgreSQL from source. Although other methods are available, I would like you to follow these directions. The directions are applicable to both Mac and Linux platforms. In each case, you will be running the installation from the terminal command line.

[b]Mac Users[/b] We need to make sure that a few settings are correct.

  • Are you running a 64-bit machine? If no, skip down to step one below. You can check by entering the following on the command line:
@demitri
demitri / simple_config.py
Last active August 29, 2015 14:17
Simple example for reading configuration files.
'''
This is a simple example of how to read configuration (or parameter) files in Python
using the ConfigParser module.
Docs:
https://docs.python.org/2.7/library/configparser.html
https://docs.python.org/3/library/configparser.html
'''
# Imagine a separate parameter file called "parameters.cfg". Values are grouped into different (named) domains.
@demitri
demitri / Healpy 1.8.1source installation
Created October 19, 2014 05:29
healpy 1.8.1 source installation, Anaconda 2.1.0, MacOS X 10.9.5, Python 2.7.8
MacBook-Air [~/tmp-healpy] % tar -xzf healpy-1.8.1.tar.gz
MacBook-Air [~/tmp-healpy] % cd healpy-1.8.1
MacBook-Air [~/tmp-healpy/healpy-1.8.1] % python setup.py build
pkg-config is not installed, falling back to pykg-config
zip_safe flag not set; analyzing archive contents...
Installed /Users/demitri/tmp-healpy/healpy-1.8.1/pykg_config-1.3.0-py2.7.egg
running build
running build_py
creating build
@demitri
demitri / healpy_pip_install_trace.txt
Last active August 29, 2015 14:07
Healpy pip installation - healpy 1.8.1, Anaconda 2.1.0, Python 2.7.8, MacOS X 10.9.5
MacBook-Air [~] % pip install healpy
Downloading/unpacking healpy
Downloading healpy-1.8.1.tar.gz (4.0MB): 4.0MB downloaded
Running setup.py (path:/private/var/folders/55/tqc0jdf55_755p_6gjxs3fph0000gn/T/pip_build_demitri/healpy/setup.py) egg_info for package healpy
pkg-config is not installed, falling back to pykg-config
zip_safe flag not set; analyzing archive contents...
Installed /private/var/folders/55/tqc0jdf55_755p_6gjxs3fph0000gn/T/pip_build_demitri/healpy/pykg_config-1.3.0-py2.7.egg
checking if configure script for library 'cfitsio' exists