Commit 892b30a4f0ea2a7b22f1ff0c162eb3df192e9a17
1 parent
ea1acf9c
Exists in
master
First commit
Showing
2 changed files
with
140 additions
and
0 deletions
Show diff stats
LabTools/IRAP/JPB/convert_all_grid_tables_from_v1_to_v2.pro
0 → 100644
... | ... | @@ -0,0 +1,26 @@ |
1 | +PRO convert_all_grid_tables_from_v1_to_v2 | |
2 | + | |
3 | +;convert_all_grid_tables_from_v1_to_v2 | |
4 | + | |
5 | +;This is to convert all previously computed tables (V1) into V2 format | |
6 | + | |
7 | +;==== Convert the Muse ISRF grids | |
8 | + | |
9 | +convert_grid_tables,'DBP90_MuseISRF_JWST_G0_YPAH_YVSG_4Phangs_isrfclass0.fits','DBP90_MuseISRF_JWST_G0_YPAH_YVSG_4Phangs_isrfclass0.fits','DBP90',fpd=0,fiv=0,use_polarisation=0 | |
10 | + | |
11 | +FOR i=1L,29 DO BEGIN | |
12 | + istr=strtrim(i,2) | |
13 | + convert_grid_tables,'DBP90_MuseISRF_JWST_G0_YPAH_YVSG_4Phangs_isrfclass'+istr+'.fits','DBP90_MuseISRF_JWST_G0_YPAH_YVSG_4Phangs_isrfclass1'+istr+'.fits','DBP90', $ | |
14 | + fpd=['(*!dustem_params).gas.g0','(*!dustem_params).g0','dustem_plugin_phangs_class_isrf_1'], $ | |
15 | + fiv=[-1.,1.,i],use_polarisation=0 | |
16 | +ENDFOR | |
17 | + | |
18 | +stop | |
19 | + | |
20 | +convert_grid_tables,'TEST_DBP90_G0.fits','TEST_DBP90_G0.fits','DBP90', $ | |
21 | + fpd=['(*!dustem_params).grains(0).mdust_o_mh','(*!dustem_params).grains(1).mdust_o_mh'], $ | |
22 | + fiv=[1.e-3,1.e-2],use_polarisation=0 | |
23 | + | |
24 | +convert_grid_tables,'DBP90_JWST_G0_YPAH_YVSG_4Phangs.fits','DBP90_JWST_G0_YPAH_YVSG_4Phangs.fits','DBP90',fpd=0,fiv=0,use_polarisation=0 | |
25 | + | |
26 | +END | |
0 | 27 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,114 @@ |
1 | +PRO convert_grid_tables,filename_in,filename_out,model,fpd=fpd,fiv=fiv,use_polarisation=use_polarisation | |
2 | + | |
3 | +; | |
4 | +;convert_grid_tables,'DBP90_JWST_G0_YPAH_YVSG_4Phangs.fits','DBP90_JWST_G0_YPAH_YVSG_4Phangs.fits','DBP90',fpd=0,fiv=0,use_polarisation=0 | |
5 | +dustem_init,model=model | |
6 | +dustem_define_la_common | |
7 | + | |
8 | +dir_in=!phangs_data_dir+'/ISRF/GRIDS/SAVED_V1/' | |
9 | +dustem_define_grid_v1,dir_in+filename_in | |
10 | +dir_out=!phangs_data_dir+'/ISRF/GRIDS/' | |
11 | + | |
12 | +a=mrdfits(dir_in+filename_in,1,h1) | |
13 | + | |
14 | +i=0L | |
15 | +count=1 | |
16 | +parameters_description=[''] | |
17 | +REPEAT BEGIN | |
18 | + v=sxpar(h1,'PNAME'+strtrim(i+1,2),count=count) | |
19 | + IF count EQ 1 THEN BEGIN | |
20 | + i=i+1 | |
21 | + parameters_description=[parameters_description,v] | |
22 | + ENDIF | |
23 | +ENDREP UNTIL count EQ 0 | |
24 | +parameters_description=parameters_description[1:*] | |
25 | +Nparams=n_elements(parameters_description) | |
26 | +iv_min=dblarr(Nparams) | |
27 | +iv_max=dblarr(Nparams) | |
28 | +iv_Nvalues=lonarr(Nparams) | |
29 | +plog=intarr(Nparams) | |
30 | +FOR i=0L,Nparams-1 DO BEGIN | |
31 | + iv_min[i]=sxpar(h1,'PMIN'+strtrim(i+1,2),count=count) | |
32 | + iv_max[i]=sxpar(h1,'PMAX'+strtrim(i+1,2),count=count) | |
33 | + iv_Nvalues[i]=sxpar(h1,'PNVAL'+strtrim(i+1,2),count=count) | |
34 | + plog[i]=sxpar(h1,'PLOG'+strtrim(i+1,2),count=count) | |
35 | +ENDFOR | |
36 | + | |
37 | +;parameter_values=!dustem_grid.ST_PARAMS | |
38 | +;IDL> help,parameter_values | |
39 | +;PARAMETER_VALUES | |
40 | +; POINTER = Array[8] | |
41 | +;IDL> help,parameter_values[0] | |
42 | +;<Expression> POINTER = <PtrHeapVar4378> | |
43 | +;IDL> help,*parameter_values[0] | |
44 | +;<PtrHeapVar4378> | |
45 | +; FLOAT = Array[3] | |
46 | + | |
47 | +Nc=(*!dustem_grid).Nsed | |
48 | +parameter_values=ptrarr(Nc) | |
49 | +par_values=dblarr(Nparams) | |
50 | +FOR i=0L,Nc-1 DO BEGIN | |
51 | + FOR j=0L,Nparams-1 DO BEGIN | |
52 | + par_values[j]=((*!dustem_grid).ST_PARAMS)[i].(j) | |
53 | + ENDFOR | |
54 | + parameter_values[i]=ptr_new(par_values) | |
55 | +ENDFOR | |
56 | + | |
57 | +;stop | |
58 | + | |
59 | +;Iem_seds_array=replicate(one_Iemsed_st,Nc) | |
60 | + | |
61 | +Iem_seds_array=(*!dustem_grid).st_seds | |
62 | +Nfilters=(*!dustem_grid).Nfilters | |
63 | +one_seds=dustem_initialize_sed(Nfilters) | |
64 | +one_seds.filter=(*!dustem_grid).filters | |
65 | +seds=ptrarr(Nc) | |
66 | + | |
67 | +;=== Fill up seds | |
68 | +FOR i=0L,Nc-1 DO BEGIN | |
69 | + FOR j=0L,Nfilters-1 DO BEGIN | |
70 | + one_seds[j].stokesI=Iem_seds_array[i].(j) | |
71 | + ;((seds[i]).stokesI)[j]=Iem_seds_array[i].(j) | |
72 | + ENDFOR | |
73 | + seds[i]=ptr_new(one_seds) | |
74 | +ENDFOR | |
75 | + | |
76 | +saved_dustem_grid=*!dustem_grid | |
77 | + | |
78 | +dustem_write_sed_grid,model,parameters_description,iv_min,iv_max,iv_Nvalues,plog,parameter_values,seds,em_spectra=0,ext_spectra=0 $ | |
79 | + ,fpd=fpd,fiv=fiv,use_polarisation=use_polarisation $ | |
80 | + ,filename=dir_out+filename_out | |
81 | + | |
82 | +;stop | |
83 | + | |
84 | +dustem_define_grid,dir_out+filename_out | |
85 | + | |
86 | +;help,saved_dustem_grid | |
87 | +;** Structure <9b80dc08>, 10 tags, length=3760784, data length=3760780, refs=2: | |
88 | +; NSED LONG 20000 | |
89 | +; NFILTERS LONG 42 | |
90 | +; NPARAMS LONG 3 | |
91 | +; FILTERS STRING Array[42] | |
92 | +; PARAMS STRING Array[3] | |
93 | +; ST_SEDS STRUCT -> <Anonymous> Array[20000] | |
94 | +; ST_PARAMS STRUCT -> <Anonymous> Array[20000] | |
95 | +; SED_TOTALS DOUBLE Array[20000] | |
96 | +; PMIN_VALUES DOUBLE Array[3] | |
97 | +; PMAX_VALUES DOUBLE Array[3] | |
98 | +;help,*!dustem_grid | |
99 | +;** Structure <cb1afe08>, 10 tags, length=3760784, data length=3760780, refs=3: | |
100 | +; NSED LONG 20000 | |
101 | +; NFILTERS LONG 42 | |
102 | +; NPARAMS LONG 3 | |
103 | +; FILTERS STRING Array[42] | |
104 | +; PARAMS STRING Array[3] | |
105 | +; ST_SEDS STRUCT -> <Anonymous> Array[20000] | |
106 | +; ST_PARAMS STRUCT -> <Anonymous> Array[20000] | |
107 | +; SED_TOTALS DOUBLE Array[20000] | |
108 | +; PMIN_VALUES DOUBLE Array[3] | |
109 | +; PMAX_VALUES DOUBLE Array[3] | |
110 | + | |
111 | +;help,saved_dustem_grid.ST_SEDS,/str | |
112 | +;help,(*!dustem_grid).ST_SEDS,/str | |
113 | + | |
114 | +END | |
0 | 115 | \ No newline at end of file | ... | ... |