Skip to content

Commit

Permalink
Change PRMaps.Setup behavior (#6)
Browse files Browse the repository at this point in the history
* Removed NSIDE from PRMaps.Setup

* Update docs generation

* Change Setup behavior, and fixed a bug in wheelfunc

* Fixed docs

* Update CHANGELOG

* Update version
  • Loading branch information
teob97 authored Dec 8, 2022
1 parent f1e9add commit f663a02
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 39 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ name: Documentation
on:
push:
branches:
- master # update to match your development branch (master, main, dev, trunk, ...)
- master
tags: '*'
pull_request:

jobs:
build:
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# HEAD

# Version 0.2.0
- Changed PRMaps.Setup behavior [#6](https://github.com/teob97/PRMaps.jl/pull/6)

# Version 0.1.0
- Added `makePolDegreeMap`, `makePolAngMap` and `differenceAngMaps`.
- Added `makeErroredMap` and `makeIdealMap` to generate sky maps observed by a given telescope setup.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "PRMaps"
uuid = "fd40e84c-20b6-49bc-bda0-919ee04f3f0e"
authors = ["Baratto Matteo <[email protected]>"]
version = "0.1.0"
version = "0.2.0"

[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Expand Down
6 changes: 3 additions & 3 deletions script_python/signal_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import numpy as np
import matplotlib.pyplot as plt
# Create a map object specifing resolution and model
sky = pysm3.Sky(nside=512, preset_strings=["s1"])
sky = pysm3.Sky(nside=512, preset_strings=["s0"])
# Restituisce un vettore numpy (3,npixel) con i parametri di stokes [I,Q,U] espressi in microKelvin_RJ (Rayleigh-Jeans)
map_40GHz = sky.get_emission(40 * u.GHz)
map_40GHz = map_40GHz.to(u.uK_CMB, equivalencies=u.cmb_equivalencies(40*u.GHz))
#map_40GHz = map_40GHz.to(u.uK_CMB, equivalencies=u.cmb_equivalencies(40*u.GHz))
# Convert from celestial coordinates to equatorial
map_40GHz_equat = pysm3.apply_smoothing_and_coord_transform(map_40GHz, rot=hp.Rotator(coord=("G", "C")))
# Save into .fits file
hp.fitsfunc.write_map("../input_maps/map_40GHz.fits", map_40GHz_equat, coord = "C", overwrite=True)
hp.fitsfunc.write_map("input_maps/map_40GHz.fits", map_40GHz_equat, coord = "C", overwrite=True)
# Visualize temperature map
# hp.mollview(map_40GHz_equat[0], min=0, max=1e2, title="I map", unit=map_40GHz_equat.unit)
# Polarization map
Expand Down
54 changes: 25 additions & 29 deletions src/pointingMaps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,15 @@ export add2pixel!

"""
Setup(
τ_s :: Float64,
times :: StepRangeLen,
NSIDE :: Int32
sampling_freq_Hz :: Float64,
total_time_s :: Float64
)
Struct containing some useful data.
Arguments:
- `τ_s` : sampling time (defined as 1 / sampling_frequency)
- `times` : time range (usually 0:τ_s:total_time)
- `NSIDE` : map resolution
"""
Base.@kwdef struct Setup
τ_s :: Float64 = 0.0
times :: StepRangeLen = 0:0:0
NSIDE :: Int32 = 0
sampling_freq_Hz :: Float64 = 0.0
total_time_s :: Float64 = 0.0
end

function add2pixel!(map, sky_value, pixel_idx, hits_map)
Expand All @@ -69,8 +61,9 @@ function fillMap!(
weightbuf = Array{Float64}(undef, 4)
dirs = Array{Float64}(undef, 1, 2)
psi = Array{Float64}(undef, 1)

for t in setup.times
times = 0 : 1.0/setup.sampling_freq_Hz : setup.total_time_s

for t in times

Sl.genpointings!(wheelfunction, cam_ang, t, dirs, psi)
pixel_index_ideal = ang2pix(signal, dirs[1], dirs[2])
Expand Down Expand Up @@ -98,8 +91,9 @@ function fillIdealMap!(
weightbuf = Array{Float64}(undef, 4)
dirs = Array{Float64}(undef, 1, 2)
psi = Array{Float64}(undef, 1)
times = 0 : 1.0/setup.sampling_freq_Hz : setup.total_time_s

for t in setup.times
for t in times

Sl.genpointings!(wheelfunction, cam_ang, t, dirs, psi)

Expand Down Expand Up @@ -137,9 +131,9 @@ function makeErroredMap(
setup :: Setup
)

map = HealpixMap{Float64, RingOrder}(setup.NSIDE)
hits = HealpixMap{Int32, RingOrder}(setup.NSIDE)
wheelfunction = x -> (0.0, deg2rad(20.0), Sl.timetorotang(x, setup.τ_s*60.))
map = HealpixMap{Float64, RingOrder}(signal.resolution.nside)
hits = HealpixMap{Int32, RingOrder}(signal.resolution.nside)
wheelfunction = x -> (0.0, deg2rad(20.0), Sl.timetorotang(x, 1.0))

fillMap!(wheelfunction, map, cam_ang, telescope_ang, signal, setup, hits)

Expand All @@ -166,9 +160,9 @@ function makeIdealMap(
setup :: Setup
)

map = HealpixMap{Float64, RingOrder}(setup.NSIDE)
hits = HealpixMap{Int32, RingOrder}(setup.NSIDE)
wheelfunction = x -> (0.0, deg2rad(20.0), Sl.timetorotang(x, setup.τ_s*60.))
map = HealpixMap{Float64, RingOrder}(signal.resolution.nside)
hits = HealpixMap{Int32, RingOrder}(signal.resolution.nside)
wheelfunction = x -> (0.0, deg2rad(20.0), Sl.timetorotang(x, 1.0))

fillIdealMap!(wheelfunction, map, cam_ang, signal, setup, hits)

Expand All @@ -194,8 +188,9 @@ function fill_IQU_ErroredMaps!(
weightbuf = Array{Float64}(undef, 4)
dirs = Array{Float64}(undef, 1, 2)
psi = Array{Float64}(undef, 1)
times = 0 : 1.0/setup.sampling_freq_Hz : setup.total_time_s

for t in setup.times
for t in times

Sl.genpointings!(wheelfunction, cam_ang, t, dirs, psi)
pixel_index_ideal = ang2pix(signal, dirs[1], dirs[2])
Expand Down Expand Up @@ -238,9 +233,9 @@ function makeErroredMapIQU(
signal :: PolarizedHealpixMap,
setup :: PRMaps.Setup
)
map = PolarizedHealpixMap{Float64, RingOrder}(setup.NSIDE)
hits = PolarizedHealpixMap{Int32, RingOrder}(setup.NSIDE)
wheelfunction = x -> (0.0, deg2rad(20.0), Sl.timetorotang(x, setup.τ_s*60.))
map = PolarizedHealpixMap{Float64, RingOrder}(signal.i.resolution.nside)
hits = PolarizedHealpixMap{Int32, RingOrder}(signal.i.resolution.nside)
wheelfunction = x -> (0.0, deg2rad(20.0), Sl.timetorotang(x, 1.0))

fill_IQU_ErroredMaps!(wheelfunction, map, cam_ang, tel_ang, signal, setup, hits)

Expand All @@ -264,8 +259,9 @@ function fill_IQU_IdealMaps!(
weightbuf = Array{Float64}(undef, 4)
dirs = Array{Float64}(undef, 1, 2)
psi = Array{Float64}(undef, 1)
times = 0 : 1.0/setup.sampling_freq_Hz : setup.total_time_s

for t in setup.times
for t in times

Sl.genpointings!(wheelfunction, cam_ang, t, dirs, psi)
pixel_index_ideal = ang2pix(signal, dirs[1], dirs[2])
Expand Down Expand Up @@ -301,9 +297,9 @@ function makeIdealMapIQU(
signal :: PolarizedHealpixMap,
setup :: PRMaps.Setup
)
map = PolarizedHealpixMap{Float64, RingOrder}(setup.NSIDE)
hits = PolarizedHealpixMap{Int32, RingOrder}(setup.NSIDE)
wheelfunction = x -> (0.0, deg2rad(20.0), Sl.timetorotang(x, setup.τ_s*60.))
map = PolarizedHealpixMap{Float64, RingOrder}(signal.i.resolution.nside)
hits = PolarizedHealpixMap{Int32, RingOrder}(signal.i.resolution.nside)
wheelfunction = x -> (0.0, deg2rad(20.0), Sl.timetorotang(x, 1.0))

fill_IQU_IdealMaps!(wheelfunction, map, cam_ang, signal, setup, hits)

Expand Down
8 changes: 4 additions & 4 deletions src/polarizationMaps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function makePolDegreeMap(
setup::Setup
)
signal_map, _ = makeErroredMapIQU(cam_ang, tel_ang, signal, setup)
p_map = HealpixMap{Float64, RingOrder}(setup.NSIDE)
p_map = HealpixMap{Float64, RingOrder}(signal.i.resolution.nside)

polDegreeMap!(p_map, signal_map.i, signal_map.q, signal_map.u)

Expand All @@ -85,7 +85,7 @@ function makePolDegreeMap(
setup::Setup
)
signal_map, _ = makeIdealMapIQU(cam_ang, signal, setup)
p_map = HealpixMap{Float64, RingOrder}(setup.NSIDE)
p_map = HealpixMap{Float64, RingOrder}(signal.i.resolution.nside)

polDegreeMap!(p_map, signal_map.i, signal_map.q, signal_map.u)

Expand Down Expand Up @@ -167,7 +167,7 @@ function makePolAngMap(
)

signal_map, _ = makeErroredMapIQU(cam_ang, tel_ang, signal, setup)
p_map = HealpixMap{Float64, RingOrder}(setup.NSIDE)
p_map = HealpixMap{Float64, RingOrder}(signal.i.resolution.nside)

polAngleMap!(p_map, signal_map.q, signal_map.u)

Expand All @@ -181,7 +181,7 @@ function makePolAngMap(
)

signal_map, _ = makeIdealMapIQU(cam_ang, signal, setup)
p_map = HealpixMap{Float64, RingOrder}(setup.NSIDE)
p_map = HealpixMap{Float64, RingOrder}(signal.i.resolution.nside)

polAngleMap!(p_map, signal_map.q, signal_map.u)

Expand Down

0 comments on commit f663a02

Please sign in to comment.