Metadata-Version: 2.4
Name: merlin-spectra
Version: 0.0.15
Summary: Interface with Cloudy Photoionization Software data and RAMSES-RT Simulation data to create galaxy images and spectra in nebular emission lines.
Project-URL: Homepage, https://github.com/BradenN6/Merlin
Author-email: Braden Marazzo-Nowicki <bnowicki@terpmail.umd.edu>
License: MIT License
        
        Copyright (c) 2025 Braden Nowicki
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: JWST,astrophysics,spectra
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Astronomy
Requires-Python: >=3.10
Requires-Dist: astropy>6.1
Requires-Dist: matplotlib>3.10
Requires-Dist: numpy>1.26
Requires-Dist: pandas>2.2
Requires-Dist: scipy>1.15
Requires-Dist: yt>4.4
Description-Content-Type: text/markdown

# Merlin

## Nebular Line Emission Diagnostics from Cosmological Simulations of 
## Early Universe Galaxies.

Author: Braden Nowicki
Advisor: Dr. Massimo Ricotti

Interface with Cloudy Photoionization Software data and RAMSES-RT Simulation
data to create galaxy images and spectra in nebular emission lines.


### File Structure:

MERLIN

merlin/ : primary package for analysis and visualizations
CloudyFiles/ : files related to Cloudy grid runs.
Reference/ : previously-developed analysis code.

#### Creating a Line List with Cloudy

The Cloudy Photoionization Code is used to generate line emission (flux)
throughout the desired parameter space. We consider gas parameters
Ionization Parameter, Hydrogen Number Density, and Temperature.
A simple grid run is performed, simulating emission for lines present in
CloudyFiles/gridrun-09-02-2026/LineList_NebularO.dat and
CloudyFiles/gridrun-09-02-2026/LineList_NebularCN.dat (can be adjusted)
from a 1 cm thick gas cell. The exact conditions can be adjusted (the star
SED, for instance) for a given run; a simulation for every combination of the
varying parameters is performed. Line list data is output in
'LineList_NebularCN.dat' and 'LineList_NebularO.dat'. 
Add a header to both with limits of U (ionisation parameter), 
N (H number density), T (temperature), such as 
"-9.0 2.0 0.5 -4.0 7.0 0.5 1.0 8.0 0.2", based on the input file.
Combine into a single 'linelist.dat' file via 'combine_tables.py'.

See CloudyFiles/gridrun-09-02-2026. interp6.in is the input file. The run file (with
executable privilege) can be used in your installation of Cloudy.
For instance, in the terminal, './run interp6' would run the desired
simulations (note that grid runs require the use of the -r option, present
in 'run', and therefore the input file is given as interp6, ommitting .in.)


#### Running Merlin on RAMSES-RT Output Data

Either use the source files themselves or 
'python3 -m pip install merlin-spectra'. With the latter, 'main.py' can be
run with a simple 'import merlin_spectra'. I recommend running in a conda
environment with the necessary packages installed.

'main.py' outlines the process: create derived field functions; load
the simulation given by the filepath (as a command line argument) pointing to
the info_*.txt file within an output folder; instantiate an
EmissionLineInterpolator object for the derived flux and luminosity
fields using the desired 'linelist.dat' table; instantiate a
VisualizationManager object; and run the desired routines/analysis for the
time slice.

NOTICE: Store the 'linelist-all.dat' file locally and update the path in
main.py. This will be updated soon to use data files from within the 
imported package source.

The class structures allow for easy testing of new features and updates.
One must call save_sim_info() for Object variables like current_redshift
to be created; afterwards, any function can be called in a modular fashion.
There are some exceptions: phase_with_profiles(), for instance, uses
an object generated by phase_plot().

NOTE: The proper updated hydro_file_descriptor.txt is formatted as, e.g.:

\# version:  1
\# ivar, variable_name, variable_type
 1, density, d
 2, velocity_x, d
 3, velocity_y, d
 4, velocity_z, d
 5, pressure, d
 6, metallicity, d
 7, xHI, d
 8, xHII, d
 9, xHeII, d
10, xHeIII, d
11, refinement-param, i


#### Running in the Cluster on Multiple Time Slices
With the desired routines and field setup chosen in a driver script
like 'main.py', analysis can be performed on multiple time slices in parallel.
For RAMSES-RT output data stored in a cluster, use scp to copy merlin,
a driver script like 'main.py', and a shell script like 'analysis.sh'
to the cluster scratch space. One may test that it works in the scratch space
by running 'main.py' on one time slice. You must first perform the module loads
and pip installs at the beginning of 'main.py' for the dependencies.
The shell script 'analysis-1.sh' shows one way to run the script on
multiple time slices in parallel (in one job). Preferably, the jobs are
submitted in a job array to run when resources are available, since the tasks
are completely independent (as in 'analysis.sh'). A python install path
can be specified to avoid using the version zaratan jobs default to.

#### Bulk Analysis of Multiple Time Slices



#### A Note on the Naming of this Code

The Merlin is a small species of falcon from the Northern Hemisphere.
The naming of this package is inspired by the Merlin's exceptionally sharp
eyesight; we generate observational diagnostics from simulated distant,
high-redshift galaxies. Birds are a bellwether of environmental decline;
populations are down nearly 3 billion birds since 1970. Please consider
supporting local efforts to safeguard birds, their migration, and their
habitats.
