Python astropy.units.arcmin() Examples
The following are 30
code examples of astropy.units.arcmin().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
astropy.units
, or try the search function
.
Example #1
Source File: test_regression.py From Carnets with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_regression_6347(): sc1 = SkyCoord([1, 2]*u.deg, [3, 4]*u.deg) sc2 = SkyCoord([1.1, 2.1]*u.deg, [3.1, 4.1]*u.deg) sc0 = sc1[:0] idx1_10, idx2_10, d2d_10, d3d_10 = sc1.search_around_sky(sc2, 10*u.arcmin) idx1_1, idx2_1, d2d_1, d3d_1 = sc1.search_around_sky(sc2, 1*u.arcmin) idx1_0, idx2_0, d2d_0, d3d_0 = sc0.search_around_sky(sc2, 10*u.arcmin) assert len(d2d_10) == 2 assert len(d2d_0) == 0 assert type(d2d_0) is type(d2d_10) assert len(d2d_1) == 0 assert type(d2d_1) is type(d2d_10)
Example #2
Source File: core.py From Carnets with BSD 3-Clause "New" or "Revised" License | 6 votes |
def kpc_proper_per_arcmin(self, z): """ Separation in transverse proper kpc corresponding to an arcminute at redshift ``z``. Parameters ---------- z : array_like Input redshifts. Must be 1D or scalar. Returns ------- d : `~astropy.units.Quantity` The distance in proper kpc corresponding to an arcmin at each input redshift. """ return (self.angular_diameter_distance(z).to(u.kpc) * arcmin_in_radians / u.arcmin)
Example #3
Source File: test_quantity_ufuncs.py From Carnets with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_radian(self, function): q1 = function(180. * u.degree, 0. * u.arcmin, 0. * u.arcsec) assert_allclose(q1.value, np.pi) assert q1.unit == u.radian q2 = function(0. * u.degree, 30. * u.arcmin, 0. * u.arcsec) assert_allclose(q2.value, (30. * u.arcmin).to(u.radian).value) assert q2.unit == u.radian q3 = function(0. * u.degree, 0. * u.arcmin, 30. * u.arcsec) assert_allclose(q3.value, (30. * u.arcsec).to(u.radian).value) # the following doesn't make much sense in terms of the name of the # routine, but we check it gives the correct result. q4 = function(3. * u.radian, 0. * u.arcmin, 0. * u.arcsec) assert_allclose(q4.value, 3.) assert q4.unit == u.radian with pytest.raises(TypeError): function(3. * u.m, 2. * u.s, 1. * u.kg)
Example #4
Source File: core.py From astropy-healpix with BSD 3-Clause "New" or "Revised" License | 6 votes |
def nside_to_pixel_resolution(nside): """ Find the resolution of HEALPix pixels given the pixel dimensions of one of the 12 'top-level' HEALPix tiles. Parameters ---------- nside : int The number of pixels on the side of one of the 12 'top-level' HEALPix tiles. Returns ------- resolution : :class:`~astropy.units.Quantity` The resolution of the HEALPix pixels See also -------- pixel_resolution_to_nside """ nside = np.asanyarray(nside, dtype=np.int64) _validate_nside(nside) return (nside_to_pixel_area(nside) ** 0.5).to(u.arcmin)
Example #5
Source File: test_core.py From astropy-healpix with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_pixel_resolution_to_nside(): # Check the different rounding options nside = pixel_resolution_to_nside(13 * u.arcmin, round='nearest') assert nside == 256 nside = pixel_resolution_to_nside(13 * u.arcmin, round='up') assert nside == 512 nside = pixel_resolution_to_nside(13 * u.arcmin, round='down') assert nside == 256 # Check that it works with arrays nside = pixel_resolution_to_nside([1e3, 10, 1e-3] * u.deg, round='nearest') assert_equal(nside, [1, 8, 65536]) with pytest.raises(ValueError) as exc: pixel_resolution_to_nside(13 * u.arcmin, round='peaches') assert exc.value.args[0] == "Invalid value for round: 'peaches'" with pytest.raises(AttributeError) as exc: pixel_resolution_to_nside(13) assert exc.value.args[0] == "'int' object has no attribute 'to'"
Example #6
Source File: test_utils.py From Carnets with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_select_step_hour(): assert_almost_equal_quantity(select_step_hour(127 * u.deg), 8. * u.hourangle) assert_almost_equal_quantity(select_step_hour(44 * u.deg), 3. * u.hourangle) assert_almost_equal_quantity(select_step_hour(18 * u.arcmin), 15 * u.arcmin) assert_almost_equal_quantity(select_step_hour(3.4 * u.arcmin), 3 * u.arcmin) assert_almost_equal_quantity(select_step_hour(2 * u.arcmin), 1.5 * u.arcmin) assert_almost_equal_quantity(select_step_hour(59 * u.arcsec), 1 * u.arcmin) assert_almost_equal_quantity(select_step_hour(33 * u.arcsec), 30 * u.arcsec) assert_almost_equal_quantity(select_step_hour(2.2 * u.arcsec), 3. * u.arcsec) assert_almost_equal_quantity(select_step_hour(0.8 * u.arcsec), 0.75 * u.arcsec) assert_almost_equal_quantity(select_step_hour(0.2 * u.arcsec), 0.15 * u.arcsec) assert_almost_equal_quantity(select_step_hour(0.11 * u.arcsec), 0.15 * u.arcsec) assert_almost_equal_quantity(select_step_hour(0.022 * u.arcsec), 0.03 * u.arcsec) assert_almost_equal_quantity(select_step_hour(0.0043 * u.arcsec), 0.003 * u.arcsec) assert_almost_equal_quantity(select_step_hour(0.00083 * u.arcsec), 0.00075 * u.arcsec) assert_almost_equal_quantity(select_step_hour(0.000027 * u.arcsec), 0.00003 * u.arcsec)
Example #7
Source File: test_utils.py From Carnets with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_select_step_degree(): assert_almost_equal_quantity(select_step_degree(127 * u.deg), 180. * u.deg) assert_almost_equal_quantity(select_step_degree(44 * u.deg), 45. * u.deg) assert_almost_equal_quantity(select_step_degree(18 * u.arcmin), 15 * u.arcmin) assert_almost_equal_quantity(select_step_degree(3.4 * u.arcmin), 3 * u.arcmin) assert_almost_equal_quantity(select_step_degree(2 * u.arcmin), 2 * u.arcmin) assert_almost_equal_quantity(select_step_degree(59 * u.arcsec), 1 * u.arcmin) assert_almost_equal_quantity(select_step_degree(33 * u.arcsec), 30 * u.arcsec) assert_almost_equal_quantity(select_step_degree(2.2 * u.arcsec), 2 * u.arcsec) assert_almost_equal_quantity(select_step_degree(0.8 * u.arcsec), 1 * u.arcsec) assert_almost_equal_quantity(select_step_degree(0.2 * u.arcsec), 0.2 * u.arcsec) assert_almost_equal_quantity(select_step_degree(0.11 * u.arcsec), 0.1 * u.arcsec) assert_almost_equal_quantity(select_step_degree(0.022 * u.arcsec), 0.02 * u.arcsec) assert_almost_equal_quantity(select_step_degree(0.0043 * u.arcsec), 0.005 * u.arcsec) assert_almost_equal_quantity(select_step_degree(0.00083 * u.arcsec), 0.001 * u.arcsec) assert_almost_equal_quantity(select_step_degree(0.000027 * u.arcsec), 0.00002 * u.arcsec)
Example #8
Source File: test_formatter_locator.py From Carnets with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_values_unit(self): # Make sure that the intrinsic unit and format unit are correctly # taken into account when using the locator fl = AngleFormatterLocator(unit=u.arcsec, format_unit=u.arcsec, decimal=True) assert_quantity_allclose(fl.locator(850, 2150)[0], [1000., 1200., 1400., 1600., 1800., 2000.] * u.arcsec) fl = AngleFormatterLocator(unit=u.arcsec, format_unit=u.degree, decimal=False) assert_quantity_allclose(fl.locator(850, 2150)[0], [15., 20., 25., 30., 35.] * u.arcmin) fl = AngleFormatterLocator(unit=u.arcsec, format_unit=u.hourangle, decimal=False) assert_quantity_allclose(fl.locator(850, 2150)[0], [60., 75., 90., 105., 120., 135.] * (15 * u.arcsec)) fl = AngleFormatterLocator(unit=u.arcsec) fl.format = 'dd:mm:ss' assert_quantity_allclose(fl.locator(0.9, 1.1)[0], [1] * u.arcsec) fl = AngleFormatterLocator(unit=u.arcsec, spacing=0.2 * u.arcsec) assert_quantity_allclose(fl.locator(0.3, 0.9)[0], [0.4, 0.6, 0.8] * u.arcsec)
Example #9
Source File: test_formatter_locator.py From Carnets with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_spacing(self): with pytest.raises(TypeError) as exc: AngleFormatterLocator(spacing=3.) assert exc.value.args[0] == "spacing should be an astropy.units.Quantity instance with units of angle" fl = AngleFormatterLocator(spacing=3. * u.degree) assert fl.values is None assert fl.number is None assert fl.spacing == 3. * u.degree values, spacing = fl.locator(34.3, 55.4) assert_almost_equal(values.to_value(u.degree), [36., 39., 42., 45., 48., 51., 54.]) fl.spacing = 30. * u.arcmin values, spacing = fl.locator(34.3, 36.1) assert_almost_equal(values.to_value(u.degree), [34.5, 35., 35.5, 36.]) with pytest.warns(UserWarning, match=r'Spacing is too small'): fl.format = 'dd' values, spacing = fl.locator(34.3, 36.1) assert_almost_equal(values.to_value(u.degree), [35., 36.])
Example #10
Source File: test_formatter_locator.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_incompatible_unit_decimal(self): with pytest.raises(UnitsError) as exc: AngleFormatterLocator(unit=u.arcmin, decimal=False) assert exc.value.args[0] == 'Units should be degrees or hours when using non-decimal (sexagesimal) mode'
Example #11
Source File: test_cosmology.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_units(): """ Test if the right units are being returned""" cosmo = core.FlatLambdaCDM(H0=70, Om0=0.27, Tcmb0=2.0) assert cosmo.comoving_distance(1.0).unit == u.Mpc assert cosmo._comoving_distance_z1z2(1.0, 2.0).unit == u.Mpc assert cosmo.comoving_transverse_distance(1.0).unit == u.Mpc assert cosmo._comoving_transverse_distance_z1z2(1.0, 2.0).unit == u.Mpc assert cosmo.angular_diameter_distance(1.0).unit == u.Mpc assert cosmo.angular_diameter_distance_z1z2(1.0, 2.0).unit == u.Mpc assert cosmo.luminosity_distance(1.0).unit == u.Mpc assert cosmo.lookback_time(1.0).unit == u.Gyr assert cosmo.lookback_distance(1.0).unit == u.Mpc assert cosmo.H0.unit == u.km / u.Mpc / u.s assert cosmo.H(1.0).unit == u.km / u.Mpc / u.s assert cosmo.Tcmb0.unit == u.K assert cosmo.Tcmb(1.0).unit == u.K assert cosmo.Tcmb([0.0, 1.0]).unit == u.K assert cosmo.Tnu0.unit == u.K assert cosmo.Tnu(1.0).unit == u.K assert cosmo.Tnu([0.0, 1.0]).unit == u.K assert cosmo.arcsec_per_kpc_comoving(1.0).unit == u.arcsec / u.kpc assert cosmo.arcsec_per_kpc_proper(1.0).unit == u.arcsec / u.kpc assert cosmo.kpc_comoving_per_arcmin(1.0).unit == u.kpc / u.arcmin assert cosmo.kpc_proper_per_arcmin(1.0).unit == u.kpc / u.arcmin assert cosmo.critical_density(1.0).unit == u.g / u.cm ** 3 assert cosmo.comoving_volume(1.0).unit == u.Mpc ** 3 assert cosmo.age(1.0).unit == u.Gyr assert cosmo.distmod(1.0).unit == u.mag
Example #12
Source File: test_cosmology.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_kpc_methods(): cosmo = core.FlatLambdaCDM(70.4, 0.272, Tcmb0=0.0) assert allclose(cosmo.arcsec_per_kpc_comoving(3), 0.0317179167 * u.arcsec / u.kpc) assert allclose(cosmo.arcsec_per_kpc_proper(3), 0.1268716668 * u.arcsec / u.kpc) assert allclose(cosmo.kpc_comoving_per_arcmin(3), 1891.6753126 * u.kpc / u.arcmin) assert allclose(cosmo.kpc_proper_per_arcmin(3), 472.918828 * u.kpc / u.arcmin)
Example #13
Source File: test_projections.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_Pix2Sky_unit(code): """Check astropy model eval against wcslib eval""" wcs_map = os.path.join(MAPS_DIR, f"1904-66_{code}.hdr") test_file = get_pkg_data_filename(wcs_map) header = fits.Header.fromfile(test_file, endcard=False, padding=False) params = [] for i in range(3): key = 'PV2_{}'.format(i + 1) if key in header: params.append(header[key]) w = wcs.WCS(header) w.wcs.crval = [0., 0.] w.wcs.crpix = [0, 0] w.wcs.cdelt = [1, 1] wcslibout = w.wcs.p2s([PIX_COORDINATES], 1) wcs_phi = wcslibout['phi'] wcs_theta = wcslibout['theta'] model = getattr(projections, 'Pix2Sky_' + code) tanprj = model(*params) phi, theta = tanprj(*PIX_COORDINATES * u.deg) assert_quantity_allclose(phi, wcs_phi * u.deg) assert_quantity_allclose(theta, wcs_theta * u.deg) phi, theta = tanprj(*(PIX_COORDINATES * u.deg).to(u.rad)) assert_quantity_allclose(phi, wcs_phi * u.deg) assert_quantity_allclose(theta, wcs_theta * u.deg) phi, theta = tanprj(*(PIX_COORDINATES * u.deg).to(u.arcmin)) assert_quantity_allclose(phi, wcs_phi * u.deg) assert_quantity_allclose(theta, wcs_theta * u.deg)
Example #14
Source File: utils.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def select_step_degree(dv): # Modified from axis_artist, supports astropy.units if dv > 1. * u.arcsec: degree_limits_ = [1.5, 3, 7, 13, 20, 40, 70, 120, 270, 520] degree_steps_ = [1, 2, 5, 10, 15, 30, 45, 90, 180, 360] degree_units = [u.degree] * len(degree_steps_) minsec_limits_ = [1.5, 2.5, 3.5, 8, 11, 18, 25, 45] minsec_steps_ = [1, 2, 3, 5, 10, 15, 20, 30] minute_limits_ = np.array(minsec_limits_) / 60. minute_units = [u.arcmin] * len(minute_limits_) second_limits_ = np.array(minsec_limits_) / 3600. second_units = [u.arcsec] * len(second_limits_) degree_limits = np.concatenate([second_limits_, minute_limits_, degree_limits_]) degree_steps = minsec_steps_ + minsec_steps_ + degree_steps_ degree_units = second_units + minute_units + degree_units n = degree_limits.searchsorted(dv.to(u.degree)) step = degree_steps[n] unit = degree_units[n] return step * unit else: return select_step_scalar(dv.to_value(u.arcsec)) * u.arcsec
Example #15
Source File: test_sky_coord_velocities.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_creation_attrs(): sc1 = SkyCoord(1*u.deg, 2*u.deg, pm_ra_cosdec=.2*u.mas/u.yr, pm_dec=.1*u.mas/u.yr, frame='fk5') assert_quantity_allclose(sc1.ra, 1*u.deg) assert_quantity_allclose(sc1.dec, 2*u.deg) assert_quantity_allclose(sc1.pm_ra_cosdec, .2*u.arcsec/u.kyr) assert_quantity_allclose(sc1.pm_dec, .1*u.arcsec/u.kyr) sc2 = SkyCoord(1*u.deg, 2*u.deg, pm_ra=.2*u.mas/u.yr, pm_dec=.1*u.mas/u.yr, differential_type=SphericalDifferential) assert_quantity_allclose(sc2.ra, 1*u.deg) assert_quantity_allclose(sc2.dec, 2*u.deg) assert_quantity_allclose(sc2.pm_ra, .2*u.arcsec/u.kyr) assert_quantity_allclose(sc2.pm_dec, .1*u.arcsec/u.kyr) sc3 = SkyCoord('1:2:3 4:5:6', pm_ra_cosdec=.2*u.mas/u.yr, pm_dec=.1*u.mas/u.yr, unit=(u.hour, u.deg)) assert_quantity_allclose(sc3.ra, 1*u.hourangle + 2*u.arcmin*15 + 3*u.arcsec*15) assert_quantity_allclose(sc3.dec, 4*u.deg + 5*u.arcmin + 6*u.arcsec) # might as well check with sillier units? assert_quantity_allclose(sc3.pm_ra_cosdec, 1.2776637006616473e-07 * u.arcmin / u.fortnight) assert_quantity_allclose(sc3.pm_dec, 6.388318503308237e-08 * u.arcmin / u.fortnight)
Example #16
Source File: test_format.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_double_superscript(): """Regression test for #5870, #8699, #9218; avoid double superscripts.""" assert (u.deg).to_string("latex") == r'$\mathrm{{}^{\circ}}$' assert (u.deg**2).to_string("latex") == r'$\mathrm{deg^{2}}$' assert (u.arcmin).to_string("latex") == r'$\mathrm{{}^{\prime}}$' assert (u.arcmin**2).to_string("latex") == r'$\mathrm{arcmin^{2}}$' assert (u.arcsec).to_string("latex") == r'$\mathrm{{}^{\prime\prime}}$' assert (u.arcsec**2).to_string("latex") == r'$\mathrm{arcsec^{2}}$' assert (u.hourangle).to_string("latex") == r'$\mathrm{{}^{h}}$' assert (u.hourangle**2).to_string("latex") == r'$\mathrm{hourangle^{2}}$' assert (u.electron).to_string("latex") == r'$\mathrm{e^{-}}$' assert (u.electron**2).to_string("latex") == r'$\mathrm{electron^{2}}$'
Example #17
Source File: test_equivalencies.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_pixel_scale(): pix = 75*u.pix asec = 30*u.arcsec pixscale = 0.4*u.arcsec/u.pix pixscale2 = 2.5*u.pix/u.arcsec assert_quantity_allclose(pix.to(u.arcsec, u.pixel_scale(pixscale)), asec) assert_quantity_allclose(pix.to(u.arcmin, u.pixel_scale(pixscale)), asec) assert_quantity_allclose(pix.to(u.arcsec, u.pixel_scale(pixscale2)), asec) assert_quantity_allclose(pix.to(u.arcmin, u.pixel_scale(pixscale2)), asec) assert_quantity_allclose(asec.to(u.pix, u.pixel_scale(pixscale)), pix) assert_quantity_allclose(asec.to(u.pix, u.pixel_scale(pixscale2)), pix)
Example #18
Source File: test_equivalencies.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_plate_scale(): mm = 1.5*u.mm asec = 30*u.arcsec platescale = 20*u.arcsec/u.mm platescale2 = 0.05*u.mm/u.arcsec assert_quantity_allclose(mm.to(u.arcsec, u.plate_scale(platescale)), asec) assert_quantity_allclose(mm.to(u.arcmin, u.plate_scale(platescale)), asec) assert_quantity_allclose(mm.to(u.arcsec, u.plate_scale(platescale2)), asec) assert_quantity_allclose(mm.to(u.arcmin, u.plate_scale(platescale2)), asec) assert_quantity_allclose(asec.to(u.mm, u.plate_scale(platescale)), mm) assert_quantity_allclose(asec.to(u.mm, u.plate_scale(platescale2)), mm)
Example #19
Source File: test_sky_coord.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_spherical_offsets(): i00 = SkyCoord(0*u.arcmin, 0*u.arcmin, frame='icrs') i01 = SkyCoord(0*u.arcmin, 1*u.arcmin, frame='icrs') i10 = SkyCoord(1*u.arcmin, 0*u.arcmin, frame='icrs') i11 = SkyCoord(1*u.arcmin, 1*u.arcmin, frame='icrs') i22 = SkyCoord(2*u.arcmin, 2*u.arcmin, frame='icrs') dra, ddec = i00.spherical_offsets_to(i01) assert_allclose(dra, 0*u.arcmin) assert_allclose(ddec, 1*u.arcmin) dra, ddec = i00.spherical_offsets_to(i10) assert_allclose(dra, 1*u.arcmin) assert_allclose(ddec, 0*u.arcmin) dra, ddec = i10.spherical_offsets_to(i01) assert_allclose(dra, -1*u.arcmin) assert_allclose(ddec, 1*u.arcmin) dra, ddec = i11.spherical_offsets_to(i22) assert_allclose(ddec, 1*u.arcmin) assert 0*u.arcmin < dra < 1*u.arcmin fk5 = SkyCoord(0*u.arcmin, 0*u.arcmin, frame='fk5') with pytest.raises(ValueError): # different frames should fail i00.spherical_offsets_to(fk5) i1deg = ICRS(1*u.deg, 1*u.deg) dra, ddec = i00.spherical_offsets_to(i1deg) assert_allclose(dra, 1*u.deg) assert_allclose(ddec, 1*u.deg) # make sure an abbreviated array-based version of the above also works i00s = SkyCoord([0]*4*u.arcmin, [0]*4*u.arcmin, frame='icrs') i01s = SkyCoord([0]*4*u.arcmin, np.arange(4)*u.arcmin, frame='icrs') dra, ddec = i00s.spherical_offsets_to(i01s) assert_allclose(dra, 0*u.arcmin) assert_allclose(ddec, np.arange(4)*u.arcmin)
Example #20
Source File: test_BackgroundSources.py From EXOSIMS with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_dNbackground(self): """ Test to ensure that dN returned has correct length, units, and is >= 0. """ coords = self.TL.coords intDepths = np.random.uniform(15.0, 25.0, len(coords)) for mod in self.allmods: with RedirectStreams(stdout=self.dev_null): obj = mod() dN = obj.dNbackground(coords, intDepths) self.assertTrue(len(dN) == len(intDepths),'dNbackground returns different length than input for %s'%mod.__name__) self.assertTrue(dN.unit == 1/u.arcmin**2,'dNbackground does not return 1/arcmin**2 for %s'%mod.__name__) self.assertTrue(np.all(dN >= 0.0),'dNbackground returns negative values for %s'%mod.__name__)
Example #21
Source File: test_representation.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_no_unnecessary_copies(): s1 = UnitSphericalRepresentation(lon=[10., 30.] * u.deg, lat=[5., 6.] * u.arcmin) s2 = s1.represent_as(UnitSphericalRepresentation) assert s2 is s1 assert np.may_share_memory(s1.lon, s2.lon) assert np.may_share_memory(s1.lat, s2.lat) s3 = s1.represent_as(SphericalRepresentation) assert np.may_share_memory(s1.lon, s3.lon) assert np.may_share_memory(s1.lat, s3.lat) s4 = s1.represent_as(CartesianRepresentation) s5 = s4.represent_as(CylindricalRepresentation) assert np.may_share_memory(s5.z, s4.z)
Example #22
Source File: test_representation.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_unit_spherical_roundtrip(): s1 = UnitSphericalRepresentation(lon=[10., 30.] * u.deg, lat=[5., 6.] * u.arcmin) s2 = CartesianRepresentation.from_representation(s1) s3 = SphericalRepresentation.from_representation(s2) s4 = UnitSphericalRepresentation.from_representation(s3) assert_allclose_quantity(s1.lon, s4.lon) assert_allclose_quantity(s1.lat, s4.lat)
Example #23
Source File: test_representation.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_init_array_nocopy(self): phi = Angle([8, 9] * u.hourangle) theta = Angle([5, 6] * u.deg) r = Distance([1, 2] * u.kpc) s1 = PhysicsSphericalRepresentation(phi=phi, theta=theta, r=r, copy=False) phi[:] = [1, 2] * u.rad theta[:] = [3, 4] * u.arcmin r[:] = [8, 9] * u.Mpc assert_allclose_quantity(phi, s1.phi) assert_allclose_quantity(theta, s1.theta) assert_allclose_quantity(r, s1.r)
Example #24
Source File: test_representation.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_init_array_nocopy(self): lon = Longitude([8, 9] * u.hourangle) lat = Latitude([5, 6] * u.deg) s1 = UnitSphericalRepresentation(lon=lon, lat=lat, copy=False) lon[:] = [1, 2] * u.rad lat[:] = [3, 4] * u.arcmin assert_allclose_quantity(lon, s1.lon) assert_allclose_quantity(lat, s1.lat)
Example #25
Source File: test_representation.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_init_array_nocopy(self): lon = Longitude([8, 9] * u.hourangle) lat = Latitude([5, 6] * u.deg) distance = Distance([1, 2] * u.kpc) s1 = SphericalRepresentation(lon=lon, lat=lat, distance=distance, copy=False) lon[:] = [1, 2] * u.rad lat[:] = [3, 4] * u.arcmin distance[:] = [8, 9] * u.Mpc assert_allclose_quantity(lon, s1.lon) assert_allclose_quantity(lat, s1.lat) assert_allclose_quantity(distance, s1.distance)
Example #26
Source File: jparser.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def shorten(name): """ Produce a shortened version of the full object name using: the prefix (usually the survey name) and RA (hour, minute), DEC (deg, arcmin) parts. e.g.: '2MASS J06495091-0737408' --> '2MASS J0649-0737' Parameters ---------- name : str Full object name with J-coords embedded. Returns ------- shortName: str """ match = search(name) return ''.join(match.group(1, 3, 4, 7, 8, 9))
Example #27
Source File: jparser.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def to_ra_dec_angles(name): """get RA in hourangle and DEC in degrees by parsing name """ groups = search(name, True).groups() prefix, hms, dms = np.split(groups, [1, 6]) ra = (_sexagesimal(hms) / (1, 60, 60 * 60) * u.hourangle).sum() dec = (_sexagesimal(dms) * (u.deg, u.arcmin, u.arcsec)).sum() return ra, dec
Example #28
Source File: prep.py From grizli with MIT License | 5 votes |
def get_irsa_catalog(ra=165.86, dec=34.829694, tab=None, radius=3, catalog='allwise_p3as_psd', wise=False, twomass=False, ROW_LIMIT=500000, TIMEOUT=3600): """Query for objects in the `AllWISE <http://wise2.ipac.caltech.edu/docs/release/allwise/>`_ source catalog Parameters ---------- ra, dec : float Center of the query region, decimal degrees radius : float Radius of the query, in arcmin Returns ------- table : `~astropy.table.Table` Result of the query """ from astroquery.irsa import Irsa Irsa.ROW_LIMIT = ROW_LIMIT Irsa.TIMEOUT = TIMEOUT #all_wise = 'wise_allwise_p3as_psd' #all_wise = 'allwise_p3as_psd' if wise: catalog = 'allwise_p3as_psd' elif twomass: catalog = 'fp_psc' coo = coord.SkyCoord(ra*u.deg, dec*u.deg) table = Irsa.query_region(coo, catalog=catalog, spatial="Cone", radius=radius*u.arcmin, get_query_payload=False) return table
Example #29
Source File: prep.py From grizli with MIT License | 5 votes |
def get_sdss_catalog(ra=165.86, dec=34.829694, radius=3): """Query for objects in the SDSS photometric catalog Parameters ---------- ra, dec : float Center of the query region, decimal degrees radius : float Radius of the query, in arcmin Returns ------- table : `~astropy.table.Table` Result of the query """ from astroquery.sdss import SDSS coo = coord.SkyCoord(ra*u.deg, dec*u.deg) fields = ['ra', 'dec', 'raErr', 'decErr', 'petroMag_r', 'petroMagErr_r'] # print fields fields = None table = SDSS.query_region(coo, radius=radius*u.arcmin, spectro=False, photoobj_fields=fields) return table
Example #30
Source File: prep.py From grizli with MIT License | 5 votes |
def get_ukidss_catalog(ra=165., dec=34.8, radius=3, database='UKIDSSDR9PLUS', programme_id='LAS'): """Query for objects in the UKIDSS catalogs Parameters ---------- ra, dec : float Center of the query region, decimal degrees radius : float Radius of the query, in arcmin Returns ------- table : `~astropy.table.Table` Result of the query """ from astroquery.ukidss import Ukidss coo = coord.SkyCoord(ra*u.deg, dec*u.deg) table = Ukidss.query_region(coo, radius=radius*u.arcmin, database=database, programme_id=programme_id) return table