Loading astrort/configure/test.yml +1 −1 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ mapper: smooth: 1 pixelsize: 0.02 center: pointing plot: false plot: true region: false output: /data01/homes/dipiano/astroRT/astrort/testing/tmp Loading astrort/simulator/base_mapper.py +8 −4 Original line number Diff line number Diff line Loading @@ -9,8 +9,7 @@ import argparse from time import time from os import makedirs from os.path import join from astrort.utils.wrap import load_yaml_conf, write_mapping_info, execute_mapper_no_visibility from astrort.utils.wrap import load_yaml_conf, write_mapping_info, execute_mapper_no_visibility, plot_map from astrort.utils.utils import get_all_seeds from astrort.configure.logging import set_logger, get_log_level, get_logfile from astrort.configure.slurmjobs import slurm_submission Loading @@ -34,9 +33,14 @@ def base_mapper(configuration_file, seeds=None): log.info(f"\n {'-'*15} \n| START MAPPER | \n {'-'*15} \n") for seed in seeds: clock_map = time() # check pointing option execute_mapper_no_visibility(configuration, log) # make map fitsmap = execute_mapper_no_visibility(configuration, log) log.info(f"Mapping (seed = {seed}) complete, took {time() - clock_map} s") # make plot if configuration['mapper']['plot']: clock_plot = time() plotmap = plot_map(fitsmap, log) log.info(f"Plotting (seed = {seed}) complete, took {time() - clock_plot} s") # timing simulation clock_map = time() - clock_map # save simulation data Loading astrort/testing/test_simulator/test_base_mapper.py +4 −1 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ # ***************************************************************************** import pytest import numpy as np from shutil import rmtree from os import listdir from os.path import isfile, join Loading @@ -15,7 +16,7 @@ from astrort.simulator.base_mapper import base_mapper from astrort.utils.wrap import load_yaml_conf @pytest.mark.test_conf_file @pytest.mark.parametrize('seeds', [None, list([1,2])]) @pytest.mark.parametrize('seeds', [None, list()]) def test_base_mapper(test_conf_file, seeds): # clean output Loading @@ -24,6 +25,8 @@ def test_base_mapper(test_conf_file, seeds): # run simulator base_simulator(test_conf_file) if type(seeds) == list: seeds = np.arange(conf['simulator']['samples']) base_mapper(test_conf_file, seeds) # check output Loading astrort/testing/test_utils/test_wrap.py +17 −4 Original line number Diff line number Diff line Loading @@ -107,11 +107,24 @@ def test_execute_mapper_no_visibility(test_conf_file): # clean output conf = load_yaml_conf(test_conf_file) rmtree(conf['mapper']['output'], ignore_errors=True) conf['simulator']['samples'] conf['simulator']['samples'] = 1 log = set_logger(logging.CRITICAL) # run simulator base_simulator(test_conf_file) execute_mapper_no_visibility(conf, log) mapfile = seeds_to_string_formatter_files(conf['simulator']['samples'], conf['simulator']['output'], conf['simulator']['name'], conf['simulator']['seed'], 'fits', suffix='map') assert isfile(mapfile) fitsmap = execute_mapper_no_visibility(conf, log) assert isfile(fitsmap) @pytest.mark.test_conf_file def test_plot_map(test_conf_file): # clean output conf = load_yaml_conf(test_conf_file) rmtree(conf['mapper']['output'], ignore_errors=True) conf['simulator']['samples'] = 1 log = set_logger(logging.CRITICAL) # run simulator base_simulator(test_conf_file) fitsmap = execute_mapper_no_visibility(conf, log) plotmap = plot_map(fitsmap, log) assert isfile(plotmap) No newline at end of file astrort/utils/plotting.py +4 −5 Original line number Diff line number Diff line Loading @@ -102,7 +102,6 @@ class Plotter(): return ra, dec def counts_map(self, file, trange=None, erange=None, roi=5, name='skymap.png', title=None, xlabel='right ascension (deg)', ylabel='declination (deg)', figsize=(10, 10), fontsize=20, cmap='CMRmap', pixelsize=0.02, sigma=1): self.__check_pointing() extent = self.get_extent(roi) # counts map data = self.get_phlist_data(file=file) Loading @@ -129,6 +128,7 @@ class Plotter(): ax.set_ylabel(ylabel, fontsize=fontsize) ax.set_title(title, fontsize=fontsize) # pointing if isinstance(self.pointing, dict): ax.plot([self.pointing['ra']], [self.pointing['dec']], 'k+', markersize=fontsize) ax.set_xlim((extent[0], extent[1])) ax.set_ylim((extent[2], extent[3])) Loading @@ -141,7 +141,6 @@ class Plotter(): return self def counts_map_with_wcs(self, file, trange=None, erange=None, roi=5, name='skymap.png', title=None, xlabel='right ascension (deg)', ylabel='declination (deg)', figsize=(10, 10), fontsize=20, cmap='CMRmap', pixelsize=0.02, sigma=1): self.__check_pointing() extent = self.get_extent(roi=roi) # counts map data = self.get_phlist_data(file=file) Loading Loading @@ -172,6 +171,7 @@ class Plotter(): ax.set_ylabel(ylabel, fontsize=fontsize) ax.set_title(title, fontsize=fontsize) # pointing if isinstance(self.pointing, dict): ax.plot([self.pointing['ra']], [self.pointing['dec']], 'k+', markersize=fontsize) ax.set_aspect('equal') #ax.invert_xaxis() Loading Loading @@ -214,7 +214,6 @@ class Plotter(): with fits.open(file) as h: try: w = WCS(h['SKYMAP'].header) print(h['SKYMAP'].header) data = h['SKYMAP'].data except KeyError as e: self.log.error(f'Missing "SKYMAP" extention, the input file may not be a compatible counts map. {e}') Loading Loading
astrort/configure/test.yml +1 −1 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ mapper: smooth: 1 pixelsize: 0.02 center: pointing plot: false plot: true region: false output: /data01/homes/dipiano/astroRT/astrort/testing/tmp Loading
astrort/simulator/base_mapper.py +8 −4 Original line number Diff line number Diff line Loading @@ -9,8 +9,7 @@ import argparse from time import time from os import makedirs from os.path import join from astrort.utils.wrap import load_yaml_conf, write_mapping_info, execute_mapper_no_visibility from astrort.utils.wrap import load_yaml_conf, write_mapping_info, execute_mapper_no_visibility, plot_map from astrort.utils.utils import get_all_seeds from astrort.configure.logging import set_logger, get_log_level, get_logfile from astrort.configure.slurmjobs import slurm_submission Loading @@ -34,9 +33,14 @@ def base_mapper(configuration_file, seeds=None): log.info(f"\n {'-'*15} \n| START MAPPER | \n {'-'*15} \n") for seed in seeds: clock_map = time() # check pointing option execute_mapper_no_visibility(configuration, log) # make map fitsmap = execute_mapper_no_visibility(configuration, log) log.info(f"Mapping (seed = {seed}) complete, took {time() - clock_map} s") # make plot if configuration['mapper']['plot']: clock_plot = time() plotmap = plot_map(fitsmap, log) log.info(f"Plotting (seed = {seed}) complete, took {time() - clock_plot} s") # timing simulation clock_map = time() - clock_map # save simulation data Loading
astrort/testing/test_simulator/test_base_mapper.py +4 −1 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ # ***************************************************************************** import pytest import numpy as np from shutil import rmtree from os import listdir from os.path import isfile, join Loading @@ -15,7 +16,7 @@ from astrort.simulator.base_mapper import base_mapper from astrort.utils.wrap import load_yaml_conf @pytest.mark.test_conf_file @pytest.mark.parametrize('seeds', [None, list([1,2])]) @pytest.mark.parametrize('seeds', [None, list()]) def test_base_mapper(test_conf_file, seeds): # clean output Loading @@ -24,6 +25,8 @@ def test_base_mapper(test_conf_file, seeds): # run simulator base_simulator(test_conf_file) if type(seeds) == list: seeds = np.arange(conf['simulator']['samples']) base_mapper(test_conf_file, seeds) # check output Loading
astrort/testing/test_utils/test_wrap.py +17 −4 Original line number Diff line number Diff line Loading @@ -107,11 +107,24 @@ def test_execute_mapper_no_visibility(test_conf_file): # clean output conf = load_yaml_conf(test_conf_file) rmtree(conf['mapper']['output'], ignore_errors=True) conf['simulator']['samples'] conf['simulator']['samples'] = 1 log = set_logger(logging.CRITICAL) # run simulator base_simulator(test_conf_file) execute_mapper_no_visibility(conf, log) mapfile = seeds_to_string_formatter_files(conf['simulator']['samples'], conf['simulator']['output'], conf['simulator']['name'], conf['simulator']['seed'], 'fits', suffix='map') assert isfile(mapfile) fitsmap = execute_mapper_no_visibility(conf, log) assert isfile(fitsmap) @pytest.mark.test_conf_file def test_plot_map(test_conf_file): # clean output conf = load_yaml_conf(test_conf_file) rmtree(conf['mapper']['output'], ignore_errors=True) conf['simulator']['samples'] = 1 log = set_logger(logging.CRITICAL) # run simulator base_simulator(test_conf_file) fitsmap = execute_mapper_no_visibility(conf, log) plotmap = plot_map(fitsmap, log) assert isfile(plotmap) No newline at end of file
astrort/utils/plotting.py +4 −5 Original line number Diff line number Diff line Loading @@ -102,7 +102,6 @@ class Plotter(): return ra, dec def counts_map(self, file, trange=None, erange=None, roi=5, name='skymap.png', title=None, xlabel='right ascension (deg)', ylabel='declination (deg)', figsize=(10, 10), fontsize=20, cmap='CMRmap', pixelsize=0.02, sigma=1): self.__check_pointing() extent = self.get_extent(roi) # counts map data = self.get_phlist_data(file=file) Loading @@ -129,6 +128,7 @@ class Plotter(): ax.set_ylabel(ylabel, fontsize=fontsize) ax.set_title(title, fontsize=fontsize) # pointing if isinstance(self.pointing, dict): ax.plot([self.pointing['ra']], [self.pointing['dec']], 'k+', markersize=fontsize) ax.set_xlim((extent[0], extent[1])) ax.set_ylim((extent[2], extent[3])) Loading @@ -141,7 +141,6 @@ class Plotter(): return self def counts_map_with_wcs(self, file, trange=None, erange=None, roi=5, name='skymap.png', title=None, xlabel='right ascension (deg)', ylabel='declination (deg)', figsize=(10, 10), fontsize=20, cmap='CMRmap', pixelsize=0.02, sigma=1): self.__check_pointing() extent = self.get_extent(roi=roi) # counts map data = self.get_phlist_data(file=file) Loading Loading @@ -172,6 +171,7 @@ class Plotter(): ax.set_ylabel(ylabel, fontsize=fontsize) ax.set_title(title, fontsize=fontsize) # pointing if isinstance(self.pointing, dict): ax.plot([self.pointing['ra']], [self.pointing['dec']], 'k+', markersize=fontsize) ax.set_aspect('equal') #ax.invert_xaxis() Loading Loading @@ -214,7 +214,6 @@ class Plotter(): with fits.open(file) as h: try: w = WCS(h['SKYMAP'].header) print(h['SKYMAP'].header) data = h['SKYMAP'].data except KeyError as e: self.log.error(f'Missing "SKYMAP" extention, the input file may not be a compatible counts map. {e}') Loading