Commit 8c683fa4d0c37275a76d37ba076865d84448bc19

Authored by Jean-Philippe Bernard
1 parent b78f1109
Exists in master

First commit

LabTools/IRAP/JPB/phangs_make_co_images.pro 0 → 100644
... ... @@ -0,0 +1,89 @@
  1 +PRO phangs_make_co_images,source_name=source_name,save=save,show_images=show_images,nostop=nostop,help=help
  2 +
  3 +;+
  4 +; NAME:
  5 +; phangs_make_co_images
  6 +; PURPOSE:
  7 +; makes JWST images usable by the Phangs ISRF project
  8 +; CATEGORY:
  9 +; Dustem Phangs
  10 +; CALLING SEQUENCE:
  11 +; phangs_make_co_images[,source_name=][,/save][,/show_images][,/nostop]
  12 +; INPUTS:
  13 +; None
  14 +; OPTIONAL INPUT PARAMETERS:
  15 +; source_name : source name (default = 'ngc0628')
  16 +; OUTPUTS:
  17 +; None
  18 +; OPTIONAL OUTPUT PARAMETERS:
  19 +; None
  20 +; ACCEPTED KEY-WORDS:
  21 +; help = If set, print this help
  22 +; save = If set, save result
  23 +; show_images= if set, show images
  24 +; nostop = if set, does not stop
  25 +; COMMON BLOCKS:
  26 +; None
  27 +; SIDE EFFECTS:
  28 +; A file is written
  29 +; RESTRICTIONS:
  30 +; None
  31 +; PROCEDURE:
  32 +; input JWST images are asumed to be in units of MJy/sr
  33 +; EXAMPLES
  34 +; phangs_make_co_images,source_name='ngc0628',/save,/show,/nostop
  35 +; MODIFICATION HISTORY:
  36 +; Written by J.-Ph. Bernard (2023)
  37 +; Evolution details on the DustEMWrap gitlab.
  38 +; See http://dustemwrap.irap.omp.eu/ for FAQ and help.
  39 +;-
  40 +
  41 +IF keyword_set(help) THEN BEGIN
  42 + doc_library,'phangs_make_co_images'
  43 + goto,the_end
  44 +ENDIF
  45 +
  46 +dustem_define_la_common
  47 +
  48 +use_source_name='ngc0628'
  49 +IF keyword_set(source_name) THEN use_source_name=source_name
  50 +
  51 +save_data_dir=!phangs_data_dir+'/ISRF/WORK/'
  52 +file=save_data_dir+use_source_name+'_ref_header.sav'
  53 +restore,file,/verb
  54 +;% RESTORE: Restored variable: HREF.
  55 +
  56 +Nx=sxpar(href,'NAXIS1')
  57 +Ny=sxpar(href,'NAXIS2')
  58 +
  59 +data_dir=!phangs_data_dir+'/phangs_drive/PHANGS_ALMA/'
  60 +
  61 +;WCO map:
  62 +file=data_dir+use_source_name+'_12m+7m+tp_co21_broad_mom0.fits'
  63 +d=readfits(file,h)
  64 +;sxaddpar,h,'CTYPE1','RA---TAN'
  65 +;sxaddpar,h,'CTYPE2','RA---TAN'
  66 +sxaddpar,h,'EQUINOX',2000.
  67 +ind=where(finite(d) NE 1,count)
  68 +IF count NE 0 THEN d[ind]=la_undef()
  69 +IF sxpar(h,'NAXIS1') NE Nx OR sxpar(h,'NAXIS2') NE Ny THEN WCO=project2(h,d,href,/silent) ELSE WCO=d
  70 +fact=4.e20/1.e21
  71 +NHCO=la_mul(WCO,fact) ;NH from CO in 1e21 H/cm2
  72 +tit=source_name+' '+'NHCO [1e21 H/cm2]'
  73 +IF keyword_set(show_images) THEN BEGIN
  74 + win=0L
  75 + window,win
  76 + win=win+1
  77 + image_cont20,NHCO,href,/square,imrange=[-0.5,10],image_color_table='jpbloadct',/silent,tit=tit
  78 + IF not keyword_set(nostop) THEN stop
  79 +ENDIF
  80 +
  81 +IF keyword_set(save) THEN BEGIN
  82 + save_file=save_data_dir+use_source_name+'_CO_images.sav'
  83 + save,NHCO,href,file=save_file
  84 + message,'Saved '+save_file,/continue
  85 +ENDIF
  86 +
  87 +the_end:
  88 +
  89 +END
0 90 \ No newline at end of file
... ...
LabTools/IRAP/JPB/phangs_make_hi_images.pro 0 → 100644
... ... @@ -0,0 +1,89 @@
  1 +PRO phangs_make_hi_images,source_name=source_name,save=save,show_images=show_images,nostop=nostop,help=help
  2 +
  3 +;+
  4 +; NAME:
  5 +; phangs_make_hi_images
  6 +; PURPOSE:
  7 +; makes HI images usable by the Phangs ISRF project
  8 +; CATEGORY:
  9 +; Dustem Phangs
  10 +; CALLING SEQUENCE:
  11 +; phangs_make_hi_images[,source_name=][,/save][,/show_images][,/nostop]
  12 +; INPUTS:
  13 +; None
  14 +; OPTIONAL INPUT PARAMETERS:
  15 +; source_name : source name (default = 'ngc0628')
  16 +; OUTPUTS:
  17 +; None
  18 +; OPTIONAL OUTPUT PARAMETERS:
  19 +; None
  20 +; ACCEPTED KEY-WORDS:
  21 +; help = If set, print this help
  22 +; save = If set, save result
  23 +; show_images= if set, show images
  24 +; nostop = if set, does not stop
  25 +; COMMON BLOCKS:
  26 +; None
  27 +; SIDE EFFECTS:
  28 +; A file is written
  29 +; RESTRICTIONS:
  30 +; None
  31 +; PROCEDURE:
  32 +; input HI images are asumed to be in units of K*km/s
  33 +; EXAMPLES
  34 +; phangs_make_hi_images,source_name='ngc0628',/save,/show,/nostop
  35 +; MODIFICATION HISTORY:
  36 +; Written by J.-Ph. Bernard (2023)
  37 +; Evolution details on the DustEMWrap gitlab.
  38 +; See http://dustemwrap.irap.omp.eu/ for FAQ and help.
  39 +;-
  40 +
  41 +IF keyword_set(help) THEN BEGIN
  42 + doc_library,'phangs_make_hi_images'
  43 + goto,the_end
  44 +ENDIF
  45 +
  46 +win=0L
  47 +dustem_define_la_common
  48 +
  49 +use_source_name='ngc0628'
  50 +IF keyword_set(source_name) THEN use_source_name=source_name
  51 +
  52 +save_data_dir=!phangs_data_dir+'/ISRF/WORK/'
  53 +file=save_data_dir+use_source_name+'_ref_header.sav'
  54 +restore,file,/verb
  55 +;% RESTORE: Restored variable: HREF.
  56 +
  57 +Nx=sxpar(href,'NAXIS1')
  58 +Ny=sxpar(href,'NAXIS2')
  59 +
  60 +data_dir=!phangs_data_dir+'/phangs_drive/PHANGS_HI/'
  61 +
  62 +file=data_dir+use_source_name+'_21cm_strictmask_mom0.fits'
  63 +d=readfits(file,h)
  64 +;stop
  65 +;sxaddpar,h,'CTYPE1','RA---TAN'
  66 +;sxaddpar,h,'CTYPE2','RA---TAN'
  67 +sxaddpar,h,'EQUINOX',2000.
  68 +ind=where(finite(d) NE 1,count)
  69 +IF count NE 0 THEN d[ind]=la_undef()
  70 +IF sxpar(h,'NAXIS1') NE Nx OR sxpar(h,'NAXIS2') NE Ny THEN WHI=project2(h,d,href,/silent) ELSE WHI=d
  71 +fact=1.83e18/1.e21
  72 +NHI=la_mul(WHI,fact) ;NH from HI in 1e21 H/cm2
  73 +tit=source_name+' '+'NHI [1e21 H/cm2]'
  74 +;stop
  75 +IF keyword_set(show_images) THEN BEGIN
  76 + window,win & win=win+1
  77 + image_cont20,NHI,href,/square,imrange=[-0.1,5],image_color_table='jpbloadct',/silent,tit=tit,axis_color_table=1
  78 + IF not keyword_set(nostop) THEN stop
  79 +ENDIF
  80 +
  81 +IF keyword_set(save) THEN BEGIN
  82 + save_file=save_data_dir+use_source_name+'_HI_images.sav'
  83 + save,NHI,href,file=save_file
  84 + message,'Saved '+save_file,/continue
  85 +ENDIF
  86 +
  87 +the_end:
  88 +
  89 +END
0 90 \ No newline at end of file
... ...
LabTools/IRAP/JPB/phangs_make_isrf_product.pro 0 → 100644
... ... @@ -0,0 +1,88 @@
  1 +PRO phangs_make_isrf_product,source_name,voronoi_id,ISRFS,G0s,object_distance,object_thickness,help=help
  2 +
  3 +;+
  4 +; NAME:
  5 +; phangs_make_isrf_product
  6 +; CALLING SEQUENCE:
  7 +; phangs_make_isrf_product,source_name,voronoi_id,ISRFS,G0s,object_distance,object_thickness,help=help
  8 +; PURPOSE:
  9 +; make and saves an ISRF product fits file
  10 +; INPUTS:
  11 +; source_name,voronoi_id,ISRFS,G0s,object_distance,object_thickness,help=help
  12 +; OPTIONAL KEYWORDS:
  13 +; save = if set, save the classes
  14 +; help = if set, print this help
  15 +; OUTPUTS:
  16 +; None
  17 +; OPTIONAL INPUT:
  18 +;
  19 +; OPTIONAL OUTPUT:
  20 +; None
  21 +; PROCEDURE AND SUBROUTINE USED
  22 +; ISRF saved is the one predicted by dustem_plugin_phangs_stellar_isrf for each Muse Voronoi bin,
  23 +; scaled in amplitude to match the Muse filter data for that Voronoi bin.
  24 +; The G0 value computed is wrt the Mathis field at 1 mic.
  25 +; SIDE EFFECTS:
  26 +; produces file _isrf_min_prediction.fits
  27 +; EXAMPLE:
  28 +; phangs_make_isrf_product,'ngc0628'
  29 +; MODIFICATION HISTORY:
  30 +; written by Jean-Philippe Bernard
  31 +;-
  32 +
  33 +IF keyword_set(help) THEN BEGIN
  34 + doc_library,'phangs_make_isrf_product'
  35 + goto,the_end
  36 +ENDIF
  37 +
  38 +dustem_init
  39 +
  40 +data_dir=!phangs_data_dir+'/ISRF/WORK/'
  41 +file=data_dir+source_name+'_isrf_min_prediction.sav'
  42 +restore,file,/verb
  43 +;% RESTORE: Restored variable: ISRFS.
  44 +;% RESTORE: Restored variable: G0S.
  45 +;% RESTORE: Restored variable: OBJECT_DISTANCE.
  46 +;% RESTORE: Restored variable: OBJECT_THICKNESS.
  47 +;% RESTORE: Restored variable: SOURCE_NAME.
  48 +
  49 +data_dir=!phangs_data_dir+'/ISRF/PRODUCTS/'
  50 +file_save=data_dir+source_name+'_isrf_min_prediction.fits'
  51 +
  52 +lambir=dustem_get_wavelengths(isrf_wavelengths=isrf_wavelengths)
  53 +
  54 +Nvor=(size(ISRFS))[2]
  55 +one_st={vid:0L,ISRF:ISRFS[*,0]}
  56 +st_isrf=replicate(one_st,Nvor)
  57 +st_wave={wavelength:isrf_wavelengths}
  58 +FOR i=0L,Nvor-1 DO BEGIN
  59 + st_isrf[i].vid=i
  60 + st_isrf[i].ISRF=ISRFS[*,i]
  61 +ENDFOR
  62 +mwrfits,st_wave,file_save,/create
  63 +
  64 +dd0=mrdfits(file_save,0,h0)
  65 +
  66 +mwrfits,st_isrf,file_save
  67 +
  68 +;==== check reading the file
  69 +dd1=mrdfits(file_save,1,h1)
  70 +dd2=mrdfits(file_save,2,h2)
  71 +
  72 +;==== add info to the headers
  73 +sxaddpar,h1,'PRODUCT','PHANGS ISRF'
  74 +sxaddpar,h1,'OBJECT',source_name
  75 +sxaddpar,h2,'PRODUCT','PHANGS ISRF'
  76 +sxaddpar,h2,'OBJECT',source_name
  77 +
  78 +;==== rewrite file (with modified headers)
  79 +mwrfits,st_wave,file_save,h1,/create
  80 +mwrfits,st_isrf,file_save,h2
  81 +
  82 +message,'Saved '+file_save,/continue
  83 +
  84 +stop
  85 +
  86 +the_end:
  87 +
  88 +END
0 89 \ No newline at end of file
... ...