From f663a0266ef634b9075fcb3b883905bb572c51f7 Mon Sep 17 00:00:00 2001 From: Matteo Baratto <75221958+teob97@users.noreply.github.com> Date: Thu, 8 Dec 2022 18:40:38 +0100 Subject: [PATCH] Change PRMaps.Setup behavior (#6) * Removed NSIDE from PRMaps.Setup * Update docs generation * Change Setup behavior, and fixed a bug in wheelfunc * Fixed docs * Update CHANGELOG * Update version --- .github/workflows/documentation.yml | 3 +- CHANGELOG.md | 3 ++ Project.toml | 2 +- script_python/signal_generator.py | 6 ++-- src/pointingMaps.jl | 54 +++++++++++++---------------- src/polarizationMaps.jl | 8 ++--- 6 files changed, 37 insertions(+), 39 deletions(-) diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index de7c27a..c995f38 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -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: diff --git a/CHANGELOG.md b/CHANGELOG.md index f3b3474..1f12da9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/Project.toml b/Project.toml index f80d82b..dcbe1ff 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "PRMaps" uuid = "fd40e84c-20b6-49bc-bda0-919ee04f3f0e" authors = ["Baratto Matteo "] -version = "0.1.0" +version = "0.2.0" [deps] Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" diff --git a/script_python/signal_generator.py b/script_python/signal_generator.py index 229dbac..0e538f7 100644 --- a/script_python/signal_generator.py +++ b/script_python/signal_generator.py @@ -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 diff --git a/src/pointingMaps.jl b/src/pointingMaps.jl index ea5c816..2a12c00 100644 --- a/src/pointingMaps.jl +++ b/src/pointingMaps.jl @@ -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) @@ -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]) @@ -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) @@ -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) @@ -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) @@ -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]) @@ -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) @@ -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]) @@ -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) diff --git a/src/polarizationMaps.jl b/src/polarizationMaps.jl index f7446c1..6b9cd7f 100644 --- a/src/polarizationMaps.jl +++ b/src/polarizationMaps.jl @@ -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) @@ -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) @@ -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) @@ -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)