Módulo:Infobox/Astro

Origem: Wikipédia, a enciclopédia livre.
Documentação do módulo[ver] [editar] [histórico] [purgar]

Descrição[editar código-fonte]

Este módulo tem funções auxiliares de {{Info/Astro}}

Uso[editar código-fonte]

Outra documentação:

local localdata = require "Módulo:Infobox/Localdata"
local item = localdata.item
local general = require "Módulo:Infobox/Funções"
local geolocalisation = require "Módulo:Infobox/Funções/Geolocalização"
local wd = require "Módulo:Infobox/Wikidata"
local wdGlobe = require "Módulo:Wikidata/Globes"
local convert = require "Módulo:Conversão"
local frame = mw.getCurrentFrame() --para a expansão de modelos não Lua

local spectralLinks = {
    ['G0V'] = 'Anã amarela',
    ['G1V'] = 'Anã amarela',
    ['G2V'] = 'Anã amarela',
    ['G3V'] = 'Anã amarela',
    ['G4V'] = 'Anã amarela',
    ['G5V'] = 'Anã amarela',
    ['G6V'] = 'Anã amarela',
    ['G7V'] = 'Anã amarela',
    ['G8V'] = 'Anã amarela',
    ['G9V'] = 'Anã amarela', -- a completar
}


local function coords() -- a converter em Lua
    if localdata['céu'] == 'não' then
        return nil
    end
    return frame:expandTemplate{ title = 'Céu/com separador', args = {localdata['asc'], localdata['decl']} }
end


local function rascension()
    local asc, ascnotes = localdata['asc'], localdata['ascenção direita notas']
    local asc2, asc2notes = localdata['asc2'], localdata['ascenção direita notas 2']
    local str
    if asc then
        str = frame:expandTemplate{ title = 'AR/com separador', args = {asc, ascnotes} }
        if asc2 then
            str = str .. frame:expandTemplate{ title = 'AR/com separador', args = {asc2, asc2notes} }
        end
    end
    return str
end

local function declination() -- fazer no modelo de reascenção

end

return {
    maincolor = '#CEDAF2',
    parts = {
        {type = 'external text', value = function() return coords() end},
        general.title(),
        general.mainimage('!Artigos de geografia sem imagens'),
        {type = 'text', label = '[[Época (astronomia)|Época]]', value = 'época', property = 'P6259'},
        {type = 'text', label = 'Natureza', value = 'natureza', property = 'P31'},
        {type = 'table', title = 'Localização', rows = {
            {type = 'row', label = 'Nome internacional', value = 'nome internacional', property = 'P1448'}, -- nome dado pela UAI
            {type = 'row', label = 'Símbolo', value = 'notação', property = 'P913'}, -- símbolo astronomico do astro
            {type = 'row', label = 'Astro', value = {'astro', 'planeta'}, property = 'P376'}, -- corpos astronomicos ou mostra-se o local
            {type = 'row', label = 'País', plurallabel = 'Países', value = {'país', 'país1', 'país2', 'país3'}, property = 'P17'}, -- SINTAXE UMA REVISÃO do país ou países onde de facto a estrela, útil em ficção científica
            {type = 'row', label = 'Região', plurallabel = 'Regiões', value = 'região', property = 'P706'}, -- regiões geográficas sem quadrangulo
            -- cordenadas : reutilizar Predefinição:Coord univers
            {type = 'row', label = '[[Ascensão reta|Asc. reta]]', value =function() return rascension() end, property = 'P6257'},
            {type = 'row', label = '[[Declinação]]', value = function() return declination() end, property = 'P6258'},
        {type = 'row', label = '[[Sistema galáctico de coordenadas|Latitude galáctico]]', value = "lat galáctico", property = 'P6261'},
        {type = 'row', label = '[[Sistema galáctico de coordenadas|Longitude galáctico]]', value = "long galáctico", property = 'P6260'},
            {type = 'row', label = '[[Constelação]]', value = {'constelacao', 'constelação'}, property = 'P59'},
        {type = 'row', label = 'Atividade', value = 'atividade'},
        }},
        {type = 'table', title = 'Espectografia', rows = {
            {type = 'row', label = '[[Classificação estelar|Tipo espectral]]', value = {'tipo espectral', 'espectral'}, wikidata = {
                property = 'P215',
                statementformat = function(statement)
                    local str = wd.formatStatement(statement)
                    local link = spectralLinks[str]
                    if link then
                        str = "[[" .. link .. '|' .. str .. "]]"
                    end
                    return str
                    end
                }
            },
            {type = 'row', label = 'Classe espectral', value = {'classificação espectral','espectro'}, property='P720'}, -- para planetas menores / asteróides
            {type = 'row', label = "Família de asteroides", value = "família de asteroides", property = 'P744'}, -- para os asteroides
            {type = 'row', label = '[[Magnitude apparente]] (J)', value = 'magnitude apparente bande J'},
            {type = 'row', label = '[[Magnitude apparente]] (K)', value = 'magnitude apparente bande K'},
        {type = 'row', label = '[[Magnitude aparente]]', plurallabel = '[[Magnitude aparente|Magnitudes aparentes]]', value = 'magnitude aparente', wikidata = {property = 'P1215', conjtype = 'new line', showqualifiers = 'P1227'}},
            {type = 'row', label = '[[Índice de cor|Índice]] U-B', value = 'u-b'},
            {type = 'row', label = '[[Índice de cor|Índice]] B-V', value = 'b-v'},
            {type = 'row', label = '[[Índice de cor|Índice]] R-I', value = 'r-i'},
            {type = 'row', label = '[[Índice de cor|Índice]] J-K', value = 'j-k'},
            {type = 'row', label = '[[Estrela variável|Variabilidade]]', value = 'variabilité', property = 'P881'},
            {type = 'row', label = '[[Albedo]]', value = 'albedo', property = 'P4501'}, -- relação média para corpos sólidos
        }},
        {type = 'table', title = 'Astrometria', rows = {
            {type = 'row', label = '[[Velocidade radial]]', value = 'velocidade radial', wikidata = {property = 'P2216', targetunit = 'kilometer per second'}},
            {type = 'row', label = '[[Movimento próprio]]', value = {'movimento próprio', 'movimento próprio dec'}, wikidata = {property = 'P2215', showlink = true}},
            {type = 'row', label = '[[Paralaxe]]', value = 'paralaxe', property = 'P2214'},
            {type = 'row', label = '[[Distância]] ao Sol', value = 'distância', wikidata = {property = 'P2583', targetunit = 'light year'}},
            {type = 'row', label = '[[Magnitude absoluta]]', value = 'magnitude absoluta', property = 'P1457'},
        }},
        {type = 'table', title = 'Órbita', rows = {
            {type = 'row', label = '[[Semieixo maior|Semi grande eixo]]', value = 'semi grande eixo', wikidata = {property = 'P2233', targetunit = 'astronomical unit' , rounding = 5}},
            {type = 'row', label = '[[Apoapside]]', value = {'aphelie', 'apoapside', 'apogeio'}, property = P2243},
            {type = 'row', label = '[[Periapside]]', value = {'perihélie', 'periapside', 'perigeio'}, property = P2244},
            {type = 'row', label = 'Circonferência orbital', value = 'circonferência orbital'},
            {type = 'row', label = '[[Excentricidade orbital|Excentricidade]]', value = 'excentricidade', property = {property = 'P1096', rounding=6}},
            {type = 'row', label = '[[Período de revolução]]', value = 'período de revolução', property = P2146},
            {type = 'row', label = '[[Período sinódico]]', value = 'período sinódico', property = P4341},
            {type = 'row', label = '[[Velocidade orbital]] média', value = 'velocidade orbital média'},
            {type = 'row', label = 'Velocidade orbital máxima', value = 'velocidade orbital máxima'},
            {type = 'row', label = 'Velocidade orbital mínima', value = 'velocidade orbital mínima'},
            {type = 'row', label = '[[Inclinação orbital|Inclinação]]', value = 'inclinação', property = 'P2045'},
            {type = 'row', label = '[[Nodo orbital|Nodo ascendente]]', value = 'nodo ascendente', property = 'P2213'},
            {type = 'row', label = '[[Argumento do periastro]]', value = {'argumento do periastro', 'argumento periastro'}, property = 'P2248'},
        }},
        {type = 'table', title = 'Caracteristicas físicas', rows = {
            {type = 'row', label = 'Massa', value = 'massa', wikidata = { property = 'P2067', showlink = true}},
            {type = 'row', label = 'Raio', value = 'raio', wikidata = { property = 'P2120', showlink = true}},
            {type = 'row', label = 'Diametro', value = {'diametro','diametro noyau'}, wikidata = {property = 'P2386', showlink = true}},
            {type = 'row', label = '[[Achatamento]]', value = 'achatamento', wikidata = {property = 'P1102', showlink = true}}, --verifique a integração da margem de erro
            {type = 'row', label = 'Luminosidade', value = 'luminosidade',  wikidata = { property = 'P2060', showlink = true}},
            {type = 'row', label = 'Temperatura', value = 'temperatura', wikidata = {  property = 'P2076', showlink = true}},
            {type = 'row', label = 'Temperature', value = 'temperatura efetiva', wikidata = {property = 'P6879', showlink = true}},
            {type = 'row', label = '[[Metalicidade]]', value = {'metalicidade', 'metalsist'}, property = 'P2227'},
            {type = 'row', label = '[[Velocidade angular]]', value = 'velociade angular', property = 'P4296'},
        {type = 'row', label = '[[Período de rotação]]', value = 'período de rotação', property = 'P2147'},
            {type = 'row', label = 'Ponto culminante', value = 'pculminante', property = 'P2044'},
            {type = 'row', label = 'Comprimento', value = 'comprimento', property = 'P2043'},
            {type = 'row', label = 'Largura', value = 'largura', property = 'P2049'},
            {type = 'row', label = 'Área', value = 'área', wikidata = {property = 'P2046', targetunit = 'square kilometer'}},
            {type = 'row', label = 'Altura', value = 'altura', wikidata = {property = 'P2048', targetunit = 'm'}},
            {type = 'row', label = 'Profundidade', value = 'profundidade', wikidata = {property = 'P2610', targetunit = 'm'}},
            {type = 'row', label = 'Idade', value = 'idade', wikidata = { property = "P571", conjtype= "or"}},
        }},
        {type = 'table', title = 'Atmosfera', rows = {
            {type = 'row', label = 'Massa volumica a 100 kPa', value = 'massa volumica', property = 'P2054'}, --não usa a pressão indicada nos qualificadores ainda
            {type = 'row', label = 'Altura de escala', value = "altura de escala"},
            {type = 'row', label = 'Massa molar média', value = 'masse média'},
        }},
        {type = 'table', title = 'Componentes', rows = {
            {type = 'row', label = 'Estrela', plurallabel = 'Estrelas', value = 'componentes estelares', wikidata =  {
                property =  'P527',
                excludespecial = true,
                condition = function (statement)
                    local id = wd.getMainId(statement)
                    return wd.isInstance('Q523', id, 2)
                    end
                }
            }
        }},
        {type = 'table', title = 'Sistema', rows = {
            {type = 'row', label = '[[Exoplaneta|Planeta]]', plurallabel = '[[Exoplaneta|Planetas]]', value = 'planetas', wikidata = {
                property = 'P398',
                condition = function(statement)
                    local v = wd.getMainId(statement)
                    return wd.isInstance('Q634', v, 3)
                    end
                }
            }
        }},
        {type = 'table', title = 'Exploração', rows = {
            {type = 'row', label = 'Descobridor', plurallabel = 'Descobridores', value = 'descobridor', property = 'P61'},
            {type = 'row', label = 'Local de descoberta', plurallabel = 'Locais de descoberta', value = 'local de descoberta', property = 'P65'},
            {type = 'row', label = 'Data de descoberta', value = 'data', property = 'P575'},
            {type = 'row', label = 'Epónimo', value = 'epónimo', property = 'P138'},
        }},
        {type = 'table', title = 'Identificadores', rows = {
            function()
                -- caso especial: usando o parâmetro 'catálogo' local

                if localdata['catálogos'] then
                    return     {type = 'row', label = 'Catálogos', value = 'catálogo'}
                end
               
                local rows = {}
               
                -- catálogos armazenados na propriedade P528
                local query = {entity = item, property = 'P528', qualifier = 'P972', qualifiervalue = {'Q105616', 'Q222662', 'Q111116', 'Q4502205', 'Q1454942', 'Q845735', 'Q392437', 'Q2937249', 'Q27891498', 'Q37859523', 'Q51905050', 'Q1045111', 'Q2941617', 'Q499138', 'Q111130', 'Q537199', 'Q27891782', 'Q4042165', 'Q1563455', 'Q693552'}} -- Bayer, Flamsteed, Gould, GCVS, 2MASS, Bonner Durchmusterung, Córdoba Durchmusterung, Cape Photographic Durchmusterung, CoRoT, Gaia DR1 et DR2, Gliese, HR, BSC, HD, Hipparcos, Kepler, KIC, Tycho, WISE
                local catalogues = wd.getClaims(query)
                for i, j in ipairs(catalogues or {}) do
                    local catnum = wd.formatStatement(j)
                    local cat = wd.getFormattedQualifiers(j, 'P972', {ucfirst = '-'})
                    cat = mw.ustring.gsub(cat, "\|designação de ", "\|") -- Encurtamento de textos
                    cat = mw.ustring.gsub(cat, "\|Designação de ", "\|") -- Encurtamento de textos
                    cat = mw.ustring.gsub(cat, "\|catálogo de ", "\|") -- Encurtamento de textos
                    cat = mw.ustring.gsub(cat, "\|Catálogo ", "\|") -- Encurtamento de textos
                    cat = mw.ustring.gsub(cat, "\|catálogo ", "\|") -- Encurtamento de textos
            cat = mw.ustring.gsub(cat, "\|General Catalogue of Variable Stars", "\|GCVS") -- Encurtamento de textos
                    table.insert(rows, {type = 'row', label = cat, wikidata = function() return catnum end} )
                end
               
                -- catálogos armazenados em identificadores externos
                local simbad = wd.formatStatements{property = 'P3083', entity = item, urlpattern = 'http://simbad.u-strasbg.fr/simbad/sim-id?Ident=$1'}
                if simbad then
                    table.insert(rows, {type = 'row', label = '[[Simbad]]', wikidata = function() return simbad end})
                end
               
                -- adicione o identificador JPL Small-Body (P716)
                -- adicione o identificador ARICNS (P999)
                -- adicione o identificador NASA Exoplanet Archive (P5667)
                -- adicione o identificador Encyclopédie des planètes extrasolaires (P5653)
                -- adicione o identificador Exoplanet Data Explorer (P5650)
                -- adicione o identificador NAIF (P2956)
                -- adicione o identificador Centro de planetas menores de um objeto celeste (P5736)
                -- adicione o identificador Open Exoplanet Catalogue (P5738)
               
                return {type = 'multi', rows = rows}
                end
        }},
    }
}