def test_set_spatial_model(tmppath): ra = 252.367 dec = 52.6356 src_dict = {'SpatialModel': 'RadialGaussian', 'ra': ra, 'dec': dec} src = Source('testsrc', src_dict) src.set_spatial_model('PointSource', {'ra': 1.0, 'dec': 2.0}) assert_allclose(src.spatial_pars['RA']['value'], 1.0) assert_allclose(src.spatial_pars['DEC']['value'], 2.0) assert_allclose(src['ra'], 1.0) assert_allclose(src['dec'], 2.0) assert src['SpatialModel'] == 'PointSource' assert src['SpatialType'] == 'SkyDirFunction' assert src['SourceType'] == 'PointSource' src_dict = {'SpatialModel': 'RadialGaussian', 'ra': ra, 'dec': dec} src = Source('testsrc', src_dict) src.set_spatial_model( 'PointSource', {'RA': {'value': 1.0}, 'DEC': {'value': 2.0}}) assert_allclose(src.spatial_pars['RA']['value'], 1.0) assert_allclose(src.spatial_pars['DEC']['value'], 2.0) assert_allclose(src['ra'], 1.0) assert_allclose(src['dec'], 2.0) src_dict = {'SpatialModel': 'RadialGaussian', 'RA': ra, 'DEC': dec} src = Source('testsrc', src_dict) src.set_spatial_model( 'PointSource', {'RA': {'value': 1.0}, 'DEC': {'value': 2.0}}) assert_allclose(src.spatial_pars['RA']['value'], 1.0) assert_allclose(src.spatial_pars['DEC']['value'], 2.0) assert_allclose(src['ra'], 1.0) assert_allclose(src['dec'], 2.0) src_dict = {'SpatialModel': 'RadialGaussian', 'RA': ra, 'DEC': dec} src = Source('testsrc', src_dict) src.set_spatial_model('RadialDisk', {'ra': 2.0, 'dec': 3.0, 'Radius': 1.0}) if src['SpatialType'] == 'RadialDisk': assert_allclose(src.spatial_pars['RA']['value'], 2.0) assert_allclose(src.spatial_pars['DEC']['value'], 3.0) assert_allclose(src.spatial_pars['Radius']['value'], 1.0) assert_allclose(src['ra'], 2.0) assert_allclose(src['dec'], 3.0) assert src['SpatialModel'] == 'RadialDisk' assert src['SourceType'] == 'DiffuseSource' src_dict = {'SpatialModel': 'RadialGaussian', 'RA': ra, 'DEC': dec} src = Source('testsrc', src_dict) src.set_spatial_model( 'RadialDisk', {'ra': 2.0, 'dec': 3.0, 'SpatialWidth': 2.0}) if src['SpatialType'] == 'RadialDisk': assert_allclose(src.spatial_pars['RA']['value'], 2.0) assert_allclose(src.spatial_pars['DEC']['value'], 3.0) assert_allclose(src['ra'], 2.0) assert_allclose(src['dec'], 3.0) assert_allclose(src['SpatialWidth'], 2.0) assert src['SpatialModel'] == 'RadialDisk' assert src['SourceType'] == 'DiffuseSource'
def test_set_spatial_model(tmppath): ra = 252.367 dec = 52.6356 src_dict = {'SpatialModel': 'GaussianSource', 'ra': ra, 'dec': dec} src = Source('testsrc', src_dict) src.set_spatial_model('PointSource') assert src['SpatialModel'] == 'PointSource' assert src['SpatialType'] == 'SkyDirFunction' assert src['SourceType'] == 'PointSource'