Ejemplo n.º 1
0
    def test_roundtrip(self):
        a = cp.logspace(-5, 10, 100)
        x = cp.logspace(-5, 10, 100)

        y = sc.gammainccinv(a, sc.gammaincc(a, x))

        assert_allclose(x, y, rtol=1e-14)
Ejemplo n.º 2
0
import cupy as cp
import numpy as np
import matplotlib.pyplot as plt
import time

start_time = time.time()

# atmosphere depth, numpy array from 0 to 10 with N_atm evenly log spaced samples
num_atm = 1
tau_atm = cp.logspace(1, 1, num_atm, base=10)

# The number of photons to simulate for each optical depth
num_photons = 10000

# An array to track the mu at escape.
escaped_mu = []

# Henyeye-Greenstein parameters to use.  Eventually these will need to be calculated from the grain size and dust composition.
g = [-1, -0.5, 0.001, 0.5, 1]

# Planck's constant, for momentum calculations when we care about wavelength.
h = 1

# The albedo of the cloud, defined as the probability of scattering.  A photon that does not scatter will absorb.
albedo = 1

# Flag for the boundary.  it can either 'absorb', 'reemit', or 'reflect'.
boundary = 'reemit'

# Define an initial state for each photon.  They are upward moving and start at (0,0,0).  Wavelength currently not used but
# included for future use, not currently used.
Ejemplo n.º 3
0
def make_sweep(freq, sr, duration):
    return cp.sin(
        cp.cumsum(2 * cp.pi * cp.logspace(cp.log2(2.0 / sr),
                                          cp.log2(float(freq) / sr),
                                          num=int(duration * sr),
                                          base=2.0)))
Ejemplo n.º 4
0
# imports
import cupy as cp
import matplotlib.pyplot as plt
import time

a = time.time()

# atmosphere depth, numpy array from 0 to 10 with N_atm evenly log spaced samples
N_atm = 1
tau_atm = cp.logspace(1, 1, N_atm, base=10)
# tau_atm = np.array([0.01,0.03,0.1,0.3,1,3,10])

# The number of photons to simulate for each optical depth
N_photons = 100

# # Set a counter for the number of photons absorbed.  Not used for momentum calculation.
# N_absorbed = cp.zeros(N_atm)

# Henyeye-Greenstein parameters
g = [-1, -0.5, 0.001, 0.5, 1]

# Keeping track of the angles photons escape at.
escape_mu = cp.array([])

g = [0.0001]

# Create an array of wavelengths.  Units in nm.
Wavelengths = cp.linspace(100, 500, 50)

# Pick a uniform grain size, units in micrometers.