diff --git a/ejercicios-clase-05-datos.md b/ejercicios-clase-05-datos.md
new file mode 100644
index 0000000000000000000000000000000000000000..17a581504266f8c27d95c8e88908ddd1391da030
--- /dev/null
+++ b/ejercicios-clase-05-datos.md
@@ -0,0 +1,1368 @@
+## Alumno: Christian Solis Calero.
+### Universidad Nacional Mayor de San Marcos, Lima. Perú
+
+### Ejercicio 05-01: Resolución espacial
+En observaciones astronómicas e imágenes en general, llamamos resolución espacial a la distancia angular minima a la que pueden estar dos fuentes puntuales de luz y aun poder ser reconocidas como objetos individuales.
+En el caso de la astronomía, este efecto tiene que ver con la dispersión de la luz al atravezar la atmósfera, la cual hace que una estrella, que debería en principio aparecer como una fuente puntual (pues las estrellas están muy lejos), aparezca en cambio como una mancha. Así, si dos estrellas están demasiado cerca sus manchas se superpondrán hasta el punto en que sea imposible distinguirlas como fuentes individuales (Ver imágenes en este link) Para modelar este efecto, típicamente consideramos la acción de la atmósfera como la convolución de la imagen "perfecta" (como se vería desde el espacio)
+con un kernel gaussiano. El ancho de esa función gaussiana 2D caracteriza las condiciones de observación, varía con las condiciones climáticas y para cada sitio de la Tierra.
+La resolución espacial normalmente se toma como el FWHM de la gaussiana caracteristica registrada durante una observación. Es decir, si dos estrellas están a una distancia aparente en el cielo menor que el FWHM del efecto atmosférico, la luz de ambas fuentes se mezclará después de la convolución hasta el punto de impedir reconocerlas de modo individual.
+Además, la atmósfera puede interactuar de maneras distintas con la luz de distintas longitudes de onda, de manera que el ancho de la gaussiana puede ser distinto para observaciones con diferentes filtros.
+El objetivo de esta tarea es medir de forma aproximada la resolución espacial en una noche de observación en Zapatoca, Santander (Colombia), a partir de una foto del cielo estrellado.
+
+### Ejercicio Pasos
+1. Leer la imagen almacenada en la carpeta data como un array de numpy. Ese array estará compuesto de 3 matrices, una tras otra, correspondiente a los canales R,G,B
+
+2. Combinar los 3 array para generar una versión blanco y negro de la imagen, en la cual ella consiste de una sola matriz 2D. Puede usar su intuición y prueba y error para combinar las 3 imágenes, explicando el procedimiento elegido. Esto será más interesante que usar un comando desconocido de una biblioteca sofisticada que haga las cosas como una caja negra (queremos practicar numpy)
+
+3. Recorte un sector de la imagen conteniendo una estrella individual y ajuste una gaussiana 2D simétrica a la imagen de la estrella por mínimos cuadrados, incluyendo una constante aditiva (el cielo "vacio" brilla)
+
+4. Repita este procedimiento para varias estrellas y presente alguna estadística sobre las medidas de la FWHM de las distintas gaussianas: histograma, media, mediana, desviación estándar
+
+5. Repita el mismo ejercicio sobre cada una de las bandas R,G,B separadamente y comente si observa diferencias en los resultados
+
+
+```python
+import numpy as np
+import matplotlib.pyplot as plt
+from matplotlib import image as img
+%matplotlib inline
+
+# load the image
+imagen = img.imread('data/zapatocaImage.jpeg')
+# convert image to numpy array
+imagen_array = np.asarray(imagen)
+print(imagen_array)
+plt.imshow(imagen_array)
+plt.grid(None) 
+plt.show()
+```
+
+    [[[25  6 10]
+      [25  6 10]
+      [25  6 10]
+      ...
+      [31 15 18]
+      [36 20 23]
+      [39 23 26]]
+    
+     [[26  7 11]
+      [26  7 11]
+      [26  7 11]
+      ...
+      [32 16 19]
+      [36 20 21]
+      [38 22 23]]
+    
+     [[27  8 12]
+      [27  8 12]
+      [27  8 12]
+      ...
+      [33 17 20]
+      [36 20 21]
+      [37 21 22]]
+    
+     ...
+    
+     [[24  8 21]
+      [23  7 20]
+      [23  7 20]
+      ...
+      [10  3 10]
+      [12  5 12]
+      [14  7 14]]
+    
+     [[22  6 19]
+      [23  7 20]
+      [24  8 21]
+      ...
+      [12  5 12]
+      [12  5 12]
+      [12  5 13]]
+    
+     [[20  4 17]
+      [22  6 19]
+      [25  9 22]
+      ...
+      [14  7 15]
+      [13  6 14]
+      [10  3 11]]]
+
+
+
+    
+![png](output_2_1.png)
+    
+
+
+
+```python
+#In RGB (Red-Green-Blue) channels, the intensity of the color is presented on a 0–255 scale, at first we rescaled to the [0,1] range.
+imagen_array = imagen_array/255
+
+#Creating a function for generate gray image, combinig channels, multiplying the red matrix by 0.2989,
+#the green matrix by 0.587 and the blue matrix by 0.114
+#and summing: 0.299 R + 0.587 G + 0.114 B to get each pixel of the grayscale image
+
+def gray_generator(rgb):
+    '''
+        Define function for generating gray image fromo RGB data.
+    '''
+    r, g, b = rgb[:,:,0], rgb[:,:,1], rgb[:,:,2]
+    gray = 0.2989 * r + 0.5870 * g + 0.1140 * b
+    return gray
+
+imagen_gris=gray_generator(imagen_array)
+
+plt.imshow(imagen_gris, cmap = 'gray')
+plt.grid(None) 
+plt.show()
+print(imagen_gris)
+```
+
+
+    
+![png](output_3_0.png)
+    
+
+
+    [[0.04758627 0.04758627 0.04758627 ... 0.07891333 0.09851922 0.11028275]
+     [0.05150745 0.05150745 0.05150745 ... 0.08283451 0.0976251  0.10546745]
+     [0.05542863 0.05542863 0.05542863 ... 0.08675569 0.0976251  0.10154627]
+     ...
+     [0.05593569 0.05201451 0.05201451 ... 0.02309804 0.03094039 0.03878275]
+     [0.04809333 0.05201451 0.05593569 ... 0.03094039 0.03094039 0.03138745]
+     [0.04025098 0.04809333 0.05985686 ... 0.0392298  0.03530863 0.0235451 ]]
+
+
+
+```python
+#Cutting stars
+# First knowing the size of image
+print(imagen_gris.shape)
+
+```
+
+    (789, 1184)
+
+
+
+```python
+#Working with a FIRST STAR
+#based in coordinates of gray image crop the stars
+star01 = imagen_gris[540:565,650:675] 
+plt.imshow(star01, cmap ='gray')
+plt.grid(None) 
+plt.show()
+
+```
+
+
+    
+![png](output_5_0.png)
+    
+
+
+
+```python
+#convert its negative image:
+y=np.shape(star01)
+negative_star01=np.zeros(y)
+#convert the image into its negative value.
+negative_star01=1-star01
+plt.xlabel("Value")
+plt.ylabel("pixels Frequency")
+plt.title("Negative image ")
+plt.imshow(negative_star01,cmap="gray")
+plt.grid(None) 
+plt.show()
+```
+
+
+    
+![png](output_6_0.png)
+    
+
+
+
+```python
+# Generate a 3D Plot
+# get coordinates (y,x) --- alternately see below for (x,y)
+yx_coords = np.column_stack(np.where(star01 >= 0))
+print (yx_coords)
+
+#Generating vectors of x and y coordinates from x,y array
+y=[item[0] for item in yx_coords]
+x=[item[1] for item in yx_coords]
+
+print(y)
+print(x)
+
+#Generating a vector from matrix of pixeles
+zcoords = star01.flatten()
+print (zcoords[7])
+print (zcoords)
+
+```
+
+    [[ 0  0]
+     [ 0  1]
+     [ 0  2]
+     ...
+     [24 22]
+     [24 23]
+     [24 24]]
+    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24]
+    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]
+    0.48553254901960785
+    [0.46733451 0.46341333 0.46345569 0.46345569 0.47129804 0.47129804
+     0.48553255 0.48553255 0.48553255 0.48161137 0.48161137 0.4776902
+     0.4776902  0.4776902  0.50121725 0.47773255 0.47381137 0.47381137
+     0.46204784 0.47381137 0.48949608 0.48165373 0.47040392 0.46648275
+     0.46256157 0.47125569 0.46733451 0.46341333 0.46737686 0.47129804
+     0.47521922 0.4933749  0.4933749  0.4933749  0.4933749  0.4933749
+     0.4933749  0.48945373 0.48945373 0.49729608 0.48165373 0.48165373
+     0.48165373 0.46596902 0.47773255 0.49733843 0.49341725 0.47040392
+     0.47040392 0.46648275 0.46733451 0.45949216 0.46341333 0.46737686
+     0.47914039 0.48306157 0.50905961 0.50905961 0.50905961 0.50905961
+     0.50905961 0.50905961 0.51298078 0.51298078 0.50905961 0.50121725
+     0.50910196 0.50910196 0.48165373 0.4855749  0.50125961 0.49733843
+     0.45864039 0.46256157 0.46256157 0.45557098 0.45557098 0.45949216
+     0.47125569 0.48306157 0.49090392 0.51803176 0.51803176 0.52082314
+     0.52082314 0.52474431 0.52474431 0.52866549 0.52866549 0.52082314
+     0.51690196 0.53262902 0.52870784 0.49733843 0.48949608 0.50125961
+     0.50125961 0.44687686 0.45079804 0.45864039 0.47933373 0.47788353
+     0.47485647 0.48242078 0.50292078 0.52252667 0.54870039 0.54450118
+     0.54091804 0.54085137 0.5448149  0.55269961 0.56388941 0.57362902
+     0.5570502  0.55280863 0.54622275 0.52819373 0.51003804 0.49446235
+     0.48794353 0.48619765 0.48913333 0.48363529 0.47489882 0.48717608
+     0.48964706 0.49054118 0.50202667 0.52644784 0.54605373 0.55743686
+     0.55805294 0.56097098 0.56410039 0.5723898  0.58099961 0.58709608
+     0.59246745 0.58066157 0.57669804 0.56550824 0.54590235 0.52427255
+     0.50594784 0.49785216 0.49744745 0.48913333 0.48755647 0.47882
+     0.48717608 0.49356824 0.49838353 0.5137902  0.54213255 0.56380471
+     0.56476549 0.57669804 0.59295647 0.61128118 0.63178118 0.64544196
+     0.65428745 0.65848667 0.62824706 0.61503333 0.59583216 0.5723051
+     0.54837333 0.52851412 0.51779608 0.5082502  0.48913333 0.48755647
+     0.47882    0.47792588 0.48572588 0.49446235 0.50986902 0.53635647
+     0.55988353 0.57948941 0.59966902 0.63088706 0.66675137 0.69735333
+     0.72088039 0.73364706 0.74176745 0.69494902 0.67389294 0.64313961
+     0.61064039 0.58193569 0.55350902 0.53252    0.52180196 0.49539882
+     0.48755647 0.47489882 0.47792588 0.48662    0.48913333 0.51076314
+     0.53243529 0.55685647 0.60844784 0.63210157 0.6785149  0.72541765
+     0.7682302  0.79870549 0.81579804 0.82229922 0.7752451  0.74937373
+     0.70091176 0.65362196 0.61505098 0.57971843 0.5497149  0.52840549
+     0.49932    0.49147765 0.47971412 0.49450471 0.50230471 0.50594784
+     0.52644784 0.55204118 0.57367098 0.63210157 0.66566392 0.73055333
+     0.80049373 0.85854392 0.89496431 0.91322902 0.92247922 0.8754251
+     0.83112    0.77409059 0.70909216 0.65483647 0.60729333 0.56552627
+     0.54074275 0.51108353 0.49932    0.48363529 0.49842588 0.50873922
+     0.52252667 0.54027765 0.57254118 0.59719804 0.65922941 0.7064102
+     0.78512941 0.86732275 0.93366235 0.9731098  0.98700627 0.98773137
+     0.96141294 0.90898745 0.83493216 0.76164431 0.69462196 0.63834235
+     0.58481176 0.55173882 0.53068941 0.51892588 0.49932    0.49446235
+     0.50873922 0.52644784 0.54812    0.58543451 0.6114749  0.68748706
+     0.73745922 0.82009961 0.9041902  0.96963569 0.98935059 0.9916949
+     0.9916949  0.9916949  0.95653098 0.87508039 0.79273569 0.7213451
+     0.65605098 0.5962549  0.56184078 0.54496627 0.52928157 0.50995373
+     0.50622588 0.51658157 0.52644784 0.54027765 0.58935569 0.63500196
+     0.68235137 0.76094392 0.86990275 0.95237412 0.98935059 0.9916949
+     0.99403922 0.99290941 0.9905651  0.98010039 0.92884706 0.84650235
+     0.75663569 0.6811549  0.6186098  0.57631098 0.55280863 0.52928157
+     0.51779608 0.50230471 0.51658157 0.52644784 0.54117176 0.58402667
+     0.63108078 0.69435059 0.7678498  0.87518941 0.95629529 0.9916949
+     0.99521137 0.99642588 0.99759804 0.99759804 0.98943529 0.9418251
+     0.8532149  0.76128196 0.68648392 0.62506863 0.58807451 0.55398078
+     0.53045373 0.52261137 0.50230471 0.51266039 0.52252667 0.53838039
+     0.58010549 0.61931725 0.69345647 0.76000745 0.85954706 0.93948078
+     0.98478902 0.99642588 0.99529608 0.99299412 0.99529608 0.98717569
+     0.93677412 0.84771686 0.75348196 0.67472039 0.61912353 0.58370627
+     0.53829608 0.5186902  0.51476902 0.49838353 0.50986902 0.51860549
+     0.5335651  0.56834196 0.60755373 0.66212941 0.72661412 0.8143902
+     0.89779804 0.95610196 0.98600353 0.99529608 0.99529608 0.98491608
+     0.95277922 0.8911702  0.80648118 0.72490392 0.6554349  0.59838784
+     0.56923608 0.54221725 0.5186902  0.51084784 0.49054118 0.50202667
+     0.51076314 0.52180157 0.55798627 0.58794784 0.63589569 0.68514275
+     0.76183804 0.83000824 0.89453529 0.94073765 0.96846392 0.97703137
+     0.92997725 0.8911702  0.82216588 0.75392902 0.69773373 0.6476349
+     0.59568118 0.56143608 0.55604706 0.53045373 0.51476902 0.47877765
+     0.49026314 0.50292078 0.51395922 0.54230157 0.56834196 0.61799373
+     0.65895137 0.70468196 0.75000784 0.79533373 0.83963882 0.86529882
+     0.87503843 0.85151137 0.80256    0.74576627 0.70060941 0.67032784
+     0.63753294 0.59184471 0.56179882 0.53252    0.50507176 0.49516314
+     0.47093529 0.48242078 0.49115725 0.50611686 0.53053804 0.55265725
+     0.59176    0.61978196 0.6521298  0.67158431 0.69730431 0.7325949
+     0.7575298  0.76447804 0.7601098  0.72522392 0.68068314 0.65355529
+     0.63593137 0.60737804 0.5672302  0.5329851  0.50507176 0.48546588
+     0.48339961 0.46701412 0.47457843 0.48723608 0.49827451 0.52269569
+     0.5448149  0.54866941 0.58061255 0.60786706 0.62732157 0.6502502
+     0.68941961 0.71597373 0.72522392 0.69732863 0.67145725 0.6375502
+     0.61915882 0.60343216 0.57605098 0.53428392 0.49890902 0.51291412
+     0.49722941 0.50692667 0.48161137 0.48161137 0.48161137 0.49426902
+     0.51779608 0.53348078 0.54089373 0.55355137 0.56919373 0.58694471
+     0.60262941 0.61920824 0.63097176 0.63489294 0.60744471 0.60352353
+     0.60262941 0.58099961 0.54873608 0.55775059 0.55293529 0.51764471
+     0.49842588 0.49450471 0.48666235 0.47376902 0.47376902 0.47376902
+     0.48642667 0.50603255 0.52171725 0.53305137 0.53697255 0.54873608
+     0.56139373 0.57707843 0.58302353 0.59086588 0.59478706 0.59086588
+     0.58536784 0.58492078 0.56026392 0.53030235 0.53332941 0.52827843
+     0.49831686 0.49842588 0.49450471 0.48666235 0.46592667 0.46592667
+     0.46984784 0.4776902  0.49426902 0.50603255 0.52184392 0.52459294
+     0.52940824 0.53725059 0.54206588 0.54990824 0.55355137 0.55355137
+     0.5641851  0.55382941 0.55382941 0.53219961 0.5008302  0.50223804
+     0.50228039 0.4743851  0.50234706 0.49450471 0.48666235 0.46200549
+     0.46592667 0.46984784 0.4776902  0.48553255 0.4933749  0.51108353
+     0.50967569 0.51359686 0.51355451 0.51792275 0.52435725 0.52827843
+     0.53219961 0.53219961 0.52043608 0.52184392 0.51404392 0.4900698
+     0.48732078 0.49034784 0.46682078 0.49842588 0.49450471 0.48274118
+     0.46345569 0.46596902 0.47381137 0.47773255 0.48165373 0.48165373
+     0.48553255 0.48553255 0.48553255 0.49034784 0.49539882 0.50575451
+     0.51359686 0.51751804 0.51751804 0.50183333 0.50692667 0.50995373
+     0.49034784 0.48646902 0.48949608 0.47773255 0.4933749  0.48553255
+     0.4776902 ]
+
+
+
+```python
+#Creating plot with the data
+# Import libraries
+from mpl_toolkits import mplot3d
+import numpy as np
+import matplotlib.pyplot as plt
+
+# Creating dataset
+z =zcoords 
+ 
+# Creating figure
+fig = plt.figure(figsize = (10, 7))
+ax = plt.axes(projection ="3d")
+ 
+# Creating plot
+ax.scatter3D(x, y, z, color = "green")
+plt.title("simple 3D scatter plot")
+
+ 
+# show plot
+plt.show()
+
+```
+
+
+    
+![png](output_8_0.png)
+    
+
+
+### Distribución Gaussiana
+![image.png](attachment:image.png)
+
+
+```python
+#tomar solo los pixeles de la línea que pasa por la mitad de la estrella
+#Valores de intensidad de pixeles correpondiente al valor 12 del array X
+import numpy as np
+import matplotlib.pyplot as plt
+plt.style.use('seaborn-whitegrid')
+%matplotlib inline
+
+Zlinea=[]
+Ylinea=[]
+j=0
+for i in range(z.size-1):
+    if x[i]==12:
+        Zlinea =np.insert(Zlinea, j, z[i])
+        j=j+1
+j=0        
+for i in range(z.size-1):
+    if x[i]==12:
+        Ylinea =np.insert(Ylinea, j, y[i])
+        j=j+1
+        
+plt.plot(Ylinea, Zlinea, 'o', color='blue');        
+plt.xlabel('Position in image')
+plt.ylabel('Intensity of pixels')
+        
+print(Zlinea.size)
+print(Zlinea)
+print(Ylinea.size)
+print(Ylinea)
+
+print(z.size)
+
+
+
+
+```
+
+    25
+    [0.4776902  0.48945373 0.51298078 0.52866549 0.56388941 0.58709608
+     0.65428745 0.73364706 0.81579804 0.91322902 0.98700627 0.9916949
+     0.99403922 0.99642588 0.99529608 0.99529608 0.96846392 0.86529882
+     0.7575298  0.71597373 0.63097176 0.59086588 0.55355137 0.52827843
+     0.51359686]
+    25
+    [ 0.  1.  2.  3.  4.  5.  6.  7.  8.  9. 10. 11. 12. 13. 14. 15. 16. 17.
+     18. 19. 20. 21. 22. 23. 24.]
+    625
+
+
+
+    
+![png](output_10_1.png)
+    
+
+
+
+```python
+#Generating an histogram of the pixel values
+plt.hist(Zlinea, bins = 'auto')
+plt.xlabel('Intervals of Intensity of pixels')
+plt.ylabel('Number of pixels')
+plt.show()
+
+```
+
+
+    
+![png](output_11_0.png)
+    
+
+
+
+```python
+import numpy as np
+import matplotlib.pyplot as plt
+from numpy import asarray as ar, exp, sqrt
+from scipy.optimize import curve_fit
+
+YLa = ar(Ylinea)
+ZLa = ar(Zlinea)
+
+n = len(ZLa)  ## <---
+mean = sum(ZLa*YLa)/n
+sigma = sqrt(sum(ZLa*(YLa-mean)**2)/n)
+
+def gaus(x,a,mu,sigma):
+    return a*exp(-(x-mu)**2/(2*sigma**2))
+
+popt,pcov = curve_fit(gaus,YLa,ZLa) # first estimation of the parameters
+print('Fitted parameters:')
+print(popt)
+
+xx = np.linspace( 0, 25, 100 )  ## <--- calculate against a continuous variable
+
+fig = plt.figure()
+plt.plot(YLa, ZLa, "ob", label = "Measured")
+plt.plot(xx,gaus(xx,*popt),'r',label='Fit')  ## <--- plot against the contious variable
+plt.xlim(0, 25)
+plt.ylim(0.4, 1.1)
+plt.xticks(YLa)
+plt.title("Fitting gaussian on pixel data of star image")
+plt.xlabel("Position in image")
+plt.ylabel("Intensity of pixels")
+plt.grid()
+plt.legend()
+plt.savefig('Fitting2D.png')
+plt.show()
+```
+
+    Fitted parameters:
+    [ 0.97409685 12.68315045  8.98659285]
+
+
+
+    
+![png](output_12_1.png)
+    
+
+
+
+```python
+import numpy as np
+from scipy.optimize import curve_fit
+import matplotlib.pyplot as plt
+from mpl_toolkits.mplot3d import Axes3D
+from numpy import asarray as ar, exp, sqrt
+
+# The two-dimensional domain of the fit.
+xmin, xmax, nx = np.min(x), np.max(x), np.size(x)
+ymin, ymax, ny = np.min(y), np.max(y), np.size(y)
+#xTa, yTa = np.linspace(xmin, xmax, nx), np.linspace(ymin, ymax, ny)
+xTa = ar(x)
+yTa = ar(y)
+
+XTa, YTa = np.meshgrid(xTa, yTa)
+
+#sigma_YTa = sqrt(sum(z*(yTa-12)**2)/(np.size)
+sigma_YTa = sqrt(sum(z*(yTa-12)**2)/625)
+
+
+# Our function to fit is a two-dimensional Gaussians
+def gaussian(x, y, x0, y0, xalpha, yalpha, A):
+    return A * np.exp( -0.5*((x-x0)/xalpha)**2 -0.5*((y-y0)/yalpha)**2)
+
+# A list of the Gaussian parameters: x0, y0, xalpha, yalpha, A
+
+gprms=[12,12,sigma_YTa,sigma_YTa,1]
+
+# Standard deviation of normally-distributed noise to add in generating
+# our test function to fit.
+noise_sigma = 0.1
+
+# The function to be fit is Z.
+
+ZTa = gaussian(XTa, YTa, 12,12,sigma_YTa,sigma_YTa,1)
+
+print(np.size(ZTa))
+print(np.size(XTa))
+# Plot the 3D figure of the gaussian function.
+fig = plt.figure()
+ax = fig.gca(projection='3d')
+ax.plot_surface(XTa, YTa, ZTa, cmap=cm.viridis,rstride=3, cstride=3, linewidth=1, antialiased=True)
+ax.set_zlim(0,np.max(ZTa))
+
+cset = ax.contourf(XTa, YTa, ZTa, zdir='z', offset=-0.95, cmap=cm.viridis)
+
+# Adjust the limits, ticks and view angle
+ax.set_zlim(-0.95,1.0)
+ax.set_zticks(np.linspace(0,1,5))
+ax.view_init(27, -21)
+
+plt.show()
+
+
+```
+
+    390625
+    390625
+
+
+
+    
+![png](output_13_1.png)
+    
+
+
+
+```python
+from scipy.optimize import leastsq
+#print(ZTa)
+#print(np.size(ZTa))
+ZTr = [z]
+for i in range(z.size-1):
+    ZTr = np.append(ZTr, [z], 0)
+
+#print(ZTr)
+#print(np.size(ZTr))
+
+parameters=[12,12,sigma_YTa,sigma_YTa,1]
+
+def gaussian3D(params,x, y):
+    #z = params[4] * np.exp( -((x-params[0])/params[2])**2 -((y-params[1])/params[3])**2)
+    z = params[4] * np.exp( -0.5*((x-params[0])/(params[2]))**2 -0.5*((y-params[1])/(params[3]))**2)
+    return z
+zOriginal=gaussian3D(parameters,xTa,yTa)
+
+
+def error3D(params,x,y,z, cols, rows):
+    errors = (gaussian3D(params,x,y)-z)
+    return errors.reshape(cols*rows)
+
+obtained_error=error3D(parameters,xTa,yTa, z, 25, 25)
+
+print('The average error between gaussian model and data is:')
+print(np.average(obtained_error))
+
+best3D,sus3D = leastsq(error3D, parameters, args = (xTa,yTa, z, 25, 25))
+
+print('Fitted parameters:')
+print(best3D)
+Fitted_parameters=[12.31,12.31,16.59,16.59,0.84]
+
+#Using the fitted parameters for obtaining pixel values
+zFitted=gaussian3D(best3D,xTa,yTa)
+
+#Showing the imagen of star with original values, values according to gaussian function and values according to fitted parameters
+plt.subplot(1, 3, 1)
+star01_01 = z.reshape(25, 25)
+plt.title('original')
+plt.imshow(star01_01,cmap="gray")
+plt.grid(None) 
+plt.subplot(1, 3, 2)
+star01_02 = zOriginal.reshape(25, 25)
+plt.title('Gaussian')
+plt.imshow(star01_02,cmap="gray")
+plt.grid(None) 
+plt.subplot(1, 3, 3)
+star01_03 = zFitted.reshape(25, 25)
+plt.title('Fitted')
+plt.imshow(star01_03,cmap="gray")
+plt.grid(None) 
+plt.show()
+
+
+```
+
+    The average error between gaussian model and data is:
+    -0.33308824487283
+    Fitted parameters:
+    [12.31003544 12.64869953 11.72961613 11.65211515  0.84817359]
+
+
+
+    
+![png](output_14_1.png)
+    
+
+
+
+```python
+#Working with a SECOND STAR
+#based in coordinates of gray image crop the stars
+star02 = imagen_gris[307:326,618:637] 
+plt.imshow(star02, cmap ='gray')
+plt.grid(None) 
+plt.show()
+```
+
+
+    
+![png](output_15_0.png)
+    
+
+
+
+```python
+# Generate a 3D Plot
+# Import libraries
+from mpl_toolkits import mplot3d
+import numpy as np
+import matplotlib.pyplot as plt
+
+# get coordinates (y,x) --- alternately see below for (x,y)
+yx_coords2 = np.column_stack(np.where(star02 >= 0))
+
+#Generating vectors of x and y coordinates from x,y array
+y2=[item[0] for item in yx_coords2]
+x2=[item[1] for item in yx_coords2]
+
+#Generating a vector from matrix of pixeles
+zcoords2 = star02.flatten()
+
+# Creating dataset
+z2 =zcoords2 
+ 
+# Creating figure
+fig = plt.figure(figsize = (10, 7))
+ax = plt.axes(projection ="3d")
+ 
+# Creating plot
+ax.scatter3D(x2, y2, z2, color = "green")
+plt.title("Simple 3D scatter plot for Star 2")
+ 
+# show plot
+plt.show()
+
+```
+
+
+    
+![png](output_16_0.png)
+    
+
+
+
+```python
+from scipy.optimize import leastsq
+
+xTa2 = ar(x2)
+yTa2 = ar(y2)
+
+#Calculating parameters
+xTa2_average=np.average(xTa2)
+yTa2_average=np.average(yTa2)
+
+print(np.size(xTa2))
+print(np.size(yTa2))
+print(np.size(z2))
+print(np.average(yTa2))
+
+sigma_yTa2 = sqrt(sum(z2*(yTa2-9)**2)/361)
+
+parameters2=[9,9,sigma_yTa2,sigma_yTa2,1]
+
+def gaussian3D(params,x, y):
+    z = params[4] * np.exp( -0.5*((x-params[0])/(params[2]))**2 -0.5*((y-params[1])/(params[3]))**2)
+    return z
+zOriginal2=gaussian3D(parameters2,xTa2,yTa2)
+
+
+def error3D(params,x,y,z, cols, rows):
+    errors = (gaussian3D(params,x,y)-z)
+    return errors.reshape(cols*rows)
+
+obtained_error2=error3D(parameters2,xTa2,yTa2, z2, 19, 19)
+
+print('The average error between gaussian model and data is:')
+print(np.average(obtained_error2))
+
+
+best3D2,sus3D2 = leastsq(error3D, parameters2, args = (xTa2,yTa2, z2, 19, 19))
+
+print('Fitted parameters:')
+print(best3D2)
+
+
+#Using the fitted parameters for obtaining pixel values
+zFitted2=gaussian3D(best3D2,xTa2,yTa2)
+
+#Showing the imagen of star with original values, values according to gaussian function and values according to fitted parameters
+plt.subplot(1, 3, 1)
+star02_01 = z2.reshape(19, 19)
+plt.title('original')
+plt.imshow(star02_01,cmap="gray")
+plt.grid(None) 
+plt.subplot(1, 3, 2)
+star02_02 = zOriginal2.reshape(19, 19)
+plt.title('Gaussian')
+plt.imshow(star02_02,cmap="gray")
+plt.grid(None) 
+plt.subplot(1, 3, 3)
+star02_03 = zFitted2.reshape(19, 19)
+plt.title('Fitted')
+plt.imshow(star02_03,cmap="gray")
+plt.grid(None) 
+plt.show()
+
+```
+
+    361
+    361
+    361
+    9.0
+    The average error between gaussian model and data is:
+    0.0009788588989791745
+    Fitted parameters:
+    [9.15491345e+00 8.91137409e+00 8.54234925e+00 8.65681230e+00
+     2.59259824e-03]
+
+
+
+    
+![png](output_17_1.png)
+    
+
+
+
+```python
+#Working with a THIRD STAR
+#based in coordinates of gray image crop the stars
+star03 = imagen_gris[369:388,441:460] 
+plt.imshow(star03, cmap ='gray')
+plt.grid(None) 
+plt.show()
+```
+
+
+    
+![png](output_18_0.png)
+    
+
+
+
+```python
+# Generate a 3D Plot
+# Import libraries
+from mpl_toolkits import mplot3d
+import numpy as np
+import matplotlib.pyplot as plt
+
+# get coordinates (y,x) --- alternately see below for (x,y)
+yx_coords3 = np.column_stack(np.where(star03 >= 0))
+
+#Generating vectors of x and y coordinates from x,y array
+y3=[item[0] for item in yx_coords3]
+x3=[item[1] for item in yx_coords3]
+
+#Generating a vector from matrix of pixeles
+zcoords3 = star03.flatten()
+
+# Creating dataset
+z3 =zcoords3 
+ 
+# Creating figure
+fig = plt.figure(figsize = (10, 7))
+ax = plt.axes(projection ="3d")
+ 
+# Creating plot
+ax.scatter3D(x3, y3, z3, color = "green")
+plt.title("Simple 3D scatter plot for Star 3")
+ 
+# show plot
+plt.show()
+
+```
+
+
+    
+![png](output_19_0.png)
+    
+
+
+
+```python
+from scipy.optimize import leastsq
+
+xTa3 = ar(x3)
+yTa3 = ar(y3)
+
+#Calculating parameters
+xTa3_average=np.average(xTa3)
+yTa3_average=np.average(yTa3)
+
+print(np.size(xTa3))
+print(np.size(yTa3))
+print(np.size(z3))
+print(np.average(yTa3))
+
+sigma_yTa3 = sqrt(sum(z3*(yTa3-9)**2)/361)
+
+parameters3=[9,9,sigma_yTa3,sigma_yTa3,1]
+
+def gaussian3D(params,x, y):
+    z = params[4] * np.exp( -0.5*((x-params[0])/(params[2]))**2 -0.5*((y-params[1])/(params[3]))**2)
+    return z
+zOriginal3=gaussian3D(parameters3,xTa3,yTa3)
+
+
+def error3D(params,x,y,z, cols, rows):
+    errors = (gaussian3D(params,x,y)-z)
+    return errors.reshape(cols*rows)
+
+obtained_error3=error3D(parameters3,xTa3,yTa3, z3, 19, 19)
+
+print('The average error between gaussian model and data is:')
+print(np.average(obtained_error2))
+
+
+best3D3,sus3D3 = leastsq(error3D, parameters3, args = (xTa3,yTa3, z3, 19, 19))
+
+print('Fitted parameters:')
+print(best3D3)
+
+
+#Using the fitted parameters for obtaining pixel values
+zFitted3=gaussian3D(best3D3,xTa3,yTa3)
+
+#Showing the imagen of star with original values, values according to gaussian function and values according to fitted parameters
+plt.subplot(1, 3, 1)
+star03_01 = z3.reshape(19, 19)
+plt.title('original')
+plt.imshow(star03_01,cmap="gray")
+plt.grid(None) 
+plt.subplot(1, 3, 2)
+star03_02 = zOriginal3.reshape(19, 19)
+plt.title('Gaussian')
+plt.imshow(star03_02,cmap="gray")
+plt.grid(None) 
+plt.subplot(1, 3, 3)
+star02_03 = zFitted2.reshape(19, 19)
+plt.title('Fitted')
+plt.imshow(star02_03,cmap="gray")
+plt.grid(None) 
+plt.show()
+
+```
+
+    361
+    361
+    361
+    9.0
+
+
+
+```python
+import numpy as np
+import matplotlib.pyplot as plt
+from numpy import asarray as ar, exp, sqrt
+from scipy.optimize import curve_fit
+
+XTa = ar(x)
+YTa = ar(y)
+ZTa = ar(z)
+
+print(np.size(XTa))
+print(np.size(YTa))
+print(np.size(ZTa))
+
+n = len(ZTa)  ## <---
+mean_YTa = sum(ZTa*YTa)/n
+sigma_YTa = sqrt(sum(ZTa*(YTa-mean_YTa)**2)/n)
+
+mean_XTa = sum(ZTa*XTa)/n
+sigma_XTa = sqrt(sum(XTa*(XTa-mean_XTa)**2)/n)
+
+A=1/(2*np.pi*sigma_XTa*sigma_YTa)
+
+def gauss3D(p,x,y):
+    exponente = -((x-p[0])**2 + (y-p[1])**2) / (2*p[2]**2)
+    z = p[3] * np.exp(exponente) + p[4]
+    return z
+parameters==[12,12,10,1,0]
+#parameters=[mean_XTa,mean_YTa,sigma_XTa,1,0]
+Zfit=gauss3D(parameters,XTa,YTa)
+
+# Creating figure
+fig = plt.figure(figsize = (10, 7))
+ax = plt.axes(projection ="3d")
+# Creating plot
+ax.scatter3D(XTa,YTa, Zfit, color = "green")
+plt.title("simple 3D scatter plot")
+
+plt.show()
+
+
+
+
+```
+
+    625
+    625
+    625
+
+
+
+    ---------------------------------------------------------------------------
+
+    ValueError                                Traceback (most recent call last)
+
+    <ipython-input-169-fc74f28461a1> in <module>
+         35 ax = fig.gca(projection='3d')
+         36 ax.plot_surface(XTa,YTa, Zfit, rstride=3, cstride=3, linewidth=1, antialiased=True,
+    ---> 37                 cmap=cm.viridis)
+         38 cset = ax.contourf(XTa,YTa, Zfit, zdir='z', offset=-0.15, cmap=cm.viridis)
+         39 
+
+
+    ~/.local/lib/python3.7/site-packages/mpl_toolkits/mplot3d/axes3d.py in plot_surface(self, X, Y, Z, norm, vmin, vmax, lightsource, *args, **kwargs)
+       1554 
+       1555         if Z.ndim != 2:
+    -> 1556             raise ValueError("Argument Z must be 2-dimensional.")
+       1557         if np.any(np.isnan(Z)):
+       1558             cbook._warn_external(
+
+
+    ValueError: Argument Z must be 2-dimensional.
+
+
+
+    
+![png](output_21_2.png)
+    
+
+
+
+```python
+#Working with the model
+#Compute average of pixels
+z_average=np.average(z)
+print("The average values is: ", z_average)
+#Compute standard deviation of pixels
+z_sd=np.std(z)
+print("The standard deviation is: ",z_sd)
+#Compute first term of gaussian equation
+A=1/(z_sd*((2*np.pi)**0.5))
+
+#Compute number of pixels
+print("The number of pixels in the image is: ",z.size)
+
+#Compute higuer and lower values
+z_max=np.max(z)
+z_min=np.min(z)
+print("The higuer value for a pixel is: ",z_max)
+print("The lower value for a pixel is: ",z_min)
+
+x_average=np.average(x)
+y_average=np.average(y)
+print(x_average)
+print(y_average)
+xy = np.array([x,y])
+cov_xy = np.cov(xy)
+print(cov_xy)
+
+x_stad=np.std(x)
+print(x_stad)
+y_stad=np.std(y)
+print(y_stad)
+```
+
+    The average values is:  0.5972459312941176
+    The standard deviation is:  0.1470436454930245
+    The number of pixels in the image is:  625
+    The higuer value for a pixel is:  0.9975980392156861
+    The lower value for a pixel is:  0.44687686274509797
+    12.0
+    12.0
+    [[52.08333333  0.        ]
+     [ 0.         52.08333333]]
+    7.211102550927978
+    7.211102550927978
+
+
+
+```python
+import numpy as np
+import matplotlib.pyplot as plt
+from matplotlib import cm
+from mpl_toolkits.mplot3d import Axes3D
+
+# Our 2-dimensional distribution will be over variables X and Y
+N = 625
+X = x
+Y = y
+X, Y = np.meshgrid(X, Y)
+
+# Mean vector and covariance matrix
+mu = np.array([12, 12])
+Sigma = np.array([[ 52.083 , 0], [0,  52.083]])
+
+# Pack X and Y into a single 3-dimensional array
+pos = np.empty(X.shape + (2,))
+pos[:, :, 0] = X
+pos[:, :, 1] = Y
+
+def multivariate_gaussian(pos, mu, Sigma):
+    """Return the multivariate Gaussian distribution on array pos.
+    pos is an array constructed by packing the meshed arrays of variables
+    x_1, x_2, x_3, ..., x_k into its _last_ dimension.
+
+    """
+    n = mu.shape[0]
+    Sigma_det = np.linalg.det(Sigma)
+    Sigma_inv = np.linalg.inv(Sigma)
+    N = np.sqrt((2*np.pi)**n * Sigma_det)
+    # This einsum call calculates (x-mu)T.Sigma-1.(x-mu) in a vectorized
+    # way across all the input variables.
+    fac = np.einsum('...k,kl,...l->...', pos-mu, Sigma_inv, pos-mu)
+
+    return np.exp(-fac / 2) / N
+
+# The distribution on the variables X, Y packed into pos.
+Z = multivariate_gaussian(pos, mu, Sigma)
+#Z = [z]
+#for i in range(z.size-1):
+#    Z = np.append(Z, [z], 0)
+print(Z)
+print(Z.size)
+print(X.size)
+print(Y.size)
+
+
+# Create a surface plot and projected filled contour plot under it.
+fig = plt.figure()
+ax = fig.gca(projection='3d')
+#ax.plot_surface(X, Y, Z, rstride=3, cstride=3, linewidth=1, antialiased=True, cmap=cm.viridis)
+
+cset = ax.contourf(X, Y, Z, zdir='z', offset=-0.15, cmap=cm.viridis)
+
+
+
+# Adjust the limits, ticks and view angle
+ax.set_zlim(-0.15,0.02)
+ax.set_zticks(np.linspace(0,1.0,5))
+ax.view_init(27, -21)
+
+plt.show()
+```
+
+    [[0.00019248 0.00024003 0.00029365 ... 0.00029365 0.00024003 0.00019248]
+     [0.00019248 0.00024003 0.00029365 ... 0.00029365 0.00024003 0.00019248]
+     [0.00019248 0.00024003 0.00029365 ... 0.00029365 0.00024003 0.00019248]
+     ...
+     [0.00019248 0.00024003 0.00029365 ... 0.00029365 0.00024003 0.00019248]
+     [0.00019248 0.00024003 0.00029365 ... 0.00029365 0.00024003 0.00019248]
+     [0.00019248 0.00024003 0.00029365 ... 0.00029365 0.00024003 0.00019248]]
+    390625
+    390625
+    390625
+
+
+
+    
+![png](output_23_1.png)
+    
+
+
+
+```python
+import matplotlib.pyplot as plt
+from scipy.optimize import curve_fit
+import pylab as py
+
+# Mean vector and covariance matrix
+mu = np.array([12, 12])
+Sigma = np.array([[52.08333333,  0.        ], [ 0.,         52.08333333]])
+
+# Our 2-dimensional distribution will be over variables X and Y
+N = z.size
+X = [x]
+Y = [y]
+Z = [z]
+for i in range(z.size-1):
+    X = np.append(X, [x], 0)
+for i in range(z.size-1):
+    Y = np.append(Y, [y], 0)
+
+for i in range(z.size-1):
+    Z = np.append(Z, [z], 0)
+
+# Create a surface plot and projected filled contour plot under it.
+fig = plt.figure()
+ax = fig.gca(projection='3d')
+ax.plot_surface(X, Y, Z, rstride=3, cstride=3, linewidth=1, antialiased=True,
+                cmap=cm.viridis)
+
+cset = ax.contourf(X, Y, Z, zdir='z', offset=-0.15, cmap=cm.viridis)
+
+# Adjust the limits, ticks and view angle
+ax.set_zlim(-0.15,0.2)
+ax.set_zticks(np.linspace(0,0.2,5))
+ax.view_init(27, -21)
+
+plt.show()
+
+```
+
+
+    
+![png](output_24_0.png)
+    
+
+
+
+```python
+import matplotlib.pyplot as plt
+from mpl_toolkits.mplot3d import Axes3D
+
+import numpy as np
+from scipy.stats import multivariate_normal
+
+
+# Need an (N, 2) array of (x, y) pairs.
+#xy = np.column_stack([x.flat, y.flat])
+xy = np.array([x,y])
+
+mu = np.array([12.0, 12.0])
+
+sigma = np.array([7.2111, 7.2111])
+covariance = np.diag(sigma**2)
+
+z = multivariate_normal.pdf(xy, mean=mu, cov=covariance)
+
+# Reshape back to a (30, 30) grid.
+z = z.reshape(x.shape)
+
+fig = plt.figure()
+ax = fig.add_subplot(111, projection='3d')
+ax.plot_surface(x,y,z)
+#ax.plot_wireframe(x,y,z)
+
+plt.show()
+```
+
+
+    ---------------------------------------------------------------------------
+
+    ValueError                                Traceback (most recent call last)
+
+    <ipython-input-81-f50a188af34c> in <module>
+         15 covariance = np.diag(sigma**2)
+         16 
+    ---> 17 z = multivariate_normal.pdf(xy, mean=mu, cov=covariance)
+         18 
+         19 # Reshape back to a (30, 30) grid.
+
+
+    ~/.local/lib/python3.7/site-packages/scipy/stats/_multivariate.py in pdf(self, x, mean, cov, allow_singular)
+        526         x = self._process_quantiles(x, dim)
+        527         psd = _PSD(cov, allow_singular=allow_singular)
+    --> 528         out = np.exp(self._logpdf(x, mean, psd.U, psd.log_pdet, psd.rank))
+        529         return _squeeze_output(out)
+        530 
+
+
+    ~/.local/lib/python3.7/site-packages/scipy/stats/_multivariate.py in _logpdf(self, x, mean, prec_U, log_det_cov, rank)
+        473 
+        474         """
+    --> 475         dev = x - mean
+        476         maha = np.sum(np.square(np.dot(dev, prec_U)), axis=-1)
+        477         return -0.5 * (rank * _LOG_2PI + log_det_cov + maha)
+
+
+    ValueError: operands could not be broadcast together with shapes (2,625) (2,) 
+
+
+
+```python
+def function(params, x, y):
+    '''
+        Define función gaussiana generalizada en dos dimensiones.
+    '''
+    A = params[0]
+    sigma_x = params[1]
+    sigma_y = params[2]
+    x0 = params[3]
+    y0 = params[4]
+    theta = params[5]
+    K = params[6]
+    
+    a = np.cos(theta)**2/(2*sigma_x**2) + np.sin(theta)**2/(2*sigma_y**2)
+    b = -np.sin(2*theta)/(4*sigma_x**2) + np.sin(2*theta)/(4*sigma_y**2)
+    c = np.sin(theta)**2/(2*sigma_x**2) + np.cos(theta)**2/(2*sigma_y**2)
+
+    z = A*np.exp( - (a*(x-x0)**2 + 2*b*(x-x0)*(y-y0) + c*(y-y0)**2)) + K
+    return z
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+import matplotlib.pyplot as plt
+from scipy.optimize import curve_fit
+import pylab as py
+
+def func(x, A, mu, sigma):
+    return (A * np.exp(-1.0 * (x - mu)**2 / (2 * sigma**2)))
+
+normalized_z = z / np.linalg.norm(z)
+#Define the data to be fit with some noise:
+y = func(z, A, z_average, z_sd)
+np.random.seed(1729)
+y_noise = 0.2 * np.random.normal(size=z.size)
+ydata = y + y_noise
+#plt.plot(z, ydata, 'b-', label='data')
+#kwargs = dict(alpha=0.5, bins=100, density=True, stacked=True)
+plt.hist(z, bins='auto', density=1, alpha=0.5)
+#plt.hist(z, **kwargs)
+
+#Fit for the parameters of the function func:
+popt, pcov = curve_fit(func, z, ydata)
+print(popt)
+plt.plot(z, func(z, *popt), 'g--',
+         label='fit: A=%5.3f, Average=%5.3f, Sigma=%5.3f' % tuple(popt))
+plt.xlabel('x')
+plt.ylabel('y')
+plt.legend()
+plt.show()
+
+
+```
+
+    [2.71531586 0.59576577 0.14279336]
+
+
+
+    
+![png](output_26_1.png)
+    
+
+
+
+```python
+from scipy.stats import norm
+
+_, bins, _ = plt.hist(z, 20, density=1, alpha=0.5)
+
+mu, sigma = norm.fit(z)
+
+best_fit_line = norm.pdf(bins, mu, sigma)
+
+plt.plot(bins, best_fit_line)
+
+```
+
+
+
+
+    [<matplotlib.lines.Line2D at 0x7fdbf5129978>]
+
+
+
+
+    
+![png](output_27_1.png)
+    
+
+
+# def function(params, x, y):
+    A = params[0]
+    sigma_x = params[1]
+    sigma_y = params[2]
+    x0 = params[3]
+    y0 = params[4]
+    theta = params[5]
+    K = params[6]
+    
+    a = np.cos(theta)**2/(2*sigma_x**2) + np.sin(theta)**2/(2*sigma_y**2)
+    b = -np.sin(2*theta)/(4*sigma_x**2) + np.sin(2*theta)/(4*sigma_y**2)
+    c = np.sin(theta)**2/(2*sigma_x**2) + np.cos(theta)**2/(2*sigma_y**2)
+
+    z = A*np.exp( - (a*(x-x0)**2 + 2*b*(x-x0)*(y-y0) + c*(y-y0)**2)) + K
+    return z
+
+
+```python
+def Error(tpl,x,y,z):
+    # x son las posiciones reportadas
+    # y son los valores medidos en las posiciones x
+    # tpl es una tupla con los parámetros para calcular el modelo
+    zmodel = function(tpl,x,y)
+    errors = (zmodel.flatten() - z.flatten())
+    return errors
+```
+
+
+```python
+def calculator(star,p0,Error):
+    x = np.arange(0,star.shape[0],1)
+    y = np.arange(0,star.shape[1],1)
+    x, y = np.meshgrid(y,x)
+    best,suss = leastsq(Error, p0, args=(x,y,star))
+    return best,x,y
+```
+
+
+```python
+
+
+# First, we retrieve all coordinates of pixels of white colour in the image
+
+# Define the white colour we want to find - remember OpenCV uses BGR ordering
+white = [0,0,0]
+# Get X and Y coordinates of all white pixels
+X,Y = np.where(np.all(imagen==white,axis=2))
+print(X,Y)
+
+# For gray image
+color = (0)
+pixels = np.argwhere(imagen_gris == color)
+print(pixels)
+color = [0]
+X,Y = np.where(np.all(imagen_gris == color,axis=2))
+print(X,Y)
+#from PIL import Image
+
+#im_crop = im.crop((60, 20, 400, 200))
+
+#star01 = imagen_grays[540:570,650:675] 
+#plt.imshow(star, cmap = 'gray')
+#plt.show()
+```
diff --git a/output_10_1.png b/output_10_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..8825520c24102a8305e47b1955313b54fd9bb830
Binary files /dev/null and b/output_10_1.png differ
diff --git a/output_11_0.png b/output_11_0.png
new file mode 100644
index 0000000000000000000000000000000000000000..8d79e3d2611bcf639de4f068b340b9bf4d0bbf36
Binary files /dev/null and b/output_11_0.png differ
diff --git a/output_12_1.png b/output_12_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..5375a0b0d2fb6ce04c7257e2baf195dfd2df40ad
Binary files /dev/null and b/output_12_1.png differ
diff --git a/output_13_1.png b/output_13_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..9541991d37f7d5c8029ec4b429fe00ddb23c9a86
Binary files /dev/null and b/output_13_1.png differ
diff --git a/output_14_1.png b/output_14_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..a938f05a1df6bd475af434348798a3f5ae716841
Binary files /dev/null and b/output_14_1.png differ
diff --git a/output_15_0.png b/output_15_0.png
new file mode 100644
index 0000000000000000000000000000000000000000..9de21d7664a486fb2bff4504446f404c899b972e
Binary files /dev/null and b/output_15_0.png differ
diff --git a/output_16_0.png b/output_16_0.png
new file mode 100644
index 0000000000000000000000000000000000000000..032edf417565be15f4c7146a2c7a852879293d8e
Binary files /dev/null and b/output_16_0.png differ
diff --git a/output_17_1.png b/output_17_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..9761d51b415bacd8e580b36b9591d23c89562054
Binary files /dev/null and b/output_17_1.png differ
diff --git a/output_18_0.png b/output_18_0.png
new file mode 100644
index 0000000000000000000000000000000000000000..23df3a716915d0090b435f2db002fb4893f3687f
Binary files /dev/null and b/output_18_0.png differ
diff --git a/output_19_0.png b/output_19_0.png
new file mode 100644
index 0000000000000000000000000000000000000000..00361dec828589bc1649ff946a85c17eba297729
Binary files /dev/null and b/output_19_0.png differ
diff --git a/output_21_2.png b/output_21_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..94137d04e04195975cedf0103d190b836784a098
Binary files /dev/null and b/output_21_2.png differ
diff --git a/output_23_1.png b/output_23_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..0f17117f923cd5a0cb99ac2e441e16e7396adc7e
Binary files /dev/null and b/output_23_1.png differ
diff --git a/output_24_0.png b/output_24_0.png
new file mode 100644
index 0000000000000000000000000000000000000000..77ad39365167c89eba70c61c0c098a8bd725fec6
Binary files /dev/null and b/output_24_0.png differ
diff --git a/output_26_1.png b/output_26_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..2b1727271028f0339a69e41bc7d6e858293364f7
Binary files /dev/null and b/output_26_1.png differ
diff --git a/output_27_1.png b/output_27_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..a71235ef4b46717625c8926386f3ce61e5b99f80
Binary files /dev/null and b/output_27_1.png differ
diff --git a/output_2_1.png b/output_2_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..28a4fe8dd5e00be49e9a19694671deac5d42836c
Binary files /dev/null and b/output_2_1.png differ
diff --git a/output_3_0.png b/output_3_0.png
new file mode 100644
index 0000000000000000000000000000000000000000..c541c146c23bd6f99f8c06248b4c51437bcc98b2
Binary files /dev/null and b/output_3_0.png differ
diff --git a/output_5_0.png b/output_5_0.png
new file mode 100644
index 0000000000000000000000000000000000000000..fde9e1fe3da6d1808ce4c53847bb47aef174cc32
Binary files /dev/null and b/output_5_0.png differ
diff --git a/output_6_0.png b/output_6_0.png
new file mode 100644
index 0000000000000000000000000000000000000000..af17997b03dfac1174857f0e8f456e506f639463
Binary files /dev/null and b/output_6_0.png differ
diff --git a/output_8_0.png b/output_8_0.png
new file mode 100644
index 0000000000000000000000000000000000000000..bba908b1b85372ca01c0d734626d53a950b98a17
Binary files /dev/null and b/output_8_0.png differ