Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mojave simulation #18

Merged
merged 5 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,30 @@
# radiosim
Simulation of radio skies to create astrophysical data sets.
This repository is part of the [`radionets-project`](https://github.com/radionets-project).

## Installation

This repository is built as a python package. We recommend creating a mamba environment to handle the dependencies of all packages.
You can create one by running the following command in this repository:
```
$ mamba env create -f environment.yml
```
You can start the environment with
```
$ mamba activate radiosim
```
after the installation.

## Usage

There are currently three supported simulation types:
1. `survey` full sky simulation
2. `jet` extended source
3. `mojave` MOJAVE like extended source

In the `radiosim` environment you can start the simulation with
```
$ radiosim path/to/rc/file.toml
```
You can find an exemplary file in `rc/default_simulation.toml`.
The simulations will be saved as `.h5` files.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ classifiers=[
dependencies = [
"astropy",
"click",
"scikit-image",
"h5py",
"matplotlib",
"numpy",
Expand Down
59 changes: 59 additions & 0 deletions radiosim/gauss.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import numpy as np
from numpy.typing import ArrayLike
from astropy.convolution import Gaussian2DKernel
from astropy.nddata.utils import Cutout2D
from scipy.stats import norm, skewnorm


def gauss(params: list, size: int):
Expand Down Expand Up @@ -82,3 +84,60 @@ def rotgauss(x, y):
return g

return rotgauss(*np.indices((size, size)))


def skewed_gauss(
size: int,
x: float,
y: float,
amp: float,
width: float,
length: float,
a: float,
) -> ArrayLike:
"""
Generate a skewed 2d normal distribution.

Parameters
----------
size: int
length of the square image
x: float
x coordinate of the center
y: float
y coordinate of the center
amp: float
maximal amplitude of the distribution
width: float
width of the distribution (perpendicular to the skewed function)
length: float
length of the distribution
a: float
skewness parameter

Returns
-------
skew_gauss: ArrayLike
two dimensional skewed gaussian distribution
"""

def skewfunc(x: float, **args) -> ArrayLike:
func = skewnorm.pdf(x, **args)
func /= func.max()
return func

vals = np.arange(size)
normal = norm.pdf(vals, loc=size / 2, scale=width).reshape(-1, 1)
normal /= normal.max()

skew = skewfunc(vals, a=a, loc=size / 2, scale=length)

skew_gauss = normal * skew
skew_gauss *= amp
skew_gauss[np.isclose(skew_gauss, 0)] = 0

skew_gauss = np.roll(
skew_gauss, (y - int(size / 2), x - int(size / 2)), axis=(0, 1)
)

return skew_gauss
Loading
Loading