Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Isedfit example #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added examples/isedfit/cosmos_example.fits.gz
Binary file not shown.
25 changes: 25 additions & 0 deletions examples/isedfit/example.bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
# Example environmental variables to add for IDLUTILS/kCorrect/iSEDfit
# add this text to your .bashrc file

export IDL_LIBS=/global/data/products

# IDLUtils -- Helper Library
export IDLUTILS_DIR=$IDL_LIBS/idlutils
export IDL_PATH=$IDL_PATH:+$IDLUTILS_DIR/pro
export IDL_PATH=$IDL_PATH:+$IDLUTILS_DIR/goddard/pro

# RED -- Cosmological utilities
export RED_DIR=$HOME/idl/red
export IDL_PATH=$IDL_PATH:+$RED_DIR

# KCorrect
export KCORRECT_DIR=$IDL_LIBS/kcorrect
export PATH=$PATH:$KCORRECT_DIR/bin
export IDL_PATH=$IDL_PATH:+$KCORRECT_DIR/pro
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$KCORRECT_DIR/lib

# IMPRO / ISEDFIT
export IMPRO_DIR=$HOME/idl/impro
export IDL_PATH=$IDL_PATH:+$IMPRO_DIR
export ISEDFIT_SSP_DIR=$HOME/raid/isedfit2/isedfit_ssp
27 changes: 27 additions & 0 deletions examples/isedfit/isedfit_buildexample.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
PRO isedfit_buildexample, _extra=extra
field = 'cosmos'
nobjects = 10
cat = im_mrdfits(getfilename(field))
ii = where(cat.isgood AND $
cat.ismass AND $
cat.zquality EQ 4, nii) ;; slightly more strict
cat = cat[ii[0:nobjects-1]]
filters = getfilters(field)
match, strtrim(cat[0].filters, 2), filters, nn, mm, count=nfilters

example = {ra:0d, $
dec:0d, $
z:0.0, $
filterlist:strarr(nfilters), $
maggies:fltarr(nfilters), $
ivarmaggies:fltarr(nfilters)}
example = replicate(example, n_elements(cat))
example.ra = cat.ra
example.dec = cat.dec
example.z = cat.z
example.filterlist = filters[mm]
example.maggies = cat.maggies[nn]
example.ivarmaggies = cat.ivarmaggies[nn]

im_mwrfits, example, 'cosmos_example.fits', _extra=extra
END
26 changes: 26 additions & 0 deletions examples/isedfit/isedfit_check.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
;+
; ISEDFIT_CHECK -- Check the current installed versions for debug
;
; e.g. IDL> check_isedfit
; -

PRO _req, cmd, name, version
;; a little wrapper that runs a command to ensure that the installed
;; version matches the required version passed into the function.
value = call_function(cmd)
status = (value EQ version) ? 'ok' : 'Failed!'
print, 'iSEDfit requires '+version+' version of '+name+'. Found: '+value+'. '+status

IF value NE version THEN BEGIN
message, ' !!! Version did not match the required version, please update'
ENDIF
END


PRO isedfit_check
;; might also want to check directories ($ISEDFIT_DIR,
;; $KCORRECT_DIR) as well.
_req, 'idlutils_version', 'IDLUtils', 'trunk'
_req, 'k_version', 'kCorrect', 'NOCVS:kcorrect'
END

84 changes: 84 additions & 0 deletions examples/isedfit/isedfit_quick.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
;+
; NAME:
; ISEDFIT_QUICK
;
; PURPOSE:
; Quick start script that goes through the process.
; Overwrites previous run results
; This is just to test that you can run isedfit quickly.
;-

PRO isedfit_quick, extras=extras

;; output directory -- depending on parameters may be large [few Gb]
prefix = 'example'

isedfit_dir = '/tmp/isedfit_example/'
montegrids_dir = isedfit_dir+'montegrids/'
file_mkdir, montegrids_dir

isedfit_paramfile = isedfit_dir+prefix+'_paramfile.par'

; --------------------------------------------------
;; catalog to be processed
example = im_mrdfits('cosmos_example.fits.gz')
filterlist = strtrim(example[0].filterlist, 2)


; --------------------------------------------------
; choose your priors: write the iSEDfit parameter file
write_isedfit_paramfile, params=params, isedfit_dir=isedfit_dir, $
prefix=prefix, filterlist=filterlist, spsmodels='fsps_v2.4_miles', $
imf='chab', redcurve='charlot', /igm, zminmax=[0.1, 1.3], zbin=0.05, $
nmodel=500L, age=[0.1, 13.0], tau=[0.1, 5.0], Zmetal=[0.004, 0.03], $
AV=[0.35, 2.0], mu=[0.1, 4.0], pburst=0.2, interval_pburst=2.0, $
tburst=[0.1, 13.0], /delayed, galchunksize=250L, /clobber

; --------------------------------------------------
; build the Monte Carlo grids [time to go read astro-ph]
isedfit_montegrids, isedfit_paramfile, isedfit_dir=isedfit_dir, $
montegrids_dir=montegrids_dir, /clobber

; --------------------------------------------------
; calculate the model photometry
isedfit_models, isedfit_paramfile, isedfit_dir=isedfit_dir, $
montegrids_dir=montegrids_dir, /clobber

; --------------------------------------------------
; fit the catalog
isedfit, isedfit_paramfile, example.maggies, example.ivarmaggies, $
example.z, ra=example.ra, dec=example.dec, $
isedfit_dir=isedfit_dir, /clobber, $
isedfit_results=mass

;; simple plot
plot, mass.mstar_50, mass.sfr100_50, psym=6, $
xtitle='Mass [M_sun]', ytitle='SFR [M_sun / yr]'


print, 'Huzza! iSEDfit finished.'
print, ' Check the plot, and make sure that these sfr/masses make sense'


;; Here be dragons...

IF keyword_set(extras) THEN BEGIN
;; Get some fancy plots [beta] that show the properties of the
;; models and the sort.

isedfit_qaplot_models, isedfit_paramfile, example.maggies, $
example.ivarmaggies, example.z, isedfit_dir=isedfit_dir, $
thesefilters=filterlist, /clobber

isedfit_kcorrect, isedfit_paramfile, isedfit_dir=isedfit_dir, $
montegrids_dir=montegrids_dir, /clobber

isedfit_qaplot_sed, isedfit_paramfile, nrandom=50, $
isedfit_dir=isedfit_dir, montegrids_dir=montegrids_dir, $
/xlog, /clobber

ENDIF



END