Skip to content
Snippets Groups Projects
Commit 019f368c authored by Sasiri Juliana Vargas Urbano's avatar Sasiri Juliana Vargas Urbano
Browse files

segundo commit

parent 893a8a96
No related branches found
No related tags found
No related merge requests found
...@@ -17,7 +17,7 @@ import statistics as stat ...@@ -17,7 +17,7 @@ import statistics as stat
class Estrella_a: class Estrella_a:
def __init__(self, estrella_map): def __init__(self, estrella_map):
print('Convertido a estrella') #print('Convertido a estrella')
self.estrella_map = estrella_map self.estrella_map = estrella_map
def x_y_grilla(self): def x_y_grilla(self):
...@@ -30,8 +30,11 @@ class Estrella_a: ...@@ -30,8 +30,11 @@ class Estrella_a:
paso_x = 255/nx paso_x = 255/nx
paso_y = 255/ny paso_y = 255/ny
x = np.arange(0,255,paso_x) #x = np.arange(0,1,paso_x)
y = np.arange(0,255,paso_y) #y = np.arange(0,1,paso_y)
x = np.arange(0,nx,1)
y = np.arange(0,ny,1)
#Grilla #Grilla
yy, xx = np.meshgrid(x,y) yy, xx = np.meshgrid(x,y)
...@@ -175,81 +178,5 @@ class Estrella_a: ...@@ -175,81 +178,5 @@ class Estrella_a:
#img=plt.imshow(data_graf,cmap="gray") #img=plt.imshow(data_graf,cmap="gray")
return data_graf #img, data_graf return data_graf, ajuste #img, data_graf
def estadistica(self, p):
"""
Retorna en su orden la moda, media, mediana, desviacion del ajuste realizado
--------------------------------------
FUNCIONAMIENTO:
Ingrese la función como:
estadistica(p)
PARÁMETROS:
p: Tipo(array 1D) -> Parámetros de ajuste. Debe contener los siguientes parámetros:
p = [a, b, c, x0, y0]
a: Amplitud de la Gaussiana
b: Offset
c: Varianza
x0: Centro en x
y0: Centro en y
"""
imagen_es = self.ajusteGauss(p)
moda=stat.mode(np.round(imagen_es,3).reshape(-1))
media=np.mean(imagen_es)
mediana=np.median(imagen_es)
desviacion=imagen_es.std()
return moda, media, mediana, desviacion
def histograma(self,p, conjuntos):
"""
Retorna el histograma del ajuste realizado
--------------------------------------
FUNCIONAMIENTO:
Ingrese la función como:
histograma(p)
PARÁMETROS:
p: Tipo(array 1D) -> Parámetros de ajuste. Debe contener los siguientes parámetros:
p = [a, b, c, x0, y0]
a: Amplitud de la Gaussiana
b: Offset
c: Varianza
x0: Centro en x
y0: Centro en y
conjuntos: Tipo(int) -> Cantidad de bins para la función de plt.hist
"""
imagen_es = self.ajusteGauss(p)
plt.figure(figsize=(9,4))
plt.hist(imagen_es,bins=conjuntos, histtype='bar', alpha=0.7, edgecolor = 'black', linewidth=0.2)
plt.show()
This diff is collapsed.
...@@ -17,6 +17,7 @@ import matplotlib.pyplot as plt ...@@ -17,6 +17,7 @@ import matplotlib.pyplot as plt
%matplotlib inline %matplotlib inline
from scipy.optimize import leastsq # Para optimizar las funciones from scipy.optimize import leastsq # Para optimizar las funciones
import statistics as stat import statistics as stat
import math
``` ```
_NOTA:_ _NOTA:_
...@@ -56,7 +57,7 @@ plt.imshow(imagen) ...@@ -56,7 +57,7 @@ plt.imshow(imagen)
<matplotlib.image.AxesImage at 0x7fd7bbf0ed68> <matplotlib.image.AxesImage at 0x7f38c3d63940>
...@@ -186,7 +187,7 @@ plt.imshow(imagen_grisss, cmap='gray') ...@@ -186,7 +187,7 @@ plt.imshow(imagen_grisss, cmap='gray')
<matplotlib.image.AxesImage at 0x7fd7bbe70c18> <matplotlib.image.AxesImage at 0x7f38c3c5b198>
...@@ -363,56 +364,6 @@ ax2.set_title('Ajuste') ...@@ -363,56 +364,6 @@ ax2.set_title('Ajuste')
**Análisis estadistico**
Para encontrar la mediana, media, moda y desviacion estandar del ajuste hecho se hace lo siguiente:
```python
#Media
media=np.mean(zz)
#Mediana
mediana=np.median(zz)
#Moda
moda=stat.mode(np.round(zz,3).reshape(-1))
#Desviacion estandar con scipy
desviacion=stat.stdev(zz.reshape(-1))
#Desviacion estandar con numpy
desviacion1=zz.std()
print('Mediana: ', mediana)
print('Media: ', media)
print('Moda: ', moda)
print('Desviacion estandar 1: ', desviacion)
print('Desviacion estandar 2: ', desviacion1)
```
Mediana: 121.00032292471543
Media: 136.12938530499758
Moda: 119.161
Desviacion estandar 1: 31.37796037027831
Desviacion estandar 2: 31.36515042470658
Para hacer el histograma
```python
plt.figure(figsize=(9,4))
plt.hist(zz, bins=5, histtype='bar', alpha=0.7, edgecolor = 'black', linewidth=0.2)
plt.show()
```
![png](Entrega_files/Entrega_42_0.png)
**Estadística con más estrellas** **Estadística con más estrellas**
Para el análisis de más estrellas se crea una función que busca estrellas analizando una imagen de entrada. Para el análisis de más estrellas se crea una función que busca estrellas analizando una imagen de entrada.
...@@ -457,6 +408,8 @@ def miniframe_estrella(estrellita_, fila, z_): ...@@ -457,6 +408,8 @@ def miniframe_estrella(estrellita_, fila, z_):
star = estrellita_[z_[0,fila]-len(ancho)-5:z_[0,fila]+len(ancho)+5, z_[1,fila]-len(ancho)-5:z_[1,fila]+len(ancho)+5] star = estrellita_[z_[0,fila]-len(ancho)-5:z_[0,fila]+len(ancho)+5, z_[1,fila]-len(ancho)-5:z_[1,fila]+len(ancho)+5]
#star = estrellita_[z_[0,fila]-10:z_[0,fila]+10, z_[1,fila]-10:z_[1,fila]+10]
#Retorna el array correspondiente a la imagen del miniframe #Retorna el array correspondiente a la imagen del miniframe
return radio, star return radio, star
...@@ -510,7 +463,7 @@ def estrellas_recortadas(img_es, intensidad): ...@@ -510,7 +463,7 @@ def estrellas_recortadas(img_es, intensidad):
while k in range(nz-2): while k in range(nz-2):
# 2. Es decir que vuelve aquí* # 2. Es decir que vuelve aquí*
k += 1 k += 1
r = abs(z[:,k]-z[:,k+1]) r = abs(z[:,k]-z[:,k+1])
...@@ -520,30 +473,35 @@ def estrellas_recortadas(img_es, intensidad): ...@@ -520,30 +473,35 @@ def estrellas_recortadas(img_es, intensidad):
if r_sum <= 2: if r_sum <= 2:
radio, miniestrella = miniframe_estrella(estrellita, k, z) radio, miniestrella = miniframe_estrella(estrellita, k, z)
lista_estrellas.append(miniestrella) lista_estrellas.append(miniestrella)
else: else:
continue # 1. Continua con el ciclo* continue # 1. Continua con el ciclo*
return np.array(lista_estrellas) #lista_estrellas = np.array(lista_estrellas)
return lista_estrellas
``` ```
Utilizando la imagen de 'Estrella 2' para el análisis, se encuentran las siguientes entrellas dentro.
```python ```python
lista_estrellas=estrellas_recortadas(estrella_2, 240) lista_estrellas=estrellas_recortadas(estrella_2, 240)
fig, axs = plt.subplots(2, 2, figsize=(6,6)) fig, axs = plt.subplots(2, 2, figsize=(6,6))
axs[0, 0].imshow(lista_estrellas[0,:,:], cmap='gray') axs[0, 0].imshow(lista_estrellas[0], cmap='gray')
axs[0, 0].set_title('Estrella 1') axs[0, 0].set_title('Estrella 1')
axs[0, 1].imshow(lista_estrellas[1,:,:], cmap='gray') axs[0, 1].imshow(lista_estrellas[1], cmap='gray')
axs[0, 1].set_title('Estrella 2') axs[0, 1].set_title('Estrella 2')
axs[1, 0].imshow(lista_estrellas[2,:,:], cmap='gray') axs[1, 0].imshow(lista_estrellas[2], cmap='gray')
axs[1, 0].set_title('Estrella 3') axs[1, 0].set_title('Estrella 3')
axs[1, 1].imshow(lista_estrellas[3,:,:], cmap='gray') axs[1, 1].imshow(lista_estrellas[3], cmap='gray')
axs[1, 1].set_title('Estrella 4') axs[1, 1].set_title('Estrella 4')
# Hide x labels and tick labels for top plots and y ticks for right plots. # Hide x labels and tick labels for top plots and y ticks for right plots.
...@@ -554,170 +512,161 @@ for ax in axs.flat: ...@@ -554,170 +512,161 @@ for ax in axs.flat:
![png](Entrega_files/Entrega_47_0.png) ![png](Entrega_files/Entrega_43_0.png)
Para el análisis de las anteriores estrellas se hace uso de la clase, se presenta además el ajuste gaussiano de dichas estrellas
```python
#Conversion a la clase estrella
clase_estrella=[]
for item in lista_estrellas:
clase_estrella.append(Estrella_a(item))
```
```python
#Impresión de las imagenes
#Para recordar: p = [a, b, c, x0, y0]
p1=np.array([1,0,1,5,5])
graficas=[]
parametros=[]
for i in range(0,len(clase_estrella)):
uno, dos = clase_estrella[i].ajusteGauss(p1)
graficas.append(uno)
parametros.append(dos)
#Impresion de imagenes
fig, axs = plt.subplots(2, 2, figsize=(6,6))
axs[0, 0].imshow(graficas[0], cmap='gray')
axs[0, 0].set_title('Estrella 1')
axs[0, 1].imshow(graficas[1], cmap='gray')
axs[0, 1].set_title('Estrella 2')
axs[1, 0].imshow(graficas[2], cmap='gray')
axs[1, 0].set_title('Estrella 3')
axs[1, 1].imshow(graficas[3], cmap='gray')
axs[1, 1].set_title('Estrella 4')
# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
ax.label_outer()
```
![png](Entrega_files/Entrega_46_0.png)
**Análisis estadistico**
Para encontrar la mediana, media, moda y desviacion estandar del ajuste hecho se hace lo siguiente:
```python
evaluar=np.array(parametros)
evaluar=evaluar*2*math.sqrt(2*math.log(2))
```
```python
zz=evaluar
```
```python
#Media
media=np.mean(zz)
#Mediana
mediana=np.median(zz)
#Moda
moda=stat.mode(np.round(zz,3).reshape(-1))
#Desviacion estandar con scipy
desviacion=stat.stdev(zz.reshape(-1))
#Desviacion estandar con numpy
desviacion1=zz.std()
print('Mediana: ', mediana)
print('Media: ', media)
print('Moda: ', moda)
print('Desviacion estandar 1: ', desviacion)
print('Desviacion estandar 2: ', desviacion1)
```
Mediana: 2.9331335083105
Media: 6.958263965191911
Moda: 15.497
Desviacion estandar 1: 6.4437838006164565
Desviacion estandar 2: 6.280623550702009
Para hacer el histograma
```python
#Histograma
plt.figure(figsize=(9,4))
plt.hist(zz, bins=5, histtype='bar', alpha=0.7, edgecolor = 'black', linewidth=0.2)
plt.show()
```
![png](Entrega_files/Entrega_53_0.png)
------------------------------------------------------------------
```python
estrellas_para_estadistica = estrellas_recortadas(imagen_grisss, 230)
```
```python ```python
#Para guardar el notebook a .md #Para guardar el notebook a .md
! jupyter nbconvert --to markdown ENTREGA.ipynb ! jupyter nbconvert --to markdown Entrega.ipynb
``` ```
[NbConvertApp] WARNING | pattern 'ENTREGA.ipynb' matched no files [NbConvertApp] Converting notebook Entrega.ipynb to markdown
This application is used to convert notebook files (*.ipynb) to various other [NbConvertApp] Support files will be in Entrega_files/
formats. [NbConvertApp] Making directory Entrega_files
[NbConvertApp] Making directory Entrega_files
WARNING: THE COMMANDLINE INTERFACE MAY CHANGE IN FUTURE RELEASES. [NbConvertApp] Making directory Entrega_files
[NbConvertApp] Making directory Entrega_files
Options [NbConvertApp] Making directory Entrega_files
======= [NbConvertApp] Making directory Entrega_files
The options below are convenience aliases to configurable class-options, [NbConvertApp] Making directory Entrega_files
as listed in the "Equivalent to" description-line of the aliases. [NbConvertApp] Making directory Entrega_files
To see all configurable class-options for some <cmd>, use: [NbConvertApp] Making directory Entrega_files
<cmd> --help-all [NbConvertApp] Making directory Entrega_files
[NbConvertApp] Making directory Entrega_files
--debug [NbConvertApp] Writing 13781 bytes to Entrega.md
set log level to logging.DEBUG (maximize logging output)
Equivalent to: [--Application.log_level=10]
--generate-config
generate default config file
Equivalent to: [--JupyterApp.generate_config=True]
-y
Answer yes to any questions instead of prompting.
Equivalent to: [--JupyterApp.answer_yes=True]
--execute
Execute the notebook prior to export.
Equivalent to: [--ExecutePreprocessor.enabled=True]
--allow-errors
Continue notebook execution even if one of the cells throws an error and include the error message in the cell output (the default behaviour is to abort conversion). This flag is only relevant if '--execute' was specified, too.
Equivalent to: [--ExecutePreprocessor.allow_errors=True]
--stdin
read a single notebook file from stdin. Write the resulting notebook with default basename 'notebook.*'
Equivalent to: [--NbConvertApp.from_stdin=True]
--stdout
Write notebook output to stdout instead of files.
Equivalent to: [--NbConvertApp.writer_class=StdoutWriter]
--inplace
Run nbconvert in place, overwriting the existing notebook (only
relevant when converting to notebook format)
Equivalent to: [--NbConvertApp.use_output_suffix=False --NbConvertApp.export_format=notebook --FilesWriter.build_directory=]
--clear-output
Clear output of current file and save in place,
overwriting the existing notebook.
Equivalent to: [--NbConvertApp.use_output_suffix=False --NbConvertApp.export_format=notebook --FilesWriter.build_directory= --ClearOutputPreprocessor.enabled=True]
--no-prompt
Exclude input and output prompts from converted document.
Equivalent to: [--TemplateExporter.exclude_input_prompt=True --TemplateExporter.exclude_output_prompt=True]
--no-input
Exclude input cells and output prompts from converted document.
This mode is ideal for generating code-free reports.
Equivalent to: [--TemplateExporter.exclude_output_prompt=True --TemplateExporter.exclude_input=True]
--allow-chromium-download
Whether to allow downloading chromium if no suitable version is found on the system.
Equivalent to: [--WebPDFExporter.allow_chromium_download=True]
--log-level=<Enum>
Set the log level by value or name.
Choices: any of [0, 10, 20, 30, 40, 50, 'DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL']
Default: 30
Equivalent to: [--Application.log_level]
--config=<Unicode>
Full path of a config file.
Default: ''
Equivalent to: [--JupyterApp.config_file]
--to=<Unicode>
The export format to be used, either one of the built-in formats
['asciidoc', 'custom', 'html', 'latex', 'markdown', 'notebook', 'pdf',
'python', 'rst', 'script', 'slides', 'webpdf'] or a dotted object name that
represents the import path for an `Exporter` class
Default: ''
Equivalent to: [--NbConvertApp.export_format]
--template=<Unicode>
Name of the template to use
Default: ''
Equivalent to: [--TemplateExporter.template_name]
--template-file=<Unicode>
Name of the template file to use
Default: None
Equivalent to: [--TemplateExporter.template_file]
--writer=<DottedObjectName>
Writer class used to write the results of the conversion
Default: 'FilesWriter'
Equivalent to: [--NbConvertApp.writer_class]
--post=<DottedOrNone>
PostProcessor class used to write the results of the conversion
Default: ''
Equivalent to: [--NbConvertApp.postprocessor_class]
--output=<Unicode>
overwrite base name use for output files. can only be used when converting
one notebook at a time.
Default: ''
Equivalent to: [--NbConvertApp.output_base]
--output-dir=<Unicode>
Directory to write output(s) to. Defaults to output to the directory of each
notebook. To recover previous default behaviour (outputting to the current
working directory) use . as the flag value.
Default: ''
Equivalent to: [--FilesWriter.build_directory]
--reveal-prefix=<Unicode>
The URL prefix for reveal.js (version 3.x). This defaults to the reveal CDN,
but can be any url pointing to a copy of reveal.js.
For speaker notes to work, this must be a relative path to a local copy of
reveal.js: e.g., "reveal.js".
If a relative path is given, it must be a subdirectory of the current
directory (from which the server is run).
See the usage documentation
(https://nbconvert.readthedocs.io/en/latest/usage.html#reveal-js-html-
slideshow) for more details.
Default: ''
Equivalent to: [--SlidesExporter.reveal_url_prefix]
--nbformat=<Enum>
The nbformat version to write. Use this to downgrade notebooks.
Choices: any of [1, 2, 3, 4]
Default: 4
Equivalent to: [--NotebookExporter.nbformat_version]
Examples
--------
The simplest way to use nbconvert is
> jupyter nbconvert mynotebook.ipynb --to html
Options include ['asciidoc', 'custom', 'html', 'latex', 'markdown', 'notebook', 'pdf', 'python', 'rst', 'script', 'slides', 'webpdf'].
> jupyter nbconvert --to latex mynotebook.ipynb
Both HTML and LaTeX support multiple output templates. LaTeX includes
'base', 'article' and 'report'. HTML includes 'basic' and 'full'. You
can specify the flavor of the format used.
> jupyter nbconvert --to html --template lab mynotebook.ipynb
You can also pipe the output to stdout, rather than a file
> jupyter nbconvert mynotebook.ipynb --stdout
PDF is generated via latex
> jupyter nbconvert mynotebook.ipynb --to pdf
You can get (and serve) a Reveal.js-powered slideshow
> jupyter nbconvert myslides.ipynb --to slides --post serve
Multiple notebooks can be given at the command line in a couple of
different ways:
> jupyter nbconvert notebook*.ipynb
> jupyter nbconvert notebook1.ipynb notebook2.ipynb
or you can specify the notebooks list in a config file, containing::
c.NbConvertApp.notebooks = ["my_notebook.ipynb"]
> jupyter nbconvert --config mycfg.py
To see all available configurables, use `--help-all`.
Entrega_files/Entrega_43_0.png

8.45 KiB

Entrega_files/Entrega_46_0.png

7.02 KiB

Entrega_files/Entrega_48_0.png

8.45 KiB

Entrega_files/Entrega_49_0.png

8.45 KiB

Entrega_files/Entrega_51_0.png

6.54 KiB

Entrega_files/Entrega_52_0.png

5.95 KiB

Entrega_files/Entrega_52_1.png

36.5 KiB

Entrega_files/Entrega_53_0.png

5.01 KiB

Entrega_files/Entrega_53_1.png

11.1 KiB

Entrega_files/Entrega_54_1.png

11.1 KiB

Entrega_files/Entrega_55_2.png

11.1 KiB

Entrega_files/Entrega_56_2.png

11.1 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment