From 8c683fa4d0c37275a76d37ba076865d84448bc19 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Bernard Date: Mon, 4 Mar 2024 11:32:20 +0100 Subject: [PATCH] First commit --- LabTools/IRAP/JPB/phangs_make_co_images.pro | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ LabTools/IRAP/JPB/phangs_make_hi_images.pro | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ LabTools/IRAP/JPB/phangs_make_isrf_product.pro | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 266 insertions(+), 0 deletions(-) create mode 100644 LabTools/IRAP/JPB/phangs_make_co_images.pro create mode 100644 LabTools/IRAP/JPB/phangs_make_hi_images.pro create mode 100644 LabTools/IRAP/JPB/phangs_make_isrf_product.pro diff --git a/LabTools/IRAP/JPB/phangs_make_co_images.pro b/LabTools/IRAP/JPB/phangs_make_co_images.pro new file mode 100644 index 0000000..393e551 --- /dev/null +++ b/LabTools/IRAP/JPB/phangs_make_co_images.pro @@ -0,0 +1,89 @@ +PRO phangs_make_co_images,source_name=source_name,save=save,show_images=show_images,nostop=nostop,help=help + +;+ +; NAME: +; phangs_make_co_images +; PURPOSE: +; makes JWST images usable by the Phangs ISRF project +; CATEGORY: +; Dustem Phangs +; CALLING SEQUENCE: +; phangs_make_co_images[,source_name=][,/save][,/show_images][,/nostop] +; INPUTS: +; None +; OPTIONAL INPUT PARAMETERS: +; source_name : source name (default = 'ngc0628') +; OUTPUTS: +; None +; OPTIONAL OUTPUT PARAMETERS: +; None +; ACCEPTED KEY-WORDS: +; help = If set, print this help +; save = If set, save result +; show_images= if set, show images +; nostop = if set, does not stop +; COMMON BLOCKS: +; None +; SIDE EFFECTS: +; A file is written +; RESTRICTIONS: +; None +; PROCEDURE: +; input JWST images are asumed to be in units of MJy/sr +; EXAMPLES +; phangs_make_co_images,source_name='ngc0628',/save,/show,/nostop +; MODIFICATION HISTORY: +; Written by J.-Ph. Bernard (2023) +; Evolution details on the DustEMWrap gitlab. +; See http://dustemwrap.irap.omp.eu/ for FAQ and help. +;- + +IF keyword_set(help) THEN BEGIN + doc_library,'phangs_make_co_images' + goto,the_end +ENDIF + +dustem_define_la_common + +use_source_name='ngc0628' +IF keyword_set(source_name) THEN use_source_name=source_name + +save_data_dir=!phangs_data_dir+'/ISRF/WORK/' +file=save_data_dir+use_source_name+'_ref_header.sav' +restore,file,/verb +;% RESTORE: Restored variable: HREF. + +Nx=sxpar(href,'NAXIS1') +Ny=sxpar(href,'NAXIS2') + +data_dir=!phangs_data_dir+'/phangs_drive/PHANGS_ALMA/' + +;WCO map: +file=data_dir+use_source_name+'_12m+7m+tp_co21_broad_mom0.fits' +d=readfits(file,h) +;sxaddpar,h,'CTYPE1','RA---TAN' +;sxaddpar,h,'CTYPE2','RA---TAN' +sxaddpar,h,'EQUINOX',2000. +ind=where(finite(d) NE 1,count) +IF count NE 0 THEN d[ind]=la_undef() +IF sxpar(h,'NAXIS1') NE Nx OR sxpar(h,'NAXIS2') NE Ny THEN WCO=project2(h,d,href,/silent) ELSE WCO=d +fact=4.e20/1.e21 +NHCO=la_mul(WCO,fact) ;NH from CO in 1e21 H/cm2 +tit=source_name+' '+'NHCO [1e21 H/cm2]' +IF keyword_set(show_images) THEN BEGIN + win=0L + window,win + win=win+1 + image_cont20,NHCO,href,/square,imrange=[-0.5,10],image_color_table='jpbloadct',/silent,tit=tit + IF not keyword_set(nostop) THEN stop +ENDIF + +IF keyword_set(save) THEN BEGIN + save_file=save_data_dir+use_source_name+'_CO_images.sav' + save,NHCO,href,file=save_file + message,'Saved '+save_file,/continue +ENDIF + +the_end: + +END \ No newline at end of file diff --git a/LabTools/IRAP/JPB/phangs_make_hi_images.pro b/LabTools/IRAP/JPB/phangs_make_hi_images.pro new file mode 100644 index 0000000..e8ac459 --- /dev/null +++ b/LabTools/IRAP/JPB/phangs_make_hi_images.pro @@ -0,0 +1,89 @@ +PRO phangs_make_hi_images,source_name=source_name,save=save,show_images=show_images,nostop=nostop,help=help + +;+ +; NAME: +; phangs_make_hi_images +; PURPOSE: +; makes HI images usable by the Phangs ISRF project +; CATEGORY: +; Dustem Phangs +; CALLING SEQUENCE: +; phangs_make_hi_images[,source_name=][,/save][,/show_images][,/nostop] +; INPUTS: +; None +; OPTIONAL INPUT PARAMETERS: +; source_name : source name (default = 'ngc0628') +; OUTPUTS: +; None +; OPTIONAL OUTPUT PARAMETERS: +; None +; ACCEPTED KEY-WORDS: +; help = If set, print this help +; save = If set, save result +; show_images= if set, show images +; nostop = if set, does not stop +; COMMON BLOCKS: +; None +; SIDE EFFECTS: +; A file is written +; RESTRICTIONS: +; None +; PROCEDURE: +; input HI images are asumed to be in units of K*km/s +; EXAMPLES +; phangs_make_hi_images,source_name='ngc0628',/save,/show,/nostop +; MODIFICATION HISTORY: +; Written by J.-Ph. Bernard (2023) +; Evolution details on the DustEMWrap gitlab. +; See http://dustemwrap.irap.omp.eu/ for FAQ and help. +;- + +IF keyword_set(help) THEN BEGIN + doc_library,'phangs_make_hi_images' + goto,the_end +ENDIF + +win=0L +dustem_define_la_common + +use_source_name='ngc0628' +IF keyword_set(source_name) THEN use_source_name=source_name + +save_data_dir=!phangs_data_dir+'/ISRF/WORK/' +file=save_data_dir+use_source_name+'_ref_header.sav' +restore,file,/verb +;% RESTORE: Restored variable: HREF. + +Nx=sxpar(href,'NAXIS1') +Ny=sxpar(href,'NAXIS2') + +data_dir=!phangs_data_dir+'/phangs_drive/PHANGS_HI/' + +file=data_dir+use_source_name+'_21cm_strictmask_mom0.fits' +d=readfits(file,h) +;stop +;sxaddpar,h,'CTYPE1','RA---TAN' +;sxaddpar,h,'CTYPE2','RA---TAN' +sxaddpar,h,'EQUINOX',2000. +ind=where(finite(d) NE 1,count) +IF count NE 0 THEN d[ind]=la_undef() +IF sxpar(h,'NAXIS1') NE Nx OR sxpar(h,'NAXIS2') NE Ny THEN WHI=project2(h,d,href,/silent) ELSE WHI=d +fact=1.83e18/1.e21 +NHI=la_mul(WHI,fact) ;NH from HI in 1e21 H/cm2 +tit=source_name+' '+'NHI [1e21 H/cm2]' +;stop +IF keyword_set(show_images) THEN BEGIN + window,win & win=win+1 + image_cont20,NHI,href,/square,imrange=[-0.1,5],image_color_table='jpbloadct',/silent,tit=tit,axis_color_table=1 + IF not keyword_set(nostop) THEN stop +ENDIF + +IF keyword_set(save) THEN BEGIN + save_file=save_data_dir+use_source_name+'_HI_images.sav' + save,NHI,href,file=save_file + message,'Saved '+save_file,/continue +ENDIF + +the_end: + +END \ No newline at end of file diff --git a/LabTools/IRAP/JPB/phangs_make_isrf_product.pro b/LabTools/IRAP/JPB/phangs_make_isrf_product.pro new file mode 100644 index 0000000..b577b2a --- /dev/null +++ b/LabTools/IRAP/JPB/phangs_make_isrf_product.pro @@ -0,0 +1,88 @@ +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 + +stop + +the_end: + +END \ No newline at end of file -- libgit2 0.21.2