Skip to content

Commit

Permalink
Data Science Machine learning la Serena Summer School and thermodynam…
Browse files Browse the repository at this point in the history
…ics 2023
  • Loading branch information
fbientrigo committed Mar 6, 2024
1 parent 2234b77 commit 0df366a
Show file tree
Hide file tree
Showing 243 changed files with 224,132 additions and 0 deletions.
Binary file removed 1y2s - Compu 2 - 2018/0813 pruebacompu1.zip
Binary file not shown.
15 changes: 15 additions & 0 deletions 1y2s - Compu 2 - 2018/0813 pruebacompu1/parte2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#Parte 2

from potencial import get_yuka#Importo la funcion definida antes en el programa anterior
import matplotlib.pylab as plt
import numpy as np


#Ahora se nos pide hacer un grafico, una curva de este, defino r como un array
rad = np.linspace(0.01,0.1,100)

plt.plot(rad,get_yuka(rad))
plt.show()



20 changes: 20 additions & 0 deletions 1y2s - Compu 2 - 2018/0813 pruebacompu1/parte3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from potencial import get_yuka
import matplotlib.pyplot as plt
import numpy as np

#Ahora se nos pide hacer un grafico, una curva de este, defino r como un array
rad = np.linspace(0.01,0.1,100)

plt.figure()

for j in range(10):

k = 10 * (j+1)
potenciales = get_yuka(rad,k)
plt.plot(rad,potenciales)
plt.legend(str(k))



plt.show()

22 changes: 22 additions & 0 deletions 1y2s - Compu 2 - 2018/0813 pruebacompu1/potencial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import numpy as np

g = 1
k = 1
m = 1

#Calculo r en base a las coordenadas, esto lo hago con otra funcion creada
def get_r(x,y):
return np.sqrt(x*2 + y*2)

#Defino la funcion que utilizare
def get_yuka(r,k=1):
return -g**2 * (np.exp(-k*m*r))/(r)

def calcularYuka():
x_pos = input("Ingrese coordenada x: ")
y_pos = input("Ingrese coordenada y: ")

r = get_r(x_pos,y_pos)
yukaw = get_yuka(r)

print(yukaw)
Binary file removed 1y2s - Compu 2 - 2018/1009 prueba.zip
Binary file not shown.
11 changes: 11 additions & 0 deletions 1y2s - Compu 2 - 2018/1009 prueba/diferencias.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Las diferencias entre los resultados se deben a como los metodos
se aproximan al problema
Mientras la regla del trapezoide creo figuras en base a la base
de la funcion, eje x; la regla de simpson tomo una aproximacion
de acercar curvas cuadraticas a mi funcion;
en el caso de simpson llego a 7.599999 excelente resultado y aproximacion
mientras que la del trapezoide por efecto de la baja cantidad de figuras
acabo con numeros de más, 7.640000; si hacemos la integral en papel..
es 7.6

-fabian trigo|
108 changes: 108 additions & 0 deletions 1y2s - Compu 2 - 2018/1009 prueba/fabiantrigo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@

# coding: utf-8

# In[24]:

import numpy as np
import matplotlib.pyplot as plt

datosP = np.loadtxt("/tmp/guest-cxgqie/Fabian Trigo/PRS_Valpo_WRF.dat")
datosT = np.loadtxt("/tmp/guest-cxgqie/Fabian Trigo/TMP_Valpo_WRF.dat")
#Pasamos de Kelvin a Celsius
datosT = datosT - 273.15


#Creamos el grafico de calor
plt.imshow(datosT,origin="lower")
plt.title("Grafico Temperatura de Valparaiso")
plt.xlabel("Tiempo en horas")
plt.ylabel("Altura")
#Hacemos una barrita para saber a que temperatura se refiere cada color
plt.colorbar(label="Celcius")
plt.show()


# In[25]:

plt.imshow(datosP,origin="lower")
plt.title("Presion del Aire en Valparaiso")
plt.xlabel("Tiempo en horas")
plt.ylabel("Altura")
plt.colorbar(label="Hecto Pascales")
plt.show()


# In[31]:

def densidadA(P,T):
R = 286.9
return P/(R*T)

#Calculo la densidad del aire con todos los datos, tendra las mismas dimensiones
densidad = densidadA(datosP,datosT)

#Y ya es crear el grafico de calor simplemente y darle los nombres
plt.imshow(densidad,origin="lower")
plt.title("Densidad del Aire en Valparaiso")
plt.xlabel("Tiempo en horas")
plt.ylabel("Altura")
plt.colorbar(label="hPa*J / kg")
plt.show()


# In[41]:

#Funcion a integrar
def funcion(x):
return x**3 + 3*x - 1.2

#Limites de integracion
lim_inf = 0.0
lim_sup = 2.0
#Cantidad de figuras
N = 10

#Definiremos el grosor de cada figura
dx = (lim_sup - lim_inf)/N


# In[42]:

#Integrar por trapezoide
#I(a,b) = dx(0.5(f(a)+f(b) + sumatoria desde i=1 a i=N-1)

#Realizaremos la sumatoria y requeriremos donde guardar
suma = 0.0 #Sera nuestro place holder
for i in range(1,N): #Es sumatoria de 1 a N-1
suma += funcion(lim_inf + i*dx) #f(a+i*dx)
IntegralT = dx*(0.5*(funcion(lim_inf)+funcion(lim_sup))+suma)

print("Integral por trapezoides: ", IntegralT)


# In[59]:

#Integrar por Simpson
#I(a,b) = 1/3 * dx((f(a)+f(b) +
# 4*sum(k=1 to N/2)(f(a + (2k-1)*dx))
# + 2*sum(k=1 to N/2 -1)(f(a + 2*k*dx))
suma1 = 0.0
for i in range(1, int(N/2)+1): #Ira de 1 a N/2 siendo entero
suma1 += funcion(lim_inf + (2*i -1 )*dx)

suma2 = 0.0
for i in range(1, int(N/2)): #De 1 a N/2 - 1
suma2 += funcion(lim_inf + 2*i*dx)

trd = 0.3333333 #Calculo de antes un 1/3 aprox
I=trd*dx*(funcion(lim_inf)+funcion(lim_sup)+4.0*suma1+2.0*suma2)



print("Integral por Simspn: ",I)


# In[ ]:



210 changes: 210 additions & 0 deletions 1y2s - Compu 2 - 2018/1009 prueba/fabiantrigo_prueba2.ipynb

Large diffs are not rendered by default.

File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added 2y2s- MMF/2023 - tutoria/Churchill 9ed.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
94 changes: 94 additions & 0 deletions u_LaSerena/10_Docker/0812g - Docker Intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
Lightweight technology of virtualization
- dosent use Hypervisor
- I want to only focus in the application

## docker image
- Base image (OS)
- build basic programs and drives on it (more images)

## concepts
- Dockerfile:
- Plain text that contains docker commands
- allows creation of image
- Docker Hub and Registries:
- Where to share the image as a repository
- Harbor (open source)
- Azure Container Registry
- AWS
- Artifact Registry

# Dockerfile
Example of running commands in docker and how to run a node shell command
```dockerfile
FROM node:17-alpine
WORKDIR /app
COPY package*.json .
RUN npm install --production
COPY . .
RUN npm run build
CMD ["node","dist/index.js"]
```

## Why docker
Its professional and may be mandatory
- **Reproducible Research**
- AI and Machine Learning
- *Field Study*
- Bioinformatics
- High performance computing
- *Scientific Simulations*
- **Collaboration**
- *Cloud Computing*
- Custom Software
- *Legacy Software Preservation*

# Running docker
`docker run hello-world` verify good instalation
`docker pull nginx` gets the image

```bash
docker run -d -p 80:80 -v $(pwd):/usr/share/nginx/html --name my_container nginx
```

- `-d` detach,
- `-p 80:80` map port 80 of image to 80 port of system
- `-v $(pwd):/usr/share/nginx/html` mounts this file into the directory

___
# Basic usage
`docker images`
see the available images

`docker inspect nginx`
Gives me information about the image called `nginx`

`docker tag nginx my_custom_nginx:latest`
Rename an image

`docker rmi nginx`
Remove the docker image to free disk space

`docker history nginx`

## Manage Containers
`docker ps`
Show all container running
- add `-a` for all container, even stopped ones

`docker start <container_id_or_image>`
Start and stopped cotainer

`docker stop <container_ir_or_image>`

`docker rm <container-id_or_name>`
after stopping a container

`docker container prune`
**Dangerous**
Remove all stopped containers

`docker logs <container_id_name>`


___

37 changes: 37 additions & 0 deletions u_LaSerena/10_Docker/0812g2 - Docker File Practice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
We can add to the docker file a command for when it instarts
```dockerfile
RUN pip install pandas matplotlib
CMD ["jupyter","notebook"]
```

- All Dockerfile starts with base image
`FROM jupyter/minimal-notebook`

- Environment configuration
`END NODE_ENV=production`

- Copying files
`COPY . /app`

- Running commands, install packages and many
`RUN npm install`

- Exposing ports
`EXPOSE 8889`
- indicates that the container listens that port

- Container Execution Command or Entry point
`CMD ["node","app.js"]`
Command when the container starts

___
We run this in command line

- Build the image
`docker build -t jupyter-server .`
This will create a docker image

- Running the image
`docker run -p 8889:8889 jupyter-server`
we use an exposed port

3 changes: 3 additions & 0 deletions u_LaSerena/10_Docker/0812g3 - Docker Compose.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Kubernets (higher level, special configs)
- Docker swamp
- Docker Compose
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 0df366a

Please sign in to comment.