phangs_isrf_pipeline.pro 11.8 KB
PRO phangs_isrf_pipeline

;Note: faire un chmod a+rwx * apres transfert sur alma1

;PHANGS ISRF pipeline
save_data_dir=!phangs_data_dir+'/ISRF/WORK/'
str='ls '+save_data_dir+'ngc0628_*SPIRE3.sav'
print,str

str='ls '+save_data_dir+'ngc0628_*images*.sav'
spawn,str
str='ls '+save_data_dir+'ngc0628_*seds_muse_pixels*.sav'
spawn,str

;==== make sky images
;produces _jwst_images.sav and _ref_header.sav
;/data/projects/phangs/phangs_drive/Archive/PHANGS_JWST/DR1/ngc0628/f1000w_psf_matched
phangs_make_jwst_images,source_name='ngc0628',/save,/show,/nostop
;produces _muse_filters_images.sav,_muse_data.sav, _muse_NH.sav
phangs_make_muse_filters_images,source_name='ngc0628',/save,/show,/nostop
;produces _astrosat_images.sav
phangs_make_astrosat_images,source_name='ngc0628',/save,/show,/nostop
;produces _herschel_images.sav
phangs_make_herschel_images,source_name='ngc0628',/save,/show,/nostop
;produces _HI_images.sav
phangs_make_hi_images,source_name='ngc0628',/save,/show,/nostop
;produces _CO_images.sav
phangs_make_co_images,source_name='ngc0628',/save,/show,/nostop

;produces _muse_data.sav,
phangs_make_muse_filters_data,source_name='ngc0628',/save,/show,/nostop

;==== extract SEDs on MUSE pixels
;produces _jwst_seds_muse_pixels.sav, _muse_seds_muse_pixels.sav', _astrosat_seds_muse_pixels.sav
;pointer for vid 40749, 41095, 41405, 41406, 41581 .... is not referenced in all_seds_indices
phangs_extract_seds,source_name='ngc0628'

;=== Compute ISRF prediction. This is done only at full resolution
;=== produce _isrf_min_prediction.sav, _isrf_min_prediction.fits (product)
make_phangs_ssps_isrf_prediction,source_name='ngc0628',/save

;==== Make isrf classes
;produces isrf_classes_one_ratio_on_*.fits, *_isrf_classes_map.fits, *_isrf_classes_voronoi.sav
make_phangs_isrf_classes,bidon,source_name='ngc0628',/save

;make_sed_phangs_tables,/test,/show_seds   ;test of plugin dustem_plugin_phangs_class_isrf.pro
;Generally very long. Do it using nohup (see make_phangs_grid.pro)
make_sed_phangs_tables,grid_type=2,isrf_class=15
make_sed_phangs_tables,grid_type=2,isrf_class=0
;...

;=== Fit the SEDs with the ISRF Grids
phangs_brute_force_fit_with_isrf_grid,source_name='ngc0628',/include_herschel,/normalize,/fit_G0,/save

phangs_brute_force_fit_with_isrf_grid,source_name='ngc0628',/include_herschel,/normalize,/fit_G0,/from_restore


;============================================================================================================
;===== NGC0628 at SPIRE3 resolution
;============================================================================================================
;resolution_filter='SPIRE3'
;ngc0628_jwst_images_SPIRE3.sav, ngc0628_ref_header_SPIRE3.sav
phangs_make_jwst_images,source_name='ngc0628',/save,/show,/nostop,resolution_filter='SPIRE3'
;ngc0628_CO_images_SPIRE3.sav
phangs_make_co_images,source_name='ngc0628',/save,/show,/nostop,resolution_filter='SPIRE3'
;ngc0628_HI_images_SPIRE3.sav
phangs_make_hi_images,source_name='ngc0628',/save,/show,/nostop,resolution_filter='SPIRE3'
;ngc0628_astrosat_data_SPIRE3.sav
phangs_make_astrosat_images,source_name='ngc0628',/save,/show,/nostop,resolution_filter='SPIRE3'

;ngc0628_muse_filters_data_SPIRE3.sav, ngc0628_muse_images_SPIRE3.sav (not produced _muse_NH_SPIRE3.sav)
phangs_make_muse_filters_images,source_name='ngc0628',/save,/show,/nostop,resolution_filter='SPIRE3'
;ngc0628_herschel_images_SPIRE3.sav
phangs_make_herschel_images,source_name='ngc0628',/save,/show,/nostop,resolution_filter='SPIRE3'

phangs_make_muse_filters_data,source_name='ngc0628',/save,/show,/nostop,resolution_filter='SPIRE3'

phangs_extract_seds,source_name='ngc0628',resolution_filter='SPIRE3'

;ngc0628_isrf_min_prediction_SPIRE3.sav
phangs_smooth_muse_isrf,'ngc0628',resolution_filter='SPIRE3',/save,/show,/nostop

make_phangs_isrf_classes,bidon,source_name='ngc0628',/save,resolution_filter='SPIRE3'

phangs_brute_force_fit_with_isrf_grid,source_name='ngc0628',/include_herschel,/normalize,/fit_G0,/save,resolution_filter='SPIRE3'

phangs_brute_force_fit_with_isrf_grid,source_name='ngc0628',/include_herschel,/normalize,/fit_G0,/save,resolution_filter='SPIRE3',/from_restore


;============================================================================================================
;===== NGC0628 at PACS3 resolution
;============================================================================================================
;resolution_filter='PACS3'
;ngc0628_jwst_images_PACS3.sav, ngc0628_ref_header_PACS3.sav
phangs_make_jwst_images,source_name='ngc0628',/save,/show,/nostop,resolution_filter='PACS3'
phangs_make_co_images,source_name='ngc0628',/save,/show,/nostop,resolution_filter='PACS3'
phangs_make_hi_images,source_name='ngc0628',/save,/show,/nostop,resolution_filter='PACS3'
phangs_make_muse_filters_images,source_name='ngc0628',/save,/show,/nostop,resolution_filter='PACS3'
phangs_make_astrosat_images,source_name='ngc0628',/save,/show,/nostop,resolution_filter='PACS3'
phangs_make_herschel_images,source_name='ngc0628',/save,/show,/nostop,resolution_filter='PACS3'

phangs_make_muse_filters_data,source_name='ngc0628',/save,/show,/nostop,resolution_filter='PACS3'

phangs_extract_seds,source_name='ngc0628',resolution_filter='PACS3'

phangs_smooth_muse_isrf,'ngc0628',resolution_filter='PACS3',/save,/show,/nostop

make_phangs_isrf_classes,bidon,source_name='ngc0628',/save,resolution_filter='PACS3'

phangs_brute_force_fit_with_isrf_grid,source_name='ngc0628',/include_herschel,/normalize,/fit_G0,/save,resolution_filter='PACS3',/show_seds

;============================================================================================================
;===== NGC0628 at PACS2 resolution
;============================================================================================================

phangs_make_jwst_images,source_name='ngc0628',/save,/show,/nostop,resolution_filter='PACS2'
phangs_make_co_images,source_name='ngc0628',/save,/show,/nostop,resolution_filter='PACS2'
phangs_make_hi_images,source_name='ngc0628',/save,/show,/nostop,resolution_filter='PACS2'
phangs_make_muse_filters_images,source_name='ngc0628',/save,/show,/nostop,resolution_filter='PACS2'
phangs_make_astrosat_images,source_name='ngc0628',/save,/show,/nostop,resolution_filter='PACS2'
phangs_make_herschel_images,source_name='ngc0628',/save,/show,/nostop,resolution_filter='PACS2'

phangs_make_muse_filters_data,source_name='ngc0628',/save,/show,/nostop,resolution_filter='PACS2'

phangs_extract_seds,source_name='ngc0628',resolution_filter='PACS2'
phangs_smooth_muse_isrf,'ngc0628',resolution_filter='PACS2',/save

make_phangs_isrf_classes,bidon,source_name='ngc0628',/save,resolution_filter='PACS2'
phangs_brute_force_fit_with_isrf_grid,source_name='ngc0628',/include_herschel,/normalize,/fit_G0,/save,resolution_filter='PACS2',/subtract_star_light

;===== j'en suis la sur mon mac









phangs_brute_force_fit_with_isrf_grid,source_name='ngc0628',/include_herschel,/normalize,/fit_G0,/from_restore,resolution_filter='PACS3'



plot_phangs_ssps_against_uv_fast,bidon

;==== Check the classes and do a plot
;==== produce ngc0682_isrf_classes_one_ratio.sav
;==== requires : ngc0628_astrosat_voronoi_prediction_fast.sav
check_phangs_ssps_isrf_prediction,/show_map

;fit_phangs_ngc0628_nir_continuum,/from_restore,/show_plots     ;fit seds of some voronoi bins
;fit_phangs_ngc0628_nir_continuum,/from_restore,/brute_force
;fit_phangs_ngc0628_nir_continuum,/from_restore,/grid_brute_force

;=== Compute ISRF prediction. This is done only at full resolution
make_phangs_ssps_isrf_prediction,source_name='ngc0628',/save
check_phangs_ssps_isrf_prediction

;==== Make isrf classes
make_phangs_isrf_classes,bidon,source_name='ngc0628',/fits




;=== had to convert previous grids like this:
convert_all_grid_tables_from_v1_to_v2

;=== Fit the SEDs with the ISRF Grids
phangs_brute_force_fit_with_isrf_grid,source_name='ngc0628',/include_herschel,/normalize,/fit_G0,/save

phangs_brute_force_fit_with_isrf_grid,source_name='ngc0628',/include_herschel,/normalize,/fit_G0,/from_restore



;============================================================================================================
;===== NGC0628 at SPIRE3 resolution
;============================================================================================================
;resolution_filter='SPIRE3'
;ngc0628_jwst_images_SPIRE3.sav, ngc0628_ref_header_SPIRE3.sav
phangs_make_jwst_images,source_name='ngc0628',/save,/show,/nostop,resolution_filter='SPIRE3'
;ngc0628_CO_images_SPIRE3.sav
phangs_make_co_images,source_name='ngc0628',/save,/show,/nostop,resolution_filter='SPIRE3'
;ngc0628_HI_images_SPIRE3.sav
phangs_make_hi_images,source_name='ngc0628',/save,/show,/nostop,resolution_filter='SPIRE3'
;ngc0628_astrosat_data_SPIRE3.sav
phangs_make_astrosat_images,source_name='ngc0628',/save,/show,/nostop,resolution_filter='SPIRE3'
;ngc0628_muse_filters_data_SPIRE3.sav, ngc0628_muse_images_SPIRE3.sav (not produced _muse_NH_SPIRE3.sav)
phangs_make_muse_filters_images,source_name='ngc0628',/save,/show,/nostop,resolution_filter='SPIRE3'
;ngc0628_herschel_images_SPIRE3.sav
phangs_make_herschel_images,source_name='ngc0628',/save,/show,/nostop,resolution_filter='SPIRE3'

phangs_make_muse_filters_data,source_name='ngc0628',/save,/show,/nostop,resolution_filter='SPIRE3'

;ngc0628_jwst_seds_muse_pixels_SPIRE3.sav,ngc0628_seds_indices_SPIRE3.sav,ngc0628_muse_seds_muse_pixels_SPIRE3.sav
;ngc0628_astrosat_seds_muse_pixels_SPIRE3.sav,ngc0628_herschel_seds_muse_pixels_SPIRE3.sav,ngc0628_all_seds_muse_pixels_SPIRE3.sav
phangs_extract_seds,source_name='ngc0628',resolution_filter='SPIRE3',/reset_seds
;ngc0628_isrf_min_prediction_SPIRE3.sav
phangs_smooth_muse_isrf,'ngc0628',resolution_filter='SPIRE3',/save
;isrf_classes_one_ratio_on_ngc0628_SPIRE3.fits,ngc0628_isrf_classes_map_SPIRE3.fits,ngc0628_isrf_classes_voronoi_SPIRE3.sav
make_phangs_isrf_classes,bidon,source_name='ngc0628',/fits,resolution_filter='SPIRE3'
;J'en SUIS LA
phangs_brute_force_fit_with_isrf_grid,source_name='ngc0628',/include_herschel,/normalize,/fit_G0,/save,resolution_filter='SPIRE3'
;J'en SUIS LA






phangs_make_jwst_images,source_name='ngc0628',/save,/show,/nostop,resolution_filter='PACS3'
phangs_make_co_images,source_name='ngc0628',/save,/show,/nostop,resolution_filter='PACS3'
phangs_make_hi_images,source_name='ngc0628',/save,/show,/nostop,resolution_filter='PACS3'
phangs_make_astrosat_images,source_name='ngc0628',/save,/show,/nostop,resolution_filter='PACS3'
phangs_make_muse_filters_images,source_name='ngc0628',/save,/show,/nostop,resolution_filter='PACS3'
phangs_make_herschel_images,source_name='ngc0628',/save,/show,/nostop,resolution_filter='PACS3'

phangs_extract_seds,source_name='ngc0628',resolution_filter='PACS3'

;=== smooth MUSE isrfs to a given resolution
;phangs_smooth_muse_isrf,'ngc0628',resolution_filter='PACS3',/test
phangs_smooth_muse_isrf,'ngc0628',resolution_filter='PACS3',/save

;==== Make isrf classes
make_phangs_isrf_classes,bidon,source_name='ngc0628',/fits,resolution_filter='PACS3'


phangs_smooth_muse_isrf,'ngc0628',reso_filter='SPIRE1',/save





;=== NGC3351
;Note: faire un chmod a+rwx * apres transfert sur alma1

source_name='ngc3351'
;J'en SUIS LA

;produces _jwst_images.sav and _ref_header.sav
phangs_make_jwst_images,source_name='ngc3351',/save,/show,/nostop
;produces _muse_filters_data.sav,_muse_images.sav, _muse_NH.sav
phangs_make_muse_filters_images,source_name='ngc3351',/save,/show,/nostop
;produces _astrosat_data.sav
phangs_make_astrosat_images,source_name='ngc3351',/save,/show,/nostop
;produces _herschel_images.sav
phangs_make_herschel_images,source_name='ngc3351',/save,/show,/nostop
phangs_make_hi_images,source_name='ngc3351',/save,/show,/nostop
phangs_make_co_images,source_name='ngc3351',/save,/show,/nostop

phangs_extract_seds,source_name='ngc3351',/save

make_phangs_ssps_isrf_prediction,source_name='ngc3351',/save

make_phangs_isrf_classes,source_name='ngc3351',/fits

phangs_brute_force_fit_with_isrf_grid,source_name='ngc3351',/include_herschel,/normalize,/fit_G0

END