def structure(radius): structure = pd.read_table('../MODEL/gas/%s.txt' % radius, sep=" ") z = structure['z'].values #altitudes in AU. dz = (structure['z'][10] - structure['z'][11]) * au.to( 'cm' ).value # dz is constant along the vertical, so we only need to compute it at one height. return structure, dz
def __init__(self,model,dx,nphi=2**12,screen_res=2,\ wavelength=1.3e-3,dpc=8400,rpc=5800,r0 = 'sgra',\ r_outer=10000000,r_inner=12,alpha='kolmogorov',\ anisotropy=2.045,pa=78,match_screen_res=False,live_dangerously=False,think_positive=False): # set initial members self.logger = logging.getLogger(self.__class__.__name__) self.live_dangerously = live_dangerously self.think_positive = think_positive self.wavelength = wavelength * 1e-3 # observing wavelength in km self.dpc = float(dpc) # earth-source distance in pc self.rpc = float(rpc) # R: source-scatterer distance in pc self.d = self.dpc - self.rpc # D: earth-scatterer distance in pc self.m = self.d / self.rpc # magnification factor (D/R) if r0 == 'sgra': # major axis (EW) phase coherence length in km self.r0 = 3136.67 * (1.3e-6 / self.wavelength) else: try: self.r0 = float(r0) except: raise ValueError('Bad value for r0') self.anisotropy = anisotropy # anisotropy for screen = (EW / NS elongation) self.pa = pa # orientation of major axis, E of N (or CCW of +y) # Fresnel scale in km self.rf = sqrt(self.dpc * pc.to(units.km).value / (2 * pi / self.wavelength) * self.m / (1 + self.m)**2) # compute pixel scale for image if match_screen_res: self.ips = 1 self.screen_dx = screen_res * self.r0 else: self.screen_dx = screen_res * self.r0 # size of a screen pixel in km self.ips = int( ceil(1e-6 * dx * self.d * au.to(units.km).value / self.screen_dx)) # image pixel / screen pixel # image arrays self.dx = 1e6 * self.ips * (self.screen_dx / (au.to(units.km).value * self.d) ) # image pixel scale in uas self.nx = int(ceil(model.shape[-1] * dx / self.dx)) # number of image pixels self.model = model # source model self.model_dx = dx # source model resolution self.iss = np.array([], dtype=np.float64) # scattered image self.isrc = np.array( [], dtype=np.float64) # source image at same scale as scattered image # screen parameters if type(nphi) == int: self.nphi = (nphi, nphi) # size of screen array else: self.nphi = nphi self.nphi = np.asarray(self.nphi) self.r_inner = r_inner # inner turbulence scale in r0 self.r_outer = r_outer # outer turbulence scale in r0 #self.qmax = 1.*screen_res/r_inner # 1 / inner turbulence scale in pix #self.qmin = 1.*screen_res/r_outer # 1 / outer tubulence scale in pix if alpha == 'kolmogorov': self.alpha = 5. / 3 else: try: self.alpha = float(alpha) except: raise ValueError('Bad value for alpha') # use logger to report self.chatter() # includes sanity check self.setModel(self.model, self.model_dx, think_positive=self.think_positive)
radii = radii( ) # radii in list, used to loop on radii and define names of columns in (r,z) opacity tables. X = X() # species names in list, used to loop on species. gas_opacity_frame = pd.DataFrame() dust_opacity_frame = pd.DataFrame() #--------------------------- for radius in radii: dz = z = Q = 0 tau_m = tau_d = structure = dust_density = 0 #-----extract physical structures and dz----- structure = pd.read_table('../MODEL/gas/%s.txt' % radius, sep=" ") z = structure['z'].values #altitudes in AU. dz = (structure['z'][10] - structure['z'][11]) * au.to( 'cm' ).value # dz is constant along the vertical, so we only need to compute it at one arbitrary height. #-------------------------------------------- #-----extract dust densities----- dust_density = pd.read_table('../MODEL/%s/dust_density.in' % radius, sep=" ") #print(dust['size1']) #-------------------------------- #-----extract dust sizes----- size_table = pd.read_table('../MODEL/%s/sizes.in' % radius, sep=" ", index_col=0, names=['value']) #print(size.loc['size1'].value)
import pencil as pc import numpy as np import math from astropy.constants import au # datadir = '../data' unit_length = au.to('cm').value par = pc.read.param(datadir=datadir) # # According to the RADMC3D manual, the way the variable coordsystem works is # # If coordsystem<100 the coordinate system is cartesian. # If 100<=coordsystem<200 thecoordinate system is spherical (polar). # If 200<=coordsystem<300 the coordinate system is cylindrical. # xdim = unit_length print(par.coord_system) if (par.coord_system == 'cartesian'): coordsystem = 99 ydim = unit_length zdim = unit_length elif (par.coord_system == 'cylindric'): coordsystem = 200 ydim = 1. zdim = unit_length elif (par.coord_system == 'spherical'): coordsystem = 100 ydim = 1. zdim = 1. else: print("the world is flat and we never got here")
from datetime import datetime import numpy as np from numpy import radians from numpy.testing import TestCase, assert_almost_equal, run_module_suite from astropy import units from astropy.constants import au from poliastro import ephem AU = au.to(units.km).value class TestEphem(TestCase): def test_vallado55(self): dd = datetime(1994, 5, 20, 20) a, ecc, inc, omega, argp, nu = ephem.mean_elements(dd, ephem.JUPITER) assert_almost_equal(a / AU, 5.202895, decimal=3) assert_almost_equal(ecc, 0.048319, decimal=3) assert_almost_equal(inc, 0.022770, decimal=4) assert_almost_equal(omega, 1.753543, decimal=2) assert_almost_equal(argp, 4.803144, decimal=1) assert_almost_equal(nu, 3.590915, decimal=1) if __name__ == '__main__': run_module_suite()
import pencil as pc import numpy as np import math from astropy.constants import au # datadir = '../data' unit_length=au.to('cm').value par=pc.read_param(datadir=datadir) # # According to the RADMC3D manual, the way the variable coordsystem works is # # If coordsystem<100 the coordinate system is cartesian. # If 100<=coordsystem<200 thecoordinate system is spherical (polar). # If 200<=coordsystem<300 the coordinate system is cylindrical. # xdim=unit_length print par.coord_system if (par.coord_system == 'cartesian'): coordsystem = 99 ydim=unit_length zdim=unit_length elif (par.coord_system == 'cylindric'): coordsystem = 200 ydim=1. zdim=unit_length elif (par.coord_system == 'spherical'): coordsystem = 100 ydim=1. zdim=1. else: print "the world is flat and we never got here"
def __init__(self,model,dx,nphi=2**12,screen_res=2,\ wavelength=1.3e-3,dpc=8400,rpc=5800,r0 = 'sgra',\ r_outer=10000000,r_inner=12,alpha='kolmogorov',\ anisotropy=2.045,pa=78,match_screen_res=False,live_dangerously=False,think_positive=False): # set initial members self.logger = logging.getLogger(self.__class__.__name__) self.live_dangerously = live_dangerously self.think_positive = think_positive self.wavelength = wavelength*1e-3 # observing wavelength in km self.dpc = float(dpc) # earth-source distance in pc self.rpc = float(rpc) # R: source-scatterer distance in pc self.d = self.dpc - self.rpc # D: earth-scatterer distance in pc self.m = self.d/self.rpc # magnification factor (D/R) if r0 == 'sgra': # major axis (EW) phase coherence length in km self.r0 = 3136.67*(1.3e-6/self.wavelength) else: try: self.r0 = float(r0) except: raise ValueError('Bad value for r0') self.anisotropy = anisotropy # anisotropy for screen = (EW / NS elongation) self.pa = pa # orientation of major axis, E of N (or CCW of +y) # Fresnel scale in km self.rf = sqrt(self.dpc*pc.to(units.km).value / (2*pi / self.wavelength) * self.m / (1+self.m)**2) # compute pixel scale for image if match_screen_res: self.ips = 1 self.screen_dx = screen_res * self.r0 else: self.screen_dx = screen_res * self.r0 # size of a screen pixel in km self.ips = int(ceil(1e-6*dx*self.d*au.to(units.km).value/self.screen_dx)) # image pixel / screen pixel # image arrays self.dx = 1e6 * self.ips * (self.screen_dx / (au.to(units.km).value * self.d)) # image pixel scale in uas self.nx = int(ceil(model.shape[-1] * dx / self.dx)) # number of image pixels self.model = model # source model self.model_dx = dx # source model resolution self.iss = np.array([],dtype=np.float64) # scattered image self.isrc = np.array([],dtype=np.float64) # source image at same scale as scattered image # screen parameters if type(nphi) == int: self.nphi = (nphi,nphi) # size of screen array else: self.nphi = nphi self.nphi = np.asarray(self.nphi) self.r_inner = r_inner # inner turbulence scale in r0 self.r_outer = r_outer # outer turbulence scale in r0 #self.qmax = 1.*screen_res/r_inner # 1 / inner turbulence scale in pix #self.qmin = 1.*screen_res/r_outer # 1 / outer tubulence scale in pix if alpha == 'kolmogorov': self.alpha = 5./3 else: try: self.alpha = float(alpha) except: raise ValueError('Bad value for alpha') # use logger to report self.chatter() # includes sanity check self.setModel(self.model,self.model_dx,think_positive=self.think_positive)