Пример #1
0
def isHabitable(xmlPair):
    system, planet, star, filename = xmlPair
    maxa = 0
    if star is None:
        return False  # no binary systems (yet)
    spectralTypeMain = getText(star, "./spectraltype", "G")[0]
    if spectralTypeMain not in spectraltypes_temp_radii:
        return False  # unsupported spectral type
    semimajoraxis = getFloat(planet, "./semimajoraxis")
    if semimajoraxis is None:
        hostmass = getFloat(star, "./mass", 1.)
        period = getFloat(planet, "./period", 265.25)
        semimajoraxis = pow(
            pow(period / 6.283 / 365.25, 2) * 39.49 / hostmass, 1.0 / 3.0)

    temperature = getFloat(star, "./temperature")

    if temperature is None:
        temperature = spectraltypes_temp_radii[spectralTypeMain][0]

    rel_temp = temperature - 5700.

    stellarMass = getFloat(star, "./mass")
    if stellarMass is None:
        stellarMass = 1.

    stellarRadius = getFloat(star, "./radius")
    if stellarRadius is None or stellarRadius < 0.01:
        #stellarRadius = 1.
        if spectralTypeMain in spectraltypes_temp_radii:
            stellarRadius = spectraltypes_temp_radii[spectralTypeMain][1]
        else:
            return False

    if stellarMass > 2.:
        luminosity = pow(stellarMass, 3.5)
    else:
        luminosity = pow(stellarMass, 4.)

    # Ref: http://adsabs.harvard.edu/abs/2007A%26A...476.1373S
    HZinner2 = (0.68 - 2.7619e-5 * rel_temp -
                3.8095e-9 * rel_temp * rel_temp) * sqrt(luminosity)
    HZouter2 = (1.95 - 1.3786e-4 * rel_temp -
                1.4286e-9 * rel_temp * rel_temp) * sqrt(luminosity)

    if semimajoraxis > HZinner2 and semimajoraxis < HZouter2:
        return True
    return False
Пример #2
0
def hzLimits(star):
    if star is None:
        return None

    temperature = getFloat(star, "./temperature")
    stellarRadius = getFloat(star, "./radius")
    if stellarRadius is not None and stellarRadius < 0.01:
        return None

    if temperature is not None and stellarRadius is not None:
        luminosity = (temperature / 5778.)**4 * stellarRadius**2
    else:
        stellarMass = getFloat(star, "./mass")
        if stellarMass is None:
            return None
        elif stellarMass > 2.:
            luminosity = pow(stellarMass, 3.5)
        else:
            luminosity = pow(stellarMass, 4.)

    spectralTypeMain = getText(star, "./spectraltype", "")[:1]
    try:
        spTemperature, spRadius = spectralTypeTempRadius[spectralTypeMain]
        if temperature is None:
            temperature = spTemperature
        if stellarRadius is None:
            stellarRadius = spRadius
    except KeyError:
        if temperature is None:
            temperature = 5700.
        if stellarRadius is None:
            stellarRadius = 1.

    rel_temp = temperature - 5700.

    # Ref: http://adsabs.harvard.edu/abs/2007A%26A...476.1373S
    HZinner2 = (0.68 - 2.7619e-5 * rel_temp -
                3.8095e-9 * rel_temp * rel_temp) * sqrt(luminosity)
    HZinner = (0.95 - 2.7619e-5 * rel_temp -
               3.8095e-9 * rel_temp * rel_temp) * sqrt(luminosity)
    HZouter = (1.67 - 1.3786e-4 * rel_temp -
               1.4286e-9 * rel_temp * rel_temp) * sqrt(luminosity)
    HZouter2 = (1.95 - 1.3786e-4 * rel_temp -
                1.4286e-9 * rel_temp * rel_temp) * sqrt(luminosity)

    return HZinner2, HZinner, HZouter, HZouter2, stellarRadius
Пример #3
0
def isHabitable(xmlPair):
    system, planet, star, filename = xmlPair
    maxa = 0
    if star is None:
        return False # no binary systems (yet)
    spectralTypeMain = getText(star,"./spectraltype","G")[0]
    if spectralTypeMain not in spectraltypes_temp_radii :
        return False # unsupported spectral type 
    semimajoraxis = getFloat(planet,"./semimajoraxis")
    if semimajoraxis is None:
        hostmass = getFloat(star,"./mass",1.)
        period = getFloat(planet,"./period",265.25)
        semimajoraxis = pow(pow(period/6.283/365.25,2)*39.49/hostmass,1.0/3.0)

    temperature = getFloat(star,"./temperature")

    if temperature is None:
        temperature = spectraltypes_temp_radii[spectralTypeMain][0]

    rel_temp = temperature - 5700.

    stellarMass = getFloat(star,"./mass")
    if stellarMass is None:
        stellarMass = 1.

    stellarRadius = getFloat(star,"./radius")
    if stellarRadius is None or stellarRadius<0.01:
        stellarRadius = 1.
        if spectralTypeMain in spectraltypes_temp_radii:
            stellarRadius = spectraltypes_temp_radii[spectralTypeMain][1]


    if stellarMass>2.:
        luminosity = pow(stellarMass,3.5)
    else:
        luminosity = pow(stellarMass,4.)

    # Ref: http://adsabs.harvard.edu/abs/2007A%26A...476.1373S
    HZinner2 = (0.68-2.7619e-5*rel_temp-3.8095e-9*rel_temp*rel_temp) *sqrt(luminosity);
    HZouter2 = (1.95-1.3786e-4*rel_temp-1.4286e-9*rel_temp*rel_temp) *sqrt(luminosity);

    if semimajoraxis>HZinner2 and semimajoraxis<HZouter2:
        return True
    return False
def hzLimits(star):
    if star is None:
        return None

    temperature = getFloat(star,"./temperature")
    stellarRadius = getFloat(star,"./radius")
    if stellarRadius is not None and stellarRadius < 0.01:
        return None

    if temperature is not None and stellarRadius is not None:
        luminosity = (temperature/5778.)**4 * stellarRadius**2
    else:
        stellarMass = getFloat(star,"./mass")
        if stellarMass is None:
            return None
        elif stellarMass>2.:
            luminosity = pow(stellarMass,3.5)
        else:
            luminosity = pow(stellarMass,4.)

    spectralTypeMain = getText(star,"./spectraltype","")[:1]
    try:
        spTemperature, spRadius = spectralTypeTempRadius[spectralTypeMain]
        if temperature is None:
            temperature = spTemperature
        if stellarRadius is None:
            stellarRadius = spRadius
    except KeyError:
        if temperature is None:
            temperature = 5700.
        if stellarRadius is None:
            stellarRadius = 1.

    rel_temp = temperature - 5700.

    # Ref: http://adsabs.harvard.edu/abs/2007A%26A...476.1373S
    HZinner2 = (0.68-2.7619e-5*rel_temp-3.8095e-9*rel_temp*rel_temp) *sqrt(luminosity);
    HZinner = (0.95-2.7619e-5*rel_temp-3.8095e-9*rel_temp*rel_temp) *sqrt(luminosity);
    HZouter = (1.67-1.3786e-4*rel_temp-1.4286e-9*rel_temp*rel_temp) *sqrt(luminosity);
    HZouter2 = (1.95-1.3786e-4*rel_temp-1.4286e-9*rel_temp*rel_temp) *sqrt(luminosity);

    return HZinner2, HZinner, HZouter, HZouter2, stellarRadius
def habitable(xmlPair):
    system, planet, star, filename = xmlPair

    stars = system.findall(".//star[planet]") # no binary systems yet
    visualizations = []
    for star in stars:
        hzdata = hzLimits(star)
        if hzdata is None:
            continue

        HZinner2, HZinner, HZouter, HZouter2, stellarRadius = hzdata

        planets = star.findall("./planet")

        maxa = 0
        for planet in planets:
            semimajoraxis = getFloat(planet,"./semimajoraxis")
            if semimajoraxis is None:
                hostmass = getFloat(star,"./mass",1.)
                period = getFloat(planet,"./period",265.25)
                semimajoraxis = pow(pow(period/6.283/365.25,2)*39.49/hostmass,1.0/3.0)
            if semimajoraxis>maxa:
                maxa = semimajoraxis

        width = 600
        height= 100
        au     = 2.0/ maxa*(width-100)*0.49
        last_text_y=12

        svg = """
            <defs>
                <radialGradient id="habitablegradient" >
                    <stop id="stops0" offset=".0" stop-color="lightgreen" stop-opacity="0"/>
                    <stop id="stops1" offset="%f" stop-color="lightgreen" stop-opacity="0"/>
                    <stop id="stops2" offset="%f" stop-color="lightgreen" stop-opacity="1"/>
                    <stop id="stops3" offset="%f" stop-color="lightgreen" stop-opacity="1"/>
                    <stop id="stops4" offset="1" stop-color="lightgreen" stop-opacity="0"/>
                </radialGradient>
            </defs>
            """ %(HZinner2/HZouter2, HZinner/HZouter2,HZouter/HZouter2 )
        if HZinner2<maxa*2:
            svg += '<ellipse cx="%f" cy="%f" rx="%f" ry="%f" fill="url(#habitablegradient)" />' %(
                    0.,
                    height/2,
                    au*HZouter2,
                    au*HZouter2)
            svg += '<text     x="%f"" y="%f" font-family="sans-serif" font-weight="normal"  font-size="12" stroke="none" style="fill:green">Habitable zone</text>' %(
                    au*HZinner2,
                    height-1)


        svg += '<ellipse cx="%f" cy="%f" rx="%f" ry="%f" style="fill:red" />' %(
                    0.,
                    height/2,
                    au*stellarRadius*0.0046524726,
                    au*stellarRadius*0.0046524726)

        svg += '<g style="stroke:black;">'
        for planet in planets:
            semimajoraxis = getFloat(planet,"./semimajoraxis")
            if semimajoraxis is None:
                hostmass = getFloat(star,"./mass",1.)
                period = getFloat(planet,"./period",265.25)
                semimajoraxis = pow(pow(period/6.283/365.25,2)*39.49/hostmass,1.0/3.0)
            size= 12
            textx=semimajoraxis*au+2
            texty=last_text_y+size
            last_text_y = texty

            svg += '<g>'
            svg += '<ellipse cx="%f" cy="%f" rx="%f" ry="%f" style="fill:none" />' %(
                        0.,
                        height/2,
                        semimajoraxis*au,
                        semimajoraxis*au)
            svg += '<text x="%f" y="%f" font-family="sans-serif" font-weight="normal"  font-size="%f" stroke="none" >%s</text>' %(
                        textx,
                        texty,
                        size,
                        getText(planet,"./name"))
            svg += '</g>'

        visualizations.append((getText(star,"./name",""),svg))

    return visualizations
Пример #6
0
def habitable(xmlPair):
    system, planet, star, filename = xmlPair 

    if star is None:
        return None # cannot draw diagram for binary systems yet

    planets = system.findall(".//planet")

    maxa = 0
    for planet in planets:
        semimajoraxis = getFloat(planet,"./semimajoraxis")
        if semimajoraxis is None:
            hostmass = getFloat(star,"./mass",1.)
            period = getFloat(planet,"./period",265.25)
            semimajoraxis = pow(pow(period/6.283/365.25,2)*39.49/hostmass,1.0/3.0) 
        if semimajoraxis>maxa:
            maxa = semimajoraxis

    temperature = getFloat(star,"./temperature")
    spectralTypeMain = getText(star,"./spectraltype","G")[0]
    if temperature is None:
        if spectralTypeMain=="O":
            temperature = 40000
        if spectralTypeMain=="B":
            temperature = 20000
        if spectralTypeMain=="A":
            temperature = 8500
        if spectralTypeMain=="F":
            temperature = 6500
        if spectralTypeMain=="G":
            temperature = 5500
        if spectralTypeMain=="K":
            temperature = 4000
        if spectralTypeMain=="M":
            temperature = 3000
        
    rel_temp = temperature - 5700.
    
    stellarMass = getFloat(star,"./mass")
    if stellarMass is None:
        stellarMass = 1.
    
    stellarRadius = getFloat(star,"./radius")
    if stellarRadius is None or stellarRadius<0.01:
        stellarRadius = 1.
        if spectralTypeMain=='O': 
            stellarRadius=10.
        if spectralTypeMain=='B': 
            stellarRadius=3.0
        if spectralTypeMain=='A': 
            stellarRadius=1.5
        if spectralTypeMain=='F': 
            stellarRadius=1.3
        if spectralTypeMain=='G': 
            stellarRadius=1.0
        if spectralTypeMain=='K': 
            stellarRadius=0.8
        if spectralTypeMain=='M': 
            stellarRadius=0.5
    
    if stellarMass>2.:
        luminosity = pow(stellarMass,3.5)
    else:
        luminosity = pow(stellarMass,4.)
    
    
    HZinner2 = (0.68-2.7619e-9*rel_temp-3.8095e-9*rel_temp*rel_temp) *sqrt(luminosity);
    HZouter2 = (1.95-1.3786e-4*rel_temp-1.4286e-9*rel_temp*rel_temp) *sqrt(luminosity);
    HZinner = (0.95-2.7619e-9*rel_temp-3.8095e-9*rel_temp*rel_temp) *sqrt(luminosity);
    HZouter = (1.67-1.3786e-4*rel_temp-1.4286e-9*rel_temp*rel_temp) *sqrt(luminosity);



    width = 600
    height= 100
    au     = 2.0/ maxa*(width-100)*0.49
    last_text_y=12

    svg = """
        <defs>
            <radialGradient id="habitablegradient" > 
                <stop id="stops0" offset=".0" stop-color="lightgreen" stop-opacity="0"/>
                <stop id="stops1" offset="%f" stop-color="lightgreen" stop-opacity="0"/>
                <stop id="stops2" offset="%f" stop-color="lightgreen" stop-opacity="1"/>
                <stop id="stops3" offset="%f" stop-color="lightgreen" stop-opacity="1"/>
                <stop id="stops4" offset="1" stop-color="lightgreen" stop-opacity="0"/>
            </radialGradient> 
        </defs>
        """ %(HZinner2/HZouter2, HZinner/HZouter2,HZouter/HZouter2 )
    if HZinner2<maxa*2:
        svg += '<ellipse cx="%f" cy="%f" rx="%f" ry="%f" fill="url(#habitablegradient)" />' %(
                0.,
                height/2,
                au*HZouter2,
                au*HZouter2)
        svg += '<text     x="%f"" y="%f" font-family="sans-serif" font-weight="normal"  font-size="12" stroke="none" style="fill:green">Habitable zone</text>' %(
                au*HZinner2,
                height-1)

        
    svg += '<ellipse cx="%f" cy="%f" rx="%f" ry="%f" style="fill:red" />' %(
                0.,
                height/2,
                au*stellarRadius*0.0046524726,
                au*stellarRadius*0.0046524726)
    
    svg += '<g style="stroke:black;">'
    for planet in planets:
        semimajoraxis = getFloat(planet,"./semimajoraxis")
        if semimajoraxis is None:
            hostmass = getFloat(star,"./mass",1.)
            period = getFloat(planet,"./period",265.25)
            semimajoraxis = pow(pow(period/6.283/365.25,2)*39.49/hostmass,1.0/3.0) 
        size= 12
        textx=semimajoraxis*au+2
        texty=last_text_y+size
        last_text_y = texty

        svg += '<g>'
        svg += '<ellipse cx="%f" cy="%f" rx="%f" ry="%f" style="fill:none" />' %(
                    0.,
                    height/2,
                    semimajoraxis*au,
                    semimajoraxis*au)
        svg += '<text x="%f" y="%f" font-family="sans-serif" font-weight="normal"  font-size="%f" stroke="none" >%s</text>' %(
                    textx,
                    texty,
                    size,
                    getText(planet,"./name"))
        svg += '</g>'
    
    return svg
Пример #7
0
def isHabitable(xmlPair):
    system, planet, star, filename = xmlPair
    maxa = 0
    if star is None:
        return False  # no binary systems (yet)
    semimajoraxis = getFloat(planet, "./semimajoraxis")
    if semimajoraxis is None:
        hostmass = getFloat(star, "./mass", 1.)
        period = getFloat(planet, "./period", 265.25)
        semimajoraxis = pow(
            pow(period / 6.283 / 365.25, 2) * 39.49 / hostmass, 1.0 / 3.0)

    temperature = getFloat(star, "./temperature")
    spectralTypeMain = getText(star, "./spectraltype", "G")[0]
    if temperature is None:
        if spectralTypeMain == "O":
            temperature = 40000
        if spectralTypeMain == "B":
            temperature = 20000
        if spectralTypeMain == "A":
            temperature = 8500
        if spectralTypeMain == "F":
            temperature = 6500
        if spectralTypeMain == "G":
            temperature = 5500
        if spectralTypeMain == "K":
            temperature = 4000
        if spectralTypeMain == "M":
            temperature = 3000

    rel_temp = temperature - 5700.

    stellarMass = getFloat(star, "./mass")
    if stellarMass is None:
        stellarMass = 1.

    stellarRadius = getFloat(star, "./radius")
    if stellarRadius is None or stellarRadius < 0.01:
        stellarRadius = 1.
        if spectralTypeMain == 'O':
            stellarRadius = 10.
        if spectralTypeMain == 'B':
            stellarRadius = 3.0
        if spectralTypeMain == 'A':
            stellarRadius = 1.5
        if spectralTypeMain == 'F':
            stellarRadius = 1.3
        if spectralTypeMain == 'G':
            stellarRadius = 1.0
        if spectralTypeMain == 'K':
            stellarRadius = 0.8
        if spectralTypeMain == 'M':
            stellarRadius = 0.5

    if stellarMass > 2.:
        luminosity = pow(stellarMass, 3.5)
    else:
        luminosity = pow(stellarMass, 4.)

    HZinner2 = (0.68 - 2.7619e-9 * rel_temp -
                3.8095e-9 * rel_temp * rel_temp) * sqrt(luminosity)
    #HZinner = (0.95-2.7619e-9*rel_temp-3.8095e-9*rel_temp*rel_temp) *sqrt(luminosity);
    #HZouter = (1.67-1.3786e-4*rel_temp-1.4286e-9*rel_temp*rel_temp) *sqrt(luminosity);
    HZouter2 = (1.95 - 1.3786e-4 * rel_temp -
                1.4286e-9 * rel_temp * rel_temp) * sqrt(luminosity)

    if semimajoraxis > HZinner2 and semimajoraxis < HZouter2:
        return True
    return False
Пример #8
0
def isHabitable(xmlPair):
    system, planet, star, filename = xmlPair
    maxa = 0
    if star is None:
        return False # no binary systems (yet)
    semimajoraxis = getFloat(planet,"./semimajoraxis")
    if semimajoraxis is None:
        hostmass = getFloat(star,"./mass",1.)
        period = getFloat(planet,"./period",265.25)
        semimajoraxis = pow(pow(period/6.283/365.25,2)*39.49/hostmass,1.0/3.0) 

    temperature = getFloat(star,"./temperature")
    spectralTypeMain = getText(star,"./spectraltype","G")[0]
    if temperature is None:
        if spectralTypeMain=="O":
            temperature = 40000
        if spectralTypeMain=="B":
            temperature = 20000
        if spectralTypeMain=="A":
            temperature = 8500
        if spectralTypeMain=="F":
            temperature = 6500
        if spectralTypeMain=="G":
            temperature = 5500
        if spectralTypeMain=="K":
            temperature = 4000
        if spectralTypeMain=="M":
            temperature = 3000
        
    rel_temp = temperature - 5700.
    
    stellarMass = getFloat(star,"./mass")
    if stellarMass is None:
        stellarMass = 1.
    
    stellarRadius = getFloat(star,"./radius")
    if stellarRadius is None or stellarRadius<0.01:
        stellarRadius = 1.
        if spectralTypeMain=='O': 
            stellarRadius=10.
        if spectralTypeMain=='B': 
            stellarRadius=3.0
        if spectralTypeMain=='A': 
            stellarRadius=1.5
        if spectralTypeMain=='F': 
            stellarRadius=1.3
        if spectralTypeMain=='G': 
            stellarRadius=1.0
        if spectralTypeMain=='K': 
            stellarRadius=0.8
        if spectralTypeMain=='M': 
            stellarRadius=0.5
    
    if stellarMass>2.:
        luminosity = pow(stellarMass,3.5)
    else:
        luminosity = pow(stellarMass,4.)
    
    HZinner2 = (0.68-2.7619e-9*rel_temp-3.8095e-9*rel_temp*rel_temp) *sqrt(luminosity);
    #HZinner = (0.95-2.7619e-9*rel_temp-3.8095e-9*rel_temp*rel_temp) *sqrt(luminosity);
    #HZouter = (1.67-1.3786e-4*rel_temp-1.4286e-9*rel_temp*rel_temp) *sqrt(luminosity);
    HZouter2 = (1.95-1.3786e-4*rel_temp-1.4286e-9*rel_temp*rel_temp) *sqrt(luminosity);

    if semimajoraxis>HZinner2 and semimajoraxis<HZouter2:
        return True
    return False
Пример #9
0
def habitable(xmlPair):
    system, planet, star, filename = xmlPair

    stars = system.findall(".//star[planet]")  # no binary systems yet
    visualizations = []
    for star in stars:
        hzdata = hzLimits(star)
        if hzdata is None:
            continue

        HZinner2, HZinner, HZouter, HZouter2, stellarRadius = hzdata

        planets = star.findall("./planet")

        maxa = 0
        for planet in planets:
            semimajoraxis = getFloat(planet, "./semimajoraxis")
            if semimajoraxis is None:
                hostmass = getFloat(star, "./mass", 1.)
                period = getFloat(planet, "./period", 265.25)
                semimajoraxis = pow(
                    pow(period / 6.283 / 365.25, 2) * 39.49 / hostmass,
                    1.0 / 3.0)
            if semimajoraxis > maxa:
                maxa = semimajoraxis

        width = 600
        height = 100
        au = 2.0 / maxa * (width - 100) * 0.49
        last_text_y = 12

        svg = """
            <defs>
                <radialGradient id="habitablegradient" >
                    <stop id="stops0" offset=".0" stop-color="lightgreen" stop-opacity="0"/>
                    <stop id="stops1" offset="%f" stop-color="lightgreen" stop-opacity="0"/>
                    <stop id="stops2" offset="%f" stop-color="lightgreen" stop-opacity="1"/>
                    <stop id="stops3" offset="%f" stop-color="lightgreen" stop-opacity="1"/>
                    <stop id="stops4" offset="1" stop-color="lightgreen" stop-opacity="0"/>
                </radialGradient>
            </defs>
            """ % (HZinner2 / HZouter2, HZinner / HZouter2, HZouter / HZouter2)
        if HZinner2 < maxa * 2:
            svg += '<ellipse cx="%f" cy="%f" rx="%f" ry="%f" fill="url(#habitablegradient)" />' % (
                0., height / 2, au * HZouter2, au * HZouter2)
            svg += '<text     x="%f"" y="%f" font-family="sans-serif" font-weight="normal"  font-size="12" stroke="none" style="fill:green">Habitable zone</text>' % (
                au * HZinner2, height - 1)

        svg += '<ellipse cx="%f" cy="%f" rx="%f" ry="%f" style="fill:red" />' % (
            0., height / 2, au * stellarRadius * 0.0046524726,
            au * stellarRadius * 0.0046524726)

        svg += '<g style="stroke:black;">'
        for planet in planets:
            semimajoraxis = getFloat(planet, "./semimajoraxis")
            if semimajoraxis is None:
                hostmass = getFloat(star, "./mass", 1.)
                period = getFloat(planet, "./period", 265.25)
                semimajoraxis = pow(
                    pow(period / 6.283 / 365.25, 2) * 39.49 / hostmass,
                    1.0 / 3.0)
            size = 12
            textx = semimajoraxis * au + 2
            texty = last_text_y + size
            last_text_y = texty

            svg += '<g>'
            svg += '<ellipse cx="%f" cy="%f" rx="%f" ry="%f" style="fill:none" />' % (
                0., height / 2, semimajoraxis * au, semimajoraxis * au)
            svg += '<text x="%f" y="%f" font-family="sans-serif" font-weight="normal"  font-size="%f" stroke="none" >%s</text>' % (
                textx, texty, size, getText(planet, "./name"))
            svg += '</g>'

        visualizations.append((getText(star, "./name", ""), svg))

    return visualizations