Blame view

LabTools/IRAP/JPB/convert_grid_tables.pro 3.5 KB
892b30a4   Jean-Philippe Bernard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
PRO convert_grid_tables,filename_in,filename_out,model,fpd=fpd,fiv=fiv,use_polarisation=use_polarisation

;
;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
dustem_init,model=model
dustem_define_la_common

dir_in=!phangs_data_dir+'/ISRF/GRIDS/SAVED_V1/'
dustem_define_grid_v1,dir_in+filename_in
dir_out=!phangs_data_dir+'/ISRF/GRIDS/'

a=mrdfits(dir_in+filename_in,1,h1)

i=0L
count=1
parameters_description=['']
REPEAT BEGIN
	v=sxpar(h1,'PNAME'+strtrim(i+1,2),count=count)
	IF count EQ 1 THEN BEGIN
		i=i+1
		parameters_description=[parameters_description,v]
	ENDIF
ENDREP UNTIL count EQ 0
parameters_description=parameters_description[1:*]
Nparams=n_elements(parameters_description)
iv_min=dblarr(Nparams)
iv_max=dblarr(Nparams)
iv_Nvalues=lonarr(Nparams)
plog=intarr(Nparams)
FOR i=0L,Nparams-1 DO BEGIN
    iv_min[i]=sxpar(h1,'PMIN'+strtrim(i+1,2),count=count)
    iv_max[i]=sxpar(h1,'PMAX'+strtrim(i+1,2),count=count)
    iv_Nvalues[i]=sxpar(h1,'PNVAL'+strtrim(i+1,2),count=count)
    plog[i]=sxpar(h1,'PLOG'+strtrim(i+1,2),count=count)
ENDFOR

;parameter_values=!dustem_grid.ST_PARAMS
;IDL> help,parameter_values
;PARAMETER_VALUES
;                POINTER   = Array[8]
;IDL> help,parameter_values[0]
;<Expression>    POINTER   = <PtrHeapVar4378>
;IDL> help,*parameter_values[0]
;<PtrHeapVar4378>
;                FLOAT     = Array[3]

Nc=(*!dustem_grid).Nsed
parameter_values=ptrarr(Nc)
par_values=dblarr(Nparams)
FOR i=0L,Nc-1 DO BEGIN
	FOR j=0L,Nparams-1 DO BEGIN
		par_values[j]=((*!dustem_grid).ST_PARAMS)[i].(j)
	ENDFOR
	parameter_values[i]=ptr_new(par_values)
ENDFOR

;stop

;Iem_seds_array=replicate(one_Iemsed_st,Nc)

Iem_seds_array=(*!dustem_grid).st_seds
Nfilters=(*!dustem_grid).Nfilters
one_seds=dustem_initialize_sed(Nfilters)
one_seds.filter=(*!dustem_grid).filters
seds=ptrarr(Nc)

;=== Fill up seds
FOR i=0L,Nc-1 DO BEGIN
	FOR j=0L,Nfilters-1 DO BEGIN
		one_seds[j].stokesI=Iem_seds_array[i].(j)
		;((seds[i]).stokesI)[j]=Iem_seds_array[i].(j)
	ENDFOR
    seds[i]=ptr_new(one_seds)
ENDFOR

saved_dustem_grid=*!dustem_grid

dustem_write_sed_grid,model,parameters_description,iv_min,iv_max,iv_Nvalues,plog,parameter_values,seds,em_spectra=0,ext_spectra=0 $
						 ,fpd=fpd,fiv=fiv,use_polarisation=use_polarisation $
						 	,filename=dir_out+filename_out

;stop

dustem_define_grid,dir_out+filename_out

;help,saved_dustem_grid
;** Structure <9b80dc08>, 10 tags, length=3760784, data length=3760780, refs=2:
;   NSED            LONG             20000
;   NFILTERS        LONG                42
;   NPARAMS         LONG                 3
;   FILTERS         STRING    Array[42]
;   PARAMS          STRING    Array[3]
;   ST_SEDS         STRUCT    -> <Anonymous> Array[20000]
;   ST_PARAMS       STRUCT    -> <Anonymous> Array[20000]
;   SED_TOTALS      DOUBLE    Array[20000]
;   PMIN_VALUES     DOUBLE    Array[3]
;   PMAX_VALUES     DOUBLE    Array[3]
;help,*!dustem_grid
;** Structure <cb1afe08>, 10 tags, length=3760784, data length=3760780, refs=3:
;   NSED            LONG             20000
;   NFILTERS        LONG                42
;   NPARAMS         LONG                 3
;   FILTERS         STRING    Array[42]
;   PARAMS          STRING    Array[3]
;   ST_SEDS         STRUCT    -> <Anonymous> Array[20000]
;   ST_PARAMS       STRUCT    -> <Anonymous> Array[20000]
;   SED_TOTALS      DOUBLE    Array[20000]
;   PMIN_VALUES     DOUBLE    Array[3]
;   PMAX_VALUES     DOUBLE    Array[3]

;help,saved_dustem_grid.ST_SEDS,/str
;help,(*!dustem_grid).ST_SEDS,/str

END