Exemplo n.º 1
0
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)
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
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)
Exemplo n.º 4
0
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)