Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matteobachetti committed Sep 8, 2023
1 parent e4c7a1b commit e7746b2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
12 changes: 10 additions & 2 deletions srttools/simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,7 @@ def simulate_map(
nbin=1,
debug=False,
start_time=0,
radec_labels_in_srcname=False,
):
"""Simulate a map.
Expand Down Expand Up @@ -757,6 +758,8 @@ def simulate_map(
put RA and DEC scans in the two directories.
channel_ratio : float
Ratio between the counts in the two channels
radec_labels_in_srcname : bool
If True, add RA and Dec labels to source name
"""

if isinstance(outdir, str):
Expand Down Expand Up @@ -787,6 +790,11 @@ def simulate_map(
if HAS_MPL and debug:
fig = plt.figure()

ralabel = declabel = ""
if radec_labels_in_srcname:
ralabel = "_RA"
declabel = "_Dec"

delta_decs = np.arange(-width_dec / 2, width_dec / 2 + spacing, spacing) / 60
logging.info("Simulating dec scans...")
for i_d, delta_dec in enumerate(tqdm(delta_decs)):
Expand Down Expand Up @@ -815,7 +823,7 @@ def simulate_map(
other_keywords=other_keywords,
src_ra=mean_ra,
src_dec=mean_dec,
srcname=srcname,
srcname=srcname + ralabel,
counts_to_K=(COUNTS_TO_K, COUNTS_TO_K / channel_ratio),
)
if HAS_MPL and debug:
Expand Down Expand Up @@ -853,7 +861,7 @@ def simulate_map(
filename=os.path.join(outdir_dec, "Dec{}.fits".format(i_r)),
src_ra=mean_ra,
src_dec=mean_dec,
srcname=srcname,
srcname=srcname + declabel,
)

if HAS_MPL and debug:
Expand Down
5 changes: 5 additions & 0 deletions srttools/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ def sim_config_file(filename, add_garbage=False, prefix=None, label=""):
pixel_size : 0.8
ignore_suffix :
_RA
_Dec
[debugging]
debug_file_format : png
Expand Down Expand Up @@ -199,6 +203,7 @@ def prepare_simulated_data(simdir):
srcname="Dummy",
channel_ratio=0.8,
baseline="flat",
radec_labels_in_srcname=True,
)

config_file = os.path.abspath(os.path.join(simdir, "test_config_sim_small.ini"))
Expand Down

0 comments on commit e7746b2

Please sign in to comment.