Skip to content

Instantly share code, notes, and snippets.

@potass13
potass13 / tkym_stat.py
Created December 16, 2014 20:25
Convert xls-files of population statistics for Takayama to a csv-file
# -*- cording: utf-8 -*-
#
# filename: tkym_stat.py
#
import os
import sys
import wget
import xlrd
if len(sys.argv) != 1:
@potass13
potass13 / pade.c
Created December 16, 2014 22:53
Pade approxmation
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX_N 13
int factorial(int n){
int i, tmp = 1;
@potass13
potass13 / ell_odrfit.py
Created December 16, 2014 23:27
Fit ellipse used by scipy.odr
import numpy as np
from scipy import odr
from matplotlib.patches import Ellipse
import matplotlib.pyplot as plt
def f(B, x):
return ((x[0]/B[0])**2+(x[1]/B[1])**2-1.)
if __name__ == '__main__':
a = 2.
@potass13
potass13 / solve_inv.bas
Last active January 25, 2016 14:07
solve for x : inv(x) = val
Function inv(x As Double) As Double
' Define involute function
inv = Tan(x) - x
End Function
Function solve_inv(val As Double) As Double
' Solve for x : inv(x) = val
Dim x0 As Double, x1 As Double
Dim eps As Double, pi As Double
@potass13
potass13 / demag.c
Last active August 26, 2018 16:05
Calculate demagnetization coefficient.
/*
demag.c
*/
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define LENG 100
static double PI = 3.141592653582;
# coding: utf-8
import numpy as np
from scipy import signal
import matplotlib.pyplot as plt
import rainflow
def f(x):
return 0.2+0.4*np.sin(x)-0.6*np.cos(2*x)+1.2*np.sin(8*x)
def main():
@potass13
potass13 / rainflow.bas
Last active March 17, 2021 17:37
rainflow (P/V Diff)
Option Explicit
Sub rainflow()
Dim mem_arr() As Variant
Dim peakdata() As Variant
Dim ex_data() As Variant
Dim ws As Worksheet
Dim i As Long
Dim j As Long
Dim k As Long
##########################################################
#
# name : binning.py
# usage : binnig analysis for ALPS
# edit : potass
# Last Update : 2014-10-18
#
##########################################################
import sys, os
##########################################################
#
# name : replace.py
# usage : xml to csv for ALPS
# edit : potass
# Last Update : 2014-10-18
#
##########################################################
import sys, os
##########################################################
#
# name : checkSS.py
# usage : checkSteadyState for ALPS based on ALPS wiki,
# http://comp-phys.org/mediawiki/index.php/Documentation:Monte_Carlo_Equilibration
# edit : potass
# Last Update : 2014-10-19
#
##########################################################