From 2d9acde04d5d25a52588923ae3972979d3d665f6 Mon Sep 17 00:00:00 2001
From: Jean-Philippe Bernard <Jean-Philippe.Bernard@irap.omp.eu>
Date: Fri, 9 Feb 2024 13:56:03 +0100
Subject: [PATCH] First commit

---
 LabTools/IRAP/JPB/calz_guess_ebv.pro             | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/idl/dustem_muse_filter_conversion_factor.pro | 18 ++++++++++++++++++
 src/idl/inspect_emiles_ssp.pro                   | 25 +++++++++++++++++++++++++
 3 files changed, 104 insertions(+), 0 deletions(-)
 create mode 100644 LabTools/IRAP/JPB/calz_guess_ebv.pro
 create mode 100644 src/idl/dustem_muse_filter_conversion_factor.pro
 create mode 100644 src/idl/inspect_emiles_ssp.pro

diff --git a/LabTools/IRAP/JPB/calz_guess_ebv.pro b/LabTools/IRAP/JPB/calz_guess_ebv.pro
new file mode 100644
index 0000000..860d1e8
--- /dev/null
+++ b/LabTools/IRAP/JPB/calz_guess_ebv.pro
@@ -0,0 +1,61 @@
+FUNCTION calz_guess_ebv,wave,flux_ratio,R_v=R_v
+
+;+
+; NAME:
+;     calz_guess_ebv,
+; PURPOSE:
+;     Guess the value of E(B-V) to get a given stellar flux ratio
+; EXPLANATION:
+;     based on calz_unred.pro by W. Landsman
+; CALLING SEQUENCE:
+;     ebv=calz_guess_ebv(wave,flux_ratio,R_v=R_v)
+; INPUT:
+;      WAVE - wavelength at which the flux ratio is given (Angstroms)
+;      FLUX_RATIO - flux ratio between unredened and redenned (observed) flux.
+; OUTPUT:
+;      EBV  - color excess E(B-V), scalar.  positive if flux_ratio is >1 ,
+;               Note that the E(B-V) computed is for 
+;               the stellar  continuum, EBV(stars), which is related to the 
+;               reddening derived from the gas, EBV(gas), via the Balmer 
+;               decrement by EBV(stars) = 0.44*EBV(gas) according to Calzetti 2000.          
+; OPTIONAL INPUT KEYWORD:
+;       R_V - Ratio of total to selective extinction, default = 4.05.  
+;             Calzetti et al. (2000) estimate R_V = 4.05 +/- 0.80 from optical
+;             -IR observations of 4 starbursts.
+; EXAMPLE:
+;
+;		print,calz_guess_ebv(10000.,1./0.98,R_v=R_v)
+;          0.0116824
+; NOTES:
+;       
+; PROCEDURE CALLS:
+;      POLY()
+; REVISION HISTORY:
+;       JPB 30 Jan 2024
+;-
+
+;flux_ratio=funred/flux must be >1 for positive E(B-V)
+;print,calz_guess_ebv(10000.,1./0.98,R_v=R_v)
+
+;wave_flux in AA
+
+x  = 10000.0/wave                      ;Wavelength in inverse microns
+
+if N_elements(R_V) EQ 0 then R_V = 4.05
+ 
+IF (wave GE 6300) AND (wave LE 22000) THEN $
+    klam = 2.659*(-1.857 + 1.040*x) + R_V
+   
+IF (wave GE  912) AND (wave LT  6300) THEN $
+    klam = 2.659*(poly(x, [-2.156, 1.509d0, -0.198d0, 0.011d0])) + R_V
+
+;Calzetti 2000 equation is
+;funred = flux*10.0^(0.4*klam*ebv)
+;stop
+
+;ebv=alog10(funred/flux)/0.4/klam
+ebv=alog10(flux_ratio)/0.4/klam
+
+RETURN,ebv
+
+END
\ No newline at end of file
diff --git a/src/idl/dustem_muse_filter_conversion_factor.pro b/src/idl/dustem_muse_filter_conversion_factor.pro
new file mode 100644
index 0000000..fd9f8c6
--- /dev/null
+++ b/src/idl/dustem_muse_filter_conversion_factor.pro
@@ -0,0 +1,18 @@
+FUNCTION dustem_muse_filter_conversion_factor,filter,pivot_wav=pivot_wav
+
+;print,dustem_muse_filter_conversion_factor('SDSS_i',pivot_wav=pivot_wav)
+
+filename=!dustem_wrap_soft_dir+'/Data/FILTERS/filters_pivot_factors.xcat'
+st=read_xcat(filename,/silent)
+
+ind=where(st.filter EQ filter,count)
+
+pivot_wav=st[ind[0]].wave
+conversion_factor=st[ind[0]].factor
+wave_prefix=st[ind[0]].prefix
+
+use_conversion_factor=conversion_factor/wave_prefix
+
+RETURN,use_conversion_factor
+
+END
\ No newline at end of file
diff --git a/src/idl/inspect_emiles_ssp.pro b/src/idl/inspect_emiles_ssp.pro
new file mode 100644
index 0000000..f29227f
--- /dev/null
+++ b/src/idl/inspect_emiles_ssp.pro
@@ -0,0 +1,25 @@
+PRO inspect_emiles_ssp
+
+loadct,13
+;dir='/Users/jpb/Soft_Libraries/dustem-wrapper_idl/Data/SSPs/ssp_emiles-ch/'
+dir='/Users/jpb/Soft_Libraries/dustem-wrapper_idl/Data/SSPs/eMILES_Ch-young-MetalPoorRemoved/'
+files=file_search(dir+'*.fits')
+Nfiles=n_elements(files)
+yr=[1.e-5,1.e-2]
+xtit='Wavelenght [mic]'
+ytit='Intensity []'
+colours=long(range_gen(Nfiles,[0,255]))
+FOR i=0L,Nfiles-1 DO BEGIN
+  message,'reading '+files[i],/continue
+  d=readfits(files[i],h)
+  make_axis,h,wav
+  wav=wav/1.e10*1.e6
+  IF i EQ 0 THEN BEGIN
+    cgplot,wav,d,/xlog,/ylog,yrange=yr,xtit=xtit,ytit=ytit
+  ENDIF ELSE BEGIN
+    cgoplot,wav,d,color=colours[i]
+    stop
+  ENDELSE
+ENDFOR
+
+END
\ No newline at end of file
--
libgit2 0.21.2