def GetAsteroidsByType(limit, day, max_dist=3, min_dist=0.5, none_frac=0.3, water_frac=0.4, metals_frac=0.14, hydrogen_frac=0.15, platinum_frac=0.01): day = day + CurrentJulianDay() jed_cur = day earth_pos_vec = EarthPositionVector(day) earth_pos_vec_2 = EarthPositionVector(day + 1) ast = [] ids = {} for t in types: ids[t] = [] while len(ast) < limit: cur_type = GetRandomType(none_frac, water_frac, metals_frac, hydrogen_frac, platinum_frac) sel = GetRandomList(1, len(asteroids_by_type[cur_type]), ids[cur_type]) for i in sel: ids[cur_type].append(i) ids[cur_type] = list(set(ids[cur_type])) a = asteroids_by_type[cur_type][i] a['earth_dist'] = DistanceToEarth(a, earth_pos_vec, day) if a['earth_dist'] < max_dist and a['earth_dist'] > min_dist: a['value'] = estimate.valuePerKg(a['spec']) ast.append(a) for i, a in enumerate(ast): #ast[i]['earth_dist'] = DistanceToEarth(a,earth_pos_vec,day) ast[i]['earth_dist_2'] = DistanceToEarth(a, earth_pos_vec, day + 1) ast[i]['earth_dv'] = (ast[i]['earth_dist_2'] - ast[i]['earth_dist']) * 149597871.0 / 86400.0 ast[i]['price'] = estimate.valuePerKg( ast[i]['spec']) * scoring.DEFAULT_MASS #ast[i]['value'] = estimate.valuePerKg(ast[i]['spec']) ast[i]['pos_vec'] = 0 ast[i]['pos_vec_2'] = 0 ast[i]['pos_vec_earth'] = 0 ast[i]['pos_vec_earth_2'] = 0 return ast
def GetRandomAsteroids(limit, day, max_dist=3, min_dist=0.5, noval_keep_frac=0.5): day = day + jed_apr142014 jed_cur = day earth_pos_vec = EarthPositionVector(day) earth_pos_vec_2 = EarthPositionVector(day + 1) ast = [] ids = [] while len(ast) < limit: sel = GetRandomList(limit - len(ast), len(asteroids), ids) for i in sel: asteroids[i]['earth_dist'] = DistanceToEarth( asteroids[i], earth_pos_vec, day) if asteroids[i]['earth_dist'] < max_dist and asteroids[i][ 'earth_dist'] > min_dist: asteroids[i]['value'] = estimate.valuePerKg( asteroids[i]['spec']) if asteroids[i]['value'] < 1E-10: asteroids[i]['value'] = 0.0 if asteroids[i]['value'] > 1E-10 or random.random( ) < noval_keep_frac: ast.append(asteroids[i]) ids.append(i) for i, a in enumerate(ast): #ast[i]['earth_dist'] = DistanceToEarth(a,earth_pos_vec,day) ast[i]['earth_dist_2'] = DistanceToEarth(a, earth_pos_vec, day + 1) ast[i]['earth_dv'] = (ast[i]['earth_dist_2'] - ast[i]['earth_dist']) * 149597871.0 / 86400.0 ast[i]['price'] = estimate.valuePerKg( ast[i]['spec']) * scoring.DEFAULT_MASS #ast[i]['value'] = estimate.valuePerKg(ast[i]['spec']) ast[i]['pos_vec'] = 0 ast[i]['pos_vec_2'] = 0 ast[i]['pos_vec_earth'] = 0 ast[i]['pos_vec_earth_2'] = 0 return ast
def price(obj): """ Returns a tuple of $ price estimates for: 0. Asteroid value per kg in raw materials. 1. Asteroid $ saved per kg versus sending it up from Earth. """ G = 6.67300e-20 # km^3 / kgs^2 if obj['spec'] == 'comet': return (-1, -1) # mass in kg exactmass = False if isinstance(obj['GM'], basestring): mass = DEFAULT_MASS obj['inexact'] = True mass = mass + (random.random() - .5) * 1e14 # some random factor else: exactmass = True mass = obj['GM'] / G if mass > 1e18: # if it's huge, penalize it because the surface will be covered in ejecta, etc. # and the goodies will be far beneath. Also, gravity well. mass = mass * 1e-6 """ # radius in m if isinstance(obj['diameter'], basestring): if exactmass: # If we know the mass, don't make assumptions about radius print 'Disqualified', obj['full_name'] return -1 # 5km radius by default radius = DEFAULT_RADIUS else: if not exactmass: # If we know the radius, don't make assumptions about mass # a lot of things meet this test #print 'Disqualified', obj['full_name'] radius = DEFAULT_RADIUS else: radius = obj['diameter'] / 2 # vol in km^3 # TODO switch to ellipsoid vol vol = 4/3 * math.pi * math.pow(radius, 3) # model as sphere # density in kg/km^3 #density = mass / vol """ stype = obj['spec'] value = estimate.valuePerKg(stype) * mass saved = estimate.savedPerKg(stype) * mass return (value, saved)
def price(obj): """ Returns a tuple of $ by two metrics: 0. Asteroid value per kg in raw materials. 1. Asteroid $ saved per kg versus sending it up from Earth. """ G = 6.67300e-20 # km^3 / kgs^2 # mass in kg exactmass = False if isinstance(obj['GM'], basestring): mass = DEFAULT_MASS obj['inexact'] = True mass = mass + (random.random() - .5) * 1e14 # some random factor else: exactmass = True mass = obj['GM'] / G if mass > 1e18: # if it's huge, penalize it because the surface will be covered in ejecta, etc. # and the goodies will be far beneath mass = mass * 1e-4 """ # radius in m if isinstance(obj['diameter'], basestring): if exactmass: # If we know the mass, don't make assumptions about radius print 'Disqualified', obj['full_name'] return -1 # 5km radius by default radius = DEFAULT_RADIUS else: if not exactmass: # If we know the radius, don't make assumptions about mass # a lot of things meet this test #print 'Disqualified', obj['full_name'] radius = DEFAULT_RADIUS else: radius = obj['diameter'] / 2 # vol in km^3 # TODO switch to ellipsoid vol vol = 4/3 * math.pi * math.pow(radius, 3) # model as sphere # density in kg/km^3 #density = mass / vol """ stype = obj['spec_B'] value = estimate.valuePerKg(stype) * mass saved = estimate.savedPerKg(stype) * mass return (value, saved)
def GetRandomAsteroids(limit, day, max_dist = 3, min_dist = 0.5, noval_keep_frac=0.5): day = day + jed_apr142014 jed_cur = day earth_pos_vec = EarthPositionVector(day) earth_pos_vec_2 = EarthPositionVector(day + 1) ast = [] ids = [] while len(ast) < limit: sel = GetRandomList(limit-len(ast),len(asteroids),ids) for i in sel: asteroids[i]['earth_dist'] = DistanceToEarth(asteroids[i],earth_pos_vec,day) if asteroids[i]['earth_dist'] < max_dist and asteroids[i]['earth_dist'] > min_dist: asteroids[i]['value'] = estimate.valuePerKg(asteroids[i]['spec']) if asteroids[i]['value'] < 1E-10: asteroids[i]['value'] = 0.0 if asteroids[i]['value'] > 1E-10 or random.random() < noval_keep_frac: ast.append(asteroids[i]) ids.append(i) for i,a in enumerate(ast): #ast[i]['earth_dist'] = DistanceToEarth(a,earth_pos_vec,day) ast[i]['earth_dist_2'] = DistanceToEarth(a,earth_pos_vec,day+1) ast[i]['earth_dv'] = (ast[i]['earth_dist_2'] - ast[i]['earth_dist']) * 149597871.0 / 86400.0 ast[i]['price'] = estimate.valuePerKg(ast[i]['spec']) * scoring.DEFAULT_MASS #ast[i]['value'] = estimate.valuePerKg(ast[i]['spec']) ast[i]['pos_vec']=0 ast[i]['pos_vec_2']=0 ast[i]['pos_vec_earth']=0 ast[i]['pos_vec_earth_2']=0 return ast
def GetAsteroidsByType(limit, day, max_dist = 3, min_dist = 0.5, none_frac=0.3, water_frac=0.4, metals_frac=0.14, hydrogen_frac=0.15, platinum_frac=0.01): day = day + CurrentJulianDay() jed_cur = day earth_pos_vec = EarthPositionVector(day) earth_pos_vec_2 = EarthPositionVector(day + 1) ast = [] ids = {} for t in types: ids[t]=[] while len(ast) < limit: cur_type = GetRandomType(none_frac,water_frac,metals_frac,hydrogen_frac,platinum_frac) sel = GetRandomList(1,len(asteroids_by_type[cur_type]),ids[cur_type]) for i in sel: ids[cur_type].append(i) ids[cur_type] = list(set(ids[cur_type])) a = asteroids_by_type[cur_type][i] a['earth_dist'] = DistanceToEarth(a,earth_pos_vec,day) if a['earth_dist'] < max_dist and a['earth_dist'] > min_dist: a['value'] = estimate.valuePerKg(a['spec']) ast.append(a) for i,a in enumerate(ast): #ast[i]['earth_dist'] = DistanceToEarth(a,earth_pos_vec,day) ast[i]['earth_dist_2'] = DistanceToEarth(a,earth_pos_vec,day+1) ast[i]['earth_dv'] = (ast[i]['earth_dist_2'] - ast[i]['earth_dist']) * 149597871.0 / 86400.0 ast[i]['price'] = estimate.valuePerKg(ast[i]['spec']) * scoring.DEFAULT_MASS #ast[i]['value'] = estimate.valuePerKg(ast[i]['spec']) ast[i]['pos_vec']=0 ast[i]['pos_vec_2']=0 ast[i]['pos_vec_earth']=0 ast[i]['pos_vec_earth_2']=0 return ast
def price(obj): """ Returns a tuple of $ price estimates for: 0. Asteroid value per kg in raw materials. 1. Asteroid $ saved per kg versus sending it up from Earth. """ G = 6.67300e-20 # km^3 / kgs^2 if obj['spec'] == 'comet': return (-1, -1) # estimate albedo if isinstance(obj['albedo'], basestring): albedo = DEFAULT_ALBEDO else: albedo = float(obj['albedo']) # estimate diameter if isinstance(obj['diameter'], basestring): if isinstance(obj['H'], basestring): # Can't estimate diameter :( diameter = DEFAULT_RADIUS * 2 else: # Compute diameter in meters abs_magnitude = float(obj['H']) #diameter = 1329 * 10 ** (-abs_magnitude/5) * albedo ** (-1/2) diameter = 1329 / math.sqrt(albedo) * (10 ** (-0.2 * abs_magnitude)) obj['est_diameter'] = diameter # keep as km # mass in kg exactmass = False if isinstance(obj['GM'], basestring): diameter = obj['est_diameter'] if 'est_diameter' in obj else obj['diameter'] if diameter: # Use diameter to estimate mass --> estimate price # Pick density based on spectral type general_spec_type = obj['spec'][0].upper() if general_spec_type in TYPE_DENSITY_MAP: assumed_density = TYPE_DENSITY_MAP[general_spec_type] else: assumed_density = DEFAULT_DENSITY # Compute mass form density and diameter # FIXME assuming a perfect sphere for now... assumed_vol = 4/3 * math.pi * ((diameter / 2) ** 3) # Volume: km^3 # Density: g/cm^3 mass = assumed_vol * assumed_density / 6 * 1e15 else: mass = DEFAULT_MASS obj['inexact'] = True mass = mass + (random.random() - .5) * 1e14 # some random factor else: exactmass = True mass = obj['GM'] / G if mass > 1e18: # if it's huge, penalize it because the surface will be covered in ejecta, etc. # and the goodies will be far beneath. Also, gravity well. mass = mass * 1e-6 stype = obj['spec'] value = estimate.valuePerKg(stype) * mass saved = estimate.savedPerKg(stype) * mass return (value, saved)
def price(obj): """ Returns a tuple of $ price estimates for: 0. Asteroid value per kg in raw materials. 1. Asteroid $ saved per kg versus sending it up from Earth. """ G = 6.67300e-20 # km^3 / kgs^2 if obj['spec'] == 'comet': return (-1, -1) # estimate albedo if isinstance(obj['albedo'], basestring): albedo = DEFAULT_ALBEDO else: albedo = float(obj['albedo']) # estimate diameter if isinstance(obj['diameter'], basestring): if isinstance(obj['H'], basestring): # Can't estimate diameter :( diameter = DEFAULT_RADIUS * 2 else: # Compute diameter in meters abs_magnitude = float(obj['H']) #diameter = 1329 * 10 ** (-abs_magnitude/5) * albedo ** (-1/2) diameter = 1329 / math.sqrt(albedo) * (10 ** (-0.2 * abs_magnitude)) obj['est_diameter'] = diameter # keep as km # mass in kg exactmass = False if isinstance(obj['GM'], basestring): diameter = obj['est_diameter'] if 'est_diameter' in obj else obj['diameter'] if diameter: # Use diameter to estimate mass --> estimate price # Pick density based on spectral type general_spec_type = obj['spec'][0].upper() if general_spec_type in TYPE_DENSITY_MAP: assumed_density = TYPE_DENSITY_MAP[general_spec_type] else: assumed_density = DEFAULT_DENSITY # Compute mass form density and diameter # FIXME assuming a perfect sphere for now... assumed_vol = 4/3 * math.pi * ((diameter / 2) ** 3) # Volume: km^3 # Density: g/cm^3 mass = assumed_vol * assumed_density / 6 * 1e15 else: mass = DEFAULT_MASS obj['inexact'] = True mass = mass + (random.random() - .5) * 1e14 # some random factor else: exactmass = True mass = obj['GM'] / G if mass > 1e18: # if it's huge, penalize it because the surface will be covered in ejecta, etc. # and the goodies will be far beneath. Also, gravity well. mass = mass * 1e-6 """ # radius in m if isinstance(obj['diameter'], basestring): if exactmass: # If we know the mass, don't make assumptions about radius print 'Disqualified', obj['full_name'] return -1 # 5km radius by default radius = DEFAULT_RADIUS else: if not exactmass: # If we know the radius, don't make assumptions about mass # a lot of things meet this test #print 'Disqualified', obj['full_name'] radius = DEFAULT_RADIUS else: radius = obj['diameter'] / 2 # vol in km^3 # TODO switch to ellipsoid vol vol = 4/3 * math.pi * math.pow(radius, 3) # model as sphere # density in kg/km^3 #density = mass / vol """ stype = obj['spec'] value = estimate.valuePerKg(stype) * mass saved = estimate.savedPerKg(stype) * mass return (value, saved)