Commit cc81fcdc5f1aa95ae4422b444a20d55643b9bc0e

Authored by Jean-Philippe Bernard
1 parent 2d9acde0
Exists in master

improved

LabTools/IRAP/JPB/check_phangs_ssps_isrf_prediction.pro
... ... @@ -4,75 +4,7 @@ PRO check_phangs_ssps_isrf_prediction,show_map=show_map,from_restore=from_restor
4 4 ;check_phangs_ssps_isrf_prediction,/from_restore
5 5 ;check_phangs_ssps_isrf_prediction,/from_classes_restore,/save
6 6  
7   -;===== predicts the minimum ISRF in voronoi bins
8   -
9   -win=0L
10   -;window,win,xsize=900,ysize=1000 & win=win+1
11   -
12   -;=== This is where the data is read from and the ISRFs will be stored
13   -;data_dir='/Volumes/PILOT_FLIGHT1/PHANGS-JWST/DR1/'
14   -data_dir=!phangs_data_dir+'/ISRF/WORK/'
15   -
16   -use_model='DBP90' ;Example with default keywords uses the DBP90 model
17   -use_polarization=0 ; initialize Dustemwrap in no polarization mode
18   -
19   -;== INITIALISE DUSTEM
20   -dustem_init,model=use_model,polarization=use_polarization,show_plots=show_plots
21   -
22   -IF keyword_set(from_restore) THEN goto,from_restore
23   -IF keyword_set(from_classes_restore) THEN goto,from_classes_restore
24   -
25   -source_name='ngc0628'
26   -object_distance=9.84 ;MPc
27   -object_thickness=0.1 ;kpc
28   -
29   -dustem_define_la_common
30   -obp=[1.1,0,1.15,1]
31   -
32   -;dustem_init,show_plots=show_plots
33   -;needed only for NHCO
34   -restore,data_dir+'ngc0628_jwst_images.sav',/verb
35   -;needed for stellar parameters and voronoi bin info
36   -restore,data_dir+'ngc0628_muse_images.sav',/verb
37   -
38   -Nvor=max(voronoi_id)
39   -
40   -use_NHmap=NHCO ;used NH map in 1.e21 (from CO)
41   -
42   -;stop
43   -!quiet=1
44   -
45   -t1=systime(0,/sec)
46   -first_vid=0L
47   -lambir=dustem_get_wavelengths()
48   -;show_each=10
49   -show_each=100
50   -Nlambir=n_elements(lambir)
51   -
52   -ISRFS=fltarr(Nlambir,Nvor)
53   -FOR vid=first_vid,Nvor-1 DO BEGIN
54   - IF vid mod show_each EQ 0 THEN BEGIN
55   - t2=systime(0,/sec)
56   - delta_t_hr=(t2-t1)/60.^2 ;elapsed time [hr]
57   - frac_perc=vid/Nvor*100
58   - delta_t_remain=delta_t_hr/frac_perc*100.-delta_t_hr ;remaining time [hr]
59   - message,'done '+strtrim(frac_perc)+' % in '+strtrim(delta_t_hr,2)+' hr remaining '+strtrim(delta_t_remain,2)+' hr',/continue
60   - ENDIF
61   - ;===== get the SSP weights for the given voronoi bins
62   - weights=phangs_binid2weights(st_muse_weights,vid,st_templates,age_values,metalicity_values,reddening=reddening)
63   - amplitude=1.
64   - reddening=0. ;This sets Muse reddening to 0. Will be contsrained later
65   - fpd=phangs_stellar_continuum_plugin_weight2params(weights,parameter_values=val,redenning=reddening,/force_include_reddening,amplitude=amplitude,/force_include_amplitude)
66   - Nparams=n_elements(val)
67   - key=intarr(Nparams)
68   - FOR i=0L,Nparams-1 DO BEGIN
69   - toto=dustem_parameter_description2type(fpd[i],string_name=string_name,key=one_key)
70   - key[i]=one_key
71   - ENDFOR
72   - ISRFS[*,vid]=dustem_plugin_phangs_stellar_isrf(key=key,val=val,object_distance=object_distance,object_thickness=object_thickness)
73   -ENDFOR
74   -
75   -save,ISRFS,object_distance,object_thickness,source_name,file=data_dir+'ngc0628_isrf_min_prediction.sav',/verb
  7 +;must have run make_phangs_ssps_isrf_prediction.pro before
76 8  
77 9 from_restore:
78 10  
... ...
LabTools/IRAP/JPB/make_phangs_isrf_classes.pro
... ... @@ -64,18 +64,18 @@ restore,data_dir+'ngc0628_astrosat_voronoi_prediction_fast.sav',/verb
64 64 ;=== attempt to classify ISRFs
65 65  
66 66 ;normalized ISRFs
67   -lambir=dustem_get_wavelengths()
  67 +lambir=dustem_get_wavelengths(isrf_wavelengths=isrf_wavelengths)
68 68  
69 69 Nlambir=(size(ISRFS))[1]
70 70 Nvor=(size(ISRFS))[2]
71 71  
72 72 n_ISRFS=fltarr(Nlambir,Nvor)
73 73 n_wavs=fltarr(Nlambir,Nvor)
74   -ind=where(lambir GT 1.)
  74 +ind=where(isrf_wavelengths GT 1.)
75 75 indd=ind[0]
76 76 FOR vid=0L,Nvor-1 DO BEGIN
77 77 n_ISRFS[*,vid]=ISRFS[*,vid]/ISRFS[indd,vid]
78   - n_wavs[*,vid]=lambir
  78 + n_wavs[*,vid]=isrf_wavelengths
79 79 ENDFOR
80 80  
81 81 ;=== 2D histogram of normalized ISRFs in NGC0628
... ... @@ -101,7 +101,7 @@ med_isrf=la_median(n_ISRFS,dim=-1)
101 101 ;refs_wavs=[0.11] ;This is set to be just before the Lymann break
102 102 reference_wavelength=1. ;all ISRFs are normalized to 1 mic
103 103 refs_wavs=[0.15] ;This is set to be just before the Lymann break
104   -ref_ratios=interpol(med_isrf,lambir,refs_wavs)
  104 +ref_ratios=interpol(med_isrf,isrf_wavelengths,refs_wavs)
105 105 ;These are the ratios which will be used to classify ISRFs
106 106  
107 107 one_class={number:0L $;class number
... ... @@ -146,14 +146,14 @@ class0.flux_ratio_wav=refs_wavs[0]
146 146 file=!dustem_soft_dir+'/data/ISRF_MATHIS.DAT'
147 147 ;file='/Users/jpb/Soft_Libraries/dustem_fortran/data/ISRF.DAT'
148 148 readcol,file,Mathis_wavs,Mathis_ISRF
149   -Mathis_ISRF=interpol(Mathis_ISRF,Mathis_wavs,lambir)
150   -n_Mathis_ISRF=Mathis_ISRF/interpol(Mathis_ISRF,lambir,class0.reference_wavelength)
  149 +Mathis_ISRF=interpol(Mathis_ISRF,Mathis_wavs,isrf_wavelengths)
  150 +n_Mathis_ISRF=Mathis_ISRF/interpol(Mathis_ISRF,isrf_wavelengths,class0.reference_wavelength)
151 151 class0.ISRF_template=ptr_new(n_Mathis_ISRF)
152   -ratio=interpol(n_Mathis_ISRF,lambir,class0.flux_ratio_wav)
  152 +ratio=interpol(n_Mathis_ISRF,isrf_wavelengths,class0.flux_ratio_wav)
153 153 class0.flux_ratio=ratio
154 154 class0.flux_ratio_min=ratio*(1.-0.1) ;arbitrary +-10% around ratio
155 155 class0.flux_ratio_max=ratio*(1.+0.1) ;arbitrary +-10% around ratio
156   -Mathis_1mic=interpol(Mathis_ISRF,lambir,1.0)
  156 +Mathis_1mic=interpol(Mathis_ISRF,isrf_wavelengths,1.0)
157 157 message,'Mathis (G0=1) has 4*pi*Inu='+strtrim(Mathis_1mic,2)+' ergs/s/cm2/Hz',/continue
158 158 message,'Mathis (G0=1) has Inu(0.15 mic)/Inu(1 mic)='+strtrim(ratio,2)+' ',/continue
159 159  
... ...
src/idl/dustem_get_wavelengths.pro
1   -FUNCTION dustem_get_wavelengths,bidon,help=help
  1 +FUNCTION dustem_get_wavelengths,bidon,help=help,isrf_wavelengths=isrf_wavelengths
2 2  
3 3 ;+
4 4 ; NAME:
... ... @@ -11,7 +11,7 @@ FUNCTION dustem_get_wavelengths,bidon,help=help
11 11 ; DUSTEM Wrapper
12 12 ;
13 13 ; CALLING SEQUENCE:
14   -; wavelengths=dustem_get_wavelengths([/help])
  14 +; wavelengths=dustem_get_wavelengths([/help][,isrf_wavelengths=])
15 15 ;
16 16 ; INPUTS:
17 17 ; None
... ... @@ -20,10 +20,10 @@ FUNCTION dustem_get_wavelengths,bidon,help=help
20 20 ; None
21 21 ;
22 22 ; OUTPUTS:
23   -; wavelengths = set of wavelengths [mic]
  23 +; wavelengths = set of Spectra wavelengths used by dustemwrap[mic]
24 24 ;
25 25 ; OPTIONAL OUTPUT PARAMETERS:
26   -; None
  26 +; isrf_wavelengths = set of ISRF wavelengths used by dustemwrap [mic]
27 27 ;
28 28 ; ACCEPTED KEY-WORDS:
29 29 ; help = if set, print this help
... ... @@ -61,6 +61,8 @@ ENDIF ELSE BEGIN
61 61 lambir=((*!dustem_params).lambda.lambda) ; there is an error here that I have noticed a long time ago. Temporary fix is @ the returned value
62 62 ENDELSE
63 63  
  64 +isrf_wavelengths=(*!dustem_params).ISRF.lambisrf
  65 +
64 66 the_end:
65 67 RETURN,lambir[1:*]
66 68  
... ...
src/idl/dustem_plugin_phangs_class_isrf.pro
... ... @@ -130,11 +130,7 @@ ENDELSE
130 130  
131 131 ;stop
132 132 ;un_red
133   -;STILL HAVE TO REDDEN BEY E(B-V)
134   -
135   -the_scope:
136   -
137   -the_paramtag:
  133 +;STILL HAVE TO REDDEN BY E(B-V)
138 134  
139 135 the_end:
140 136 RETURN,ISRF
... ...
src/idl/dustem_plugin_phangs_stellar_isrf.pro
... ... @@ -91,9 +91,12 @@ use_factor=4.*!pi*1.e-20*1.e7*1.e4*use_omega_ratio
91 91  
92 92 ;stop
93 93 Inu_stars=dustem_plugin_phangs_stellar_continuum(key=key,val=val)
94   -
95 94 ISRF=Inu_stars[*,0]*use_factor
96 95  
  96 +;REM: Inu_stars is on lambir wavelength. For an ISRF plugins, needs to to be interpolated on isrf wavelengths
  97 +spec_wavelengths=dustem_get_wavelengths(isrf_wavelengths=isrf_wavelengths)
  98 +ISRF=interpol(ISRF,spec_wavelengths,isrf_wavelengths)
  99 +
97 100 the_end:
98 101 RETURN,ISRF
99 102  
... ...
src/idl/dustem_read_cb19_stellar_templates.pro
... ... @@ -67,7 +67,7 @@ Z=alog10(Z/Z0)
67 67 ; -2.18299 -1.88196 -1.48401 -1.18298 -0.881955 -0.580925 -0.404834 -0.279895 -0.182985 -0.0368569 0.0474640 0.118045 0.294136 0.419075 0.595166
68 68 NZ=n_elements(Z)
69 69  
70   -dir_templates=!phangs_data_dir+'/SSPs/CB2019/CB19_Chabrier/Mu100/'
  70 +dir_templates=!phangs_data_dir+'/ISRF/SSPs/CB2019/CB19_Chabrier/Mu100/'
71 71 ;dir_templates=!dustem_wrap_soft_dir+'/Data/SSPs/CB2019/CB19_Chabrier/Mu100/'
72 72 files=file_search(dir_templates+'*.fits')
73 73 Nfiles=n_elements(files)
... ...
src/idl/dustem_read_emiles_stellar_templates.pro
... ... @@ -53,7 +53,7 @@ IF keyword_set(help) THEN BEGIN
53 53 END
54 54  
55 55 ;dir_templates=!dustem_wrap_soft_dir+'/Data/SSPs/ssp_emiles-ch/'
56   -dir_templates=!phangs_data_dir+'/SSPs/ssp_emiles-ch_extended/'
  56 +dir_templates=!phangs_data_dir+'/ISRF/SSPs/ssp_emiles-ch_extended/'
57 57 ;dir_templates=!dustem_wrap_soft_dir+'/Data/SSPs/ssp_emiles-ch_extended/'
58 58  
59 59 ;read templates info file
... ...
src/idl/dustem_write_isrf_release.pro
... ... @@ -107,7 +107,8 @@ IF count_add_isrf NE 0 OR count_replace_isrf NE 0 THEN BEGIN
107 107 IF ptr_valid((*!dustem_plugin)[ind_replace_isrf].spec) THEN BEGIN
108 108 c[1]='# DUSTEM_WRAP: replaced by radiation field from plugin '+(*!dustem_plugin)[ind_replace_isrf].name
109 109 ;final_isrf=final_isrf+(*(*!dustem_plugin)[tstusrisrf].spec)
110   - final_isrf=interpol(*(*!dustem_plugin)[ind_replace_isrf].spec,lambir,st.lambisrf)
  110 + ;final_isrf=interpol(*(*!dustem_plugin)[ind_replace_isrf].spec,lambir,st.lambisrf)
  111 + final_isrf=*(*!dustem_plugin)[ind_replace_isrf].spec
111 112 ENDIF ELSE BEGIN
112 113 message,'Replacement ISRF not found. Using Mathis',/continue
113 114 ;stop
... ... @@ -121,8 +122,8 @@ IF count_add_isrf NE 0 OR count_replace_isrf NE 0 THEN BEGIN
121 122 IF count_add_isrf NE 0 THEN BEGIN
122 123 IF ptr_valid((*!dustem_plugin)[ind_add_isrf].spec) THEN BEGIN
123 124 c[2]='# DUSTEM_WRAP: added radiation field from plugin '+(*!dustem_plugin)[ind_replace_isrf].name
124   - ;final_isrf=final_isrf+(*(*!dustem_plugin)[ind_add_isrf].spec)
125   - final_isrf=final_isrf+interpol(*(*!dustem_plugin)[ind_add_isrf].spec,lambir,st.lambisrf)
  125 + final_isrf=final_isrf+(*(*!dustem_plugin)[ind_add_isrf].spec)
  126 + ;final_isrf=final_isrf+interpol(*(*!dustem_plugin)[ind_add_isrf].spec,lambir,st.lambisrf)
126 127 ENDIF ELSE BEGIN
127 128 ;stop
128 129 ;LEFT blank intensionally
... ...