Skip to content

Instantly share code, notes, and snippets.

View hovedguy's full-sized avatar

Hoved hovedguy

View GitHub Profile
@hovedguy
hovedguy / A-01_2D_matplotlib_ graph.py
Last active October 14, 2018 09:24
To create 2d graphs from matplotlib
## 01A. TO PLOT A SINGLE GRAPH AS OUTPUT - 2D (should prefer 01B)
#
import matplotlib.pyplot as plt
# data creation
x = list(i for i in range(5, 11))
print(f"x value: {x}")
y1 = list(i ** 2 for i in range(5, 11))
print(f"y1 value: {y1}")
@hovedguy
hovedguy / A-02_numpy_array.py
Last active October 15, 2018 10:56
To read 2d arrays from a file with numpy (better way to do with pandas)
## 01. TO READ 2D ARRAY - SPACE DELIMITED
# ref: https://www.datacamp.com/community/tutorials/python-numpy-tutorial#make
# file:
Value1 Value2 Value3
0.1 0.2 0.3
0.4 0.5 NA
NA 0.8 0.9
0.2 0.3 0.4
# code:
@hovedguy
hovedguy / A-03_get_pi_til_defined_decimal_place.py
Created October 14, 2018 09:30
To get value of pi till defined decimal place
from math import pi
def get_pi():
try:
n = int(input("Enter decimal places: "))
if n < 17:
import os
inp_dir = r"C:\SUVOPAM_local\Dolwin5\02_Aba\slamming\und23"
double_prec = False
n_cpu = 16
searchInpFiles = False
multi_job_names = ['x', 'y', 'z'] # if searchInpFiles = False
if searchInpFiles:
@hovedguy
hovedguy / B-02_element_node_write.py
Created October 14, 2018 09:33
writes element id, node id and co-ordinates to a file in same directory as model db
'''writes element id, node id and co-ordinates to a file in same directory as model db'''
def exp(model_name, part_name):
m = mdb.models[model_name]
p = m.parts[part_name]
el_set = p.allSets
el_key_list = el_set.keys()
mfile = open("el_node_db.txt", "w+")
for x in range(len(el_key_list)):
e = el_key_list[x]
model_name = "aba1" # enter model name
part_name = "PART-1" # enter part name
diagonal = [(272.190002,117.444252,543.400024), (272.339996,117.050499,543.400024)] # diagonal of searching volume
tol = 1e-6 # default tolerance value for finding the nodes 1e-6
def node_dict_creator(model_name_, part_name_):
'''returns node_dict which holds node label against its co-ordinates'''
node_dict = {}
m = mdb.models[model_name_]
model_name = "aba1" # enter model name
part_name = "PART-1" # enter part name
def exp(model_name_, part_name_):
m = mdb.models[model_name_]
f = m.rootAssembly.features
f_dict = {}
for i in f.keys():
try:
redundant = f[i].xValue # to clean PART number key from selection
import regionToolset
model_name = "aba1" # model name
instance_name = "PART-1-1"
def exp(model_name_, instance_name_):
m = mdb.models[model_name_]
a = m.rootAssembly
## MPC CONSTRAIN CREATION B/W RP AND COLLECTION OF NODES
from part import *
from material import *
from section import *
from assembly import *
from step import *
from interaction import *
from load import *
from mesh import *
from optimization import *
from job import *
import pandas as pd
import quandl, math
quandl.ApiConfig.api_key = 'Ssn1muRqsyT5SBvP3wDm'
df = quandl.get("WIKI/GOOGL")
# print(df.head())
# print(df.shape)
df = df[['Adj. Open', 'Adj. High', 'Adj. Low', 'Adj. Close', 'Adj. Volume']]
df['HL_PCT'] = (df['Adj. High'] - df['Adj. Low']) / df['Adj. Close'] * 100.0