Skip to content

Instantly share code, notes, and snippets.

@flare9x
flare9x / ehlers_cycles.jl
Created December 18, 2018 12:18
John Ehlers Market Cycles
##############################
# TO DO
# 5-2. Dominant Cycle Measured by Zero Crossings of the Band-Pass Filter - Validated against TS up to DC portion
# 8-3. Autocorrelation Periodogram - Validated against TS up to Normalization
# Outstanding
# 9-1 onwards
##############################
using Statistics
@flare9x
flare9x / API-579_general_metal_loss_level_1_2.R
Last active April 5, 2024 18:44
Fitness-For-Service API 579-1/ASME FFS-1, June, 2016 - PART 4 – ASSESSMENT OF GENERAL METAL LOSS
#################################################################
# Fitness-For-Service API 579-1/ASME FFS-1, June, 2016
# PART 4 – ASSESSMENT OF GENERAL METAL LOSS
#################################################################
# Methods:
# 1. Point Thickness Readings (PTR)
# 2. Critical Thickness Profile (CTP)
# By: Andrew Bannerman 12.18.2018
@flare9x
flare9x / rectangle_vessel_stresses_tmin.R
Last active March 21, 2024 14:07
ASME Section VIII – Division 1 - Appendix 13
# ASME VIII 2017
# 13-4 DESIGN OF VESSELS OF NONCIRCULAR CROSS SECTION
# Figure 13-2(a) Vessels of Rectangular Cross Section
# Selection = Sketch (1)
#--- Begin single script - validate calculations against example problem
# ASME PTB-4-2013 - Example Problem - Header Box Data
# Material = SA516, Grade 70 (S)
@flare9x
flare9x / required_structural_thickness.jl
Last active February 10, 2024 21:04
Calculating the Required Structural Thickness of Pipe Using Beam Stress Theory
#############################################################################################
# Calculating the Required Structural Thickness of Pipe Using Beam Stress Theory
#############################################################################################
# Input parameters
P = 850 # pressure
Do = 12.75 # outside diameter
S = 17900 # code allowable stress
E = .85 # weld joint efficieny
W = 1.0
Y = 0.4
@flare9x
flare9x / PSMSL_tide_data.R
Created October 19, 2019 06:11
PSMSL Tide Data
# PSMSL Tide Data
library(lubridate)
library(data.table)
# Individual File Reading
# Read the gauge file list (location, names)
file_list = read.csv("C:/Users/Andrew.Bannerman/Desktop/PSMSL Tidal Data/rlr_monthly/rlr_monthly/filelist.txt",stringsAsFactors = FALSE, header=F,sep=";")
# Read 1x data set - oldest station with 1807 start date (sets the initial date)
@flare9x
flare9x / rolling_RS_hurst.jl
Created June 12, 2018 01:49
Rolling R/S Hurst Exponent
####################################################################################
# Rolling Hurst
####################################################################################
# initialize outputs
m = Array{Float64}(length(d_es_close),0)
log_n_out = m
out_RS = m
# Set lags (range or specific)
@flare9x
flare9x / sind_cosd.jl
Created May 18, 2023 05:19
sine and cosine
# julia language
using Plots
# n = degrees
n = 360
sin_out = fill(NaN,n)
cos_out = fill(NaN,n)
for i = 1:size(sin_out,1)
# julia function - sind,cosd = sin/cos in degrees
sin_out[i] = sind(i)
cos_out[i] = cosd(i)
@flare9x
flare9x / api_579_pitting_assessment_level_1.R
Last active May 1, 2023 10:34
API 579 Pitting Assessment Level 1
# API 579 Pitting Assessment
# Level 1
# Piping Assessment
#################################################################
# Fitness-For-Service API 579-1/ASME FFS-1, June, 2016
# PART 6 – ASSESSMENT OF PITTING CORROSION
#################################################################
# Pipe Data
@flare9x
flare9x / rectangle_vessel_one_stay_plate.R
Last active August 23, 2022 16:23
# Rectangle Vessels With Stay Plate - ASME VIII # Figure 13-2(a) - Sketch (7)
# Rectangle Vessels With Stay Plates
# Figure 13-2(a) - Sketch (7)
# 13-9 STAYED VESSELS OF RECTANGULAR CROSS SECTION
# [FIGURE 13-2(A) SKETCHES (7) AND (8)]
#--- Begin single Script
# Material SA-516 Gr 70 (S)
S = 20000
@flare9x
flare9x / rsi.jl
Last active July 13, 2022 02:40
rsi indicator
"""
```
Relative strength index
rsi(x::Array{T}; n::Int64=14)::Array{Float64}
Indicator weights the average gain and loss correctly not averaging over 0 values. Accounts for NaN in the calculation
using NaNMath; nm=NaNMath
```
"""
function rsi(x::AbstractArray{T}; n::Int64=14)::Array{Float64} where {T<:Real}
dims = size(x,1)