# ebupi/galaxies-and-cosmology architecture

> Architecture diagram of the GitHub repository ebupi/galaxies-and-cosmology, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ebupi/galaxies-and-cosmology
- Repository: https://github.com/ebupi/galaxies-and-cosmology

## Overview

##### Project type and purpose
- This is a research-oriented “Galaxies and Cosmology Class Notes” repository. It is not a user-facing application but a collection of Jupyter notebooks, Python scripts, and data assets used to explore topics like the Milky Way 3D mapping, isophote fitting, and dust extinction.

##### File structure
- Top-level notebooks (FRW.ipynb, Galaxy-3d-map.ipynb, izofot.ipynb, etc.) each implement an analysis or visualization.
- Python scripts (sfd.py, etkin-yaricap-galaxy.py) encapsulate reusable logic—e.g., loading FITS files or computing dust extinction.
- Data assets: raw FITS files (frame-g-003918-3-0213.fits, SFD_dust_4096_ngp.fits, etc.), plus a dustmap-master directory containing code and data for the SFD dustmap.
- README.md describes high-level topics and dependencies (e.g., pip-installable dustmap or local dustmap zip).

##### README for additional insights
- The sequence of notebooks corresponds to course modules: “Milkway 3d map,” “Isophote – effective radius,” “Lin-Shu.”
- The dustmap submodule is required to compute galactic extinction if the pip version fails.

a. Main components
- Data Layer: FITS files in root and dustmap-master subfolder
- Processing/Library Layer:
– sfd.py (SFD dust computations)
– dustmap-master/sfd.py (alternative implementation)
– Other helpers (etkin-yaricap-galaxy.py)
- Notebook Layer: FRW.ipynb, Galaxy-3d-map.ipynb, izofot.ipynb, plancks-for-sed.ipynb, sersic.ipynb, etc.
- External Services/Libraries: astropy, numpy, matplotlib, pip-installed dustmap package
- Outputs: Figures, computed parameters, inline notebook results

b. Relationships and interactions
1. Notebooks import the Processing/Library Layer
2. Processing scripts read raw FITS files from the Data Layer
3. Processing scripts optionally call the external dustmap library or the bundled dustmap-master code
4. Results flow back to the Notebook Layer for visualization and further analysis

c. Architectural patterns and principles
- Separation of concerns: data, core algorithms, and presentation are in distinct components.
- Modularity: swapping between pip-installed dustmap and the local dustmap-master directory.
- Reproducibility: all raw data and code are versioned together.

d. Technologies and libraries
- Python ecosystem: astropy for FITS I/O, numpy/pandas for data manipulation, matplotlib/seaborn for plotting
- dustmap (SFD) for extinction maps, either via pip or local code
- Jupyter Notebooks for literate programming

##### Detailed capture of architectural elements
- FITS file or group them under a “FITS Data” container
- Both dustmap code paths (pip and local zip)
- Sfd.py and dustmap-master/sfd.py to the notebooks that call them
- Configuration needs (e.g., unzip dustmap-master before running notebooks)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Data Layer
    subgraph "Data Layer"
        direction TB
        subgraph "FITS Files"
            frame["frame-g-003918-3-0213.fits"]:::data
            ngp["SFD_dust_4096_ngp.fits"]:::data
            sgp["SFD_dust_4096_sgp.fits"]:::data
        end
    end

    %% Processing Layer
    subgraph "Processing Layer"
        direction TB
        SFD["sfd.py"]:::script
        LocalSFD["dustmap-master/sfd.py"]:::script
        Radius["etkin-yaricap-galaxy.py"]:::script
    end

    %% Notebook Layer
    subgraph "Notebook Layer"
        direction TB
        subgraph "Cosmology & Mapping"
            FRW["FRW.ipynb"]:::notebook
            Map3d["Galaxy-3d-map.ipynb"]:::notebook
        end
        subgraph "Isophote Analysis"
            Iso["izofot.ipynb"]:::notebook
            IsoSrc["izofot-kaynak.ipynb"]:::notebook
        end
        subgraph "SED & Profiles"
            Planck["plancks-for-sed.ipynb"]:::notebook
            Sersic["sersic.ipynb"]:::notebook
        end
    end

    %% Documentation Layer
    subgraph "Documentation & Packaging"
        direction TB
        README["README.md"]:::doc
        DustZip["dustmap-master.zip"]:::doc
        LocalModule["dustmap-master"]:::doc
        LocalReadme["dustmap-master/README.md"]:::doc
    end

    %% External Libraries
    subgraph "External Libraries"
        direction TB
        Astropy["Astropy"]:::external
        Numpy["NumPy"]:::external
        Matplotlib["Matplotlib"]:::external
        DustmapPy["dustmap (pip)"]:::external
    end

    %% Connections: Data to Processing
    frame --> SFD
    ngp --> LocalSFD
    sgp --> LocalSFD
    frame --> LocalSFD

    %% Processing to Notebooks
    SFD --> FRW
    SFD --> Map3d
    SFD --> Iso
    SFD --> Planck
    SFD --> Sersic

    LocalSFD --> FRW
    LocalSFD --> Map3d
    LocalSFD --> Iso
    LocalSFD --> Planck
    LocalSFD --> Sersic

    Radius --> FRW
    Radius --> Map3d
    Radius --> Iso
    Radius --> Planck
    Radius --> Sersic

    %% Notebooks to External
    FRW --> Astropy
    FRW --> Numpy
    FRW --> Matplotlib
    FRW --> DustmapPy

    Map3d --> Astropy
    Map3d --> Numpy
    Map3d --> Matplotlib
    Map3d --> DustmapPy

    Iso --> Astropy
    Iso --> Numpy
    Iso --> Matplotlib
    Iso --> DustmapPy

    Planck --> Astropy
    Planck --> Numpy
    Planck --> Matplotlib
    Planck --> DustmapPy

    Sersic --> Astropy
    Sersic --> Numpy
    Sersic --> Matplotlib
    Sersic --> DustmapPy

    %% Documentation references
    README --> SFD
    README --> LocalSFD
    DustZip --> LocalModule
    LocalModule --> LocalReadme

    %% Click Events
    click frame "https://github.com/ebupi/galaxies-and-cosmology/blob/master/./frame-g-003918-3-0213.fits"
    click ngp "https://github.com/ebupi/galaxies-and-cosmology/blob/master/./dustmap-master/SFD_dust_4096_ngp.fits"
    click sgp "https://github.com/ebupi/galaxies-and-cosmology/blob/master/./dustmap-master/SFD_dust_4096_sgp.fits"
    click SFD "https://github.com/ebupi/galaxies-and-cosmology/blob/master/./sfd.py"
    click LocalSFD "https://github.com/ebupi/galaxies-and-cosmology/blob/master/./dustmap-master/sfd.py"
    click Radius "https://github.com/ebupi/galaxies-and-cosmology/blob/master/./etkin-yaricap-galaxy.py"
    click FRW "https://github.com/ebupi/galaxies-and-cosmology/blob/master/./FRW.ipynb"
    click Map3d "https://github.com/ebupi/galaxies-and-cosmology/blob/master/./Galaxy-3d-map.ipynb"
    click Iso "https://github.com/ebupi/galaxies-and-cosmology/blob/master/./izofot.ipynb"
    click IsoSrc "https://github.com/ebupi/galaxies-and-cosmology/blob/master/./izofot-kaynak.ipynb"
    click Planck "https://github.com/ebupi/galaxies-and-cosmology/blob/master/./plancks-for-sed.ipynb"
    click Sersic "https://github.com/ebupi/galaxies-and-cosmology/blob/master/./sersic.ipynb"
    click README "https://github.com/ebupi/galaxies-and-cosmology/blob/master/./README.md"
    click DustZip "https://github.com/ebupi/galaxies-and-cosmology/blob/master/./dustmap-master.zip"
    click LocalModule "https://github.com/ebupi/galaxies-and-cosmology/tree/master/./dustmap-master/"
    click LocalReadme "https://github.com/ebupi/galaxies-and-cosmology/blob/master/./dustmap-master/README.md"

    %% Styles
    classDef data fill:#cce5ff,stroke:#004085,color:#004085,shape:database
    classDef script fill:#d4edda,stroke:#155724,color:#155724
    classDef notebook fill:#fff3cd,stroke:#856404,color:#856404,shape:rounded
    classDef external fill:#e2e3e5,stroke:#6c757d,color:#6c757d,shape:hexagon
    classDef doc fill:#f8d7da,stroke:#721c24,color:#721c24shape:folder
```
