# ******* DEFINCICIONES ***************** import pyodide_js await pyodide_js.loadPackage('pandas') import pandas as pd await pyodide_js.loadPackage('matplotlib') import matplotlib.pyplot as plt import math as mt import numpy as np # await pyodide_js.loadPackage('requests') # from datetime import datetime # import time # import shutil # from pyscript import fetch #import datetime as dt # ************** DIBUJOS ******************* # from pyscript import display # ************** datos ******************* ma=1 ri=100 radamo=0.03 deini=0.2 veini=1.8 # ************** Calculos ******************* periodo=2*3.14159*mt.sqrt(ma/ri) omega = mt.sqrt(ri/ma) # print (ma,ri,radamo,deini,veini,periodo,omega) # print() t_values = [] y_values = [] t1_values = [] y1_values = [] # print(" valores t, y") for t in np.arange(0, 15,0.1): y = (deini*np.cos(omega*t) + (((veini+radamo*omega*deini)/omega)*np.sin(omega*t)))*mt.exp(-1*radamo*omega*t) t_values.append(t) y_values.append(y) # print(t,y) plt.xlabel('TIEMPO (seg)') plt.ylabel('DEFORMACION (cm)') plt.title('FREE VIBRATION RESPONSE OF A BUILDING') plt.plot(t_values, y_values) plt.show() # print(" lista t") # print(t_values) # print(" lista y") # print(y_values) for t in np.arange(0, 15,0.1): y1 = deini*np.cos(omega*t) + veini/omega*np.sin(omega*t) t1_values.append(t) y1_values.append(y1) # print(t,y1) plt.plot(t1_values, y1_values) plt.show() # ************** INPUTS ******************* # print ("Por favor ingrese su nombre: ") # nombre = input () # nombre = input("Por favor ingrese su nombre: ") #Acá el usuario ya sabe qué debe ingresar # print("Bienvenido al sistema ", nombre, ". Gracias por usar mi programa.", sep="") # now = dt.datetime.now() # now2 = str(now) # dfecha2 = 19-len(now2) # if len(now2)>19: # now2 = now2[:dfecha2] # print('\t FECHA DE HOY : ' + now2) # print() # print(terremotos) # esto se activa para ver el formato Json #cont=0 # contador # ******* TITULOS ***************** # print(" 1 2 3 4 5 6 7 ") # print("123456789012345678901234567890123456789012345678901234567890123456789012345678") # print('NUM ' + ' MAGN ' + '\t FECHA ' + '\t\t\t LUGAR ' ) # ******* CONSTRUCCION DE TABLA ***************** # for terremoto in terremotos ["features"]: # TOMA valores # coordenadas = terremoto["geometry"]["coordinates"] # lugar = terremoto["properties"]["place"] # magnitude = terremoto["properties"]["mag"] # fecha = terremoto["properties"]["time"] # cont=cont+1 # CONTADOR # fecha100 = datetime.fromtimestamp(fecha/1000) # TRANSFORMACION DE DATESTAMP A FECHA NORMAL # fecha200 = str(fecha100) # dfecha = 19-len(fecha200) # if len(fecha200)>19: # fecha200 = fecha200[:dfecha] # cont2 = str(cont) # cont3 = cont2.zfill(5) # magnitude=round(magnitude,1) # mag2 = str(magnitude) # if len(mag2)==1: # mag2 = mag2 +".0" # lug2 = str(lugar) # lug3 = lug2[0:42] # magnitude = "%.2f" % magnitude # redondea la magnitud a 2 decimales # ******* IMPRIME LA TABLA ***************** # print(cont3 + ' '+ mag2 + ' ' + fecha200 + ' ' + lug3) # lugar = lugar.zfill(28) # LLENA DE EL LUGAR DE 28 CARACTERES # str(len(lugar[0:27])) str(len(cont3)) str(len(mag2)) str(lugar[0:28]) # esto nos da la longitud de l string # print(type(fecha100)) # esto es para saber que tipo de variable tengo, terremoto es dict, lugar es src, coordenadas es list y magnitude es float #3 separar en listas # Convertir las cadenas a listas # coordenadas2 = coordenadas.split() # magnitudes2 = magnitude.split() # Crear un DataFrame #df = pd.DataFrame({ # 'coordenadas': coordenadas2, # 'magnitude': magnitudes2 #}) # num = 3 # print("lugar (i)") # for i in range (11): # print(i, lugar[i]) # 4) FIN # Convertir el diccionario a un DataFrame # import pandas as pd # df = pd.DataFrame.from_dict(terremotos) # print(df) # 2) FIN # df = pd.DataFrame.from_dict(terremotos) # print(df) # ******* FIN ***************** # ******* FIN ***************** # print(" SENO - COSENO - SENO + COSENO ") # x= np.arange(0,30,0.1) # y=np.sin(x) # plt.plot (x,y) # plt.show() # x= np.arange(0,30,0.1) # y=np.cos(x) # plt.plot (x,y) # plt.show() # x= np.arange(0,30,0.1) # y=np.cos(x) +np.sin(x) # plt.plot (x,y) # plt.show() # fig1 =plt.plot (x,y) # display(fig1, target="mpl")