From 33b3bcd3d9ba085c15a8d4e18288daf1e14efe9e Mon Sep 17 00:00:00 2001 From: ODA bot Date: Tue, 6 Feb 2024 13:09:02 +0000 Subject: [PATCH 01/12] update tool AGN cacades --- tools/agn-cacades/Simulate.py | 267 +++++++++++++++++++ tools/agn-cacades/agn_cacades_astro_tool.xml | 43 +++ 2 files changed, 310 insertions(+) create mode 100644 tools/agn-cacades/Simulate.py create mode 100644 tools/agn-cacades/agn_cacades_astro_tool.xml diff --git a/tools/agn-cacades/Simulate.py b/tools/agn-cacades/Simulate.py new file mode 100644 index 00000000..77406f09 --- /dev/null +++ b/tools/agn-cacades/Simulate.py @@ -0,0 +1,267 @@ +#!/usr/bin/env python +# coding: utf-8 + +# In[ ]: + + +import json +import os +import shutil +import sys + +try: + import numpy as np + _numpy_available = True +except ImportError: + _numpy_available = False + +try: + from oda_api.json import CustomJSONEncoder +except ImportError: + from json import JSONEncoder as CustomJSONEncoder + +_galaxy_wd = os.getcwd() + + +# In[100]: + + +import numpy as np +import matplotlib.pyplot as plt +from numpy import log10,pi,log,exp +from scipy.interpolate import interp1d +import glob + +from oda_api.data_products import PictureProduct +from oda_api.data_products import ODAAstropyTable + + +# In[4]: + + +get_ipython().system('git lfs install ; git lfs pull') + + +# In[5]: + + +get_ipython().system('bash install.sh') + + +# In[88]: + + +Gamma=2.4 # http://odahub.io/ontology#Float +Emax=1e15 # http://odahub.io/ontology#Float +Ecut=1e14 # http://odahub.io/ontology#Float +B=1e2 # http://odahub.io/ontology#Float + + +# In[ ]: + + +with open('inputs.json', 'r') as fd: + inp_dic = json.load(fd) +if '_data_product' in inp_dic.keys(): + inp_pdic = inp_dic['_data_product'] +else: + inp_pdic = inp_dic + +for vn, vv in inp_pdic.items(): + if vn != '_selector': + globals()[vn] = type(globals()[vn])(vv) + + +# In[89]: + + +fname='pp_a'+str(Gamma)+'_'+str(f"{Ecut:.2e}")+'_'+str(B) +fname='run' +get_ipython().system('cp propagation/pp_a2.4_E1e14.xsw propagation/{fname}.xsw') +get_ipython().system('cp propagation/pp_a2.4_E1e14_step2g.xsw propagation/{fname}_step2g.xsw') +get_ipython().system('cp propagation/pp_a2.4_E1e14_step3e.xsw propagation/{fname}_step3e.xsw') +get_ipython().system('cp propagation/pp_a2.4_E1e14_step4g.xsw propagation/{fname}_step4g.xsw') + + +# In[90]: + + +get_ipython().system('python propagation/replacePar CommonAlpha {str(Gamma)} propagation/{fname}.xsw') +get_ipython().system('python propagation/getPar CommonAlpha propagation/{fname}.xsw') + +get_ipython().system('python propagation/replacePar Emax {str(Emax)} propagation/{fname}.xsw') +get_ipython().system('python propagation/getPar Emax propagation/{fname}.xsw') + +Ecut_rel=Ecut/Emax +get_ipython().system('python propagation/replacePar injSpectraHigherCutoff {str(Ecut_rel)} propagation/{fname}.xsw') +get_ipython().system('python propagation/getPar injSpectraHigherCutoff propagation/{fname}.xsw') + + +get_ipython().system('python propagation/replacePar B0 {str(B)} propagation/{fname}_step2g.xsw') +get_ipython().system('python propagation/replacePar B0 {str(B)} propagation/{fname}_step3e.xsw') +get_ipython().system('python propagation/replacePar B0 {str(B)} propagation/{fname}_step4g.xsw') +get_ipython().system('python propagation/getPar B0 propagation/{fname}_step2g.xsw') + + +# In[ ]: + + +get_ipython().run_cell_magic('bash', '', 'cd propagation\n./run_all.sh run.xsw\n') + + +# In[95]: + + +get_ipython().system("cat 'propagation/results/run_step4g/fin/tot'") + + +# In[96]: + + +d=np.genfromtxt('propagation/results/run_step4g/fin/tot') +E=d[:,0] +gam=d[:,1] +nu=d[:,2] +elec=d[:,3] +prot=d[:,4] +plt.plot(E,gam) +plt.plot(E,nu) +plt.xscale('log') +plt.yscale('log') +plt.ylim(1e-20,1e-8) + + +# In[98]: + + +d=np.genfromtxt('NGC_1068_contour.csv') +gam=d[:,0] +f=d[:,1] +x_nu=np.logspace(3,5,10) +ymax=np.zeros(len(x_nu)) +ymin=np.ones(len(x_nu)) +for i in range(len(gam)): + y=3*f[i]*1e-11*(x_nu/1e3)**(2-gam[i]) + ymax=np.maximum(y,ymax) + ymin=np.minimum(y,ymin) +plt.fill_between(x_nu,ymin,ymax,color='blue',alpha=0.5) + +d=np.genfromtxt('SED_1068.csv') +nu=d[:,0] +nufnu=d[:,1] +en=2*pi*6.6e-16*nu/1e9 +efe=nufnu*1e-23/1.6 +plt.scatter(en,efe) + +d=np.genfromtxt('Fermi_1068.csv') +ee=d[:,0] +ff=d[:,1] +ff_max=d[:,2] +ff_min=d[:,3] +plt.errorbar(ee,ff,yerr=[ff-ff_min,ff_max-ff]) + +A=7e43/1.6e-12 /1e6 /log(10/2.) #1/eV/s +FX0=A*1e6/1e12/4/pi/(16.3*3e24)**2 +print(FX0) +x=[1e-6,1e-4] +y=[FX0,FX0] +plt.plot(x,y,color='black',linestyle='dashed') +A=4e43/1.6e-12 /1e6 /log(10/2.) #1/eV/s +FX0=A*1e6/1e12/4/pi/(16.3*3e24)**2 +A=14e43/1.6e-12 /1e6 /log(10/2.) #1/eV/s +FX1=A*1e6/1e12/4/pi/(16.3*3e24)**2 +x=[1e-6,1e-4,1e-4,1e-6] +y=[FX1,FX1,FX0,FX0] +plt.fill(x,y,alpha=0.3,color='black',linestyle='none') + +spec_file = 'propagation/results/run_step4g/fin/tot' +d=np.genfromtxt(spec_file) +E=d[:,0]*1e-9 +gam=d[:,1] # for original format d[:,3] +nu=d[:,2] # for original format (d[:,4]+d[:,5]+d[:,7]+d[:,8]) +f_nu = interp1d(np.log(E), nu , kind='linear', fill_value=0.) +interp_nu = f_nu(np.log(x_nu)) +N = 0.8*np.min(ymax/interp_nu) +plt.plot(E,N*gam*(E>5.e-9), label='$\\gamma$',color='blue',alpha=0.3) +plt.plot(E,N*gam*(E>5.e-7), color='black') +plt.plot(E,N*nu, label='$\\nu$') +backgr = np.genfromtxt('propagation/results/run_step4g/fin/backgr') +Eb = backgr[:,0] * 1e-9 +FE2 = backgr[:,0] * backgr[:,1] * 1e-12 * 3e10/4/np.pi*(1e13/4.6285163711e+25)**2 +plt.plot(Eb, 20*FE2, label='backgr3') + +plt.xscale('log') +plt.yscale('log') +plt.ylim(6e-14,3e-8) +plt.xlim(3e-11,1e6) +plt.tick_params(labelsize=12) +plt.xlabel(r'$E$, GeV',fontsize=12) +plt.ylabel(r'$EF_E$, TeV/(cm$^2$s)',fontsize=12) +plt.savefig('Spectrum.png',format='png',bbox_inches='tight') + + +# In[101]: + + +bin_image = PictureProduct.from_file('Spectrum.png') +from astropy.table import Table +data=[E,gam,nu] +names=('E[eV]','E2 dN/dE gamma [TeV/cm2s]','E2 dN/dE nu[ TeV/cm2 s]') +spectrum = ODAAstropyTable(Table(data, names = names)) + + +# In[102]: + + +picture = bin_image # http://odahub.io/ontology#ODAPictureProduct +spectrum_astropy_table = spectrum # http://odahub.io/ontology#ODAAstropyTable + + +# In[ ]: + + + + + +# In[ ]: + + +_simple_outs, _oda_outs = [], [] +_galaxy_meta_data = {} +_oda_outs.append(('out_Simulate_picture', 'picture_galaxy.output', picture)) +_oda_outs.append(('out_Simulate_spectrum_astropy_table', 'spectrum_astropy_table_galaxy.output', spectrum_astropy_table)) + +for _outn, _outfn, _outv in _oda_outs: + _galaxy_outfile_name = os.path.join(_galaxy_wd, _outfn) + if isinstance(_outv, str) and os.path.isfile(_outv): + shutil.move(_outv, _galaxy_outfile_name) + _galaxy_meta_data[_outn] = {'ext': '_sniff_'} + elif getattr(_outv, "write_fits_file", None): + _outv.write_fits_file(_galaxy_outfile_name) + _galaxy_meta_data[_outn] = {'ext': 'fits'} + elif getattr(_outv, "write_file", None): + _outv.write_file(_galaxy_outfile_name) + _galaxy_meta_data[_outn] = {'ext': '_sniff_'} + else: + with open(_galaxy_outfile_name, 'w') as fd: + json.dump(_outv, fd, cls=CustomJSONEncoder) + _galaxy_meta_data[_outn] = {'ext': 'json'} + +for _outn, _outfn, _outv in _simple_outs: + _galaxy_outfile_name = os.path.join(_galaxy_wd, _outfn) + if isinstance(_outv, str) and os.path.isfile(_outv): + shutil.move(_outv, _galaxy_outfile_name) + _galaxy_meta_data[_outn] = {'ext': '_sniff_'} + elif _numpy_available and isinstance(_outv, np.ndarray): + with open(_galaxy_outfile_name, 'wb') as fd: + np.savez(fd, _outv) + _galaxy_meta_data[_outn] = {'ext': 'npz'} + else: + with open(_galaxy_outfile_name, 'w') as fd: + json.dump(_outv, fd) + _galaxy_meta_data[_outn] = {'ext': 'expression.json'} + +with open(os.path.join(_galaxy_wd, 'galaxy.json'), 'w') as fd: + json.dump(_galaxy_meta_data, fd) +print("*** Job finished successfully ***") + diff --git a/tools/agn-cacades/agn_cacades_astro_tool.xml b/tools/agn-cacades/agn_cacades_astro_tool.xml new file mode 100644 index 00000000..d5655df9 --- /dev/null +++ b/tools/agn-cacades/agn_cacades_astro_tool.xml @@ -0,0 +1,43 @@ + + + cmake + gfortran + gsl + compilers + xerces-c + ipython + astropy + matplotlib + astroquery + scipy + oda-api + + nbconvert + + ipython '$__tool_directory__/Simulate.py' + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From e8d534e6726eb4dfe13e4b06b7a33fc69939fe16 Mon Sep 17 00:00:00 2001 From: ODA bot Date: Tue, 6 Feb 2024 14:04:51 +0000 Subject: [PATCH 02/12] update tool AGN cacades --- tools/agn-cacades/Simulate.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/agn-cacades/Simulate.py b/tools/agn-cacades/Simulate.py index 77406f09..f9195dcd 100644 --- a/tools/agn-cacades/Simulate.py +++ b/tools/agn-cacades/Simulate.py @@ -36,6 +36,12 @@ from oda_api.data_products import ODAAstropyTable +# In[1]: + + +get_ipython().system('pwd') + + # In[4]: @@ -45,7 +51,7 @@ # In[5]: -get_ipython().system('bash install.sh') +get_ipython().run_cell_magic('bash', '', './install.sh\n') # In[88]: From 241ab13c6be287012673cbc21a5b58f4d2ac3759 Mon Sep 17 00:00:00 2001 From: ODA bot Date: Wed, 7 Feb 2024 20:44:47 +0000 Subject: [PATCH 03/12] update tool AGN cacades --- tools/agn-cacades/agn_cacades_astro_tool.xml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/agn-cacades/agn_cacades_astro_tool.xml b/tools/agn-cacades/agn_cacades_astro_tool.xml index d5655df9..27fc8ba9 100644 --- a/tools/agn-cacades/agn_cacades_astro_tool.xml +++ b/tools/agn-cacades/agn_cacades_astro_tool.xml @@ -6,14 +6,16 @@ compilers xerces-c ipython - astropy + astropy + scipy + gammapy matplotlib - astroquery - scipy oda-api + nbconvert + wget + astroquery - nbconvert ipython '$__tool_directory__/Simulate.py' From a91533ec9ea250cdd1b8274501c4787c7cf85cb8 Mon Sep 17 00:00:00 2001 From: ODA bot Date: Thu, 8 Feb 2024 14:04:31 +0000 Subject: [PATCH 04/12] update tool AGN cacades --- tools/agn-cacades/agn_cacades_astro_tool.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/agn-cacades/agn_cacades_astro_tool.xml b/tools/agn-cacades/agn_cacades_astro_tool.xml index 27fc8ba9..e114c2b2 100644 --- a/tools/agn-cacades/agn_cacades_astro_tool.xml +++ b/tools/agn-cacades/agn_cacades_astro_tool.xml @@ -10,7 +10,7 @@ scipy gammapy matplotlib - oda-api + oda-api nbconvert wget astroquery From 7a6eb4f9279660c49ec18c003459f263afcb945b Mon Sep 17 00:00:00 2001 From: ODA bot Date: Thu, 8 Feb 2024 14:11:14 +0000 Subject: [PATCH 05/12] update tool AGN cacades --- tools/agn-cacades/Simulate.py | 53 ++++++++++++-------- tools/agn-cacades/agn_cacades_astro_tool.xml | 14 +++++- 2 files changed, 45 insertions(+), 22 deletions(-) diff --git a/tools/agn-cacades/Simulate.py b/tools/agn-cacades/Simulate.py index f9195dcd..9a6f7bf7 100644 --- a/tools/agn-cacades/Simulate.py +++ b/tools/agn-cacades/Simulate.py @@ -23,7 +23,7 @@ _galaxy_wd = os.getcwd() -# In[100]: +# In[ ]: import numpy as np @@ -36,31 +36,34 @@ from oda_api.data_products import ODAAstropyTable -# In[1]: +# In[ ]: get_ipython().system('pwd') -# In[4]: +# In[ ]: get_ipython().system('git lfs install ; git lfs pull') -# In[5]: +# In[ ]: get_ipython().run_cell_magic('bash', '', './install.sh\n') -# In[88]: +# In[ ]: Gamma=2.4 # http://odahub.io/ontology#Float Emax=1e15 # http://odahub.io/ontology#Float Ecut=1e14 # http://odahub.io/ontology#Float -B=1e2 # http://odahub.io/ontology#Float +B=1e4 # http://odahub.io/ontology#Float +background_norm_mode='density_cm3' # http://odahub.io/ontology#String ; oda:allowed_value "absolute","density_cm3","energy_density_eV_cm3" +corona_backround_norm_cm3=4.18876e15 # http://odahub.io/ontology#Float +disk_background_norm_cm3=1.39654e17 # http://odahub.io/ontology#Float # In[ ]: @@ -78,18 +81,21 @@ globals()[vn] = type(globals()[vn])(vv) -# In[89]: +# In[ ]: + + +background_norm_mode_index=["absolute","density_cm3","energy_density_eV_cm3"].index(background_norm_mode) + + +# In[ ]: fname='pp_a'+str(Gamma)+'_'+str(f"{Ecut:.2e}")+'_'+str(B) fname='run' get_ipython().system('cp propagation/pp_a2.4_E1e14.xsw propagation/{fname}.xsw') -get_ipython().system('cp propagation/pp_a2.4_E1e14_step2g.xsw propagation/{fname}_step2g.xsw') -get_ipython().system('cp propagation/pp_a2.4_E1e14_step3e.xsw propagation/{fname}_step3e.xsw') -get_ipython().system('cp propagation/pp_a2.4_E1e14_step4g.xsw propagation/{fname}_step4g.xsw') -# In[90]: +# In[ ]: get_ipython().system('python propagation/replacePar CommonAlpha {str(Gamma)} propagation/{fname}.xsw') @@ -103,10 +109,17 @@ get_ipython().system('python propagation/getPar injSpectraHigherCutoff propagation/{fname}.xsw') -get_ipython().system('python propagation/replacePar B0 {str(B)} propagation/{fname}_step2g.xsw') -get_ipython().system('python propagation/replacePar B0 {str(B)} propagation/{fname}_step3e.xsw') -get_ipython().system('python propagation/replacePar B0 {str(B)} propagation/{fname}_step4g.xsw') -get_ipython().system('python propagation/getPar B0 propagation/{fname}_step2g.xsw') +get_ipython().system('python propagation/replacePar B0 {str(B)} propagation/step??_template.xsw') +get_ipython().system('python propagation/getPar B0 propagation/step2g_template.xsw') + +get_ipython().system('python propagation/replacePar iroMult {str(disk_background_norm_cm3)} propagation/step??_template.xsw') +get_ipython().system('python propagation/getPar iroMult propagation/step2g_template.xsw') + +get_ipython().system('python propagation/replacePar IROBackgroundNormMode {str(background_norm_mode_index)} propagation/step??_template.xsw') +get_ipython().system('python propagation/getPar IROBackgroundNormMode propagation/step2g_template.xsw') + +get_ipython().system('python propagation/replacePar CustomBackgroundNormMode {str(background_norm_mode_index)} propagation/step??_template.xsw') +get_ipython().system('python propagation/getPar CustomBackgroundNormMode propagation/step2g_template.xsw') # In[ ]: @@ -115,13 +128,13 @@ get_ipython().run_cell_magic('bash', '', 'cd propagation\n./run_all.sh run.xsw\n') -# In[95]: +# In[ ]: get_ipython().system("cat 'propagation/results/run_step4g/fin/tot'") -# In[96]: +# In[ ]: d=np.genfromtxt('propagation/results/run_step4g/fin/tot') @@ -137,7 +150,7 @@ plt.ylim(1e-20,1e-8) -# In[98]: +# In[ ]: d=np.genfromtxt('NGC_1068_contour.csv') @@ -206,7 +219,7 @@ plt.savefig('Spectrum.png',format='png',bbox_inches='tight') -# In[101]: +# In[ ]: bin_image = PictureProduct.from_file('Spectrum.png') @@ -216,7 +229,7 @@ spectrum = ODAAstropyTable(Table(data, names = names)) -# In[102]: +# In[ ]: picture = bin_image # http://odahub.io/ontology#ODAPictureProduct diff --git a/tools/agn-cacades/agn_cacades_astro_tool.xml b/tools/agn-cacades/agn_cacades_astro_tool.xml index e114c2b2..2ed095a2 100644 --- a/tools/agn-cacades/agn_cacades_astro_tool.xml +++ b/tools/agn-cacades/agn_cacades_astro_tool.xml @@ -25,7 +25,14 @@ - + + + + + + + + @@ -36,7 +43,10 @@ - + + + + From ed921ec9ad5c5024e33f28e7e77fdb7e93fd7b5f Mon Sep 17 00:00:00 2001 From: ODA bot Date: Thu, 8 Feb 2024 16:16:11 +0000 Subject: [PATCH 06/12] update tool AGN cacades --- tools/agn-cacades/Simulate.py | 46 ++++++++++++++------ tools/agn-cacades/agn_cacades_astro_tool.xml | 4 ++ 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/tools/agn-cacades/Simulate.py b/tools/agn-cacades/Simulate.py index 9a6f7bf7..8529ee45 100644 --- a/tools/agn-cacades/Simulate.py +++ b/tools/agn-cacades/Simulate.py @@ -23,7 +23,7 @@ _galaxy_wd = os.getcwd() -# In[ ]: +# In[1]: import numpy as np @@ -36,34 +36,36 @@ from oda_api.data_products import ODAAstropyTable -# In[ ]: +# In[2]: get_ipython().system('pwd') -# In[ ]: +# In[3]: get_ipython().system('git lfs install ; git lfs pull') -# In[ ]: +# In[4]: get_ipython().run_cell_magic('bash', '', './install.sh\n') -# In[ ]: +# In[15]: Gamma=2.4 # http://odahub.io/ontology#Float Emax=1e15 # http://odahub.io/ontology#Float Ecut=1e14 # http://odahub.io/ontology#Float B=1e4 # http://odahub.io/ontology#Float +source_size_cm=3.0856e+13 # http://odahub.io/ontology#Float background_norm_mode='density_cm3' # http://odahub.io/ontology#String ; oda:allowed_value "absolute","density_cm3","energy_density_eV_cm3" corona_backround_norm_cm3=4.18876e15 # http://odahub.io/ontology#Float disk_background_norm_cm3=1.39654e17 # http://odahub.io/ontology#Float +min_steps=100 #http://odahub.io/ontology#Integer ; oda:lower_limit 10 ; oda:upper_limit 10000 # In[ ]: @@ -81,13 +83,17 @@ globals()[vn] = type(globals()[vn])(vv) -# In[ ]: +# In[16]: background_norm_mode_index=["absolute","density_cm3","energy_density_eV_cm3"].index(background_norm_mode) +distance_Mpc = source_size_cm/3.0856775807e+24 +electron_distance_Mpc = 100*distance_Mpc # electrons propagate longer +min_step_Mpc = distance_Mpc/min_steps +electron_min_step_Mpc = electron_distance_Mpc/min_steps -# In[ ]: +# In[17]: fname='pp_a'+str(Gamma)+'_'+str(f"{Ecut:.2e}")+'_'+str(B) @@ -95,7 +101,7 @@ get_ipython().system('cp propagation/pp_a2.4_E1e14.xsw propagation/{fname}.xsw') -# In[ ]: +# In[18]: get_ipython().system('python propagation/replacePar CommonAlpha {str(Gamma)} propagation/{fname}.xsw') @@ -121,20 +127,32 @@ get_ipython().system('python propagation/replacePar CustomBackgroundNormMode {str(background_norm_mode_index)} propagation/step??_template.xsw') get_ipython().system('python propagation/getPar CustomBackgroundNormMode propagation/step2g_template.xsw') +get_ipython().system('python propagation/replacePar L_short_distance_test {str(distance_Mpc)} propagation/step?g_template.xsw') +get_ipython().system('python propagation/getPar L_short_distance_test propagation/step2g_template.xsw') -# In[ ]: +get_ipython().system('python propagation/replacePar L_short_distance_test {str(electron_distance_Mpc)} propagation/step3e_template.xsw') +get_ipython().system('python propagation/getPar L_short_distance_test propagation/step3e_template.xsw') + +get_ipython().system('python propagation/replacePar microStep {str(min_step_Mpc)} propagation/step?g_template.xsw') +get_ipython().system('python propagation/getPar microStep propagation/step2g_template.xsw') + +get_ipython().system('python propagation/replacePar microStep {str(electron_min_step_Mpc)} propagation/step3e_template.xsw') +get_ipython().system('python propagation/getPar microStep propagation/step3e_template.xsw') + + +# In[9]: get_ipython().run_cell_magic('bash', '', 'cd propagation\n./run_all.sh run.xsw\n') -# In[ ]: +# In[10]: get_ipython().system("cat 'propagation/results/run_step4g/fin/tot'") -# In[ ]: +# In[11]: d=np.genfromtxt('propagation/results/run_step4g/fin/tot') @@ -150,7 +168,7 @@ plt.ylim(1e-20,1e-8) -# In[ ]: +# In[12]: d=np.genfromtxt('NGC_1068_contour.csv') @@ -219,7 +237,7 @@ plt.savefig('Spectrum.png',format='png',bbox_inches='tight') -# In[ ]: +# In[13]: bin_image = PictureProduct.from_file('Spectrum.png') @@ -229,7 +247,7 @@ spectrum = ODAAstropyTable(Table(data, names = names)) -# In[ ]: +# In[14]: picture = bin_image # http://odahub.io/ontology#ODAPictureProduct diff --git a/tools/agn-cacades/agn_cacades_astro_tool.xml b/tools/agn-cacades/agn_cacades_astro_tool.xml index 2ed095a2..2da1570b 100644 --- a/tools/agn-cacades/agn_cacades_astro_tool.xml +++ b/tools/agn-cacades/agn_cacades_astro_tool.xml @@ -26,6 +26,7 @@ + @@ -33,6 +34,7 @@ + @@ -44,9 +46,11 @@ + + From 33b3744f1f1f8be5723653ae63f491311d129f28 Mon Sep 17 00:00:00 2001 From: ODA bot Date: Thu, 8 Feb 2024 16:18:47 +0000 Subject: [PATCH 07/12] update tool AGN cacades --- tools/agn-cacades/Simulate.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tools/agn-cacades/Simulate.py b/tools/agn-cacades/Simulate.py index 8529ee45..89d23043 100644 --- a/tools/agn-cacades/Simulate.py +++ b/tools/agn-cacades/Simulate.py @@ -23,7 +23,7 @@ _galaxy_wd = os.getcwd() -# In[1]: +# In[ ]: import numpy as np @@ -36,25 +36,25 @@ from oda_api.data_products import ODAAstropyTable -# In[2]: +# In[ ]: get_ipython().system('pwd') -# In[3]: +# In[ ]: get_ipython().system('git lfs install ; git lfs pull') -# In[4]: +# In[ ]: get_ipython().run_cell_magic('bash', '', './install.sh\n') -# In[15]: +# In[ ]: Gamma=2.4 # http://odahub.io/ontology#Float @@ -83,7 +83,7 @@ globals()[vn] = type(globals()[vn])(vv) -# In[16]: +# In[ ]: background_norm_mode_index=["absolute","density_cm3","energy_density_eV_cm3"].index(background_norm_mode) @@ -93,7 +93,7 @@ electron_min_step_Mpc = electron_distance_Mpc/min_steps -# In[17]: +# In[ ]: fname='pp_a'+str(Gamma)+'_'+str(f"{Ecut:.2e}")+'_'+str(B) @@ -101,7 +101,7 @@ get_ipython().system('cp propagation/pp_a2.4_E1e14.xsw propagation/{fname}.xsw') -# In[18]: +# In[ ]: get_ipython().system('python propagation/replacePar CommonAlpha {str(Gamma)} propagation/{fname}.xsw') @@ -140,19 +140,19 @@ get_ipython().system('python propagation/getPar microStep propagation/step3e_template.xsw') -# In[9]: +# In[ ]: get_ipython().run_cell_magic('bash', '', 'cd propagation\n./run_all.sh run.xsw\n') -# In[10]: +# In[ ]: get_ipython().system("cat 'propagation/results/run_step4g/fin/tot'") -# In[11]: +# In[ ]: d=np.genfromtxt('propagation/results/run_step4g/fin/tot') @@ -168,7 +168,7 @@ plt.ylim(1e-20,1e-8) -# In[12]: +# In[ ]: d=np.genfromtxt('NGC_1068_contour.csv') @@ -237,7 +237,7 @@ plt.savefig('Spectrum.png',format='png',bbox_inches='tight') -# In[13]: +# In[ ]: bin_image = PictureProduct.from_file('Spectrum.png') @@ -247,7 +247,7 @@ spectrum = ODAAstropyTable(Table(data, names = names)) -# In[14]: +# In[ ]: picture = bin_image # http://odahub.io/ontology#ODAPictureProduct From 814ea3882e44d9746237cfa37ceb966ef36f1796 Mon Sep 17 00:00:00 2001 From: ODA bot Date: Wed, 21 Feb 2024 17:06:01 +0000 Subject: [PATCH 08/12] automatic update following https://gitlab.renkulab.io/astronomy/mmoda/agn-cacades/-/commit/c6f78a37a542d6df9329e315a09946421928a015 --- tools/agn-cacades/.shed.yml | 9 + tools/agn-cacades/Simulate.py | 479 +++++++++---------- tools/agn-cacades/agn_cacades_astro_tool.xml | 16 +- 3 files changed, 240 insertions(+), 264 deletions(-) create mode 100644 tools/agn-cacades/.shed.yml diff --git a/tools/agn-cacades/.shed.yml b/tools/agn-cacades/.shed.yml new file mode 100644 index 00000000..1ea3ca81 --- /dev/null +++ b/tools/agn-cacades/.shed.yml @@ -0,0 +1,9 @@ +categories: +- Astronomy +description: AGN cacades +homepage_url: null +long_description: AGN cacades +name: agn_cacades_astro_tool +owner: astroteam +remote_repository_url: https://github.com/esg-epfl-apc/tools-astro/tree/main/tools +type: unrestricted diff --git a/tools/agn-cacades/Simulate.py b/tools/agn-cacades/Simulate.py index 89d23043..f7747ca5 100644 --- a/tools/agn-cacades/Simulate.py +++ b/tools/agn-cacades/Simulate.py @@ -1,304 +1,269 @@ #!/usr/bin/env python # coding: utf-8 -# In[ ]: - +# flake8: noqa import json import os import shutil -import sys - -try: - import numpy as np - _numpy_available = True -except ImportError: - _numpy_available = False - -try: - from oda_api.json import CustomJSONEncoder -except ImportError: - from json import JSONEncoder as CustomJSONEncoder - -_galaxy_wd = os.getcwd() - -# In[ ]: - - -import numpy as np import matplotlib.pyplot as plt -from numpy import log10,pi,log,exp +import numpy as np +from numpy import log, pi +from oda_api.data_products import ODAAstropyTable, PictureProduct +from oda_api.json import CustomJSONEncoder from scipy.interpolate import interp1d -import glob - -from oda_api.data_products import PictureProduct -from oda_api.data_products import ODAAstropyTable - - -# In[ ]: - - -get_ipython().system('pwd') - - -# In[ ]: - - -get_ipython().system('git lfs install ; git lfs pull') - - -# In[ ]: +get_ipython().system("pwd") # noqa: F821 -get_ipython().run_cell_magic('bash', '', './install.sh\n') +get_ipython().system("git lfs install ; git lfs pull") # noqa: F821 +get_ipython().run_cell_magic("bash", "", "./install.sh\n") # noqa: F821 -# In[ ]: - - -Gamma=2.4 # http://odahub.io/ontology#Float -Emax=1e15 # http://odahub.io/ontology#Float -Ecut=1e14 # http://odahub.io/ontology#Float -B=1e4 # http://odahub.io/ontology#Float -source_size_cm=3.0856e+13 # http://odahub.io/ontology#Float -background_norm_mode='density_cm3' # http://odahub.io/ontology#String ; oda:allowed_value "absolute","density_cm3","energy_density_eV_cm3" -corona_backround_norm_cm3=4.18876e15 # http://odahub.io/ontology#Float -disk_background_norm_cm3=1.39654e17 # http://odahub.io/ontology#Float -min_steps=100 #http://odahub.io/ontology#Integer ; oda:lower_limit 10 ; oda:upper_limit 10000 - - -# In[ ]: +Gamma = 2.4 # http://odahub.io/ontology#Float +Emax = 1e15 # http://odahub.io/ontology#Float +Ecut = 1e14 # http://odahub.io/ontology#Float +B = 1e4 # http://odahub.io/ontology#Float +source_size_cm = 3.0856e13 # http://odahub.io/ontology#Float +background_norm_mode = "density_cm3" # http://odahub.io/ontology#String ; oda:allowed_value "absolute","density_cm3","energy_density_eV_cm3" +corona_backround_norm_cm3 = 4.18876e15 # http://odahub.io/ontology#Float +disk_background_norm_cm3 = 1.39654e17 # http://odahub.io/ontology#Float +min_steps = 100 # http://odahub.io/ontology#Integer ; oda:lower_limit 10 ; oda:upper_limit 10000 +_galaxy_wd = os.getcwd() -with open('inputs.json', 'r') as fd: +with open("inputs.json", "r") as fd: inp_dic = json.load(fd) -if '_data_product' in inp_dic.keys(): - inp_pdic = inp_dic['_data_product'] +if "_data_product" in inp_dic.keys(): + inp_pdic = inp_dic["_data_product"] else: inp_pdic = inp_dic for vn, vv in inp_pdic.items(): - if vn != '_selector': + if vn != "_selector": globals()[vn] = type(globals()[vn])(vv) - -# In[ ]: - - -background_norm_mode_index=["absolute","density_cm3","energy_density_eV_cm3"].index(background_norm_mode) -distance_Mpc = source_size_cm/3.0856775807e+24 -electron_distance_Mpc = 100*distance_Mpc # electrons propagate longer -min_step_Mpc = distance_Mpc/min_steps -electron_min_step_Mpc = electron_distance_Mpc/min_steps - - -# In[ ]: - - -fname='pp_a'+str(Gamma)+'_'+str(f"{Ecut:.2e}")+'_'+str(B) -fname='run' -get_ipython().system('cp propagation/pp_a2.4_E1e14.xsw propagation/{fname}.xsw') - - -# In[ ]: - - -get_ipython().system('python propagation/replacePar CommonAlpha {str(Gamma)} propagation/{fname}.xsw') -get_ipython().system('python propagation/getPar CommonAlpha propagation/{fname}.xsw') - -get_ipython().system('python propagation/replacePar Emax {str(Emax)} propagation/{fname}.xsw') -get_ipython().system('python propagation/getPar Emax propagation/{fname}.xsw') - -Ecut_rel=Ecut/Emax -get_ipython().system('python propagation/replacePar injSpectraHigherCutoff {str(Ecut_rel)} propagation/{fname}.xsw') -get_ipython().system('python propagation/getPar injSpectraHigherCutoff propagation/{fname}.xsw') - - -get_ipython().system('python propagation/replacePar B0 {str(B)} propagation/step??_template.xsw') -get_ipython().system('python propagation/getPar B0 propagation/step2g_template.xsw') - -get_ipython().system('python propagation/replacePar iroMult {str(disk_background_norm_cm3)} propagation/step??_template.xsw') -get_ipython().system('python propagation/getPar iroMult propagation/step2g_template.xsw') - -get_ipython().system('python propagation/replacePar IROBackgroundNormMode {str(background_norm_mode_index)} propagation/step??_template.xsw') -get_ipython().system('python propagation/getPar IROBackgroundNormMode propagation/step2g_template.xsw') - -get_ipython().system('python propagation/replacePar CustomBackgroundNormMode {str(background_norm_mode_index)} propagation/step??_template.xsw') -get_ipython().system('python propagation/getPar CustomBackgroundNormMode propagation/step2g_template.xsw') - -get_ipython().system('python propagation/replacePar L_short_distance_test {str(distance_Mpc)} propagation/step?g_template.xsw') -get_ipython().system('python propagation/getPar L_short_distance_test propagation/step2g_template.xsw') - -get_ipython().system('python propagation/replacePar L_short_distance_test {str(electron_distance_Mpc)} propagation/step3e_template.xsw') -get_ipython().system('python propagation/getPar L_short_distance_test propagation/step3e_template.xsw') - -get_ipython().system('python propagation/replacePar microStep {str(min_step_Mpc)} propagation/step?g_template.xsw') -get_ipython().system('python propagation/getPar microStep propagation/step2g_template.xsw') - -get_ipython().system('python propagation/replacePar microStep {str(electron_min_step_Mpc)} propagation/step3e_template.xsw') -get_ipython().system('python propagation/getPar microStep propagation/step3e_template.xsw') - - -# In[ ]: - - -get_ipython().run_cell_magic('bash', '', 'cd propagation\n./run_all.sh run.xsw\n') - - -# In[ ]: - - -get_ipython().system("cat 'propagation/results/run_step4g/fin/tot'") - - -# In[ ]: - - -d=np.genfromtxt('propagation/results/run_step4g/fin/tot') -E=d[:,0] -gam=d[:,1] -nu=d[:,2] -elec=d[:,3] -prot=d[:,4] -plt.plot(E,gam) -plt.plot(E,nu) -plt.xscale('log') -plt.yscale('log') -plt.ylim(1e-20,1e-8) - - -# In[ ]: - - -d=np.genfromtxt('NGC_1068_contour.csv') -gam=d[:,0] -f=d[:,1] -x_nu=np.logspace(3,5,10) -ymax=np.zeros(len(x_nu)) -ymin=np.ones(len(x_nu)) +background_norm_mode_index = [ + "absolute", + "density_cm3", + "energy_density_eV_cm3", +].index(background_norm_mode) +distance_Mpc = source_size_cm / 3.0856775807e24 +electron_distance_Mpc = 100 * distance_Mpc # electrons propagate longer +min_step_Mpc = distance_Mpc / min_steps +electron_min_step_Mpc = electron_distance_Mpc / min_steps + +fname = "pp_a" + str(Gamma) + "_" + str(f"{Ecut:.2e}") + "_" + str(B) +fname = "run" +get_ipython().system( # noqa: F821 + "cp propagation/pp_a2.4_E1e14.xsw propagation/{fname}.xsw" +) + +get_ipython().system( # noqa: F821 + "python propagation/replacePar CommonAlpha {str(Gamma)} propagation/{fname}.xsw" +) +get_ipython().system( # noqa: F821 + "python propagation/getPar CommonAlpha propagation/{fname}.xsw" +) + +get_ipython().system( # noqa: F821 + "python propagation/replacePar Emax {str(Emax)} propagation/{fname}.xsw" +) +get_ipython().system("python propagation/getPar Emax propagation/{fname}.xsw") # noqa: F821 + +Ecut_rel = Ecut / Emax +get_ipython().system( # noqa: F821 + "python propagation/replacePar injSpectraHigherCutoff {str(Ecut_rel)} propagation/{fname}.xsw" +) +get_ipython().system( # noqa: F821 + "python propagation/getPar injSpectraHigherCutoff propagation/{fname}.xsw" +) + +get_ipython().system( # noqa: F821 + "python propagation/replacePar B0 {str(B)} propagation/step??_template.xsw" +) +get_ipython().system( # noqa: F821 + "python propagation/getPar B0 propagation/step2g_template.xsw" +) + +get_ipython().system( # noqa: F821 + "python propagation/replacePar iroMult {str(disk_background_norm_cm3)} propagation/step??_template.xsw" +) +get_ipython().system( # noqa: F821 + "python propagation/getPar iroMult propagation/step2g_template.xsw" +) + +get_ipython().system( # noqa: F821 + "python propagation/replacePar IROBackgroundNormMode {str(background_norm_mode_index)} propagation/step??_template.xsw" +) +get_ipython().system( # noqa: F821 + "python propagation/getPar IROBackgroundNormMode propagation/step2g_template.xsw" +) + +get_ipython().system( # noqa: F821 + "python propagation/replacePar CustomBackgroundNormMode {str(background_norm_mode_index)} propagation/step??_template.xsw" +) +get_ipython().system( # noqa: F821 + "python propagation/getPar CustomBackgroundNormMode propagation/step2g_template.xsw" +) + +get_ipython().system( # noqa: F821 + "python propagation/replacePar L_short_distance_test {str(distance_Mpc)} propagation/step?g_template.xsw" +) +get_ipython().system( # noqa: F821 + "python propagation/getPar L_short_distance_test propagation/step2g_template.xsw" +) + +get_ipython().system( # noqa: F821 + "python propagation/replacePar L_short_distance_test {str(electron_distance_Mpc)} propagation/step3e_template.xsw" +) +get_ipython().system( # noqa: F821 + "python propagation/getPar L_short_distance_test propagation/step3e_template.xsw" +) + +get_ipython().system( # noqa: F821 + "python propagation/replacePar microStep {str(min_step_Mpc)} propagation/step?g_template.xsw" +) +get_ipython().system( # noqa: F821 + "python propagation/getPar microStep propagation/step2g_template.xsw" +) + +get_ipython().system( # noqa: F821 + "python propagation/replacePar microStep {str(electron_min_step_Mpc)} propagation/step3e_template.xsw" +) +get_ipython().system( # noqa: F821 + "python propagation/getPar microStep propagation/step3e_template.xsw" +) + +get_ipython().run_cell_magic( # noqa: F821 + "bash", "", "cd propagation\n./run_all.sh run.xsw\n" +) + +get_ipython().system("cat 'propagation/results/run_step4g/fin/tot'") # noqa: F821 + +d = np.genfromtxt("propagation/results/run_step4g/fin/tot") +E = d[:, 0] +gam = d[:, 1] +nu = d[:, 2] +elec = d[:, 3] +prot = d[:, 4] +plt.plot(E, gam) +plt.plot(E, nu) +plt.xscale("log") +plt.yscale("log") +plt.ylim(1e-20, 1e-8) + +d = np.genfromtxt("NGC_1068_contour.csv") +gam = d[:, 0] +f = d[:, 1] +x_nu = np.logspace(3, 5, 10) +ymax = np.zeros(len(x_nu)) +ymin = np.ones(len(x_nu)) for i in range(len(gam)): - y=3*f[i]*1e-11*(x_nu/1e3)**(2-gam[i]) - ymax=np.maximum(y,ymax) - ymin=np.minimum(y,ymin) -plt.fill_between(x_nu,ymin,ymax,color='blue',alpha=0.5) - -d=np.genfromtxt('SED_1068.csv') -nu=d[:,0] -nufnu=d[:,1] -en=2*pi*6.6e-16*nu/1e9 -efe=nufnu*1e-23/1.6 -plt.scatter(en,efe) - -d=np.genfromtxt('Fermi_1068.csv') -ee=d[:,0] -ff=d[:,1] -ff_max=d[:,2] -ff_min=d[:,3] -plt.errorbar(ee,ff,yerr=[ff-ff_min,ff_max-ff]) - -A=7e43/1.6e-12 /1e6 /log(10/2.) #1/eV/s -FX0=A*1e6/1e12/4/pi/(16.3*3e24)**2 + y = 3 * f[i] * 1e-11 * (x_nu / 1e3) ** (2 - gam[i]) + ymax = np.maximum(y, ymax) + ymin = np.minimum(y, ymin) +plt.fill_between(x_nu, ymin, ymax, color="blue", alpha=0.5) + +d = np.genfromtxt("SED_1068.csv") +nu = d[:, 0] +nufnu = d[:, 1] +en = 2 * pi * 6.6e-16 * nu / 1e9 +efe = nufnu * 1e-23 / 1.6 +plt.scatter(en, efe) + +d = np.genfromtxt("Fermi_1068.csv") +ee = d[:, 0] +ff = d[:, 1] +ff_max = d[:, 2] +ff_min = d[:, 3] +plt.errorbar(ee, ff, yerr=[ff - ff_min, ff_max - ff]) + +A = 7e43 / 1.6e-12 / 1e6 / log(10 / 2.0) # 1/eV/s +FX0 = A * 1e6 / 1e12 / 4 / pi / (16.3 * 3e24) ** 2 print(FX0) -x=[1e-6,1e-4] -y=[FX0,FX0] -plt.plot(x,y,color='black',linestyle='dashed') -A=4e43/1.6e-12 /1e6 /log(10/2.) #1/eV/s -FX0=A*1e6/1e12/4/pi/(16.3*3e24)**2 -A=14e43/1.6e-12 /1e6 /log(10/2.) #1/eV/s -FX1=A*1e6/1e12/4/pi/(16.3*3e24)**2 -x=[1e-6,1e-4,1e-4,1e-6] -y=[FX1,FX1,FX0,FX0] -plt.fill(x,y,alpha=0.3,color='black',linestyle='none') - -spec_file = 'propagation/results/run_step4g/fin/tot' -d=np.genfromtxt(spec_file) -E=d[:,0]*1e-9 -gam=d[:,1] # for original format d[:,3] -nu=d[:,2] # for original format (d[:,4]+d[:,5]+d[:,7]+d[:,8]) -f_nu = interp1d(np.log(E), nu , kind='linear', fill_value=0.) +x = [1e-6, 1e-4] +y = [FX0, FX0] +plt.plot(x, y, color="black", linestyle="dashed") +A = 4e43 / 1.6e-12 / 1e6 / log(10 / 2.0) # 1/eV/s +FX0 = A * 1e6 / 1e12 / 4 / pi / (16.3 * 3e24) ** 2 +A = 14e43 / 1.6e-12 / 1e6 / log(10 / 2.0) # 1/eV/s +FX1 = A * 1e6 / 1e12 / 4 / pi / (16.3 * 3e24) ** 2 +x = [1e-6, 1e-4, 1e-4, 1e-6] +y = [FX1, FX1, FX0, FX0] +plt.fill(x, y, alpha=0.3, color="black", linestyle="none") + +spec_file = "propagation/results/run_step4g/fin/tot" +d = np.genfromtxt(spec_file) +E = d[:, 0] * 1e-9 +gam = d[:, 1] # for original format d[:,3] +nu = d[:, 2] # for original format (d[:,4]+d[:,5]+d[:,7]+d[:,8]) +f_nu = interp1d(np.log(E), nu, kind="linear", fill_value=0.0) interp_nu = f_nu(np.log(x_nu)) -N = 0.8*np.min(ymax/interp_nu) -plt.plot(E,N*gam*(E>5.e-9), label='$\\gamma$',color='blue',alpha=0.3) -plt.plot(E,N*gam*(E>5.e-7), color='black') -plt.plot(E,N*nu, label='$\\nu$') -backgr = np.genfromtxt('propagation/results/run_step4g/fin/backgr') -Eb = backgr[:,0] * 1e-9 -FE2 = backgr[:,0] * backgr[:,1] * 1e-12 * 3e10/4/np.pi*(1e13/4.6285163711e+25)**2 -plt.plot(Eb, 20*FE2, label='backgr3') - -plt.xscale('log') -plt.yscale('log') -plt.ylim(6e-14,3e-8) -plt.xlim(3e-11,1e6) +N = 0.8 * np.min(ymax / interp_nu) +plt.plot(E, N * gam * (E > 5.0e-9), label="$\\gamma$", color="blue", alpha=0.3) +plt.plot(E, N * gam * (E > 5.0e-7), color="black") +plt.plot(E, N * nu, label="$\\nu$") +backgr = np.genfromtxt("propagation/results/run_step4g/fin/backgr") +Eb = backgr[:, 0] * 1e-9 +FE2 = ( + backgr[:, 0] + * backgr[:, 1] + * 1e-12 + * 3e10 + / 4 + / np.pi + * (1e13 / 4.6285163711e25) ** 2 +) +plt.plot(Eb, 20 * FE2, label="backgr3") + +plt.xscale("log") +plt.yscale("log") +plt.ylim(6e-14, 3e-8) +plt.xlim(3e-11, 1e6) plt.tick_params(labelsize=12) -plt.xlabel(r'$E$, GeV',fontsize=12) -plt.ylabel(r'$EF_E$, TeV/(cm$^2$s)',fontsize=12) -plt.savefig('Spectrum.png',format='png',bbox_inches='tight') - - -# In[ ]: +plt.xlabel(r"$E$, GeV", fontsize=12) +plt.ylabel(r"$EF_E$, TeV/(cm$^2$s)", fontsize=12) +plt.savefig("Spectrum.png", format="png", bbox_inches="tight") - -bin_image = PictureProduct.from_file('Spectrum.png') +bin_image = PictureProduct.from_file("Spectrum.png") from astropy.table import Table -data=[E,gam,nu] -names=('E[eV]','E2 dN/dE gamma [TeV/cm2s]','E2 dN/dE nu[ TeV/cm2 s]') -spectrum = ODAAstropyTable(Table(data, names = names)) - - -# In[ ]: - - -picture = bin_image # http://odahub.io/ontology#ODAPictureProduct -spectrum_astropy_table = spectrum # http://odahub.io/ontology#ODAAstropyTable - - -# In[ ]: +data = [E, gam, nu] +names = ("E[eV]", "E2 dN/dE gamma [TeV/cm2s]", "E2 dN/dE nu[ TeV/cm2 s]") +spectrum = ODAAstropyTable(Table(data, names=names)) +picture = bin_image # http://odahub.io/ontology#ODAPictureProduct +spectrum_astropy_table = spectrum # http://odahub.io/ontology#ODAAstropyTable - - -# In[ ]: - - -_simple_outs, _oda_outs = [], [] +# output gathering _galaxy_meta_data = {} -_oda_outs.append(('out_Simulate_picture', 'picture_galaxy.output', picture)) -_oda_outs.append(('out_Simulate_spectrum_astropy_table', 'spectrum_astropy_table_galaxy.output', spectrum_astropy_table)) +_oda_outs = [] +_oda_outs.append(("out_Simulate_picture", "picture_galaxy.output", picture)) +_oda_outs.append( + ( + "out_Simulate_spectrum_astropy_table", + "spectrum_astropy_table_galaxy.output", + spectrum_astropy_table, + ) +) for _outn, _outfn, _outv in _oda_outs: _galaxy_outfile_name = os.path.join(_galaxy_wd, _outfn) if isinstance(_outv, str) and os.path.isfile(_outv): shutil.move(_outv, _galaxy_outfile_name) - _galaxy_meta_data[_outn] = {'ext': '_sniff_'} + _galaxy_meta_data[_outn] = {"ext": "_sniff_"} elif getattr(_outv, "write_fits_file", None): _outv.write_fits_file(_galaxy_outfile_name) - _galaxy_meta_data[_outn] = {'ext': 'fits'} + _galaxy_meta_data[_outn] = {"ext": "fits"} elif getattr(_outv, "write_file", None): _outv.write_file(_galaxy_outfile_name) - _galaxy_meta_data[_outn] = {'ext': '_sniff_'} + _galaxy_meta_data[_outn] = {"ext": "_sniff_"} else: - with open(_galaxy_outfile_name, 'w') as fd: + with open(_galaxy_outfile_name, "w") as fd: json.dump(_outv, fd, cls=CustomJSONEncoder) - _galaxy_meta_data[_outn] = {'ext': 'json'} - -for _outn, _outfn, _outv in _simple_outs: - _galaxy_outfile_name = os.path.join(_galaxy_wd, _outfn) - if isinstance(_outv, str) and os.path.isfile(_outv): - shutil.move(_outv, _galaxy_outfile_name) - _galaxy_meta_data[_outn] = {'ext': '_sniff_'} - elif _numpy_available and isinstance(_outv, np.ndarray): - with open(_galaxy_outfile_name, 'wb') as fd: - np.savez(fd, _outv) - _galaxy_meta_data[_outn] = {'ext': 'npz'} - else: - with open(_galaxy_outfile_name, 'w') as fd: - json.dump(_outv, fd) - _galaxy_meta_data[_outn] = {'ext': 'expression.json'} + _galaxy_meta_data[_outn] = {"ext": "json"} -with open(os.path.join(_galaxy_wd, 'galaxy.json'), 'w') as fd: +with open(os.path.join(_galaxy_wd, "galaxy.json"), "w") as fd: json.dump(_galaxy_meta_data, fd) print("*** Job finished successfully ***") - diff --git a/tools/agn-cacades/agn_cacades_astro_tool.xml b/tools/agn-cacades/agn_cacades_astro_tool.xml index 2da1570b..c8adfedb 100644 --- a/tools/agn-cacades/agn_cacades_astro_tool.xml +++ b/tools/agn-cacades/agn_cacades_astro_tool.xml @@ -6,20 +6,22 @@ compilers xerces-c ipython - astropy - scipy + oda-api + astropy + matplotlib gammapy - matplotlib - oda-api - nbconvert - wget astroquery + scipy + nbconvert + wget + pydantic + tqdm ipython '$__tool_directory__/Simulate.py' - + From e7a7b4c2d612c2f14da43e2b904a1f8b5b6fad47 Mon Sep 17 00:00:00 2001 From: ODA bot Date: Tue, 27 Feb 2024 00:03:37 +0000 Subject: [PATCH 09/12] automatic update following https://gitlab.renkulab.io/astronomy/mmoda/agn-cacades/-/commit/c6f78a37a542d6df9329e315a09946421928a015 --- tools/agn-cacades/agn_cacades_astro_tool.xml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tools/agn-cacades/agn_cacades_astro_tool.xml b/tools/agn-cacades/agn_cacades_astro_tool.xml index c8adfedb..78ec9216 100644 --- a/tools/agn-cacades/agn_cacades_astro_tool.xml +++ b/tools/agn-cacades/agn_cacades_astro_tool.xml @@ -5,15 +5,18 @@ gsl compilers xerces-c - ipython - oda-api + ipython astropy + numpy + scipy + iminuit matplotlib + wget + multiprocess + oda-api + nbconvert gammapy astroquery - scipy - nbconvert - wget pydantic tqdm + nbconvert ipython '$__tool_directory__/Simulate.py' - + - + @@ -47,9 +40,9 @@ - + - + From 822074ce3ae58a825b8f9241d255f43f18d6c322 Mon Sep 17 00:00:00 2001 From: mmoda-esg-bot Date: Fri, 7 Jun 2024 09:19:39 +0000 Subject: [PATCH 11/12] automatic update following https://gitlab.renkulab.io/astronomy/mmoda/agn-cacades/-/commit/b4c82a8bdab71c4f84baaa1d8f78ebcc208efc6b --- tools/agn-cacades/Simulate.py | 12 ++++++------ tools/agn-cacades/agn_cacades_astro_tool.xml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/agn-cacades/Simulate.py b/tools/agn-cacades/Simulate.py index e1b3ad81..a9152e27 100644 --- a/tools/agn-cacades/Simulate.py +++ b/tools/agn-cacades/Simulate.py @@ -53,7 +53,7 @@ min_step_Mpc = distance_Mpc / min_steps electron_min_step_Mpc = electron_distance_Mpc / min_steps -fname = "pp_a" + str(Gamma) + "_" + str(f"{Ecut:.2e}") + "_" + str(B) +# fname='pp_a'+str(Gamma)+'_'+str(f"{Ecut:.2e}")+'_'+str(B) fname = "run" get_ipython().system( # noqa: F821 "cp propagation/pp_a2.4_E1e14.xsw propagation/{fname}.xsw" @@ -115,7 +115,7 @@ ) get_ipython().system( # noqa: F821 - "python propagation/replacePar L_short_distance_test {str(electron_distance_Mpc)} propagation/step3e_template.xsw" + "python propagation/replacePar L_short_distance_test {str(electron_distance_Mpc)} propagation/step?e_template.xsw" ) get_ipython().system( # noqa: F821 "python propagation/getPar L_short_distance_test propagation/step3e_template.xsw" @@ -129,7 +129,7 @@ ) get_ipython().system( # noqa: F821 - "python propagation/replacePar microStep {str(electron_min_step_Mpc)} propagation/step3e_template.xsw" + "python propagation/replacePar microStep {str(electron_min_step_Mpc)} propagation/step?e_template.xsw" ) get_ipython().system( # noqa: F821 "python propagation/getPar microStep propagation/step3e_template.xsw" @@ -139,9 +139,9 @@ "bash", "", "cd propagation\n./run_all.sh run.xsw\n" ) -get_ipython().system("cat 'propagation/results/run_step4g/fin/tot'") # noqa: F821 +get_ipython().system("cat propagation/results/run_final/tot") # noqa: F821 -d = np.genfromtxt("propagation/results/run_step4g/fin/tot") +d = np.genfromtxt("propagation/results/run_final/tot") E = d[:, 0] gam = d[:, 1] nu = d[:, 2] @@ -238,7 +238,7 @@ y = [FX1, FX1, FX0, FX0] plt.fill(x, y, alpha=0.3, color="black", linestyle="none") -spec_file = "propagation/results/run_step4g/fin/tot" +spec_file = "propagation/results/run_final/tot" d = np.genfromtxt(spec_file) E = d[:, 0] * 1e-9 gam = d[:, 1] # for original format d[:,3] diff --git a/tools/agn-cacades/agn_cacades_astro_tool.xml b/tools/agn-cacades/agn_cacades_astro_tool.xml index 731f1f13..af003952 100644 --- a/tools/agn-cacades/agn_cacades_astro_tool.xml +++ b/tools/agn-cacades/agn_cacades_astro_tool.xml @@ -1,6 +1,6 @@ - cmake + cmake gfortran gsl compilers From 80f02ccf0972cb94943d3db131eea4c31a3135c4 Mon Sep 17 00:00:00 2001 From: mmoda-esg-bot Date: Tue, 2 Jul 2024 11:38:25 +0000 Subject: [PATCH 12/12] automatic update following https://gitlab.renkulab.io/astronomy/mmoda/agn-cacades/-/commit/b4c82a8bdab71c4f84baaa1d8f78ebcc208efc6b --- tools/agn-cacades/agn_cacades_astro_tool.xml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tools/agn-cacades/agn_cacades_astro_tool.xml b/tools/agn-cacades/agn_cacades_astro_tool.xml index af003952..1ca3e98f 100644 --- a/tools/agn-cacades/agn_cacades_astro_tool.xml +++ b/tools/agn-cacades/agn_cacades_astro_tool.xml @@ -1,16 +1,22 @@ - cmake + cmake gfortran gsl compilers xerces-c - ipython - astropy - matplotlib - astroquery - scipy + pandas oda-api + matplotlib + requests + astroquery + rdflib + beautifulsoup4 + sparqlwrapper + networkx + scipy + ipython + astropy nbconvert