Skip to content

Instantly share code, notes, and snippets.

View kenkehoe's full-sized avatar

Ken Kehoe kenkehoe

  • University of Oklahoma
  • Boulder, CO
View GitHub Profile
@kenkehoe
kenkehoe / zbrent.pro
Created October 1, 2014 20:43
Find the zero of a 1-D function up to specified tolerance with IDL.
function ZBRENT, x1, x2, FUNC_NAME=func_name, $
MAX_ITERATIONS=maxit, TOLERANCE=TOL
;+
; NAME:
; ZBRENT
; PURPOSE:
; Find the zero of a 1-D function up to specified tolerance with IDL.
; EXPLANTION:
; This routine assumes that the function is known to have a zero.
; Adapted from procedure of the same name in "Numerical Recipes" by
@kenkehoe
kenkehoe / planck.pro
Created October 1, 2014 20:35
IDL function to compute the Planck or inverse fucnction on a list [array] and return the absolute radiance or temperature value
;+
;=========================================================================================
; NAME:
; planck
;
; TYPE:
; Function
;
; DESCRIPTION:
; IDL function to compute the Planck or inverse fucnction on a list [array]
@kenkehoe
kenkehoe / dewpoint.pro
Created October 1, 2014 20:29
IDL function to calculate dewpoint from drybulb temperature and relative humidity.
;+
; Function to calculate dewpoint from drybulb temperature and
; relative humidity.
;
; :Uses:
; svp.pro
;
; :Params:
; temp : in, required, type="array"
; drybulb temperature in degree Celsius
@kenkehoe
kenkehoe / data_average.pro
Created October 1, 2014 20:27
IDL procedure to averge data to lower frequency.
;+
; IDL procedure to averge data to lower frequency. Data will be modified and retured.
; All data is converted to type FLOAT and missing values will be replaced with NaN.
;
; :Params:
; time : in, required, type=1-D array of times in IDL format
; Will return middle of averaging period in type DOUBLE
; data : in, required, type=1-D array
; Will return averaged data in type FLOAT
; return_freq : in, required, type = scalar
@kenkehoe
kenkehoe / bits.pro
Created October 1, 2014 20:21
IDL function to decode bit packed numbers or remove/add bits from/to a bit packed number.
;+
; IDL function to decode bit packed numbers or remove/add bits from/to a bit packed number.
;
; :Post:
; Only works with IDL 8.0 or greater.
;
; :Params:
; number : in, required, type = scaler integer
; The bit packed number or array of bit packed numbers to return bits or remove bits.
;
@kenkehoe
kenkehoe / armfs.R
Created October 1, 2014 20:15
Function to parse ARM NetCDF file name with R
# Purpose: Function to parse ARM NetCDF file name with R
# Inputs: String or string array/list containing filename or datastream
# (full UNIX/Linux path allowed)
#
# Returns: List with values assigned to set elements of the list.
# Default value is NULL
# - site, platform, facility, level, date, time, ext, datastream
#
# Example: nameList = armfs('/data/sgpmetE13.b1.20100301.000010.cdf')
# site = nameList$site # site equals 'sgp'
@kenkehoe
kenkehoe / datesInclude.R
Created October 1, 2014 20:13
Function to create an array of 8 digit dates.
# Purpose: Function to create an array of 8 digit dates.
# Inputs:
# _Required_ String or integer containing start date in yyyymmdd
# _Optional_ String or integer containing end date in yyyymmdd
# If ommitted, will use current sytem date
#
#
# Returns: Vector of dates from start date to end date in yyyymmdd
#
# Example: dates = datesInclude(20100301,20100303)
@kenkehoe
kenkehoe / armfs.pro
Created September 30, 2014 19:53
IDL procedure to split ARM file names into component parts
;+
; IDL procedure to split ARM file names into component parts
;
; :Params:
; file : in, required, type=String or string array
; The filename(s) or datastream(s) to parse
;
; :Keywords:
; DSNAME : out, optional, type=String or string array
; The Partial Datastream Name (ie sgpmfrsrE13)
@kenkehoe
kenkehoe / simple_arm_time.pro
Created September 30, 2014 19:44
Simple way to convert ARM time from NetCDF file into native IDL Julian Dates
; Simple way to convert ARM time from NetCDF file into native IDL Julian Dates
; kenkehoe
ncdf_id = NCDF_OPEN(file, /NOWRITE) ; Open NetCDF file to extract times
NCDF_VARGET, ncdf_id, 'base_time', base_time ; retrieve base_time
NCDF_VARGET, ncdf_id, 'time_offset', time_offset ; retrieve time_offset
NCDF_CLOSE, ncdf_id ; Close NetCDF file
; Convert epoch seconds into Julian Dates
idltime = JULDAY(1,1,1970,0,0,base_time + time_offset)
# this_is_my_gist.txt
# Created by kenkehoe
This is my gist.
There are many like it, but this one is mine.
My gist is my life.
I must master it as I must master my life.
Without me my gist is useless.
Without my gist, I am useless.