<s> from __future__ import print_function , division <EOL> import collections <EOL> from copy import deepcopy <EOL> import numpy as np <EOL> from astropy import log as logger <EOL> from . . densities import FlaredDisk , AlphaDisk , PowerLawEnvelope , UlrichEnvelope , AmbientMedium <EOL> from . . util . interpolate import interp1d_fast_loglog <EOL> from . . util . constants import pi , sigma , c , G <EOL> from . . sources import SphericalSource , SpotSource <EOL> from . . util . functions import FreezableClass , virtual_file <EOL> from . . grid import SphericalPolarGrid , CylindricalPolarGrid <EOL> from . import Model <EOL> def _min_none ( * args ) : <EOL> "<STR_LIT>" <EOL> return min ( x for x in args if x is not None ) <EOL> def _max_none ( * args ) : <EOL> "<STR_LIT>" <EOL> return max ( x for x in args if x is not None ) <EOL> class Star ( FreezableClass ) : <EOL> def __init__ ( self ) : <EOL> self . sources = { } <EOL> self . sources [ '<STR_LIT>' ] = SphericalSource ( name = '<STR_LIT>' ) <EOL> self . mass = None <EOL> self . radius = None <EOL> self . limb = False <EOL> self . _freeze ( ) <EOL> @ classmethod <EOL> def read ( self , filename ) : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> def add_spot ( self , * args , ** kwargs ) : <EOL> self . sources [ '<STR_LIT>' ] . add_spot ( SpotSource ( * args , ** kwargs ) ) <EOL> def __setattr__ ( self , attribute , value ) : <EOL> if self . isfinal ( ) : <EOL> raise Exception ( "<STR_LIT>" % attribute ) <EOL> if attribute in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> self . sources [ '<STR_LIT>' ] . __setattr__ ( attribute , value ) <EOL> return <EOL> elif attribute in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> for source in self . sources : <EOL> self . sources [ source ] . __setattr__ ( attribute , value ) <EOL> FreezableClass . __setattr__ ( self , attribute , value ) <EOL> def __getattr__ ( self , attribute ) : <EOL> if attribute in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> return getattr ( self . sources [ '<STR_LIT>' ] , attribute ) <EOL> else : <EOL> return FreezableClass . __getattr__ ( self , attribute ) <EOL> def total_luminosity ( self ) : <EOL> "<STR_LIT>" <EOL> ltot = <NUM_LIT:0.> <EOL> for source in self . sources : <EOL> if self . sources [ source ] . luminosity is not None : <EOL> ltot += self . sources [ source ] . luminosity <EOL> return ltot <EOL> def effective_temperature ( self ) : <EOL> "<STR_LIT>" <EOL> return ( self . total_luminosity ( ) / ( <NUM_LIT> * pi * self . radius ** <NUM_LIT> * sigma ) ) ** <NUM_LIT> <EOL> def total_spectrum ( self , bnu_range = None ) : <EOL> '''<STR_LIT>''' <EOL> nu_all , fnu_all = [ ] , [ ] <EOL> for source in self . sources : <EOL> if self . sources [ source ] . temperature is not None : <EOL> if bnu_range is None : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> nu , fnu = self . sources [ source ] . get_spectrum ( nu_range = bnu_range ) <EOL> else : <EOL> nu , fnu = self . sources [ source ] . get_spectrum ( ) <EOL> nu_all . append ( nu ) <EOL> fnu_all . append ( fnu ) <EOL> nu_min = np . min ( [ nu . min ( ) for nu in nu_all ] ) <EOL> nu_max = np . max ( [ nu . max ( ) for nu in nu_all ] ) <EOL> nu_common = np . unique ( np . sort ( np . hstack ( nu_all ) ) ) <EOL> nu_common = nu_common [ ( nu_common >= nu_min ) & ( nu_common <= nu_max ) ] <EOL> fnu_total = np . zeros ( nu_common . shape ) <EOL> for i in range ( len ( self . sources ) ) : <EOL> fnu_total += interp1d_fast_loglog ( nu_all [ i ] , fnu_all [ i ] , nu_common , bounds_error = False , fill_value = <NUM_LIT:0.> ) <EOL> return nu_common , fnu_total <EOL> class AnalyticalYSOModel ( Model ) : <EOL> def __init__ ( self , name = None ) : <EOL> "<STR_LIT>" <EOL> self . star = Star ( ) <EOL> self . disks = [ ] <EOL> self . envelopes = [ ] <EOL> self . ambients = [ ] <EOL> Model . __init__ ( self , name = name ) <EOL> def add_density_grid ( self , * args , ** kwargs ) : <EOL> raise NotImplementedError ( "<STR_LIT>" ) <EOL> def use_quantities ( self , * args , ** kwargs ) : <EOL> raise NotImplementedError ( "<STR_LIT>" ) <EOL> def use_geometry ( self , * args , ** kwargs ) : <EOL> raise NotImplementedError ( "<STR_LIT>" ) <EOL> def add_ambient_medium ( self , subtract = [ ] ) : <EOL> '''<STR_LIT>''' <EOL> ambient = AmbientMedium ( ) <EOL> ambient . star = self . star <EOL> ambient . subtract = subtract <EOL> self . ambients . append ( ambient ) <EOL> return ambient <EOL> def add_flared_disk ( self ) : <EOL> '''<STR_LIT>''' <EOL> disk = FlaredDisk ( ) <EOL> disk . star = self . star <EOL> self . disks . append ( disk ) <EOL> return disk <EOL> def add_alpha_disk ( self ) : <EOL> '''<STR_LIT>''' <EOL> disk = AlphaDisk ( ) <EOL> disk . star = self . star <EOL> self . disks . append ( disk ) <EOL> return disk <EOL> def add_settled_disks ( self , reference_disk , reference_size , eta = <NUM_LIT:0.> , <EOL> sizes = [ ] , dust_files = [ ] ) : <EOL> '''<STR_LIT>''' <EOL> exists = False <EOL> for disk in self . disks : <EOL> if disk is reference_disk : <EOL> logger . warn ( "<STR_LIT>" ) <EOL> exists = True <EOL> if not exists : <EOL> logger . warn ( "<STR_LIT>" ) <EOL> self . disks . append ( reference_disk ) <EOL> for i , size in enumerate ( sizes ) : <EOL> disk = deepcopy ( reference_disk ) <EOL> disk . star = self . star <EOL> disk . h_0 *= ( size / reference_size ) ** ( - eta ) <EOL> disk . dust = dust_files [ i ] <EOL> self . disks . append ( disk ) <EOL> def add_ulrich_envelope ( self ) : <EOL> '''<STR_LIT>''' <EOL> envelope = UlrichEnvelope ( ) <EOL> envelope . star = self . star <EOL> self . envelopes . append ( envelope ) <EOL> return envelope <EOL> def add_power_law_envelope ( self ) : <EOL> '''<STR_LIT>''' <EOL> envelope = PowerLawEnvelope ( ) <EOL> envelope . star = self . star <EOL> self . envelopes . append ( envelope ) <EOL> return envelope <EOL> def _check_all_set ( self ) : <EOL> for disk in self . disks : <EOL> disk . _check_all_set ( ) <EOL> for envelope in self . envelopes : <EOL> envelope . _check_all_set ( ) <EOL> for ambient in self . ambients : <EOL> ambient . _check_all_set ( ) <EOL> def print_midplane_tau ( self , wavelength ) : <EOL> for i , disk in enumerate ( self . disks ) : <EOL> if disk . mass > <NUM_LIT:0.> : <EOL> tau = ( disk . midplane_cumulative_density ( np . array ( [ disk . rmax ] ) ) <EOL> * disk . dust . interp_chi_wav ( wavelength ) ) <EOL> print ( "<STR_LIT>" % ( i + <NUM_LIT:1> , tau ) ) <EOL> def get_midplane_tau ( self , r ) : <EOL> self . _check_all_set ( ) <EOL> tau_midplane = np . zeros ( r . shape ) <EOL> for i , disk in enumerate ( self . disks ) : <EOL> if disk . mass > <NUM_LIT:0.> : <EOL> if disk . dust is None : <EOL> raise Exception ( "<STR_LIT>" % i ) <EOL> nu_min = disk . dust . optical_properties . nu [ <NUM_LIT:0> ] <EOL> nu_max = disk . dust . optical_properties . nu [ - <NUM_LIT:1> ] <EOL> nu , fnu = self . star . total_spectrum ( bnu_range = [ nu_min , nu_max ] ) <EOL> if np . any ( fnu > <NUM_LIT:0.> ) : <EOL> tau_midplane += ( disk . midplane_cumulative_density ( r ) <EOL> * disk . dust . chi_nu_spectrum ( nu , fnu ) ) <EOL> for i , envelope in enumerate ( self . envelopes ) : <EOL> if envelope . exists ( ) : <EOL> if envelope . dust is None : <EOL> raise Exception ( "<STR_LIT>" % i ) <EOL> nu_min = envelope . dust . optical_properties . nu [ <NUM_LIT:0> ] <EOL> nu_max = envelope . dust . optical_properties . nu [ - <NUM_LIT:1> ] <EOL> nu , fnu = self . star . total_spectrum ( bnu_range = [ nu_min , nu_max ] ) <EOL> if np . any ( fnu > <NUM_LIT:0.> ) : <EOL> tau_midplane += ( envelope . midplane_cumulative_density ( r ) <EOL> * envelope . dust . chi_nu_spectrum ( nu , fnu ) ) <EOL> return tau_midplane <EOL> def plot_midplane_tau ( self , filename ) : <EOL> import matplotlib . pyplot as plt <EOL> tau_midplane = self . get_midplane_tau ( self . grid . r_wall [ <NUM_LIT:1> : ] ) <EOL> fig = plt . figure ( ) <EOL> ax = fig . add_subplot ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> ax . loglog ( self . grid . r [ <NUM_LIT:1> : ] / self . grid . r [ <NUM_LIT:1> ] - <NUM_LIT:1.> , <EOL> tau_midplane [ <NUM_LIT:1> : ] - tau_midplane [ : - <NUM_LIT:1> ] , <EOL> drawstyle = '<STR_LIT>' ) <EOL> fig . savefig ( filename ) <EOL> def radial_range ( self ) : <EOL> if ( len ( self . disks ) == <NUM_LIT:0> and <EOL> len ( self . envelopes ) == <NUM_LIT:0> and <EOL> len ( self . ambients ) == <NUM_LIT:0> ) : <EOL> rmin = self . star . radius <EOL> else : <EOL> rmin_values = ( [ disk . rmin for disk in self . disks ] + <EOL> [ envelope . rmin for envelope in self . envelopes ] + <EOL> [ ambient . rmin for ambient in self . ambients ] ) <EOL> rmin = _min_none ( * rmin_values ) <EOL> rmax_values = [ self . star . radius ] <EOL> rmax_values += ( [ disk . rmax for disk in self . disks ] + <EOL> [ envelope . rmax for envelope in self . envelopes ] + <EOL> [ ambient . rmax for ambient in self . ambients ] ) <EOL> rmax = _max_none ( * rmax_values ) <EOL> if rmax >= rmin : <EOL> return rmin , rmax <EOL> else : <EOL> return self . star . radius , self . star . radius <EOL> def set_cylindrical_polar_grid_auto ( self , n_w , n_z , n_phi , <EOL> wmin = None , wmax = None , zmin = None , zmax = None , min_spacing = <NUM_LIT> ) : <EOL> '''<STR_LIT>''' <EOL> self . grid = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : n_w , '<STR_LIT>' : n_z , '<STR_LIT>' : n_phi , <EOL> '<STR_LIT>' : wmin , '<STR_LIT>' : wmax , '<STR_LIT>' : zmin , '<STR_LIT>' : zmax , '<STR_LIT>' : min_spacing } <EOL> def set_spherical_polar_grid_auto ( self , n_r , n_theta , n_phi , <EOL> rmax = None , min_spacing = <NUM_LIT> ) : <EOL> '''<STR_LIT>''' <EOL> self . grid = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : n_r , '<STR_LIT>' : n_theta , '<STR_LIT>' : n_phi , <EOL> '<STR_LIT>' : rmax , '<STR_LIT>' : min_spacing } <EOL> def _set_polar_grid_auto ( self , n1 = None , n2 = None , n3 = None , grid_type = None , <EOL> zmin = None , zmax = None , rmin = None , rmax = None , min_spacing = <NUM_LIT> ) : <EOL> if self . star . radius is None : <EOL> raise Exception ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> if grid_type is '<STR_LIT>' : <EOL> n_r , n_theta , n_phi = n1 , n2 , n3 <EOL> elif grid_type is '<STR_LIT>' : <EOL> n_r , n_z , n_phi = n1 , n2 , n3 <EOL> else : <EOL> raise Exception ( "<STR_LIT>" % grid_type ) <EOL> if rmin is None : <EOL> if len ( self . disks ) == <NUM_LIT:0> and len ( self . envelopes ) == <NUM_LIT:0> : <EOL> rmin = self . star . radius <EOL> else : <EOL> rmin_values = ( [ disk . rmin for disk in self . disks ] + <EOL> [ envelope . rmin for envelope in self . envelopes ] + <EOL> [ ambient . rmin for ambient in self . ambients ] ) <EOL> rmin = _min_none ( * rmin_values ) <EOL> if rmax is None : <EOL> rmax_values = [ <NUM_LIT> * self . star . radius ] <EOL> rmax_values += ( [ disk . rmax for disk in self . disks ] + <EOL> [ envelope . rmax for envelope in self . envelopes ] + <EOL> [ ambient . rmax for ambient in self . ambients ] ) <EOL> rmax = _max_none ( * rmax_values ) <EOL> if rmax < rmin : <EOL> logger . warn ( "<STR_LIT>" ) <EOL> rmin = self . star . radius <EOL> rmax = <NUM_LIT> * self . star . radius <EOL> if np . isnan ( rmin ) : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> if np . isnan ( rmax ) : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> if rmin == <NUM_LIT:0> : <EOL> raise ValueError ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT:.>" % grid_type ) <EOL> r_wall = [ self . star . radius / <NUM_LIT> , rmin ] <EOL> r = np . logspace ( - <NUM_LIT> , np . log10 ( ( rmax - rmin ) / rmin ) , <NUM_LIT> ) * rmin + rmin <EOL> r [ <NUM_LIT:0> ] = rmin <EOL> tau_midplane = self . get_midplane_tau ( r ) <EOL> r_next_real = rmin * ( ( rmax / rmin ) ** ( <NUM_LIT:1.> / n_r ) - <NUM_LIT:1.> ) <EOL> if tau_midplane [ - <NUM_LIT:1> ] <= <NUM_LIT:0.1> : <EOL> r_next_tau = rmax - rmin <EOL> else : <EOL> r_next_tau = np . interp ( <NUM_LIT:0.1> , tau_midplane , r ) - rmin <EOL> rnext = min ( r_next_real , r_next_tau ) <EOL> if rmin * ( <NUM_LIT:1.> + min_spacing ) > rnext + rmin : <EOL> logger . warn ( "<STR_LIT>" . format ( min_spacing ) ) <EOL> rnext = rmin * min_spacing <EOL> r_wall = np . hstack ( [ <NUM_LIT:0.> , np . logspace ( np . log10 ( rnext / rmin ) , np . log10 ( ( rmax - rmin ) / rmin ) , n_r - <NUM_LIT:1> ) ] ) * rmin + rmin <EOL> r_wall = np . hstack ( [ <NUM_LIT:0.> , r_wall ] ) <EOL> if grid_type is '<STR_LIT>' : <EOL> t_wall = np . linspace ( <NUM_LIT:0> , pi , n_theta + <NUM_LIT:1> ) <EOL> t_wall = t_wall + np . sin ( <NUM_LIT:2> * t_wall ) / <NUM_LIT> <EOL> elif grid_type is '<STR_LIT>' : <EOL> if not zmax : <EOL> zmax = rmax <EOL> if zmin is None and len ( self . disks ) > <NUM_LIT:0> : <EOL> zmin = np . inf <EOL> for disk in self . disks : <EOL> zmin = min ( zmin , disk . scale_height_at ( rmin ) ) <EOL> if zmin is not None : <EOL> if n_z % <NUM_LIT:2> == <NUM_LIT:0> : <EOL> n_zn = n_z / <NUM_LIT:2> <EOL> z_wall1 = np . linspace ( zmin * <NUM_LIT:0.1> , zmin * <NUM_LIT> , <NUM_LIT:10> ) <EOL> z_wall2 = np . logspace ( np . log10 ( zmin ) , <EOL> np . log10 ( zmax ) , <EOL> n_zn - <NUM_LIT:10> ) <EOL> z_wall = np . hstack ( [ z_wall1 , z_wall2 ] ) <EOL> z_wall = np . hstack ( [ - z_wall [ : : - <NUM_LIT:1> ] , z_wall ] ) <EOL> else : <EOL> n_zn = ( n_z - <NUM_LIT:1> ) / <NUM_LIT:2> <EOL> z_wall1 = np . linspace ( zmin * <NUM_LIT:0.1> , zmin * <NUM_LIT> , <NUM_LIT:10> ) <EOL> z_wall2 = np . logspace ( np . log10 ( zmin ) , <EOL> np . log10 ( zmax ) , <EOL> n_zn - <NUM_LIT:10> ) <EOL> z_wall = np . hstack ( [ z_wall1 , z_wall2 ] ) <EOL> z_wall = np . hstack ( [ - z_wall [ : : - <NUM_LIT:1> ] , <NUM_LIT:0.> , z_wall ] ) <EOL> else : <EOL> z_wall = np . linspace ( - zmax , zmax , n_z + <NUM_LIT:1> ) <EOL> p_wall = np . linspace ( <NUM_LIT:0.> , <NUM_LIT> * pi , n_phi + <NUM_LIT:1> ) <EOL> if grid_type is '<STR_LIT>' : <EOL> return SphericalPolarGrid ( r_wall , t_wall , p_wall ) <EOL> else : <EOL> return CylindricalPolarGrid ( r_wall , z_wall , p_wall ) <EOL> def setup_magnetospheric_accretion ( self , mdot , rtrunc , fspot , <EOL> xwav_min = <NUM_LIT> , xwav_max = <NUM_LIT> ) : <EOL> '''<STR_LIT>''' <EOL> lstar = self . star . sources [ '<STR_LIT>' ] . luminosity <EOL> if self . star . mass is None : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> lshock = G * self . star . mass * mdot * ( <NUM_LIT:1> / self . star . radius - <NUM_LIT:1> / rtrunc ) <EOL> fluxratio = <NUM_LIT:0.5> * lshock / lstar / fspot <EOL> teff = ( lstar / ( <NUM_LIT> * pi * self . star . radius ** <NUM_LIT:2> * sigma ) ) ** <NUM_LIT> <EOL> tshock = teff * ( <NUM_LIT:1> + fluxratio ) ** <NUM_LIT> <EOL> self . star . sources [ '<STR_LIT>' ] = SphericalSource ( name = '<STR_LIT>' , <EOL> radius = self . star . radius ) <EOL> self . star . sources [ '<STR_LIT>' ] . luminosity = lshock / <NUM_LIT> + lstar * fspot <EOL> self . star . sources [ '<STR_LIT>' ] . temperature = tshock <EOL> wav = np . logspace ( np . log10 ( xwav_min ) , np . log10 ( xwav_max ) , <NUM_LIT:100> ) [ : : - <NUM_LIT:1> ] <EOL> nu = c * <NUM_LIT> / wav <EOL> fnu = np . repeat ( <NUM_LIT:1.> , nu . shape ) <EOL> self . star . sources [ '<STR_LIT>' ] = SphericalSource ( name = '<STR_LIT>' , <EOL> radius = self . star . radius ) <EOL> self . star . sources [ '<STR_LIT>' ] . luminosity = lshock / <NUM_LIT> <EOL> self . star . sources [ '<STR_LIT>' ] . spectrum = ( nu , fnu ) <EOL> self . star . sources [ '<STR_LIT>' ] . luminosity *= <NUM_LIT:1> - fspot <EOL> def to_model ( self , merge_if_possible = True ) : <EOL> '''<STR_LIT>''' <EOL> if self . grid is None : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> m = Model ( ) <EOL> if isinstance ( self . grid , collections . Mapping ) : <EOL> m . grid = self . _set_polar_grid_auto ( ** self . grid ) <EOL> else : <EOL> m . grid = deepcopy ( self . grid ) <EOL> m . name = self . name <EOL> m . conf = deepcopy ( self . conf ) <EOL> m . sources = deepcopy ( self . sources ) <EOL> m . binned_output = deepcopy ( self . binned_output ) <EOL> m . peeled_output = deepcopy ( self . peeled_output ) <EOL> m . _minimum_temperature = deepcopy ( self . _minimum_temperature ) <EOL> m . _minimum_specific_energy = deepcopy ( self . _minimum_specific_energy ) <EOL> m . _monochromatic = self . _monochromatic <EOL> m . _frequencies = self . _frequencies <EOL> g = virtual_file ( ) <EOL> self . write_run_conf ( g ) <EOL> m . read_run_conf ( g ) <EOL> g . close ( ) <EOL> for i , disk in enumerate ( self . disks ) : <EOL> if disk . rmin >= disk . rmax : <EOL> logger . warn ( "<STR_LIT>" ) <EOL> elif disk . mass == <NUM_LIT:0.> : <EOL> logger . warn ( "<STR_LIT>" ) <EOL> else : <EOL> if not disk . dust : <EOL> raise Exception ( "<STR_LIT>" % ( i + <NUM_LIT:1> ) ) <EOL> m . add_density_grid ( disk . density ( m . grid ) , disk . dust , <EOL> merge_if_possible = merge_if_possible ) <EOL> for i , envelope in enumerate ( self . envelopes ) : <EOL> if envelope . rmin >= envelope . rmax : <EOL> logger . warn ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> elif isinstance ( envelope , UlrichEnvelope ) and envelope . rho_0 == <NUM_LIT:0.> : <EOL> logger . warn ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> elif isinstance ( envelope , PowerLawEnvelope ) and envelope . mass == <NUM_LIT:0.> : <EOL> logger . warn ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> else : <EOL> if not envelope . dust : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> m . add_density_grid ( envelope . density ( m . grid ) , envelope . dust , <EOL> merge_if_possible = merge_if_possible ) <EOL> if envelope . cavity is not None : <EOL> if envelope . cavity . theta_0 == <NUM_LIT:0.> : <EOL> logger . warn ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> elif envelope . cavity . rho_0 == <NUM_LIT:0.> : <EOL> logger . warn ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> else : <EOL> if not envelope . cavity . dust : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> m . add_density_grid ( envelope . cavity . density ( m . grid ) , <EOL> envelope . cavity . dust , <EOL> merge_if_possible = merge_if_possible ) <EOL> for i , ambient in enumerate ( self . ambients ) : <EOL> if ambient . density == <NUM_LIT:0.> : <EOL> logger . warn ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> else : <EOL> if not ambient . dust : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> m . add_density_grid ( ambient . density ( m . grid ) , <EOL> ambient . dust , <EOL> merge_if_possible = merge_if_possible ) <EOL> if self . star . sources [ '<STR_LIT>' ] . luminosity > <NUM_LIT:0> : <EOL> if self . star . sources [ '<STR_LIT>' ] not in self . sources : <EOL> m . add_source ( self . star . sources [ '<STR_LIT>' ] ) <EOL> if '<STR_LIT>' in self . star . sources and self . star . sources [ '<STR_LIT>' ] . luminosity > <NUM_LIT:0.> : <EOL> if self . star . sources [ '<STR_LIT>' ] not in self . sources : <EOL> m . add_source ( self . star . sources [ '<STR_LIT>' ] ) <EOL> if '<STR_LIT>' in self . star . sources and self . star . sources [ '<STR_LIT>' ] . luminosity > <NUM_LIT:0.> : <EOL> if self . star . sources [ '<STR_LIT>' ] not in self . sources : <EOL> m . add_source ( self . star . sources [ '<STR_LIT>' ] ) <EOL> for i , disk in enumerate ( self . disks ) : <EOL> if isinstance ( disk , AlphaDisk ) : <EOL> if disk . rmin >= disk . rmax : <EOL> logger . warn ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> elif disk . mass == <NUM_LIT:0.> : <EOL> logger . warn ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> elif disk . lvisc == <NUM_LIT:0.> : <EOL> logger . warn ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> else : <EOL> m . add_map_source ( luminosity = disk . lvisc , map = disk . accretion_luminosity ( m . grid ) , name = '<STR_LIT>' % i ) <EOL> return m <EOL> def write ( self , filename = None , compression = True , copy = True , <EOL> absolute_paths = False , wall_dtype = float , <EOL> physics_dtype = float , overwrite = True , merge_if_possible = True ) : <EOL> '''<STR_LIT>''' <EOL> self . filename = filename <EOL> m = self . to_model ( merge_if_possible = merge_if_possible ) <EOL> m . write ( filename = filename , compression = compression , <EOL> copy = copy , absolute_paths = absolute_paths , <EOL> wall_dtype = wall_dtype , physics_dtype = physics_dtype , <EOL> overwrite = overwrite ) </s>
