Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tradução do arquivo FITS-images.ipynb para o português #5

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 54 additions & 50 deletions FITS-images.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,33 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Viewing and manipulating FITS images\n",
"# Visualização e manipulação de imagens FITS\n",
"\n",
"## Authors\n",
"## Autores\n",
"Lia Corrales, Kris Stern, Stephanie T. Douglas, Kelle Cruz\n",
"\n",
"## Learning Goals\n",
"* Open FITS files and load image data\n",
"2. Make a 2D histogram with image data\n",
"3. Stack several images into a single image\n",
"4. Write image data to a FITS file\n",
"## Tradução\n",
"Filipe Góis\n",
"\n",
"## Keywords\n",
"FITS, file input/output, image manipulation, numpy, matplotlib, histogram, colorbar\n",
"## Objetivos\n",
"* Abrir arquivos FITS e carregar dados da imagem\n",
"2. Fazer um histograma 2D com dados da imagem\n",
"3. Juntar várias imagens em uma única imagem\n",
"4. Escreve dados da imagem em um arquivo FITS\n",
"\n",
"## Summary\n",
"## Palavras-chave\n",
"FITS, entrada/saída de arquivo, manipulação de imagem, numpy, matplotlib, histograma, barra de cor\n",
"\n",
"This tutorial demonstrates the use of `astropy.utils.data` to download a data file, then uses `astropy.io.fits` to open the file, and lastly uses `matplotlib` to view the image with different color scales and stretches and to make histograms. In this tutorial we've also included a demonstration of simple image stacking."
"## Resumo\n",
"\n",
"Este tutorial mostra o uso do astropy.utils.data para baixar um arquivo de dados, então usa astropy.io.fits para abrir o arquivo, e, por fim, usa matplotlib para vizualizar a imagem com diferentes escalas de cores, stretches e para fazer histogramas. Neste tutorial, incluímos, também, uma demonstração de uma junção simples de imagens"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Geralmente, a informação da imagem está localizada no bloco <code>PRIMARY</code>. Os blocos são numerado e podem ser acessados indexando <code>hud_list</code>."
]
},
{
Expand All @@ -42,7 +52,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Download the example FITS files for this tutorial."
"Baixe os arquivos FITS para este tutorial"
]
},
{
Expand All @@ -59,14 +69,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Opening FITS files and loading the image data"
"## Abrindo arquivos FITS e carregando os dados da imagem"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's open the FITS file to find out what it contains."
"Abramos o arquivo FITS para descobrir o que ele contém."
]
},
{
Expand All @@ -79,13 +89,6 @@
"hdu_list.info()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Generally, the image information is located in the <code>PRIMARY</code> block. The blocks are numbered and can be accessed by indexing <code>hdu_list</code>."
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -99,7 +102,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Our data is now stored as a 2D numpy array. But how do we know the dimensions of the image? We can look at the `shape` of the array."
"Agora, nosso dado está armazenado em um *array* Numpy bidimensional. Mas como sabemos as dimensões da imagem? Podemos analisar o `shape` do *array*."
]
},
{
Expand All @@ -116,7 +119,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Great! At this point, we can close the FITS file because we've stored everything we wanted to a variable."
"Ótimo! A esta altura, podemos fechar o arquivo FITS, porque já armazenamos tudo que queríamos para uma variável."
]
},
{
Expand All @@ -132,14 +135,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### SHORTCUT"
"### ATALHO"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If you don't need to examine the FITS header, you can call `fits.getdata` to bypass the previous steps."
"Se você não precisa examinar o cabeçalho do arquivo FITS, você pode chamar a função `fits.getdata` para pular os passos anteriores."
]
},
{
Expand All @@ -157,7 +160,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Viewing the image data and getting basic statistics"
"## Vendo o dado da imagem e obtendo estatísticas básicas"
]
},
{
Expand All @@ -169,15 +172,15 @@
"plt.imshow(image_data, cmap='gray')\n",
"plt.colorbar()\n",
"\n",
"# To see more color maps\n",
"# Para ver mais mapas de cores\n",
"# http://wiki.scipy.org/Cookbook/Matplotlib/Show_colormaps"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's get some basic statistics about our image:"
"Obtenhamos algumas estatísticas básicas de nossa imagem:"
]
},
{
Expand All @@ -196,21 +199,21 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Plotting a histogram"
"### Plotando um histograma"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To make a histogram with `matplotlib.pyplot.hist()`, we'll need to cast the data from a 2D array to something one dimensional."
"Para fazer um histograma com `matplotlib.pyplot.hist()`, precisamos transferir o dado de um *array* bidimensional para algo unidimensional."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In this case, let's use the `ndarray.flatten()` to return a 1D numpy array."
"Neste caso, usemos a função `ndarray.flatten()` para transformar um *array* Numpy unidimensional. "
]
},
{
Expand All @@ -235,14 +238,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Displaying the image with a logarithmic scale"
"### Mostando a imagem em escala logarítmica"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"What if we want to use a logarithmic color scale? To do so, we'll need to load the `LogNorm` object from `matplotlib`."
"E se quisermos usar uma escala logarítmica de cores? Para fazer isso, precisamos carregar o objeto `LogNorm` da biblioteca `matplotlib`."
]
},
{
Expand All @@ -262,6 +265,7 @@
"source": [
"plt.imshow(image_data, cmap='gray', norm=LogNorm())\n",
"\n",
"# Escolhi as marcas de escala baseado no histograma acima\n",
"# I chose the tick marks based on the histogram above\n",
"cbar = plt.colorbar(ticks=[5.e3,1.e4,2.e4])\n",
"cbar.ax.set_yticklabels(['5,000','10,000','20,000'])"
Expand All @@ -271,21 +275,21 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Basic image math: image stacking"
"## Matemática Básica com a imagem: junção de imagens"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can also perform math with the image data like any other numpy array. In this particular example, we'll stack several images of M13 taken with a ~10'' telescope."
"Você também pode fazer cálculos com o dado da imagem com qualquer outro *array* Numpy. Neste exemplo em particular, juntaremos várias imagens de M13 tiradas com um telescópio de ~10\"."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's start by opening a series of FITS files and store the data in a list, which we've named `image_concat`."
"Comecemos abrindo uma série de aruivo FITS e armazenando o dado em uma lista, a qual chamamos de `image_concat`."
]
},
{
Expand All @@ -305,7 +309,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we'll stack the images by summing the concatenated list."
"Agora, juntaremos as imagens chamando a lista concatenada."
]
},
{
Expand All @@ -314,21 +318,21 @@
"metadata": {},
"outputs": [],
"source": [
"# The long way\n",
"# O caminho mais longo\n",
"final_image = np.zeros(shape=image_concat[0].shape)\n",
"\n",
"for image in image_concat:\n",
" final_image += image\n",
"\n",
"# The short way\n",
"# O caminho mais curto\n",
"# final_image = np.sum(image_concat, axis=0)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We're going to show the image, but need to decide on the best stretch. To do so let's plot a histogram of the data."
"Vamos mostrar a imagem, mas precisamos decidir qual o melhor trecho. Para isso, plotemos um histograma do dado. "
]
},
{
Expand All @@ -344,7 +348,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We'll use the keywords `vmin` and `vmax` to set limits on the color scaling for `imshow`."
"Usaremos as palavras-chave `vmin` and `vmax` para limitar a escala de cores para `imshow`."
]
},
{
Expand All @@ -361,21 +365,21 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Writing image data to a FITS file"
"## Escrevendo o dado da imagem em um arquivo FITS"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can do this with the `writeto()` method."
"Podemos fazer isso com o método `writeto()`."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Warning: you'll receive an error if the file you are trying to write already exists. That's why we've set `overwrite=True`."
"**AVISO:** você receberá uma mensagem de erro se o arquivo que você está tentando escrever já existe. Por isso, colocamos `overwrite=True`."
]
},
{
Expand All @@ -394,14 +398,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercises"
"## Exercícios"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Determine the mean, median, and standard deviation of a part of the stacked M13 image where there is *not* light from M13. Use those statistics with a sum over the part of the image that includes M13 to estimate the total light in this image from M13."
"Determine a média, mediana e o desvio-padrão da parte da imagem juntada de M13 onde *não* há luz de M13. Use estas estatísticas com uma soma sobre a parte da imagem que inclui M13 para estimar a luz total nesta imagem de M13. "
]
},
{
Expand All @@ -415,8 +419,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Show the image of the Horsehead Nebula, but in units of *surface brightness* (magnitudes per square arcsecond).\n",
"(Hint: the *physical* size of the image is 15x15 arcminutes.)"
"Mostre a image da Nebulosa Cabeça de Cavalo, mas em unidade de *brilho superficial* (magnitudes por segundo de arco ao quadrado). \n",
"(Dica: o tamanho *físico* da imagem é 15x15 minutos de arco.)"
]
},
{
Expand All @@ -430,8 +434,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Now write out the image you just created, preserving the header the original image had, but add a keyword 'UNITS' with the value 'mag per sq arcsec'.\n",
"(Hint: it may be helpful to read the [astropy.io.fits](http://docs.astropy.org/en/stable/io/fits/index.html) documentation if you're not sure how to include both the header and the data.)"
"Agora, salve a imagem que você acabou de criar, preservando o cabeçalho da imagem original, mas adicione a chave 'UNITS' com o valor 'mag per sq arcsec'. \n",
"(Dica: leia a documentação de [astropy.io.fits](http://docs.astropy.org/en/stable/io/fits/index.html) se você não sabe como incluir o cabeçalho e o dado.)"
]
},
{
Expand Down