SDSS fits cutouts

Since quite some time I have been trying to get image cutouts from the SDSS in fits format. The jpg images in the cutout service are ok for simple tasks but nothing serious. Recently a colleague told me about Montage, a great tool to automate fits cutout, mosaic generation, coverage masks etc. Since Montage doesn’t include a script to retrieve SDSS cutouts in a simple way (there is actually one but I could not make it run) I wrote the following bash script based on Inseok Song’s pleiades script.

You need to install Montage first and add Montage’s bin folder to your PATH


Download and install Montage:

http://montage.ipac.caltech.edu/


Add Montage’s bin folder to your path, this can be done in your .bashrc file. My Montage installation is in /home/miguel/Packages/Montage :

export PATH="/home/miguel/Packages/Montage/bin:$PATH"

 

This is the fits cutout script:


int a;

if (a > b){

printf(b);

}

 



[sourcecode language="bash"]
 #!/bin/bash # # Cutout fits images from SDSS # # Adapted from Inseok Song, 2007 # http://irsa.ipac.caltech.edu/docs/howto/DSS_pleiades_mosaic.html # # Arguments: # $1 ra # $2 dec # $3 size # $4 base_name # # Usage: sh get_sdss_atlas.sh 199.54198 -1.2436732 0.05 gal_000 # Miguel Aragon-Calvo, 2017 # echo ra $1 echo dec $2 echo size $3 echo file $4 #--- Working directory mkdir $4; cd $4; mHdr -p 0.4 "\"$1 $2\"" $3 $4.hdr for bands in u g r i z; do echo Processing ${bands}; mkdir $bands; cd $bands; mkdir raw projected; cd raw; mArchiveList sdss ${bands} "\"$1 $2\"" $3 $3 remote.tbl; mArchiveExec remote.tbl; cd .. ; mImgtbl raw rimages.tbl ; mProjExec -p raw rimages.tbl ../$4.hdr projected stats.tbl ; mImgtbl projected pimages.tbl ; mAdd -p projected pimages.tbl ../$4.hdr ${bands}.fits ; cd .. ; mv ${bands}/${bands}.fits . ; rm -rf ${bands} ; done cd .. ; #mJPEG -blue $4/g/g.fits -1s "99.999%" gaussian-log -green $4/r/r.fits -1s "99.999%" gaussian-log -red $4/i/i.fits -1s "99.999%" gaussian-log -out $4.jpg [/sourcecode]

For instance, to retrieve and generate fits images for all SDSS filters (u,g,r,i,z) centered at ra=19.54198, dec=-1.2436732 (the galaxy at the top of this post) with 0.05 degrees of size we call the script as follows:

$ sh get_sdss_atlas.sh 199.54198 -1.2436732 0.05 gal_000

The final fits files can be found in the folder gal_000 as gal_000/u.fits, gal_000/g.fits, etc.

The (commented) last line produces a jpg image using logarithmic scaling. The asinh scaling (http://adsabs.harvard.edu/abs/2004PASP..116..133L) is a better option.

Note that Montage will retrieve fits of complete sdss fields, probably more than one file per band. From these files it will cut the desired image. In the case of (small) individual galaxies this can be very  IO wasteful. For the galaxy called above Montage will download ~400MB of sdss field fits files in order to generate 5 fits files with 1.6MB each. The script automatically deletes the intermediate files.

 

 

Advertisements

Delaunay volumes

This post shows some experiments I have been doing with pseudo volume rendering using Delaunay tessellations.While there are lots of techniques that can be used to display large point datasets there are very few techniques for visualizing sparsely sampled points. This is a very common situation when dealing with (astronomical) real data like galaxy redshift catalogues.

This technique does not produce “correct” volume renderings but it is very fast, uses memory efficiently and looks very cool.  This approach is based on the Delaunay tessellation of the point distribution. Densities at each point are estimated assuming that they are proportional to the volume of the contiguous voronoi cell of the point. The density value can be computed at any point inside the convex hull of the point distribution by linearly interpolating the density between the 4 vertices of the tetrahedron containing the sampling point.

This is a pesudo volume rendering. Instead of computing the integrals along the line of sight for each pixel one uses summatory of the interpolated values along the faces of the tetrahedra that intersect with the line of sight. This is just a complicated way of saying that one simply has to display the triangles using the density at each point to color them. While this is technically wrong one can see that for visualization purposes it actually works very well. It was the advantage of not requiring any computation from the CPU since all the drawing is done in the graphics card.

This is a very simple OpenGL application. It still needs a lot of work. In regions with high density one could use GLpoints or point quads. I disable z-ordering so it is not possible to assign opacity to the triangles. I am also working on a .obj file loader to visualize objects like 3D survey masks, fancy axis, field lines, etc.

The advantage of using triangulation becomes clear in the low-density regions. One can resolve filamentary structures with less than 30 particles!

The images are rendering from a low-res N-body simulation. The mass per particle is in the order of 10^11 solar masses.

A fly through the Universe

This post describes the main steps in the making of a SDSS fly-though I have been developing since some time ago. I started with povray but moved to Blender due to its flexibility,  especially  with its python api.

Since its first light the SDSS has been continuously taking both images and spectra across the northern sky. The last data release (DR7) contains almost one million galaxies with spectra and many more galaxy images. From the +- million galaxies with measured redshift only a very small fraction has high quality images. This is mainly due to the intrinsic resolution of the telescope and the atmospheric conditions at the time of observation. In order to produce images with the desired quality each galaxy in the spectroscopic sample was matched with a high-res image from a template of galaxies. The matching was done by choosing the closest galaxy in color — concentration-index space. Elliptical galaxies were displayed as quad sprites with a dense bulge and a diffuse 3D halo.

Galaxy template
Galaxy template

Loading galaxies into Blender
Once all galaxies have been assigned an image from the template the next step is to load the galaxy’s position, size, inclination and image into Blender. The python interface provided by Blender makes this very easy.

Galaxies were binned by their respective templates. The all galaxies were loaded into a single object in Blender. So there are 300 objects each holding several thousand quads for each galaxy. This saves memory since there is no need to store all the possible properties for each galaxy.

Loading galaxies into Blender
Loading galaxies into Blender

In progress…