Skip to content

Instantly share code, notes, and snippets.

View GiovanniBalestrieri's full-sized avatar
🍣
When there is a shell, there is a way

UserK GiovanniBalestrieri

🍣
When there is a shell, there is a way
View GitHub Profile
@GiovanniBalestrieri
GiovanniBalestrieri / Part_Candidate_trajectory_Probl.py
Created August 9, 2016 17:26
Create the ProblemDefinition object, by passing the relevant information and callbacks to its constructor:
problem = scikits.bvp_solver.ProblemDefinition(num_ODE = 2,
num_parameters = 0,
num_left_boundary_conditions = 1,
boundary_points = (0, TF),
function = function,
boundary_conditions = boundary_conditions)
@GiovanniBalestrieri
GiovanniBalestrieri / Part_Candidate_trajectory_Fcn.py
Created August 9, 2016 17:19
Definition of the function and boundary conditions
wAltitude, wSpeed = 1,+1
def function(a , T):
return numpy.array([T[1] , # evaluate dx1/dt
(wAltitude/wSpeed)*T[0]]) # evaluate dx2/dt
def boundary_conditions(Ta,Tb):
return (numpy.array([Ta[0] - X1T0]),
numpy.array([Tb[0] - X1Tf]))
@GiovanniBalestrieri
GiovanniBalestrieri / Part_Candidate_trajectory.py
Last active August 9, 2016 17:36
Import bvp solver and set the boundary conditions
import scikits.bvp_solver
import numpy,math
# next we define bounday conditions and the final time
# next we define the important constants
X1T0 = 0
X1Tf = 11
X2T0 = 0
X2Tf = -2
TF = 10
@GiovanniBalestrieri
GiovanniBalestrieri / Example1.py
Last active August 8, 2016 15:54
counter current heat exchanger; a hot liquid enters a device and exchanges heat across a metal plate with a cold liquid traveling through the device in the opposite direction.
"""
First we import scikits.bvp_solver and numpy because the callback functions must return numpy arrays.
"""
import scikits.bvp_solver
import numpy
# next we define the important constants
T10 = 130
T2Ahx = 70
Ahx = 5
@GiovanniBalestrieri
GiovanniBalestrieri / PrintAcc.m
Created May 30, 2016 14:30
[Matlab] Plots values from a csv file assuming the format is String,value1,value2,value3,String
%%
% Enjoy
% Giovanni Balestrieri
% userk.co.uk
%
%%Insert the path of your csv file
fileID = fopen('~/accRaw.csv');
C = textscan(fileID, '%s %f %f %f %d %s','delimiter', ',', 'EmptyValue', -Inf)
N=200;
@GiovanniBalestrieri
GiovanniBalestrieri / mergeAndConvert2Arff.sh
Last active April 13, 2016 17:44
This script appends one file to the other and creates the corresponding ARFF file for Weka
#!/bin/bash
# Path variables
wekaPath="/home/userk/programs/weka-3-6-13"
csvPath="/tmp"
testSet="testSetAll.csv"
testSetWeka="testSetWeka"
echo Please, enter the initial portion of the filename you want to modify
read filename
@GiovanniBalestrieri
GiovanniBalestrieri / createFristLine.sh
Created April 13, 2016 16:43
Adds details to the csv file
sed -i '1ititleAffinity,genre,category,director,actor1,actor2,imageFeature1,imageFeature2,imageFeature3,imageFeature4,class' $csvPath/${testSet} > /dev/null
@GiovanniBalestrieri
GiovanniBalestrieri / CreateFolderAndCallCSVloaderWeka.sh
Last active April 13, 2016 17:44
Creates a new folder with the name provided before. Convert the CSV file to ARFF file
testSetWeka="testSetWeka"
#Create Folde if does not exist
mkdir -p ${wekaPath}/${filename}
relativePath=${wekaPath}/${filename}
# Create Arff file
java -cp ${wekaPath}/weka.jar weka.core.converters.CSVLoader -S "2,3" -N "last" ${csvPath}/${testSet} > ${relativePath}/${testSetWeka}.arff
@GiovanniBalestrieri
GiovanniBalestrieri / MergeAndSort.sh
Created April 13, 2016 14:26
Merges two files in one and sorts lines
trainingSet="trainingSet"
#Merge positive and negative instances in a new Training file
cat $csvPath/${file} $csvPath/${fileNo} > $csvPath/${trainingSet}.csv
#Sort lines in file
sort -R $csvPath/${trainingSet} -o $csvPath/${trainingSet}
@GiovanniBalestrieri
GiovanniBalestrieri / countLines.sh
Created April 13, 2016 14:20
Saves in variables the number of lines from a file
# Controls the length of files
echo "Controlling length of files:"
numLab=$(cat $csvPath/${file} | wc -l)
echo "Labelled: ${numLab}"
numUnLab=$(cat $csvPath/${fileNo} | wc -l)
echo "UnLabelled: ${numUnLab}"