Wiki

Clone wiki

Sunrise / SunriseBootCamp

UW Sunrise Boot Camp

THIS IS VERSION 3.5 OF THIS TUTORIAL

HOW TO MAKE ARTIFICIAL IMAGES FROM GASOLINE COSMOLOGICAL SIMULATIONS USING SUNRISE "seattle" V3.5 aug 08

Index

0.0 version number and recent changes

1.0 Introduction

2.0 How to get the test tar bootcamp and check libraries

3.0 CREATING/SELECTING THE DATA FILE to be Sunrised 3.1 using TIPSY 3.2 using IDL (useful for batch runs)

4.0 Running SUNRISE 4.1 sfrhist 4.1.1 sfrhist.stub 4.1.2 sfrhist.config 4.1.3 makegrid.stub 4.1.4 makegrid.config 4.1.5 units examples 4.2 mcrx 4.2.1 mcrx.stub 4.2.2 mcrx.config 4.2.3 SEDs with python script sed.py 4.3 broadband 4.3.1 broadband.stub 4.3.2 postprocess.config (includes high z postprocessing)

5 Advanced Features 5.1 Multiple cameras 5.2 Pretty Images


Note: (search for it!) marks parameters that might need to be fine tuned depending on the run.

0.0 ----------------

V3.2 -Mostly updates to stub and config files that are precision related.

-A few notes on making images for movies. V3.3 - sfrhist.stub: modified the mass of a star forming region to 5e6 (sunrise does not like the e6.5 format..) - corrected a few typos V3.4 -makegrid.stub changed the following lines:

max_level 13 tau_tolerance 0.9 This makes sure that cells are open just where the optical density is high. Before tau_tolerance was set way too small forcing makegrid to open too many cells where not needed. max_level 13 gives a few million cells for our cosmo50cmb.1536 runs, using abput 40gb of ram. 14 would crash elektra for lack of memory. (11 would likely be good as well) V3.5 -more tuning of the cells business. Maybe no IR crash?

  • sfrhist.stub
    1. ax_radius 0.15 / kpc Maximum stellar radius is now obsolete.

      A BUG WAS FIXED THAT MADE THE SIZE OF STAR FORMING REGIONS AS BIG AS THE SOFTENING. THAT CREATED ARTIFICIALLY LOW DUST ABSORPTIONS star_radius_factor 0.2 / was added. sets the size of starforming regions as a fraction of the force softening. so for runs cosmo50cmb.1536 force = 0.3 kpc -> size SF region = 60pc. Use 0.1 for low resolution runs as cosmo25.256 larger numbers might be required for very high res runs.


1.0 INTRODUCTION


You can make images, get magnitudes and artificial spectral energy

distributions of your cosmological simulation snapshots using the code Sunrise. Patrik Jonsson wrote it and here is a link to his web site:

http://www.ucolick.org/~patrik/sunrise/

and the wiki:

http://code.google.com/p/sunrise/

In addition, here is a brief tutorial Fabio and Chris wrote that will get you started with Sunrise on elektra.astro.washington.edu. We are using Sunrise "3.0" i.e the version as June 20th 2008. This tutorial will let you:

-select galaxies to sunrise from an existing simulation -run sunrise -get some preliminary results.

This HOWTO is available on the ftp astro site or on the Twiki web page at mc.master.edu (not yet as of June 08 FG)

This blurb assumes that sunrise has been correctly compiled on the UW astro environment and you can see the executables.

Sunrise produces as a final output fits files with: 2D "astronomical" images from N-Body simulation that contains stars and gas. For each pixel the code records also the full flux SED of the sources along that line of sight. Sunrise includes a full treatment of dust reprocessing with radiative transfer.



2.0 HOW TO GET THE TEST TAR BOOTCAMP

2.1 GET STARTED get

an account on elektra by sending an email to (better) help@astro.washington.edu or (last resort) Tom Quinn trq@astro.washington.edu. That is were the analysis is supposed to be done. You can use a computer with smaller RAM for tests limited to a few thousand particles.

2.2 Get the relevant sample files from ftp.astro.washington.edu

ftp ftp.astro.washington.edu login anonymous passwd yourname@youraccount

cd pub/users/fabio get BootCamp.sunrise.v3.4.tar.gz untar in a directory of your choice.

You might also try /astro/net/safe1/fabio/BootCamp.vX.Y/ where you might find a fresher version.

2.3) point Sunrise to the right libraries

setenv LD_LIBRARY_PATH /astro/users/patrik/lib setenv PYTHONPATH /astro/users/patrik/python

type "limit coredumpsize 0k", just because.

Sunrise is actually a suite of programs that have to be run sequentially. The files program.stub contain parameter settings that are rarely changed and that should be common to all the outputs you need to analyze at the same time. The program.outputname.config contain the information relative to each specific output. A few ancillary files have to be in the same dir where you keep your data to be "sunrised", there are also a few idl routines that you might keep there or in your IDL repository. namely:

IDL routines:

rtipsy.pro wtipsy.pro align.pro read_lon_array.pro stdSats.pro TIPSY related programs: smooth std2ascii SUNRISE related files:

filters 4 config files 4 stub files pahtemplate DATA files a number of h258 files:

00512 000512.[stat,grp,gtp]

BenIDL contains idl routines to handle large batch runs imageIDL contains idl routines to make fake color images

Now we check that you can see the sunrise executables:

"which sfrhist" should output:

/astro/users/patrik/bin/sfrhist

do the same with:

mcrx broadband

if not put the directory in your path!


3.0 CREATING/SELECTING THE DATA FILE to be Sunrised. This assumes that you want

to select a galaxy (in practice a group of stars, gas and Dark Matter from a simulation) to study. IMPORTANT: this HOWTO assumes that the run you are looking at has been passed through AMIGA, our favorite halo finder. AMIGA finds high density spherical regions in cosmological simulations. Some of them will have stars and gas and we call them "galaxies". Some of them might be satellites of larger galaxies. That is OK. It is useful for the

selected galaxy to be aligned with the xy axis.

This howto contains the file h258.cosmo50cmb.1536g2bwK.00512. This is

the z=0 output of a simulation of a disk galaxy in a LCDM Universe. This time we are looking at halo 5, a small SMC-like dwarf that is at the outskirts of the main halo.

3.1 THIS THE MANUAL PROCEDURE TO SELECT A HALO Start TIPSY by typing:

tipsy

at the new prompt:

openb h258.cosmo50cmb.1536g2bwK.00512 loads 1 loadall readarray h258.cosmo50cmb.1536g2bwK.00512.amiga.grp markarray 0 4.5 5.5 psize mark 4 xarray all default 1 30 clip That should show a handful of halos, one in bright green. zoom in by left clicking a few times. Make a small box centered AT THE VERY CENTER of the small green halo: makebox 1 (shift+left click on two projections Make a sphere centered on the small halo setsphere 2 pot 1 0.001 That makes a sphere of 25 kpc in radius centered on the halo.

writebox 2 file.asc That will create an ascii tipsy file of the halo we want to play with. ascii2std <file.asc>file.std Will create a TIPSY standard

NOTE: a TIPSY HOWTO is posted on the McMaster TWIKI

3.2 THIS IS THE IDL PROCEDURE to select a halo.

you need:

  • the GASOLINE simulation output file and a few other files.

h258.cosmo50cmb.1536g2bwK.00512 h258.cosmo50cmb.1536g2bwK.00512.amiga.grp h258.cosmo50cmb.1536g2bwK.00512.amiga.gtp h258.cosmo50cmb.1536g2bwK.00512.amiga.stat

grp is an array that contains the parent halo index for each particle (0 if the particles does not belong to any halo) gtp is a TIPSY standard format file. Every star particle has the mass and coordinates of a halo identified by AMIGA. stat is an ascii file that contains info on the halos/galaxies identified by AMIGA. Do a "more" of it, read what it says for halo 5. It is a small dwarf like galaxy of 3.4e10 solar masses.

start idl typing

idl

compile the idl programs that you will need:

.r rtipsy.pro .r wtipsy.pro .r read_lon_array.pro .r stdSats.pro .r align.pro (note: align uses a sphere of a few kpc to align the galaxy along the Jz axis)

stdSats, 'h258.cosmo50cmb.1536g2bwK.00512',5,2,50000

In our example we select halo nr. 5, a little dwarf galaxy formed in a comological simulation, at z=0. 50000 is the box unit in kpc. the box unit IS SIMULATION DEPENDENT and an input of stdSats.pro

5= halo ID 2= how many halos with ID>=5 we want. 50000=box size in comoving kpc

System units for the example run are in h258.cosmo50cmb.1536g2bwK.param dKpcUnit=50000 is the line you want.

If this worked out you should have a file

h258.cosmo50cmb.1536g2bwK.00512.5.std

(and a .....6.std as well, but we will not use .6 further).

Now we need to run:

./smooth -s 32g -o h258.cosmo50cmb.1536g2bwK.00512.5 hsmooth < h258.cosmo50cmb.1536g2bwK.00512.5.std

Where "h258..." is your selected galaxy. That will create a file "h258...hsm" (it contains information on the size of each gas particle).

NOTE: these files are already in your SunBootCamp directory.

Make a directory called:

mkdir h258.cosmo50cmb.1536g2bwK.5

move in the following files:

cp filters pahtemplate stubconfig h258.cosmo50cmb.1536g2bwK.5/

cd h258.cosmo50cmb.1536g2bwK.5/ create links to files in the above directory: ln -s ../h258.cosmo50cmb.1536g2.00512.5.std galaxy.std ln -s ../h258.cosmo50cmb.1536g2.00512.5.hsm galaxy.hsm make an ascii version of galaxy.std ../std2ascii<galaxy.std>galaxy.asc ln -s galaxy.asc galaxy

This is because we have scripts where the standard galaxy name is "galaxy" and so you do not need to edit them every time. So the files we work with are always called "galaxy" and the real galaxy ID comes from the directory.


4.0 RUNNING SUNRISE --------------------------

4.1 SFRHIST. This program builds the cell by cell SFH for our galaxy.

the files used here are:

sfrhist.stub sfrhist.config makegrid.stub makegrid.config

4.1.1 sfrhist.stub

contains a lot of useful comments but you do not need to change anything if for special cases (movies, runs with no dust, see below). However:

This is where the IMF (Kroupa) for most of our runs and the model for local dust absorption get set. The mass of the average star forming region as been set to 5e6 Msol. If you are running massive starbursts or quiescent dwarfs check the effect of setting it to 1e7 or 1e6 respectively. star_radius_factor sets the max size of a star forming region in units of the force softening. 0.2 is probably a good number.

It should be 0.1 for low resolution runs and bigger than 0.2 if the run is very high resolution. Star forming regions have sizes of a few tens of pc. seed 0 the random seed. it is useful to test the amount of noise introduced by random samplings. expansion: this tells the code that we are using a cosmological run and says time (in tipsy output0 =expansion factor. Set to false if you are dealing with an isolated galaxy where the tipsy variable time is an actual time. (Note: ask if are not sure).


ANALYSIS WITH NO DUST. Set:

use use_mapping_sed false

This because otherwise "mappings" includes unresolved dust absorption from sources (i.e from the star forming regions at scales <<1kpc)


TO MAKE MOVIES - comment out mapping_sed_file - set stellarmodelfile as: supersparse-imfK-Zmulti.fits (to be consistent)

This should be much faster.


4.1.2 sfrhist.config: This is where the units get set so expect to edit some stuff.

NOTE: setting the units in sfrhist.config is where most of the errors get made.

IMPORTANT The mass and length simulation units and the initial star particle mass (UnitMass,UnitLenght and m_star_creation) are set in the GASOLINE param file: h258.cosmo50cmb.1536g2bwK.param

we assume: solar mass = 1.98892 10^33 g 1 pc 3.08568 10^18 cm

UNIT choices for run h258 at z=0.

-UnitMass_in_g from param file variable dMsolUnit=1.84793e16 Solar Masses UnitLenght_in_cm from param file variable -dKpcUnit = 50000 Length Unit in kpc -UnitVelocity_in_cm_per_s Velocity Unit: 1261.05 km/sec (H0 Box size in Mpc/ 2.894405 (do not ask)). -snaptime = 0.354155 This is in simulation units. Here at z=0 and for Omega0=0.24, Lambda=0.76,H0=74. This is the time after the Big Bang for the output at hand in simulation units. This is the time at which the simulation is observed, so it has to be precise within a 1e6 yrs or so. -m_star_creation = 0.34645e-11 Star particle mass at creation in simulation units.

Snaptime is hard to get right. The BEST option is to use the largest (also the last) "tform" in the TIPSY output file. We assumed a Kroupa IMF. (if your run assumes a different IMF changes MUST be made to "stellarmodelfile" in the stub).

NOTE: there are NO h factors in the units anywhere.

4.1.3 makegrid.stub

This is where the output is divided in 3D subcells for future analysis.

tau_tolerance 0.9 / .md Grid should resolve optical depth to 0.5 updated in v3.4 tau is the maximum optical depth that is fully resolved. Lower it to make the run more precise. size_factor 4 max_level 13 / the maximum number of sublevels for the cells. 14 usually makes too many...explore 11 -13.

work_chunk_levels 7 / higher makes less cells. make it smaller if one of the threads while running sfrhist takes a long time to finish.

See below for nthreads=4 Building grid Starting with 125 initial grid cells Creating balanced work chunks Thread starting Thread starting Thread starting Thread starting Thread exiting Thread exiting Thread exiting ... Thread exiting

4.1.4 makegrid.config

n_threads 4

this sets the number of CPUs to use for the sfrhist step. 2-6 is likely a good range.

RUN IT!

time sfrhist sfrhist.config

Running sfrhist on elektra with 10k stars and 20k gas particles takes about 2 minutes.


4.1.5 ADDED INFO ON UNITS IN COSMO RUNS: How to check you put the right time unit

The "snap time" unit in the TIPSY output cosmo runs is actually the expansion factor. The time in simulation time units for each step is the first column in the ascii .log file of each run. The second column is the redshift. First line=step1... n line n step.

However, for runs with star formation the easiest way to get the time in simulation units for a given output is to get the tform of the very last star particle. tform records the time at which every star particle was formed. Star particles are listed sequentially in the order they formed. The last star particle to form should also have the largest tform. That is the time that sunrise needs (in simulation units). Note that if the input time is smaller than any tform in the tipsy output then Sunrise will crash as it thinks that one of the stars has a formation time "in the future".

This is how it works in physical terms for two practical examples.

Xruns (those that begin with h1201....)

The assumed cosmology is H0=70, Omega0=0.3 Lambda=0.7 :

z=0 = t=0.333 in sim units (from the log file) = 13.4665 Gyrs (time from the Big Bang, got using age.f ). The time unit is then=40.44Gyrs

step 84 for the h1201..X5 runs has a snap time (or expansion factor) = 0.2588. This means z= 2.864, or time from the Big Bang= 2.2235 Gyrs. In simulation units this means 2.2235/40.44 = 0.054983. This should be real close to the largest tform in the output.

EXAMPLE 2:

for the cosmo[25,50]cmb runs

H0=73, omega0=0.24, Lambda=0.76

Step 36 has snap time= expansion factor = 0.144716 -> z = 5.91

at z=0 time in sim units: 0.3541544 (from another, completed run) the age of the Universe for such a cosmology = 13.73 Gyrs the time unit of this run is then = 38.76 the age of the Universe at z=5.91 is 1.002 Gyrs the time in sim units at z=5.91 is then 0.02584

This is the value that sunrise wants as an input parameter. Again check that it is equal or just a tiny bit larger than the largest tform in the output.

OUTPUT: In the example the output is written in grid.fits

grep "Total number of cells:" in the screen output from sfrhist and mark down the number.

check that the number of cells for which the tau tolerance is exceeded is "not too high". Look for:

"WARNING: 1052 grid cells exceed tau tolerance"

To make a SUNRISE more precise go to the makegrid.stub

lower the tau_tolerance (now is set at 0.9). This makes sure that optically thick regions are more resolved.

increase max_level This creates more cells.

THE CURRENT VALUES 0.9 AND 13 ARE LIKELY OK. (lower the leves to 12 if the number of cells exceeds 1e6...it seems to happen with massive ellipticals)


4.2 MCRX This program creates the large cell by cell SED info. The config file contains a lot of important parameters that set how precise SUNRISE's radiate transfer is, how big the image in kpc and pixels.

4.2.1 mcrx.stub contains info on how the radiative transfer is done. Read the comments in it, but do not change it unless you really know what you are doing.

keep this commented in the mcrx.stub as for June 08. 1. r_equilibrium_tolerance 1e-4

4.2.2 mcrx.config contains the more run dependent parameters.

  • ntheta,nphi set how many images are created.
  • exclude_south_pole true avoid repeating some images. -cameradistance do not change it. -camerafov 50kpc is good to include even the largest galaxies. NOTE: if too small some particles will be left out and the total magnitude will be overestimated. On the other hand it might be set to a value similar to the aperture of a given survey.
  • npixels nr of pixels per image. I suppose that the px size in kpc is = fov/npx. This changes the memory requirements so increase npixels

    only if you need detailed 2D maps.

The CPU cost grows with the number of rays shot through the simulation. HOW MANY RAYS SHOULD WE SHOOT?

  • 1 check how many stars are in the output
  • 2 grep "Total number of cells:" in the screen output from sfrhist.

n stars = 33284 in our test run. n cells = 90000 with nlevels = 12 These are the recommended numbers:

  • nrays_unscatter 10-20 rays per star particles (this is cheap)
  • nrays_scatter 10-20 rays per star particles
  • nrays_aux 10*nrays_unscatter (this is cheap and makes cool 2D maps)
  • nrays_ir 10-20 per nr of cells. Max 1e6 as of aug 08. More makes code crash.

n_threads 2-6 depending on elektra... seed 0 random seed, change to check the error of different statistical realizations and see if you need more rays.

4.2.3 SEDs

From mcrx we can obtain the spectral energy distribution of our object. All we need is a Little python magic:

ipython --pylab

In 1: import sed

In 2: sed.plot(files=['mcrx_012.fits']) ['mcrx_012.fits']

also has functionality for plotting the variation of seds as a shaded region if you do sed.sigma.

the python script sed.py is included in the BootCamp distribution

TO RUN: mcrx mcrx.config

4.3 BROADBAND

TO RUN: broadband postprocess.config

Here is where 2D images are made from the data cube

4.3.1 broadband.stub (leave it alone)

4.3.2 postprocess.config

broadband postprocess.config

Adding into Redshift Untested as of June 25th 08

It is possible to create broadband images of a galaxy that incorporates redshift, luminosity dimming for a given z and lyman limit absorption.

To do this, add the following line to you broadband.config file:

redshift z (e.g 2.2) use_lyman_absorption true

where "z" is the numerical value of the redshift of the galaxy. This will result in images in which the wavelengths have been increased by (1+z) and the luminosity has been dimmed by 1/(1+z)^XX.

NOTE THE CODE OUTPUTS ABSOLUTE MAGNITUDES, SO ONE NEEDS TO CORRECT FOR THE DISTANCE MODULUS. GET IT HERE:

http://faraday.uwyo.edu/%7Echip/misc/Cosmo2/cosmo.cgi

e.g. at z=3 the distance modulus is about 47 , for the h258 cosmology.


  1. ADVANCED STUFF :

5.1 HOW TO GET MULTIPLE CAMERAS

ntheta 4

nphi 1

exclude_south_pole true

ntheta sets the number of theta points. if the south pole option is false, there will be one point on the north and south pole respectively. if it's true, the points will be distributed AS IF there were n+1 theta points, but the last one on the south pole won't be there. This is to avoid always making redundant views from the +-z axis.



5.2 PRETTY PICTURES:

Making 3 color composite artificial images of your Sunrised Galaxy is now easy! We use the package created by David Hogg, available at: http://astro.physics.nyu.edu/hogg/visualization/

Chris has made some small changes to the code to deal with our files, and so the package is best attained from :

images/IDL

to run this is very easy! just compile all the .pro routines (.r xxx.pro). You need a fits file called "broadband,jpg" in the same directory.

idl make_jpeg,bands=[5,4,3],scale=[4,3.2,3.4],nonlinearity=3

that is it... you can run with default values just by

make_jpeg

That makes an image called "image.jpg" with the same number of pixels as set in the Sunrise image.

bands are from our standard filter list (starting at 0, reproduced below) bands relate to r,g,b, color respectively If you do not specify bands, then the defaults are 5,4,3, which from our filter list are i.r.g, so color assignment is rgb=irg

If you do not specify scale, the values are set in nw_scale_rgb.pro This is the input which you need to play with to get color right, it gives weighting of r,g,b and also the saturation is different (higher) if you do [50,40,30] rather than [5,4,3].

If you do not specify nonlinearity, then default = 3, as set in nw_arcsinh_fit.pro (3 seems good, generally leave it, but can be worth playing with)

IMAGE ORIENTATION: So you want one of those neat "edge on" images? The broadband.fits file contains images using 1 or more camera angles, imaged with and without dust. The row number of these images varies according to the overall number of camera angles you chose. In order to tell make_jpeg which of the images you want to access, you need to know the row number of the image in the broadband.fits data cube. You can find this row number by opening in fv . e.g.

14 CAMERA0-BROADBAND 800x800x18 Header Image Table 18 CAMERA1-BROADBAND-NONSCATTER 800x800x18 Header Image Table

Note that in the BootCamp example there is only one angle (which I think is face on. FG).


IMPORTANT: there is not much actual science in the scale=.md values that you set, but visually, you should be able to compare 2 or more galaxies, with the colors indicative of recent star formation and or metallicity. For example I get a much "redder" elliptical galaxy if I set scale=[5.,3.,3.9]. Similarly, if you compare with SDSS images of real galaxies make sure to use the same values as used by the observers.


Auxiliary IMAGES camera0_aux

in the broadband.fits under cameraxx_aux there are color maps of important physicial quantities: gas temperature, metallicity etc. (add details here)

standard filters list (as in Sunrise BootCamp) 0 FUV_GALEX.res 1 NUV_GALEX.res 2 u_SDSS.res 3 g_SDSS.res 4 r_SDSS.res 5 i_SDSS.res 6 z_SDSS.res 7 ACS_F435_NEW.res 8 ACS_F606_NEW.res 9 ACS_F775_NEW.res 10 ACS_F850_NEW.res 11 B_Johnson.res 12 V_Johnson.res 13 I_Cousins.res 14 H_Johnson.res 15 J_Johnson.res 16 K_Johnson.res 17 Ks_2MASS.res 18 IRAC1_SIRTF.res 19 IRAC2_SIRTF.res 20 MIPS24_SIRTF.res


THIS is an old way of doing that we now consider obsolete. It is in imagesIDL.old

it is possible to make composite images stacking different filters together. This assigns red blue and green to three filters of your choice, and stacks the images. The method employed follows closely those used in Lupton et al. (2004 PASP, 116 133, astro-ph/0312483). This is also the technique used by Andrew West in generating these images:

http://www.astro.washington.edu/west/

We will use an IDL routine for this... You can get this at: /astro/net/mega-1/cbrook/idl/sunriseImages/west_mimic.pro

you will also need : /astro/net/mega-1/cbrook/idl/sunriseImages/find_hdu.pro

This has several inputs, which you do not need to change, but are certainly free to play around with if you want to witness the effects.. for full explanations, see the Lupton paper above... here we just provide a "howto".

compile west_mimic, then run

west_all,'h258',[0,n],.2,9,0,/save,start_hdu="CAMERA0-BROADBAND"

this makes color images of all the "broadband_MW1hr_xxx.fits" files, using cameras 0-n. Note, this means Scatter Cameras 0 to n and Non-Scatter (ie without dust), Cameras 0 to n.. of course if you have added more camera angles above then this range increases.

The code will ask you which bands you want to use for rgb colors, and provide a list with corresponding numbers.

SDSS i,r,g bands for rgb is a good option for this.. also HST ACS F775, 606 and 435 makes a decent combination..... Just type the relevant numbers, 5,4,3 or 9,8,7 for these cases...

It is easy to edit the IDL code slightly to allow combinations of 5 bands... eg

red = ((i_band)+(z_band))scale0 green = ((r_band))scale1 blue = ((g_band)+(u_band))scale2

optional input scale=scales: this will change the weight given to r,g,b.. default is equal weighting

.2,9,0 are stretch parameters, you can play with them for your purpose, but these numbers seem reasonable . The .2 is the linear stretch in the faint areas and the 9 is a softening in bright areas. keep the 0 0. (please, see Lupton for full explanation)

/save input will write jpg images in a directory called ./color

Updated