Skip to content

Commit

Permalink
Merge pull request #87 from kateharborne/dev-noise
Browse files Browse the repository at this point in the history
dev-noise
  • Loading branch information
kateharborne committed Jun 20, 2023
2 parents d3e0675 + 5651c1e commit 3bf98ef
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: SimSpin
Type: Package
Title: SimSpin - A package for the kinematic analysis of galaxy simulations
Version: 2.4.9
Version: 2.4.10
Author: Katherine Harborne
Co-author: Alice Serene
Maintainer: <katherine.harborne@icrar.org>
Expand Down
7 changes: 4 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SimSpin v2.4.8 News
# SimSpin v2.4.10 News

### Last edit: 13/06/23
### Last edit: 15/06/23

Below is a table containing a summary of all changes made to SimSpin, since the date this file was created on 26/08/2021.

Expand All @@ -16,7 +16,8 @@ All changes are noted in the changelog table below.

| Date | Summary of change | Version | Commit | Author |
|---------- |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |--------- |------------------------------------------ | ----------------- |
| 13/06/23 | Adding the thermal dispersion component to the observed gas maps. | 2.4.9 | | Kate Harborne |
| 15/06/23 | Updating the noise implementation for `build_datacube` using the median flux pixel to scale the level of noise such that the S/N does not go extreme towards the peak flux or minimum flux in the image. | 2.4.10 | | Kate Harborne |
| 13/06/23 | Adding the thermal dispersion component to the observed gas maps. | 2.4.9 | d3e0675a80a0036da3e372344e40bf979ad9ffa7 | Kate Harborne |
| 09/06/23 | Fixing the SFR maps produced in method = `gas` or `sf gas` mode. Previous values returned were mass-weighted mean SFR along the line-of-sight, now adjusted to give the sum of spawned fraction SFR along the LOS. | 2.4.8 | e1a6dd49d0aa74510c27aba5ccfeac8ab8a5e920 | Kate Harborne |
| 26/04/23 | Inverse variance cubes have large values that do not save to FITS successfully. Dividing by 1e40 to remove this issue and incorporating this with the units. Also modifying S/N description to give the MINIMUM S/N in the image, not the maximum. | 2.4.7 | fb904cd302cc6b8edda2032bb68fa8cd6b233f8a | Kate Harborne |
| 23/04/23 | Fixing the noise implementation in methods spectral and velocity. Adding inverse variance cubes to the output when a S/N value is specified. Incorporating tests to check proper incorporation and behaviour. | 2.4.6 | 8eef4e6dea8f9901b83ced8f2b43cee1438fe034 | Kate Harborne |
Expand Down
7 changes: 4 additions & 3 deletions R/build_datacube.R
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,9 @@ build_datacube = function(simspin_file, telescope, observing_strategy,
output$variance_cube = noise_cube # initialising empty arrays

noise_cube = .add_noise(output$spectral_cube,
sqrt(min(raw_images$flux_image[raw_images$flux_image > 0], na.rm=T))/
sqrt(median(raw_images$flux_image[raw_images$particle_image > 0], na.rm=T))/
(observation$signal_to_noise*sqrt(raw_images$flux_image)))

output$spectral_cube = output$spectral_cube + noise_cube
output$variance_cube = 1/(noise_cube)^2
output$variance_cube[is.infinite(output$variance_cube)] = 0
Expand Down Expand Up @@ -369,7 +370,7 @@ build_datacube = function(simspin_file, telescope, observing_strategy,
output$variance_cube = noise_cube # initialising empty arrays

noise_cube = .add_noise(output$velocity_cube,
sqrt(min(raw_images$flux_image[raw_images$flux_image > 0], na.rm=T))/
sqrt(median(raw_images$flux_image[raw_images$particle_image > 0], na.rm=T))/
(observation$signal_to_noise*sqrt(raw_images$flux_image)))
noise_image = output$observed_images$flux_image*(rowSums(noise_cube, dims=2)/rowSums(output$velocity_cube, dims=2))

Expand Down Expand Up @@ -476,7 +477,7 @@ build_datacube = function(simspin_file, telescope, observing_strategy,
output$variance_cube = noise_cube # initialising empty arrays

noise_cube = .add_noise(output$velocity_cube,
sqrt(min(raw_images$mass_image[raw_images$mass_image > 0], na.rm=T))/
sqrt(median(raw_images$mass_image[raw_images$particle_image > 0], na.rm=T))/
(observation$signal_to_noise*sqrt(raw_images$mass_image)))
noise_image = output$observed_images$flux_image*(rowSums(noise_cube, dims=2)/rowSums(output$velocity_cube, dims=2))

Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test_utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ test_that("interp_quick fails if given more than a scalar", {
})

test_that("kernel weights sum to 1", {
expect_true(sum(.generate_uniform_sphere(100, kernel = "WC2")$weight) == 1)
expect_true(sum(.generate_uniform_sphere(100, kernel = "WC6")$weight) == 1)
expect_true(sum(.generate_uniform_sphere(100, kernel = "M4")$weight) == 1)
expect_equal(sum(.generate_uniform_sphere(100, kernel = "WC2")$weight), 1)
expect_equal(sum(.generate_uniform_sphere(100, kernel = "WC6")$weight), 1)
expect_equal(sum(.generate_uniform_sphere(100, kernel = "M4")$weight), 1)
})

0 comments on commit 3bf98ef

Please sign in to comment.