Python astropy.units.second() Examples
The following are 30
code examples of astropy.units.second().
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_lightcurve.py From lightkurve with MIT License | 6 votes |
def test_KeplerLightCurveFile(path, mission): lc = KeplerLightCurveFile(path, flux_column="sap_flux", quality_bitmask=None) assert lc.obsmode == 'long cadence' assert len(lc.pos_corr1) == len(lc.pos_corr2) assert lc.mission.lower() == mission.lower() if lc.mission.lower() == 'kepler': assert lc.meta.get('campaign') is None assert lc.quarter == 8 elif lc.mission.lower() == 'k2': assert lc.campaign == 8 assert lc.meta.get('quarter') is None assert lc.time.format == 'bkjd' assert lc.time.scale == 'tdb' assert lc.flux.unit == u.electron / u.second # Does the data match what one would obtain using pyfits.open? hdu = pyfits.open(path) assert lc.label == hdu[0].header['OBJECT'] nanmask = ~np.isnan(hdu[1].data['TIME']) assert_array_equal(lc.time.value, hdu[1].data['TIME'][nanmask]) assert_array_equal(lc.flux.value, hdu[1].data['SAP_FLUX'][nanmask])
Example #2
Source File: test_quantity.py From Carnets with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_inverse_quantity(): """ Regression test from issue #679 """ q = u.Quantity(4., u.meter / u.second) qot = q / 2 toq = 2 / q npqot = q / np.array(2) assert npqot.value == 2.0 assert npqot.unit == (u.meter / u.second) assert qot.value == 2.0 assert qot.unit == (u.meter / u.second) assert toq.value == 0.5 assert toq.unit == (u.second / u.meter)
Example #3
Source File: test_quantity.py From Carnets with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_quantity_comparison(self): assert u.Quantity(1100, unit=u.meter) > u.Quantity(1, unit=u.kilometer) assert u.Quantity(900, unit=u.meter) < u.Quantity(1, unit=u.kilometer) with pytest.raises(u.UnitsError): assert u.Quantity(1100, unit=u.meter) > u.Quantity(1, unit=u.second) with pytest.raises(u.UnitsError): assert u.Quantity(1100, unit=u.meter) < u.Quantity(1, unit=u.second) assert u.Quantity(1100, unit=u.meter) >= u.Quantity(1, unit=u.kilometer) assert u.Quantity(1000, unit=u.meter) >= u.Quantity(1, unit=u.kilometer) assert u.Quantity(900, unit=u.meter) <= u.Quantity(1, unit=u.kilometer) assert u.Quantity(1000, unit=u.meter) <= u.Quantity(1, unit=u.kilometer) with pytest.raises(u.UnitsError): assert u.Quantity( 1100, unit=u.meter) >= u.Quantity(1, unit=u.second) with pytest.raises(u.UnitsError): assert u.Quantity(1100, unit=u.meter) <= u.Quantity(1, unit=u.second) assert u.Quantity(1200, unit=u.meter) != u.Quantity(1, unit=u.kilometer)
Example #4
Source File: test_quantity.py From Carnets with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_complicated_operation(self): """ Perform a more complicated test """ from astropy.units import imperial # Multiple units distance = u.Quantity(15., u.meter) time = u.Quantity(11., u.second) velocity = (distance / time).to(imperial.mile / u.hour) assert_array_almost_equal( velocity.value, 3.05037, decimal=5) G = u.Quantity(6.673E-11, u.m ** 3 / u.kg / u.s ** 2) new_q = ((1. / (4. * np.pi * G)).to(u.pc ** -3 / u.s ** -2 * u.kg)) # Area side1 = u.Quantity(11., u.centimeter) side2 = u.Quantity(7., u.centimeter) area = side1 * side2 assert_array_almost_equal(area.value, 77., decimal=15) assert area.unit == u.cm * u.cm
Example #5
Source File: test_quantity.py From Carnets with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_1(self): # create objects through operations with Unit objects: quantity = 11.42 * u.meter # returns a Quantity object assert isinstance(quantity, u.Quantity) quantity = u.meter * 11.42 # returns a Quantity object assert isinstance(quantity, u.Quantity) quantity = 11.42 / u.meter assert isinstance(quantity, u.Quantity) quantity = u.meter / 11.42 assert isinstance(quantity, u.Quantity) quantity = 11.42 * u.meter / u.second assert isinstance(quantity, u.Quantity) with pytest.raises(TypeError): quantity = 182.234 + u.meter with pytest.raises(TypeError): quantity = 182.234 - u.meter with pytest.raises(TypeError): quantity = 182.234 % u.meter
Example #6
Source File: test_lombscargle.py From Carnets with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_errors_on_unit_mismatch(method, data): t, y, dy = data t = t * u.second y = y * u.mag frequency = np.linspace(0.5, 1.5, 10) # this should fail because frequency and 1/t units do not match with pytest.raises(ValueError) as err: LombScargle(t, y, fit_mean=False).power(frequency, method=method) assert str(err.value).startswith('Units of frequency not equivalent') # this should fail because dy and y units do not match with pytest.raises(ValueError) as err: LombScargle(t, y, dy, fit_mean=False).power(frequency / t.unit) assert str(err.value).startswith('Units of dy not equivalent') # we don't test all normalizations here because they are tested above # only test method='auto' because unit handling does not depend on method
Example #7
Source File: test_quantity_interaction.py From Carnets with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_valid_quantity_operations1(self): """Check adding/substracting/comparing a time-valued quantity works with a TimeDelta. Addition/subtraction should give TimeDelta""" t0 = TimeDelta(106400., format='sec') q1 = 10.*u.second t1 = t0 + q1 assert isinstance(t1, TimeDelta) assert t1.value == t0.value+q1.to_value(u.second) q2 = 1.*u.day t2 = t0 - q2 assert isinstance(t2, TimeDelta) assert allclose_sec(t2.value, t0.value-q2.to_value(u.second)) # now comparisons assert t0 > q1 assert t0 < 1.*u.yr # and broadcasting q3 = np.arange(12.).reshape(4, 3) * u.hour t3 = t0 + q3 assert isinstance(t3, TimeDelta) assert t3.shape == q3.shape assert allclose_sec(t3.value, t0.value + q3.to_value(u.second))
Example #8
Source File: test_basic.py From Carnets with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_ymdhms_output(): t = Time({'year': 2015, 'month': 2, 'day': 3, 'hour': 12, 'minute': 13, 'second': 14.567}, scale='utc') # NOTE: actually comes back as np.void for some reason # NOTE: not necessarily a python int; might be an int32 assert t.ymdhms.year == 2015 # There are two stages of validation now - one on input into a format, so that # the format conversion code has tidy matched arrays to work with, and the # other when object construction does not go through a format object. Or at # least, the format object is constructed with "from_jd=True". In this case the # normal input validation does not happen but the new input validation does, # and can ensure that strange broadcasting anomalies can't happen. # This form of construction uses from_jd=True.
Example #9
Source File: test_basic.py From Carnets with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_now(): """ Tests creating a Time object with the `now` class method. """ now = datetime.datetime.utcnow() t = Time.now() assert t.format == 'datetime' assert t.scale == 'utc' dt = t.datetime - now # a datetime.timedelta object # this gives a .1 second margin between the `utcnow` call and the `Time` # initializer, which is really way more generous than necessary - typical # times are more like microseconds. But it seems safer in case some # platforms have slow clock calls or something. assert dt.total_seconds() < 0.1
Example #10
Source File: utils.py From radvel with MIT License | 6 votes |
def semi_major_axis(P, Mtotal): """Semi-major axis Kepler's third law Args: P (float): Orbital period [days] Mtotal (float): Mass [Msun] Returns: float or array: semi-major axis in AU """ # convert inputs to array so they work with units P = np.array(P) Mtotal = np.array(Mtotal) Mtotal = Mtotal*c.M_sun.value P = (P * u.d).to(u.second).value G = c.G.value a = ((P**2)*G*Mtotal/(4*(np.pi)**2))**(1/3.) a = a/c.au.value return a
Example #11
Source File: test_lightcurve.py From lightkurve with MIT License | 6 votes |
def test_TessLightCurveFile(quality_bitmask): lc = TessLightCurveFile.read(TESS_SIM, quality_bitmask=quality_bitmask, flux_column="sap_flux") hdu = pyfits.open(TESS_SIM) assert lc.mission == 'TESS' assert lc.label == hdu[0].header['OBJECT'] assert lc.time.format == 'btjd' assert lc.time.scale == 'tdb' assert lc.flux.unit == u.electron / u.second assert lc.sector == hdu[0].header['SECTOR'] assert lc.camera == hdu[0].header['CAMERA'] assert lc.ccd == hdu[0].header['CCD'] assert lc.ra == hdu[0].header['RA_OBJ'] assert lc.dec == hdu[0].header['DEC_OBJ'] assert_array_equal(lc.time[0:10].value, hdu[1].data['TIME'][0:10]) assert_array_equal(lc.flux[0:10].value, hdu[1].data['SAP_FLUX'][0:10]) # Regression test for https://github.com/KeplerGO/lightkurve/pull/236 assert np.isnan(lc.time.value).sum() == 0
Example #12
Source File: test_lightcurve.py From lightkurve with MIT License | 6 votes |
def test_flux_unit(): """Checks the use of lc.flux_unit and lc.flux_quantity.""" with warnings.catch_warnings(): # We deprecated `flux_unit` in v2.0 warnings.simplefilter("ignore", LightkurveDeprecationWarning) unit_obj = u.Unit("electron/second") # Can we set flux units using a Unit object? time, flux = range(3), np.ones(3) lc = LightCurve(time=time, flux=flux, flux_unit=unit_obj) assert lc.flux.unit == unit_obj # Can we set flux units using a string? lc = LightCurve(time=time, flux=flux, flux_unit="electron/second") assert lc.flux.unit == unit_obj # Can we pass a quantity to flux? lc = LightCurve(time=time, flux=flux*unit_obj) assert lc.flux.unit == unit_obj # Can we retrieve correct flux quantities? with warnings.catch_warnings(): # flux_quantity is deprecated warnings.simplefilter("ignore", LightkurveDeprecationWarning) assert lc.flux_quantity.unit ==unit_obj assert_array_equal(lc.flux_quantity.value, flux) # Is invalid user input validated? with pytest.raises(ValueError) as err: lc = LightCurve(time=time, flux=flux, flux_unit="blablabla") assert "not a valid unit" in err.value.args[0]
Example #13
Source File: test_tso.py From mirage with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_interpolate_lightcurve(): """Test that a lightcurve is correctly interpolated to have the correct number of entries """ samples_per_frame_time = 5 frame_time = 1. # Create simple lightcurve light_curve = {} light_curve['times'] = np.arange(0, 10) * u.second light_curve['fluxes'] = np.repeat(1., len(light_curve['times'])) * FLAMBDA_CGS_UNITS # Interpolate interp = tso.interpolate_lightcurve(light_curve, samples_per_frame_time, frame_time) assert len(interp['times'].value) == (10 - 1) * frame_time * (samples_per_frame_time - 1) assert np.all(interp['times'].value[0:5] == [0, 0.25, 0.5, 0.75, 1.0])
Example #14
Source File: obs_generator.py From mirage with BSD 3-Clause "New" or "Revised" License | 5 votes |
def get_cr_rate(self): """Get the base cosmic ray impact probability. The following values are based on JWST-STScI-001928, "A library of simulated cosmic ray events impacting JWST HgCdTe detectors by Massimo Robberto", Table 1, times the pixel area of 18 microns square = 3.24e-06 square cm. Values are in nucleon events per pixel per second. Corresponding values from the report are 4.8983 nucleons/cm^2/second, 1.7783 nucleons/cm^2/second, and 3046.83 nucleons/cm^2/second. The expected rates per full frame read (10.73677 seconds) over the whole set of 2048x2048 pixels are 715, 259, and 444609 events respectively. Note that the SUNMIN rate is lower than the SUNMAX rate. The MIN and MAX labels refer to the solar activity, and the galactic cosmic ray contribution at L2 is reduced at solar maximum compared to solar minimum. The FLARE case is for the largest solar flare event on record (see the Robberto report) and corresponds to conditions under which JWST would presumably not be operating. """ self.crrate = 0. # The previous values were per full frame read and there was a transcription issue in Volk's code. These # have been corrected. Values are cosmic ray "hit" rates per pixel per second. if "SUNMIN" in self.params["cosmicRay"]["library"]: self.crrate = 1.587e-05 if "SUNMAX" in self.params["cosmicRay"]["library"]: self.crrate = 5.762e-06 if "FLARES" in self.params["cosmicRay"]["library"]: self.crrate = 0.0098729 if self.crrate > 0.: print("Base cosmic ray probability per pixel per second: {}".format(self.crrate))
Example #15
Source File: test_quantity.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_quantity_mutability(): q = u.Quantity(9.8, u.meter / u.second / u.second) with pytest.raises(AttributeError): q.value = 3 with pytest.raises(AttributeError): q.unit = u.kg
Example #16
Source File: test_quantity.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_incompatible_units(self): """ When trying to add or subtract units that aren't compatible, throw an error """ q1 = u.Quantity(11.412, unit=u.meter) q2 = u.Quantity(21.52, unit=u.second) with pytest.raises(u.UnitsError): new_q = q1 + q2
Example #17
Source File: test_periodogram.py From lightkurve with MIT License | 5 votes |
def test_periodogram_normalization(): """Tests the normalization options""" lc = LightCurve(time=np.arange(1000), flux=np.random.normal(1, 0.1, 1000), flux_err=np.zeros(1000)+0.1, flux_unit='electron/second') # Test amplitude normalization and correct units pg = lc.to_periodogram(normalization='amplitude') assert pg.power.unit == u.electron / u.second pg = lc.normalize(unit='ppm').to_periodogram(normalization='amplitude') assert pg.power.unit == u.cds.ppm # Test PSD normalization and correct units pg = lc.to_periodogram(freq_unit=u.microhertz, normalization='psd') assert pg.power.unit == (u.electron/u.second)**2 / u.microhertz pg = lc.normalize(unit='ppm').to_periodogram(freq_unit=u.microhertz, normalization='psd') assert pg.power.unit == u.cds.ppm**2 / u.microhertz
Example #18
Source File: test_downsample.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_downsample(): down_1 = aggregate_downsample(ts, time_bin_size=1*u.second) u.isclose(down_1.time_bin_size, [1, 1, 1, 1]*u.second) assert_equal(down_1.time_bin_start.isot, Time(['2016-03-22T12:30:31.000', '2016-03-22T12:30:32.000', '2016-03-22T12:30:33.000', '2016-03-22T12:30:34.000'])) assert_equal(down_1["a"].data, np.array([1, 2, 3, 4])) down_2 = aggregate_downsample(ts, time_bin_size=2*u.second) u.isclose(down_2.time_bin_size, [2, 2]*u.second) assert_equal(down_2.time_bin_start.isot, Time(['2016-03-22T12:30:31.000', '2016-03-22T12:30:33.000'])) assert_equal(down_2["a"].data, np.array([1, 3])) down_3 = aggregate_downsample(ts, time_bin_size=3*u.second) u.isclose(down_3.time_bin_size, [3, 3]*u.second) assert_equal(down_3.time_bin_start.isot, Time(['2016-03-22T12:30:31.000', '2016-03-22T12:30:34.000'])) assert_equal(down_3["a"].data, np.array([2, 4])) down_4 = aggregate_downsample(ts, time_bin_size=4*u.second) u.isclose(down_4.time_bin_size, [4]*u.second) assert_equal(down_4.time_bin_start.isot, Time(['2016-03-22T12:30:31.000'])) assert_equal(down_4["a"].data, np.array([2])) down_units = aggregate_downsample(ts_units, time_bin_size=4*u.second) u.isclose(down_units.time_bin_size, [4]*u.second) assert_equal(down_units.time_bin_start.isot, Time(['2016-03-22T12:30:31.000'])) assert down_units["a"].unit.name == 'ct' assert_equal(down_units["a"].data, np.array([2.5]))
Example #19
Source File: test_binned.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_read(): timeseries = BinnedTimeSeries.read(CSV_FILE, time_bin_start_column='time_start', time_bin_end_column='time_end', format='csv') assert timeseries.colnames == ['time_bin_start', 'time_bin_size', 'bin_size', 'A', 'B', 'C', 'D', 'E', 'F'] assert len(timeseries) == 10 assert timeseries['B'].sum() == 1151.54 timeseries = BinnedTimeSeries.read(CSV_FILE, time_bin_start_column='time_start', time_bin_size_column='bin_size', time_bin_size_unit=u.second, format='csv') assert timeseries.colnames == ['time_bin_start', 'time_bin_size', 'time_end', 'A', 'B', 'C', 'D', 'E', 'F'] assert len(timeseries) == 10 assert timeseries['B'].sum() == 1151.54
Example #20
Source File: test_binned.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_read_size_missing(): with pytest.raises(ValueError) as exc: BinnedTimeSeries.read(CSV_FILE, time_bin_start_column='time_start', time_bin_size_column="missing", time_bin_size_unit=u.second, format='csv') assert exc.value.args[0] == "Bin size column 'missing' not found in the input data."
Example #21
Source File: test_binned.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_read_start_time_missing(): with pytest.raises(ValueError) as exc: BinnedTimeSeries.read(CSV_FILE, time_bin_start_column='abc', time_bin_size_column='bin_size', time_bin_size_unit=u.second, format='csv') assert exc.value.args[0] == "Bin start time column 'abc' not found in the input data."
Example #22
Source File: test_periodogram.py From lightkurve with MIT License | 5 votes |
def test_periodogram_units(): """Tests whether periodogram has correct units""" # Fake, noisy data lc = LightCurve(time=np.arange(1000), flux=np.random.normal(1, 0.1, 1000), flux_err=np.zeros(1000)+0.1, flux_unit='electron/second') p = lc.to_periodogram(normalization='amplitude') # Has units assert hasattr(p.frequency, 'unit') # Has the correct units assert p.frequency.unit == 1./u.day assert p.power.unit == u.electron / u.second assert p.period.unit == u.day assert p.frequency_at_max_power.unit == 1./u.day assert p.max_power.unit == u.electron / u.second
Example #23
Source File: test_quantity_interaction.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_delta_tdb_tt(self): t = Time('2010-01-01 00:00:00', format='iso', scale='tt', precision=6) t.delta_tdb_tt = 20. * u.second assert t.tdb.iso == '2010-01-01 00:00:20.000000' t.delta_tdb_tt = 30. / 60. * u.minute assert t.tdb.iso == '2010-01-01 00:00:30.000000' with pytest.raises(u.UnitsError): t.delta_tdb_tt = 0.4 * u.m # Also check that a TimeDelta works. t.delta_tdb_tt = TimeDelta(40., format='sec') assert t.tdb.iso == '2010-01-01 00:00:40.000000' t.delta_tdb_tt = TimeDelta(50./24./3600., format='jd') assert t.tdb.iso == '2010-01-01 00:00:50.000000'
Example #24
Source File: test_quantity_interaction.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_valid_quantity_operations2(self): """Check that TimeDelta is treated as a quantity where possible.""" t0 = TimeDelta(100000., format='sec') f = 1./t0 assert isinstance(f, u.Quantity) assert f.unit == 1./u.day g = 10.*u.m/u.second**2 v = t0 * g assert isinstance(v, u.Quantity) assert u.allclose(v, t0.sec * g.value * u.m / u.second) q = np.log10(t0/u.second) assert isinstance(q, u.Quantity) assert q.value == np.log10(t0.sec) s = 1.*u.m v = s/t0 assert isinstance(v, u.Quantity) assert u.allclose(v, 1. / t0.sec * u.m / u.s) t = 1.*u.s t2 = t0 * t assert isinstance(t2, u.Quantity) assert u.allclose(t2, t0.sec * u.s ** 2) t3 = [1] / t0 assert isinstance(t3, u.Quantity) assert u.allclose(t3, 1 / (t0.sec * u.s)) # broadcasting t1 = TimeDelta(np.arange(100000., 100012.).reshape(6, 2), format='sec') f = np.array([1., 2.]) * u.cycle * u.Hz phase = f * t1 assert isinstance(phase, u.Quantity) assert phase.shape == t1.shape assert u.allclose(phase, t1.sec * f.value * u.cycle) q = t0 * t1 assert isinstance(q, u.Quantity) assert np.all(q == t0.to(u.day) * t1.to(u.day)) q = t1 / t0 assert isinstance(q, u.Quantity) assert np.all(q == t1.to(u.day) / t0.to(u.day))
Example #25
Source File: test_quantity_interaction.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_valid_quantity_input(self): """Test that TimeDelta can take quantity input.""" q = 500.25*u.day dt1 = TimeDelta(q, format='jd') assert dt1.value == q.value dt2 = TimeDelta(q, format='sec') assert dt2.value == q.to_value(u.second) dt3 = TimeDelta(q) assert dt3.value == q.value
Example #26
Source File: test_quantity_interaction.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_valid_quantity_operations(self): """Check that adding a time-valued quantity to a Time gives a Time""" t0 = Time(100000., format='cxcsec') q1 = 10.*u.second t1 = t0 + q1 assert isinstance(t1, Time) assert t1.value == t0.value+q1.to_value(u.second) q2 = 1.*u.day t2 = t0 - q2 assert allclose_sec(t2.value, t0.value-q2.to_value(u.second)) # check broadcasting q3 = np.arange(15.).reshape(3, 5) * u.hour t3 = t0 - q3 assert t3.shape == q3.shape assert allclose_sec(t3.value, t0.value-q3.to_value(u.second))
Example #27
Source File: test_tso.py From mirage with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_check_lightcurve_time(): """Check that the lightcurve time is compared to the total exposure time correctly """ exposure_time = 1000. frame_time = 1. # Case where light curve is too short light_curve = {} light_curve['times'] = np.arange(0, 500) * u.second light_curve['fluxes'] = np.repeat(1., len(light_curve['times'])) * FLAMBDA_CGS_UNITS new_lc = tso.check_lightcurve_time(light_curve, exposure_time, frame_time) assert np.max(new_lc['times'].data) >= exposure_time # Case where lightcurve start time is < 0 light_curve = {} light_curve['times'] = np.arange(-10, 500) * u.second light_curve['fluxes'] = np.repeat(1., len(light_curve['times'])) * FLAMBDA_CGS_UNITS new_lc = tso.check_lightcurve_time(light_curve, exposure_time, frame_time) assert np.min(new_lc['times'].data) == 0. # Case where lightcurve start time is > 0 light_curve = {} light_curve['times'] = np.arange(30, 500) * u.second light_curve['fluxes'] = np.repeat(1., len(light_curve['times'])) * FLAMBDA_CGS_UNITS new_lc = tso.check_lightcurve_time(light_curve, exposure_time, frame_time) assert np.min(new_lc['times'].data) == 0.
Example #28
Source File: test_nduncertainty.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_assigning_uncertainty_with_bad_unit_to_parent_fails(NDClass, UncertClass): # Does assigning an uncertainty with a non-matching unit to an NDData # with a unit work? ndd = NDClass([1, 1], unit=u.adu) # Set the unit to something inconsistent with ndd's unit v = UncertClass([1, 1], unit=u.second) with pytest.raises(u.UnitConversionError): ndd.uncertainty = v
Example #29
Source File: transformations.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, func, fromsys, tosys, priority=1, register_graph=None, finite_difference_frameattr_name='obstime', finite_difference_dt=1*u.second, symmetric_finite_difference=True): super().__init__(func, fromsys, tosys, priority, register_graph) self.finite_difference_frameattr_name = finite_difference_frameattr_name self.finite_difference_dt = finite_difference_dt self.symmetric_finite_difference = symmetric_finite_difference
Example #30
Source File: core.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _set_delta_ut1_utc(self, val): del self.cache if hasattr(val, 'to'): # Matches Quantity but also TimeDelta. val = val.to(u.second).value val = self._match_shape(val) self._delta_ut1_utc = val # Note can't use @property because _get_delta_tdb_tt is explicitly # called with the optional jd1 and jd2 args.