diff --git a/page_distances.py b/page_distances.py deleted file mode 100644 index 6f734c0..0000000 --- a/page_distances.py +++ /dev/null @@ -1,154 +0,0 @@ -""" -CosmOracleApp -Created December 2021 -@authors: -[Marco Bonici](https://github.com/marcobonici), -[Niko Sarcevic](https://github.com/nikosarcevic) and -[Matthijs van der Wild](https://github.com/lonbar) -""" - -import numpy as np -import streamlit as st -import background as bg - -<<<<<<< HEAD -from helpers import plot_graph, get_parametersets, get_cosmologies, store_data -======= -from helpers import plot_graph, get_parametersets, get_cosmologies, store_data, get_redshifts ->>>>>>> f52f80ce39b7cf8c1fd2cf5848093a09d67cc2ca - -def show_page(): - - - - section_title = "Cosmological Distances" - - # Set default values - parameterset = st.sidebar.selectbox("Parameter set", get_parametersets()) - cosmologies = get_cosmologies(parameterset) - ΩM = cosmologies['matter-density'] - ΩDE = cosmologies['DE-density'] - ΩR = cosmologies['rad-density'] - w0 = cosmologies['w0'] - wa = cosmologies['wa'] - H0 = cosmologies['Hubble0'] - - z_value = st.sidebar.text_input('Redshift') - H0_value = st.sidebar.text_input('Hubble Constant [km/s/Mpc]', str(H0)) - ΩM_value = st.sidebar.text_input('Matter Density', str(ΩM)) - ΩDE_value = st.sidebar.text_input('Dark Energy Density', str(ΩDE)) - ΩR_value = st.sidebar.text_input('Radiation Density', str(ΩR)) - w0_value = st.sidebar.text_input('w0', str(w0)) - wa_value = st.sidebar.text_input('wa', str(wa)) - - sig_digits = int(st.sidebar.text_input('Significant Digits', str(4))) - - if z_value: - - z_array = np.linspace(0, float(z_value), 300) - - inputParms = bg.distanceData(z_array, float(H0_value), float(ΩM_value), float(ΩDE_value), - float(ΩR_value), float(w0_value), float(wa_value)) - - st.title('Results') - - st.write('Comoving distance at redshift', str(inputParms.redshift[-1]), 'is:', - str(round(inputParms.comoving_distance[-1], sig_digits)), 'Mpc') - st.write('Transverse comoving distance at redshift', str(inputParms.redshift[-1]), 'is:', - str(round(inputParms.transverse_comoving_distance[-1], sig_digits)), 'Mpc') - st.write('Luminosity distance at redshift', str(inputParms.redshift[-1]), 'is:', - str(round(inputParms.luminosity_distance[-1], sig_digits)), 'Mpc') - st.write('Angular diameter distance at redshift', str(inputParms.redshift[-1]), 'is:', - str(round(inputParms.angular_diameter_distance[-1], sig_digits)), 'Mpc') - st.write('An object spanning an angle of 1 arcsec at redshift', str(inputParms.redshift[-1]), 'is therefore', - str(round(inputParms.proper_separation[-1], sig_digits)), 'kpc across.') - st.write('Comoving volume at redshift', str(inputParms.redshift[-1]), 'is:', - str(round(inputParms.comoving_volume[-1], sig_digits)), 'Gpc³') - st.write('Lookback time at redshift', str(inputParms.redshift[-1]), 'is:', - str(round(inputParms.lookback_time[-1], sig_digits)), 'Gyrs') - - rz_array = inputParms.comoving_distance - trz_array = inputParms.transverse_comoving_distance - DLz_array = inputParms.luminosity_distance - DAz_array = inputParms.angular_diameter_distance - VCz_array = inputParms.comoving_volume - tlz_array = inputParms.lookback_time - - store_data(inputParms) - - st.write(" ") - - plot_rz = st.checkbox('Plot Comoving Distance Dc(z)') - plot_trz = st.checkbox('Plot Transverse Comoving Distance Dm(z)') - plot_DLz = st.checkbox('Plot Luminosity Distance Dl(z)') - plot_DAz = st.checkbox('Plot Angular Diameter Distance Da(z)') - - st.write(" ") - - if plot_rz or plot_trz or plot_DLz or plot_DAz: - - width = st.slider("plot width", 1, 25, 10) - height = st.slider("plot height", 1, 25, 5) - - log_checkbox = st.checkbox('Switch to semi-log scale') - - st.write(" ") - - plot = plot_graph(width, height, z_array, - (plot_rz, rz_array, "Comoving distance"), - (plot_trz, trz_array, "Transverse comoving distance"), - (plot_DLz, DLz_array, "Luminosity distance"), - (plot_DAz, DAz_array, "Angular diameter distance"), - is_log = log_checkbox) - - st.pyplot(plot) - - st.write(" ") - - my_expander = st.expander(label='Click for more plots') - with my_expander: - - plot_VCz = st.checkbox('Plot Comoving Volume Vc(z)') - plot_tlz = st.checkbox('Plot Lookback Time tl(z)') - - if plot_VCz: - - width = st.slider("Plot width Vc(z)", 1, 25, 10) - height = st.slider("Plot height Vc(z)", 1, 25, 5) - - log_checkbox = st.checkbox('Switch to semi-log scale Vc(z)') - - st.write(" ") - plot = plot_graph(width, height, z_array, - (plot_VCz, inputParms.comoving_volume, "Comoving Volume"), - axis_label = "Comoving volume [Gpc³]", is_log = log_checkbox) - - st.pyplot(plot) - - - if plot_tlz: - - width = st.slider("Plot width tl(z)", 1, 25, 10) - height = st.slider("Plot height tl(z)", 1, 25, 5) - - log_checkbox = st.checkbox('Switch to semi-log scale tl(z)') - - st.write(" ") - - plot = plot_graph(width, height, z_array, - (plot_tlz, inputParms.lookback_time, "Lookback time"), - axis_label = "Lookback time [Gyr]", is_log = log_checkbox) - - st.pyplot(plot) - - st.write(" ") - - st.header('Download calculated data as a text file') - f = open("output.txt", encoding = 'utf-8') - file_name = st.text_input('Name the file', "filename.txt") - st.download_button('Click to download', f, file_name = file_name) - else: - st.title(section_title) - st.write('Enter the value of redshift and cosmological parameters in the sidebar and press enter.') - - return diff --git a/streamlit_app.py b/streamlit_app.py deleted file mode 100644 index ed3a03c..0000000 --- a/streamlit_app.py +++ /dev/null @@ -1,46 +0,0 @@ -""" -CosmOracleApp -Created December 2021 -@authors: -[Marco Bonici](https://github.com/marcobonici), -[Niko Sarcevic](https://github.com/nikosarcevic) and -[Matthijs van der Wild](https://github.com/lonbar) -""" - -import streamlit as st -from helpers import read_markdown - -#import Introduction as pi -#import page_distances as pd -#import page_documentation as doc - - -# Page settings - -st.set_page_config(page_title='CosmΩracle') - -#Sidebar settings - -logo, name = st.sidebar.columns(2) -with logo: - image = 'https://github.com/nikosarcevic/CosmOracle/blob/main/images/LogowName.png?raw=true' - st.image(image, use_column_width=True) - -st.sidebar.write(" ") - -#pages = { -# "Introduction": pi, -# "Cosmological Distances": pd, -# "Definitions": doc, -# } - -st.sidebar.title("Main options") - -# Radio buttons to select desired option -#page = st.sidebar.radio("", tuple(pages.keys())) - -#pages[page].show_page() - -# About -about = read_markdown("docs/markdown/about.md") -st.sidebar.markdown(about)