Python numpy.log10() Examples
The following are 30 code examples for showing how to use numpy.log10(). These examples are extracted from open source projects. 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 check out the related API usage on the sidebar.
You may also want to check out all available functions/classes of the module
numpy
, or try the search function
.
Example 1
Project: BiblioPixelAnimations Author: ManiacalLabs File: system_eq.py License: MIT License | 6 votes |
def get_audio_data(self): frames = self.rec.get_frames() result = [0] * self.bins if len(frames) > 0: # keeps only the last frame current_frame = frames[-1] # plots the time signal # self.line_top.set_data(self.time_vect, current_frame) # computes and plots the fft signal fft_frame = np.fft.rfft(current_frame) if self.auto_gain: fft_frame /= np.abs(fft_frame).max() else: fft_frame *= (1 + self.gain) / 5000000. fft_frame = np.abs(fft_frame) if self.log_scale: fft_frame = np.log10(np.add(1, np.multiply(10, fft_frame))) result = [min(int(max(i, 0.) * 1023), 1023) for i in fft_frame][0:self.bins] return result
Example 2
Project: BiblioPixelAnimations Author: ManiacalLabs File: system_eq.py License: MIT License | 6 votes |
def get_audio_data(self): frames = self.rec.get_frames() result = [0] * self.bins if len(frames) > 0: # keeps only the last frame current_frame = frames[-1] # plots the time signal # self.line_top.set_data(self.time_vect, current_frame) # computes and plots the fft signal fft_frame = np.fft.rfft(current_frame) if self.auto_gain: fft_frame /= np.abs(fft_frame).max() else: fft_frame *= (1 + self.gain) / 5000000. fft_frame = np.abs(fft_frame) if self.log_scale: fft_frame = np.log10(np.add(1, np.multiply(10, fft_frame))) result = [min(int(max(i, 0.) * 1023), 1023) for i in fft_frame][0:self.bins] return result
Example 3
Project: dustmaps Author: gregreen File: test_bayestar.py License: GNU General Public License v2.0 | 6 votes |
def _interp_ebv(self, datum, dist): """ Calculate samples of E(B-V) at an arbitrary distance (in kpc) for one test coordinate. """ dm = 5. * (np.log10(dist) + 2.) idx_ceil = np.searchsorted(datum['DM_bin_edges'], dm) if idx_ceil == 0: dist_0 = 10.**(datum['DM_bin_edges'][0]/5. - 2.) return dist/dist_0 * datum['samples'][:,0] elif idx_ceil == len(datum['DM_bin_edges']): return datum['samples'][:,-1] else: dm_ceil = datum['DM_bin_edges'][idx_ceil] dm_floor = datum['DM_bin_edges'][idx_ceil-1] a = (dm_ceil - dm) / (dm_ceil - dm_floor) return ( (1.-a) * datum['samples'][:,idx_ceil] + a * datum['samples'][:,idx_ceil-1] )
Example 4
Project: padasip Author: matousc89 File: error_evaluation.py License: MIT License | 6 votes |
def logSE(x1, x2=-1): """ 10 * log10(e**2) This function accepts two series of data or directly one series with error. **Args:** * `x1` - first data series or error (1d array) **Kwargs:** * `x2` - second series (1d array) if first series was not error directly,\\ then this should be the second series **Returns:** * `e` - logSE of error (1d array) obtained directly from `x1`, \\ or as a difference of `x1` and `x2`. The values are in dB! """ e = get_valid_error(x1, x2) return 10*np.log10(e**2)
Example 5
Project: End-to-end-ASR-Pytorch Author: Alexander-H-Liu File: optim.py License: MIT License | 6 votes |
def speech_aug_scheduler(step, s_r, s_i, s_f, peak_lr): # Starting from 0, ramp-up to set LR and converge to 0.01*LR, w/ exp. decay final_lr_ratio = 0.01 exp_decay_lambda = -np.log10(final_lr_ratio)/(s_f-s_i) # Approx. w/ 10-based cur_step = step+1 if cur_step<s_r: # Ramp-up return peak_lr*float(cur_step)/s_r elif cur_step<s_i: # Hold return peak_lr elif cur_step<=s_f: # Decay return peak_lr*np.power(10,-exp_decay_lambda*(cur_step-s_i)) else: # Converge return peak_lr*final_lr_ratio
Example 6
Project: EXOSIMS Author: dsavransky File: test_PlanetPopulation.py License: BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_dist_sma(self): """ Test that smas outside of the range have zero probability """ for mod in self.allmods: if 'dist_sma' in mod.__dict__: with RedirectStreams(stdout=self.dev_null): pp = mod(**self.spec) a = np.logspace(np.log10(pp.arange[0].to('AU').value/10.),np.log10(pp.arange[1].to('AU').value*10.),100) fa = pp.dist_sma(a) self.assertTrue(np.all(fa[a < pp.arange[0].to('AU').value] == 0),'dist_sma high bound failed for %s'%mod.__name__) self.assertTrue(np.all(fa[a > pp.arange[1].to('AU').value] == 0),'dist_sma low bound failed for %s'%mod.__name__) self.assertTrue(np.all(fa[(a >= pp.arange[0].to('AU').value) & (a <= pp.arange[1].to('AU').value)] >= 0.),'dist_sma generates negative densities within range for %s'%mod.__name__)
Example 7
Project: EXOSIMS Author: dsavransky File: test_PlanetPopulation.py License: BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_dist_radius(self): """ Test that radii outside of the range have zero probability """ for mod in self.allmods: if 'dist_radius' in mod.__dict__: with RedirectStreams(stdout=self.dev_null): pp = mod(**self.spec) Rp = np.logspace(np.log10(pp.Rprange[0].to('earthRad').value/10.),np.log10(pp.Rprange[1].to('earthRad').value*100.),100) fr = pp.dist_radius(Rp) self.assertTrue(np.all(fr[Rp < pp.Rprange[0].to('earthRad').value] == 0),'dist_radius high bound failed for %s'%mod.__name__) self.assertTrue(np.all(fr[Rp > pp.Rprange[1].to('earthRad').value] == 0),'dist_radius high bound failed for %s'%mod.__name__) self.assertTrue(np.all(fr[(Rp >= pp.Rprange[0].to('earthRad').value) & (Rp <= pp.Rprange[1].to('earthRad').value)] > 0),'dist_radius generates zero probabilities within range for %s'%mod.__name__)
Example 8
Project: EXOSIMS Author: dsavransky File: test_PlanetPopulation.py License: BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_dist_mass(self): """ Test that masses outside of the range have zero probability """ for mod in self.allmods: if 'dist_mass' in mod.__dict__: with RedirectStreams(stdout=self.dev_null): pp = mod(**self.spec) Mp = np.logspace(np.log10(pp.Mprange[0].value/10.),np.log10(pp.Mprange[1].value*100.),100) fr = pp.dist_mass(Mp) self.assertTrue(np.all(fr[Mp < pp.Mprange[0].value] == 0),'dist_mass high bound failed for %s'%mod.__name__) self.assertTrue(np.all(fr[Mp > pp.Mprange[1].value] == 0),'dist_mass high bound failed for %s'%mod.__name__) self.assertTrue(np.all(fr[(Mp >= pp.Mprange[0].value) & (Mp <= pp.Mprange[1].value)] > 0))
Example 9
Project: EXOSIMS Author: dsavransky File: test_PlanetPopulation.py License: BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_dist_sma_radius(self): """ Test that sma and radius values outside of the range have zero probability """ for mod in self.allmods: if 'dist_sma_radius' in mod.__dict__: with RedirectStreams(stdout=self.dev_null): pp = mod(**self.spec) a = np.logspace(np.log10(pp.arange[0].value/10.),np.log10(pp.arange[1].value*100),100) Rp = np.logspace(np.log10(pp.Rprange[0].value/10.),np.log10(pp.Rprange[1].value*100),100) aa, RR = np.meshgrid(a,Rp) fr = pp.dist_sma_radius(aa,RR) self.assertTrue(np.all(fr[aa < pp.arange[0].value] == 0),'dist_sma_radius low bound failed on sma for %s'%mod.__name__) self.assertTrue(np.all(fr[aa > pp.arange[1].value] == 0),'dist_sma_radius high bound failed on sma for %s'%mod.__name__) self.assertTrue(np.all(fr[RR < pp.Rprange[0].value] == 0),'dist_sma_radius low bound failed on radius for %s'%mod.__name__) self.assertTrue(np.all(fr[RR > pp.Rprange[1].value] == 0),'dist_sma_radius high bound failed on radius for %s'%mod.__name__) self.assertTrue(np.all(fr[(aa > pp.arange[0].value) & (aa < pp.arange[1].value) & (RR > pp.Rprange[0].value) & (RR < pp.Rprange[1].value)] > 0),'dist_sma_radius is improper pdf for %s'%mod.__name__)
Example 10
Project: EXOSIMS Author: dsavransky File: GarrettCompleteness.py License: BSD 3-Clause "New" or "Revised" License | 6 votes |
def maxdmag(self, s): """Calculates the maximum value of dMag for projected separation Args: s (float): Projected separation (AU) Returns: maxdmag (float): Maximum planet delta magnitude """ if s == 0.0: maxdmag = self.cdmax - 2.5*np.log10(self.Phi(np.pi)) elif s < self.rmax: maxdmag = self.cdmax - 2.5*np.log10(np.abs(self.Phi(np.pi-np.arcsin(s/self.rmax)))) else: maxdmag = self.cdmax - 2.5*np.log10(self.Phi(np.pi/2.0)) return maxdmag
Example 11
Project: EXOSIMS Author: dsavransky File: Stark.py License: BSD 3-Clause "New" or "Revised" License | 6 votes |
def calclogf(self): """ # wavelength dependence, from Table 19 in Leinert et al 1998 # interpolated w/ a quadratic in log-log space Returns: interpolant (object): a 1D quadratic interpolant of intensity vs wavelength """ self.zodi_lam = np.array([0.2, 0.3, 0.4, 0.5, 0.7, 0.9, 1.0, 1.2, 2.2, 3.5, 4.8, 12, 25, 60, 100, 140]) # um self.zodi_Blam = np.array([2.5e-8, 5.3e-7, 2.2e-6, 2.6e-6, 2.0e-6, 1.3e-6, 1.2e-6, 8.1e-7, 1.7e-7, 5.2e-8, 1.2e-7, 7.5e-7, 3.2e-7, 1.8e-8, 3.2e-9, 6.9e-10]) # W/m2/sr/um x = np.log10(self.zodi_lam) y = np.log10(self.zodi_Blam) return interp1d(x, y, kind='quadratic')
Example 12
Project: EXOSIMS Author: dsavransky File: deltaMag.py License: BSD 3-Clause "New" or "Revised" License | 6 votes |
def deltaMag(p,Rp,d,Phi): """ Calculates delta magnitudes for a set of planets, based on their albedo, radius, and position with respect to host star. Args: p (ndarray): Planet albedo Rp (astropy Quantity array): Planet radius in units of km d (astropy Quantity array): Planet-star distance in units of AU Phi (ndarray): Planet phase function Returns: dMag (ndarray): Planet delta magnitudes """ dMag = -2.5*np.log10(p*(Rp/d).decompose()**2*Phi).value return dMag
Example 13
Project: kapre Author: keunwoochoi File: test_backend.py License: MIT License | 6 votes |
def test_amplitude_to_decibel(): """test for backend_keras.amplitude_to_decibel""" from kapre.backend_keras import amplitude_to_decibel x = np.array([[1e-20, 1e-5, 1e-3, 5e-2], [0.3, 1.0, 20.5, 9999]]) # random positive numbers amin = 1e-5 dynamic_range = 80.0 x_decibel = 10 * np.log10(np.maximum(x, amin)) x_decibel = x_decibel - np.max(x_decibel, axis=(1,), keepdims=True) x_decibel_ref = np.maximum(x_decibel, -1 * dynamic_range) x_var = K.variable(x) x_decibel_kapre = amplitude_to_decibel(x_var, amin, dynamic_range) assert np.allclose(K.eval(x_decibel_kapre), x_decibel_ref, atol=TOL)
Example 14
Project: Spoken-language-identification Author: YerevaNN File: create_spectrograms.py License: MIT License | 6 votes |
def plotstft(audiopath, binsize=2**10, plotpath=None, colormap="gray", channel=0, name='tmp.png', alpha=1, offset=0): samplerate, samples = wav.read(audiopath) samples = samples[:, channel] s = stft(samples, binsize) sshow, freq = logscale_spec(s, factor=1, sr=samplerate, alpha=alpha) sshow = sshow[2:, :] ims = 20.*np.log10(np.abs(sshow)/10e-6) # amplitude to decibel timebins, freqbins = np.shape(ims) ims = np.transpose(ims) # ims = ims[0:256, offset:offset+768] # 0-11khz, ~9s interval ims = ims[0:256, :] # 0-11khz, ~10s interval #print "ims.shape", ims.shape image = Image.fromarray(ims) image = image.convert('L') image.save(name)
Example 15
Project: PyRadarMet Author: nguy File: system.py License: GNU General Public License v2.0 | 6 votes |
def gain_Pratio(p1, p2): """ Antenna gain [dB] via power ratio. From Rinehart (1997), Eqn 2.1 Parameters ---------- p1 : float or array Power on the beam axis [W] p2 : float or array Power from an isotropic antenna [W] Notes ----- Ensure that both powers have the same units! If arrays are used, either for one okay, or both must be the same length. """ return 10. * np.log10(np.asarray(p1) / np.asarray(p2))
Example 16
Project: PyRadarMet Author: nguy File: variables.py License: GNU General Public License v2.0 | 6 votes |
def zdr(z_h, z_v): """ Differential reflectivity [dB]. From Rinehart (1997), Eqn 10.3 and Seliga and Bringi (1976) Parameters ---------- z_h : float or array Horizontal reflectivity [mm^6/m^3] z_v : float or array Vertical reflectivity [mm^6/m^3] Notes ----- Ensure that both powers have the same units! Alternating horizontally and linearly polarized pulses are averaged. Notes ----- If arrays are used, either for one okay, or both must be the same length. """ return 10. * np.log10(np.asarray(z_h) / np.asarray(z_v))
Example 17
Project: python-control Author: python-control File: freqresp_test.py License: BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_mimo(self): # MIMO B = np.matrix('1,0;0,1') D = np.matrix('0,0') sysMIMO = ss(self.A,B,self.C,D) frqMIMO = sysMIMO.freqresp(self.omega) tfMIMO = tf(sysMIMO) #bode(sysMIMO) # - should throw not implemented exception #bode(tfMIMO) # - should throw not implemented exception #plt.figure(3) #plt.semilogx(self.omega,20*np.log10(np.squeeze(frq[0]))) #plt.figure(4) #bode(sysMIMO,self.omega)
Example 18
Project: python-control Author: python-control File: ctrlutil.py License: BSD 3-Clause "New" or "Revised" License | 6 votes |
def db2mag(db): """Convert a gain in decibels (dB) to a magnitude If A is magnitude, db = 20 * log10(A) Parameters ---------- db : float or ndarray input value or array of values, given in decibels Returns ------- mag : float or ndarray corresponding magnitudes """ return 10. ** (db / 20.)
Example 19
Project: python-control Author: python-control File: ctrlutil.py License: BSD 3-Clause "New" or "Revised" License | 6 votes |
def mag2db(mag): """Convert a magnitude to decibels (dB) If A is magnitude, db = 20 * log10(A) Parameters ---------- mag : float or ndarray input magnitude or array of magnitudes Returns ------- db : float or ndarray corresponding values in decibels """ return 20. * np.log10(mag)
Example 20
Project: pyGSTi Author: pyGSTio File: testCore.py License: Apache License 2.0 | 6 votes |
def test_LGST_1overSqrtN_dependence(self): my_datagen_gateset = self.model.depolarize(op_noise=0.05, spam_noise=0) # !!don't depolarize spam or 1/sqrt(N) dependence saturates!! nSamplesList = np.array([ 16, 128, 1024, 8192 ]) diffs = [] for nSamples in nSamplesList: ds = pygsti.construction.generate_fake_data(my_datagen_gateset, self.lgstStrings, nSamples, sampleError='binomial', seed=100) mdl_lgst = pygsti.do_lgst(ds, self.fiducials, self.fiducials, self.model, svdTruncateTo=4, verbosity=0) mdl_lgst_go = pygsti.gaugeopt_to_target(mdl_lgst, my_datagen_gateset, {'spam':1.0, 'gate': 1.0}, checkJac=True) diffs.append( my_datagen_gateset.frobeniusdist(mdl_lgst_go) ) diffs = np.array(diffs, 'd') a, b = polyfit(np.log10(nSamplesList), np.log10(diffs), deg=1) #print "\n",nSamplesList; print diffs; print a #DEBUG self.assertLess( a+0.5, 0.05 )
Example 21
Project: Black-Box-Audio Author: rtaori File: run_audio_attack.py License: MIT License | 5 votes |
def db(audio): if len(audio.shape) > 1: maxx = np.max(np.abs(audio), axis=1) return 20 * np.log10(maxx) if np.any(maxx != 0) else np.array([0]) maxx = np.max(np.abs(audio)) return 20 * np.log10(maxx) if maxx != 0 else np.array([0])
Example 22
Project: RF-Monitor Author: EarToEarOak File: cli.py License: GNU General Public License v2.0 | 5 votes |
def __on_scan_data(self, event): levels = numpy.log10(event['l']) levels *= 10 noise = numpy.percentile(levels, self._dynP) for monitor in self._monitors: freq = monitor.get_frequency() if monitor.get_enabled(): monitor.set_noise(noise) index = numpy.where(freq == event['f'])[0] signal = monitor.set_level(levels[index][0], event['timestamp'], self._location) if signal is not None: signals = 'Signals: {}\r'.format(self.__count_signals() - self._signalCount) self.__std_out(signals, False) if signal.end is not None: recording = format_recording(freq, signal) if self._pushUri is not None: self._push.send(self._pushUri, recording) if self._server is not None: self._server.send(recording) if self._json: sys.stdout.write(recording + '\n')
Example 23
Project: RF-Monitor Author: EarToEarOak File: gui.py License: GNU General Public License v2.0 | 5 votes |
def __on_scan_data(self, event): levels = numpy.log10(event['l']) levels *= 10 self._levels = levels noise = numpy.percentile(levels, self._toolbar.get_dynamic_percentile()) updated = False for monitor in self._monitors: freq = monitor.get_frequency() if monitor.get_enabled(): monitor.set_noise(noise) index = numpy.where(freq == event['f'])[0] signal = monitor.set_level(levels[index][0], event['timestamp'], self._location) if signal is not None: updated = True if signal.end is not None: recording = format_recording(freq, signal) if self._settings.get_push_enable(): self._push.send(self._settings.get_push_uri(), recording) if self._server is not None: self._server.send(recording) if updated: if self._isSaved: self._isSaved = False self.__set_title() self.__set_timeline() self.__set_spectrum(noise) self._rssi.set_noise(numpy.mean(levels)) self._rssi.set_level(numpy.max(levels))
Example 24
Project: Griffin_lim Author: candlewill File: audio.py License: MIT License | 5 votes |
def _amp_to_db(x): return 20 * np.log10(np.maximum(1e-5, x))
Example 25
Project: models Author: kipoi File: dataloader.py License: MIT License | 5 votes |
def sign_log_func(x): return np.sign(x) * np.log10(np.abs(x) + 1)
Example 26
Project: OpenCV-Computer-Vision-Projects-with-Python Author: PacktPublishing File: saliency.py License: MIT License | 5 votes |
def calc_magnitude_spectrum(self): """Plots the magnitude spectrum This method calculates the magnitude spectrum of the image passed to the class constructor. :returns: magnitude spectrum """ # convert the frame to grayscale if necessary if len(self.frame_orig.shape) > 2: frame = cv2.cvtColor(self.frame_orig, cv2.COLOR_BGR2GRAY) else: frame = self.frame_orig # expand the image to an optimal size for FFT rows, cols = self.frame_orig.shape[:2] nrows = cv2.getOptimalDFTSize(rows) ncols = cv2.getOptimalDFTSize(cols) frame = cv2.copyMakeBorder(frame, 0, ncols-cols, 0, nrows-rows, cv2.BORDER_CONSTANT, value=0) # do FFT and get log-spectrum img_dft = np.fft.fft2(frame) spectrum = np.log10(np.abs(np.fft.fftshift(img_dft))) # return for plotting return 255*spectrum/np.max(spectrum)
Example 27
Project: contextualbandits Author: david-cortes File: utils.py License: BSD 2-Clause "Simplified" License | 5 votes |
def _gen_random_grad_norms(X, n_pos, n_neg, random_state): ### Note: there isn't any theoretical reason behind these chosen distributions and numbers. ### A custom function might do a lot better. magic_number = np.log10(X.shape[1]) smooth_prop = (n_pos + 1.0) / (n_pos + n_neg + 2.0) return np.c_[random_state.gamma(magic_number / smooth_prop, magic_number, size=X.shape[0]), random_state.gamma(magic_number * smooth_prop, magic_number, size=X.shape[0])]
Example 28
Project: EXOSIMS Author: dsavransky File: test_BrownvGarrett.py License: BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_target_completeness_def(self): """ Compare calculated completenesses for multiple targets under default population settings. """ with RedirectStreams(stdout=self.dev_null): TL = TargetList(ntargs=100,**copy.deepcopy(self.spec)) mode = list(filter(lambda mode: mode['detectionMode'] == True, TL.OpticalSystem.observingModes))[0] IWA = mode['IWA'] OWA = mode['OWA'] rrange = TL.PlanetPopulation.rrange maxd = (rrange[1]/np.tan(IWA)).to(u.pc).value mind = (rrange[0]/np.tan(OWA)).to(u.pc).value #want distances to span from outer edge below IWA to inner edge above OWA TL.dist = np.logspace(np.log10(mind/10.),np.log10(maxd*10.),TL.nStars)*u.pc Brown = EXOSIMS.Completeness.BrownCompleteness.BrownCompleteness(**copy.deepcopy(self.spec)) Garrett = EXOSIMS.Completeness.GarrettCompleteness.GarrettCompleteness(**copy.deepcopy(self.spec)) cBrown = Brown.target_completeness(TL) cGarrett = Garrett.target_completeness(TL) np.testing.assert_allclose(cGarrett,cBrown,rtol=0.1,atol=1e-6) # test when scaleOrbits == True TL.L = np.exp(np.random.uniform(low=np.log(0.1), high=np.log(10.), size=TL.nStars)) Brown.PlanetPopulation.scaleOrbits = True Garrett.PlanetPopulation.scaleOrbits = True cBrown = Brown.target_completeness(TL) cGarrett = Garrett.target_completeness(TL) cGarrett = cGarrett[cBrown != 0 ] cBrown = cBrown[cBrown != 0] meandiff = np.mean(np.abs(cGarrett - cBrown)/cBrown) self.assertLessEqual(meandiff,0.1)
Example 29
Project: EXOSIMS Author: dsavransky File: test_OpticalSystem.py License: BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_init_iwa_owa_contrast(self): r"""Test of initialization and __init__ -- IWA, OWA vs. contrast domain constraint. Method: We instantiate OpticalSystem objects and verify that IWA and OWA vary as expected with the domain of WA of the contrast lookup table (from 0 to 1). """ filename = os.path.join(resource_path(), 'OpticalSystem', 'i_quad100.fits') Cmin = 0.25 # the minimum of the above lookup table is 0.25 expected_dmaglim = -2.5 * np.log10(Cmin) # the input dict is modified in-place -- so copy it our_specs = deepcopy(specs_default) for (IWA,OWA) in zip([0.0,0.2,0.5,1.1],[1.0,1.4,1.6,2.0]): for syst in our_specs['starlightSuppressionSystems']: syst['core_contrast'] = filename syst['IWA'] = IWA syst['OWA'] = OWA if IWA <= 1.0: optsys = self.fixture(**deepcopy(our_specs)) # Check that the range constraint of the contrast lookup table # (it covers WA in 0 to 1) does constrain the system OWA and IWA. self.assertTrue(optsys.OWA.value == min(1.0, OWA), msg='contrast lookup table OWA') self.assertTrue(optsys.IWA.value == max(0.0, IWA), msg='contrast lookup table IWA') else: # IWA > 1 but lookup table covers [0,1] -- conflict with self.assertRaises(AssertionError): optsys = self.fixture(**deepcopy(our_specs))
Example 30
Project: EXOSIMS Author: dsavransky File: FakeCatalog.py License: BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, ntargs=1000, star_dist=5, **specs): StarCatalog.__init__(self,**specs) # ntargs must be an integer >= 1 self.ntargs = max(int(ntargs), 1) # list of astropy attributes self.coords = self.inverse_method(self.ntargs,star_dist) # ICRS coordinates self.ntargs = int(len(self.coords.ra)) self.dist = star_dist*np.ones(self.ntargs)*u.pc # distance self.parx = self.dist.to('mas', equivalencies=u.parallax()) # parallax self.pmra = np.zeros(self.ntargs)*u.mas/u.yr # proper motion in RA self.pmdec = np.zeros(self.ntargs)*u.mas/u.yr # proper motion in DEC self.rv = np.zeros(self.ntargs)*u.km/u.s # radial velocity # list of non-astropy attributes to pass target list filters self.Name = np.array([str(x) for x in range(self.ntargs)]) # star names self.Spec = np.array(['G']*self.ntargs) # spectral types self.Umag = np.zeros(self.ntargs) # U magnitude self.Bmag = np.zeros(self.ntargs) # B magnitude self.Vmag = 5*np.ones(self.ntargs) # V magnitude self.Rmag = np.zeros(self.ntargs) # R magnitude self.Imag = np.zeros(self.ntargs) # I magnitude self.Jmag = np.zeros(self.ntargs) # J magnitude self.Hmag = np.zeros(self.ntargs) # H magnitude self.Kmag = np.zeros(self.ntargs) # K magnitude self.BV = np.zeros(self.ntargs) # B-V Johnson magnitude self.MV = self.Vmag - 5*( np.log10(star_dist) - 1 ) # absolute V magnitude self.BC = -0.10*np.ones(self.ntargs) # bolometric correction BM = self.MV + self.BC L0 = 3.0128e28 BMsun = 4.74 self.L = L0*10**(0.4*(BMsun-BM)) # stellar luminosity in ln(SolLum) self.Binary_Cut = np.zeros(self.ntargs, dtype=bool) # binary closer than 10 arcsec # populate outspecs self._outspec['ntargs'] = self.ntargs