Custom map simulations

In this tutorial we will build a simulation from scratch.

We start by defining a Band that will determine our array’s sensitivity to different spectra. We then generate an array by specifying a field of view, which will be populated by evenly-spaced beams of the given band.

[1]:
import maria
from maria.instrument import Band

f090 = Band(center=90, # in GHz
            width=20,
            sensitivity=3e-5,
            gain_error=5e-2) # in K sqrt(s)

f150 = Band(center=150,
            width=30,
            sensitivity=5e-5,
            knee=1e0,
            gain_error=1e-1)
[2]:
array = {"field_of_view": 0.5, "primary_size": 20, "bands": [f090, f150]}

instrument = maria.get_instrument(array=array)

instrument.plot()
../_images/tutorials_custom-map-simulations_3_0.png

As something to observe, we can download a map and construct a map. We also define a plan to do a daisy scan centered on the center of the map.

[3]:
from maria.io import fetch

map_filename = fetch("maps/big_cluster.fits")

input_map = maria.map.read_fits(filename=map_filename,
                                index=1,
                                width=1,
                                center=(150, 10),
                                units="Jy/pixel")

input_map.to(units="K_RJ").plot()
2024-10-17 04:21:23.833 INFO: downloaded data (4.2 MB) to /tmp/maria-data/maps/big_cluster.fits
../_images/tutorials_custom-map-simulations_5_1.png
[4]:
plan = maria.Plan(scan_pattern="daisy",
                  scan_options={"radius": 0.5, "speed": 0.1}, # in degrees
                  duration=600, # in seconds
                  sample_rate=50, # in Hz
                  scan_center=(150, 10),
                  frame="ra_dec")

plan.plot()
../_images/tutorials_custom-map-simulations_6_0.png
[5]:
sim = maria.Simulation(instrument,
                       plan=plan,
                       site="llano_de_chajnantor",
                       map=input_map,
                       atmosphere="2d",
                      )
2024-10-17 04:21:31.339 INFO: Initialized base in 6978 ms.
Building atmosphere: 100%|██████████| 6/6 [00:36<00:00,  6.07s/it]
2024-10-17 04:22:10.766 INFO: Initialized atmosphere in 39400 ms.
[6]:
tod = sim.run()
Generating turbulence: 100%|██████████| 6/6 [00:00<00:00, 191.39it/s]
Sampling turbulence: 100%|██████████| 6/6 [00:07<00:00,  1.31s/it]
Computing atmospheric emission (f150): 100%|██████████| 2/2 [00:02<00:00,  1.10s/it]
Computing atmospheric transmission (f150): 100%|██████████| 2/2 [00:02<00:00,  1.10s/it]
Sampling map (f150): 100%|██████████| 2/2 [00:29<00:00, 14.51s/it]
Generating noise: 100%|██████████| 2/2 [00:03<00:00,  1.80s/it]
[7]:
from maria.map.mappers import BinMapper

mapper = BinMapper(center=(150, 10),
                   frame="ra_dec",
                   width=1e0,
                   height=1e0,
                   resolution=5e-3,
                   tod_preprocessing={
                        "window": {"tukey": {"alpha": 0.1}},
                        "despline": {"knot_spacing": 5},
                    },
                    map_postprocessing={
                        "gaussian_filter": {"sigma": 1},
                        "median_filter": {"size": 1},
                    },
                  )

mapper.add_tods(tod)

output_map = mapper.run()
Running mapper (f090): 100%|██████████| 1/1 [00:19<00:00, 19.82s/it]
Running mapper (f150): 100%|██████████| 1/1 [00:19<00:00, 19.55s/it]
[8]:
ptod = tod.process(**{
                        "window": {"tukey": {"alpha": 0.1}},
                        "despline": {"knot_spacing": 10},
                    })
[9]:
ptod.plot()
../_images/tutorials_custom-map-simulations_11_0.png
[10]:
output_map.plot()
../_images/tutorials_custom-map-simulations_12_0.png
../_images/tutorials_custom-map-simulations_12_1.png
[ ]: