Blame view

LabTools/IRAP/JPB/phangs_make_isrf_product.pro 2.36 KB
8c683fa4   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
PRO phangs_make_isrf_product,source_name,voronoi_id,ISRFS,G0s,object_distance,object_thickness,help=help

;+
; NAME:
;       phangs_make_isrf_product
; CALLING SEQUENCE:
;       phangs_make_isrf_product,source_name,voronoi_id,ISRFS,G0s,object_distance,object_thickness,help=help
; PURPOSE:
;       make and saves an ISRF product fits file
; INPUTS:
;       source_name,voronoi_id,ISRFS,G0s,object_distance,object_thickness,help=help
; OPTIONAL KEYWORDS:
;       save        = if set, save the classes
;       help        = if set, print this help
; OUTPUTS:
;	    None
; OPTIONAL INPUT:
;       
; OPTIONAL OUTPUT:
;       None
; PROCEDURE AND SUBROUTINE USED
;       ISRF saved is the one predicted by dustem_plugin_phangs_stellar_isrf for each Muse Voronoi bin,
;       scaled in amplitude to match the Muse filter data for that Voronoi bin.
;       The G0 value computed is wrt the Mathis field at 1 mic.
; SIDE EFFECTS:
;       produces file _isrf_min_prediction.fits
; EXAMPLE:
;       phangs_make_isrf_product,'ngc0628'
; MODIFICATION HISTORY:
;       written by Jean-Philippe Bernard
;-

IF keyword_set(help) THEN BEGIN
  doc_library,'phangs_make_isrf_product'
  goto,the_end
ENDIF

dustem_init

data_dir=!phangs_data_dir+'/ISRF/WORK/'
file=data_dir+source_name+'_isrf_min_prediction.sav'
restore,file,/verb
;% RESTORE: Restored variable: ISRFS.
;% RESTORE: Restored variable: G0S.
;% RESTORE: Restored variable: OBJECT_DISTANCE.
;% RESTORE: Restored variable: OBJECT_THICKNESS.
;% RESTORE: Restored variable: SOURCE_NAME.

data_dir=!phangs_data_dir+'/ISRF/PRODUCTS/'
file_save=data_dir+source_name+'_isrf_min_prediction.fits'

lambir=dustem_get_wavelengths(isrf_wavelengths=isrf_wavelengths)

Nvor=(size(ISRFS))[2]
one_st={vid:0L,ISRF:ISRFS[*,0]}
st_isrf=replicate(one_st,Nvor)
st_wave={wavelength:isrf_wavelengths}
FOR i=0L,Nvor-1 DO BEGIN
	st_isrf[i].vid=i
	st_isrf[i].ISRF=ISRFS[*,i]
ENDFOR
mwrfits,st_wave,file_save,/create

dd0=mrdfits(file_save,0,h0)

mwrfits,st_isrf,file_save

;==== check reading the file
dd1=mrdfits(file_save,1,h1)
dd2=mrdfits(file_save,2,h2)

;==== add info to the headers
sxaddpar,h1,'PRODUCT','PHANGS ISRF'
sxaddpar,h1,'OBJECT',source_name
sxaddpar,h2,'PRODUCT','PHANGS ISRF'
sxaddpar,h2,'OBJECT',source_name

;==== rewrite file (with modified headers)
mwrfits,st_wave,file_save,h1,/create
mwrfits,st_isrf,file_save,h2

message,'Saved '+file_save,/continue

de766928   Jean-Philippe Bernard   improved
84
;stop
8c683fa4   Jean-Philippe Bernard   First commit
85
86
87
88

the_end:

END