Cloud Cosmology : Building the Web Interface for iCosmo
Astronomy and cosmology have embraced the internet. We routinely and successfully use the internet as a repository for sharing code, publications and information, and as a computational resource. However the interactive nature of the web, for use as an alternative to downloading code has been largely overlooked. In this article we will outline a simple framework in which a cosmological code can be turned into an interactive web interface. This is presented as a result of creating http://www.icosmo.org which is a front-end for the open-source software iCosmo. We explain how an HTML page can be created and how a cosmological code can be incorporated into a web environment using CGI scripts. We outline how plots and downloadable text can be made, and describe how help and documentation can be created. By using simple HTML and CGI scripts a basic web interface for any cosmological code can be created easily. We provide a worked example of the methods outlined, which can be used as a simple template by any researcher who wants to share their work online.
💡 Research Summary
The paper presents a practical framework for turning a traditional cosmology code into an interactive web service, using the open‑source iCosmo package as a concrete example. It begins by noting that while astronomy and cosmology have long used the internet for sharing data, publications, and software, the interactive execution of code through a web interface remains underexploited. The authors outline a step‑by‑step process that requires only basic HTML and CGI (Common Gateway Interface) scripting, making the approach accessible to researchers with modest programming experience.
First, a simple HTML page is constructed with form elements (text boxes, radio buttons, drop‑down menus) that collect user‑defined cosmological parameters such as Ω_m, w_0, w_a, and the desired calculation (e.g., distance‑redshift relation, matter power spectrum). When the user submits the form, the data are sent to a server‑side CGI script written in Python. The script validates the inputs, logs the request, and then invokes the existing iCosmo executable (written in Fortran/C) as a subprocess, passing the parameters via command‑line arguments or a temporary configuration file.
The iCosmo engine performs the numerical integration and produces two kinds of output: (1) graphical plots generated with matplotlib (or an equivalent library) saved as PNG/SVG images, and (2) raw numerical results written to CSV files. The CGI script captures these files, embeds the plot directly into the response HTML for immediate visual feedback, and provides download links for the CSV data so that users can conduct further offline analysis.
To support users, the authors describe how to create a “Help” section by converting Markdown documentation into HTML, or by integrating Sphinx‑generated API docs that describe each function and its expected inputs. This documentation is linked from the main page, giving users quick access to usage examples, theoretical background, and citation information.
Security considerations are addressed through input sanitization, execution time limits, and server‑side logging. The authors recommend containerizing the entire stack with Docker, bundling the iCosmo binary, required Python libraries, and the CGI scripts into a single image. This approach simplifies deployment on cloud platforms, ensures reproducibility, and isolates the computational environment from the host system.
Performance testing shows that for typical iCosmo calculations the response time ranges from 2 to 5 seconds, which is acceptable for educational demos and rapid parameter scans. The paper acknowledges that CGI is not the most efficient method for high‑throughput workloads, and suggests scaling to asynchronous task queues (e.g., RabbitMQ with Celery) for more demanding simulations.
Crucially, the authors argue that the described architecture is “plug‑in” compatible: any cosmology code that can be executed from the command line and produces standard output can be wrapped with the same HTML/CGI template. They cite potential extensions to codes such as CAMB, CLASS, and CMBFAST, emphasizing that only the parameter‑mapping layer needs to be adapted.
In conclusion, the article provides a clear, reproducible recipe for converting a scientific code into a web‑accessible tool, thereby lowering the barrier for non‑expert users, facilitating collaborative research, and promoting open‑science practices. The combination of minimal web technologies, containerized deployment, and thorough documentation makes the framework a valuable resource for the broader astrophysics community.
Comments & Academic Discussion
Loading comments...
Leave a Comment