Home IDL routines Weather Risk Attribution Forecast Publications

Dáithí Stone's Climate Site    
A Library of IDL Programs    


This page lists a compilation of IDL code made available for public use.
Please report any bugs to dastone@runbox.com.
We welcome any modified or new routines you would like to add. We would like to know if you have found any of these routines useful.

Maintained by: Dáithí Stone (dastone@runbox.com)
Last modified: 18 September 2018 by idl_lib_html.pro.
Number of routines: 154
Contributors: Myles Allen, Benjamin Grandey, Daithi Stone, Edward Wiebe
Licence: The IDL routines available from this page are free for non-commercial use under the terms of this Creative Commons License unless otherwise noted in the routine.


Links to categories
 Array   C20C dtos v2   Calendar   File system 

 Geographical   Graphics   Input/Output   Mathematics 

 Miscellaneous   Optimal Detection Package v2.1 

 Optimal Detection Package v3.1.2   Physics   Statistics   Strings 

 Time series analysis 


Complete packages
The following packages are available with all required files contained in a single archive file.
  • Full IDL routine library
    The full collection of code provided in this library, omitting the Optimal Detection Package v2.1 code.
    Click here for a .tar archive.
    Click here for a .zip archive.
    These dependencies external to IDL are also required: https://github.com/axismaps/colorbrewer/tree/master/export/gpl, ncdump, cdo, ncks, wget.
  • Optimal Detection v3.1.2
    This is the current version of the optimal detection code, which performs optimal fingerprinting in a multiple linear regression. This code works in both IDL and GDL.
    Click here for a .tar archive.
    Click here for a .zip archive.
  • Optimal Detection v2.1
    This is on old version of the optimal detection, which performs optimal fingerprinting in a multiple linear regression. This code works in both IDL and PV-WAVE, and is the last version to work in PV-WAVE.
    Click here for a .tar archive.
    Click here for a .zip archive.
  • C20C dtos v2
    The collection of code used for generating the sea surface temperature and sea ice concentration input data used in the C20C+ D&A project simulations.
    Click here for a .tar archive.
    Click here for a .zip archive.
    These dependencies external to IDL are also required: cdo, ncdump, ncks, wget.


News
  • 2017-06-09: This library of IDL routines was permanently moved from http://www.csag.uct.ac.za/~daithi/idl_lib.
  • See bottom for more update information.
Recent updates


Array
  • add_dim
    This function returns an array with extra dimensions added, filled with copies of the original array.
    Modified 2018-08-13
  • ARRAY_TOTAL
    This function does more flexible array integration than IDL's total.
    Modified 2018-08-28
  • DIMENSION
    This function returns the dimension of an array. It returns 0 if the input variable is scalar.
    Written 2000-07-05
  • INTERVAL_CALC
    This function calculates a convenient maximum value for a data set.
    Modified 2001-01-11
  • ISIN
    This function will tell you whether or not a token is contained in an array.
    Modified 2011-02-22
  • LENGTH
    Find the length of a vector (or the longest dimension of an array).
    Written 2002-06-09
  • Nearest_Index
    Search for the index of the value nearest to x in the vector mx.
    Written 2002-11-29
  • NONUNIQ
    Return the subscripts of the non-unique elements in an array.
    Written 2002-07-23
  • SHUFFLE
    This function shuffles the values in an array.
    Modified 2011-11-06
  • Slice
    Slice a two dimensional array out of a three dimensional array.
    Written 2000-06-09


C20C dtos v2
  • c20c_dtos_v2_adjust_sic
    This procedure adjusts the sea ice coverage from an input data set by interpreting the effect of a delta-sea-surface-temperature field on input coverage and sea surface temperature.
    Modified 2018-05-08
  • c20c_dtos_v2_adjust_sic_diag
    This procedure produces a postscript set of plots which report on the sea ice adjustments performed in c20c_dtos_adjust_sic.pro.
    Modified 2017-11-22
  • c20c_dtos_v2_adjust_sic_pall2007
    This procedure returns the sea ice concentration versus sea surface temperature function used in Pall (2007) and Pall et alii (2011).
    Modified 2017-10-13
  • c20c_dtos_v2_adjust_sic_stonepall2018
    This procedure returns the sea ice concentration versus sea surface temperature function used in Stone and Pall (2018) and used in the C20C+ D&A project Nat-Hist/CMIP5-est1 estimate of a world without human interference with the climate system.
    Modified 2018-08-17
  • c20c_dtos_v2_download_obs
    This procedure downloads observational data from an ftp or html address and converts non-NetCDF data to NetCDF format.
    Modified 2018-08-23
  • c20c_dtos_v2_make_tossic
    This procedure generates sea surface temperature and sea ice concentration data for use in the C20C+ Detection and Attribution project.
    Modified 2018-09-18
  • c20c_dtos_v2_map_experiment.xml
    This library contains lists of details concerning the various experiments performed under the C20C+ Detection and Attribution project.
    Modified 2018-03-02
  • c20c_dtos_v2_map_institute.xml
    This library contains lists of institutions contributing to the C20C+ Detection and Attribution project as well as various properties of those institutions.
    Modified 2018-03-02
  • c20c_dtos_v2_map_model.xml
    This library contains lists of models contributed to the C20C+ Detection and Attribution project as well as various properties of those models.
    Modified 2018-09-07
  • c20c_dtos_v2_map_scenario.xml
    This library contains lists of scenarios contributed to the C20C+ and Attribution project from various models.
    Modified 2018-03-02
  • c20c_dtos_v2_unnan
    This procedure fills in NaNs in a 2-dimensional spatial field, contained in a 2-dimensional or 3-dimensional array, with the value of the spatially nearest non-NaN neighbours.
    Modified 2017-09-20


Calendar
  • convert_time_format
    This function converts a time vector from one format to another.
    Modified 2018-09-03
  • CORRECT_DATE
    This function returns a corrected version of the input date, when the days are out of the range for the month.
    Modified 2017-10-10
  • MONTH_DAY
    This function returns the first and last days of the month.
    Modified 2010-02-05
  • MONTH_NAME
    This function returns the name of the desired calendar month.
    Modified 2010-08-10
  • MONTH_NUM
    This function returns the month number given the name.
    Written 1999-10-14
  • MONTHS_TO_SEASONS
    This function extracts seasonal data from monthly data.
    Modified 2008-03-18
  • SEASON_NAME
    This function returns the initials of the months contained in a given season.
    Modified 2010-01-05


File system
  • LS
    This procedure runs the UNIX ls (list files) command.
    Modified 2000-06-29
  • PathTo
    Find a file in the $IDL_PATH search tree.
    Modified 2002-03-06


Geographical
  • EXTRACT_REGION
    This function extracts regional data from a [longitude,latitude,time] data file.
    Modified 2010-03-09
  • GEO_DIST
    This function returns the great circle distance (in km) between two geographical points.
    Modified 2002-08-12
  • GEO_MEAN
    This function returns the coordinates of the central geographical point of the input points.
    Written 2015-01-15
  • GEO_MID
    This function returns the coordinates of the geographical point midway between the two input points.
    Modified 2002-08-12
  • ipcc_regions
    This function returns the coordinates of the boxes defining the requested geographical regions selected for use in the IPCC AR4 of WG1.
    Modified 2009-09-30
  • LAND_MASK
    This function creates and returns a global gridded land mask of the desired resolution.
    Modified 2006-07-25
  • MASK_LONLATMONTH
    This procedure returns a version of the input lon-lat-month data set Data which has been masked according to Mask and other selected criteria. It will also do some area and time averaging.
    Modified 2007-01-22
  • MASK_LONLATTIME
    This procedure returns a version of the input lon-lat-time data set Data which has been interpolated to the grid of Mask and/or masked according to Mask.
    Modified 2011-03-30
  • PROCESS_LONLATMONTH
    This procedure returns a processed version of the input lon-lat-month data set. Processing includes lon-lat interpolation masking, taking anomalies, and taking averages.
    Modified 2011-03-30
  • ROTATE_POLE
    Convert geographical coordinates to a new polar coordinate system with a different North Pole.
    Written 2015-01-14


Graphics
  • ARROWS
    This function plots arrows onto the current window.
    Modified 2018-09-06
  • B_PLOT
    This procedure contours a data by drawing each element of an array as a rectangular box.
    Modified 2009-12-08
  • BAR_GRAPH
    This procedure plots bar graphs.
    Modified 2003-06-16
  • BLOCK_CELL
    This procedure draws a boxed contour plot, where boxes are assigned a level instead of calculating smooth boundaries for the levels.
    Modified 2018-05-02
  • BOX
    This procedure draws a rectangular box on the screen.
    Modified 2009-12-08
  • BULLET_LEGEND
    This procedure plots a legend for bullet plots.
    Modified 2000-09-12
  • BULLET_PLOT
    This procedure draws bullet plots with bullets whose sizes are scaled to values in an input vector.
    Modified 2001-03-06
  • CHOOSE_LEVELS
    This function chooses convenient values for contour levels.
    Modified 2002-06-02
  • CIRCLE
    This function returns the x- and y- coordinates of a circle.
    Modified 2004-11-26
  • COLORBREWER
    This procedure implements the colour palettes suggested at http://colorbrewer2.org.
    Modified 2018-08-15
  • CONTOUR_LEGEND
    This procedure plots a legend for colour-contour plots.
    Modified 2009-10-27
  • CONTOUR_WORLD
    This procedure draws a colour contour of a data field over a world map.
    Modified 2018-08-24
  • ERROR_BARS.pro
    This procedure plots error bars over plotted data.
    Modified 2006-02-17
  • Fill_Regions
    Fill regions with a colour on a plot of data from the UVic Climate Model.
    Written 1999-02-12
  • LINE_LEGEND
    This procedure plots a legend for line plots.
    Modified 2015-01-08
  • Outline_Regions
    Draw a line around regions on a contour plot.
    Written 1999-02-12
  • PIE.pro
    This procedure plots a pie chart.
    Modified 2005-08-05
  • PNG_START
    Prepare IDL to create a .png file using the z-buffer device.
    Modified 2002-03-28
  • PNG_WRITE
    Write out the contents of the currently active window as a .png file. If PNG_START is called before the graphics are generated the current device will be the z-buffer.
    Modified 2002-04-29
  • tek_color_spectrum
    This function returns colour indices that make a spectrum out of the TEK_COLOR colours.
    Modified 2004-07-21
  • TIFF_START
    Prepare IDL to create a .tiff file using the z-buffer device.
    Written 2002-04-29
  • TIFF_WRITE
    Write out the contents of the currently active window as a .tiff file. If TIFF_START is called before the graphics are generated the current device will be the z-buffer.
    Written 2002-04-29
  • TRUECOL_ROTATE
    This a wrapper for the rotate function. Rotate doesn't like arrays from true colour images.
    Written 2000-12-18
  • TWO_AXES
    Demonstrates how to make a plot with two different y-axes.
    Modified 2002-01-10


Input/Output
  • CLEAR
    This procedure clears the active IDL display window.
    Modified 2000-07-14
  • CLS
    This procedure clears the IDL terminal window.
    Modified 2000-07-14
  • LANDSCAPE
    This procedure sets the plotting output to landscape orientation.
    Written 2000-06-13
  • markup_read
    This procedure reads entries from an input file following a markup language format.
    Modified 2018-08-22
  • NCDF_FILEINQ
    Print a table of the contents of an ncdf file to the terminal and/or save the structure of the file in a structure!
    Modified 2002-08-09
  • netcdf_read.pro
    This function reads and returns the desired data variable from the desired NetCDF file.
    Modified 2018-09-18
  • netcdf_read_geo.pro
    This function reads and returns the desired geographical data variable from a NetCDF file. It also returns dimension variables and can do some data manipulation, thus acting as a driver of netcdf_read.pro for geographical data.
    Modified 2018-09-18
  • netcdf_read_geo_multitime.pro
    This function reads and returns the desired geographical data variable from a collection of NetCDF files which differ only in the time period included. It also returns dimension variables and can do some data manipulation, thus acting as a driver of netcdf_read.pro for geographical data.
    Modified 2018-09-18
  • netcdf_read_geo_varinfo.xml
    This library contains lists of alternate names and standard units for various variables and dimensions.
    Modified 2018-09-18
  • netcdf_read_metadata.pro
    This function reads and returns the list of variables stored in the requested NetCDF file.
    Written 2017-11-30
  • netcdf_write
    This procedure writes data from one or more variables and their associated dimensions and metadata to a NetCDF file.
    Modified 2018-08-16
  • netcdf_write_metadata.pro
    This procedure returns default NetCDF attribute values for a requested list of variables.
    Modified 2017-12-24
  • PORTRAIT
    This procedure sets the plotting output to portrait orientation.
    Written 2000-06-13
  • PS_CLOSE
    This procedure closes a postscript file for plotting output.
    Written 2000-06-13
  • PS_OPEN
    This procedure opens a postscript file for plotting output.
    Written 2000-06-13
  • READ
    This function extracts column delimited data (whitespace between columns) from a file and loads it into an array It is intended to work with integer or floating point data but will always read the data as if it were floating point.
    Modified 2009-09-29
  • SREAD
    This function extracts column delimited data (whitespace between columns) of data from a file and loads it into an string array.
    Modified 2018-05-28
  • TEE
    Mimics the Unix tee command allowing output to go to the terminal and to a file.
    Written 2000-08-29
  • W_CLOSE
    This procedure closes an existing plotting window.
    Written 2000-06-13
  • W_OPEN
    This procedure opens a new plotting window.
    Written 2000-06-13


Mathematics
  • DECIMAL_PLACE
    This function returns the decimal place of the first significant digit.
    Modified 2002-02-06
  • FACTORS
    This function calculates the prime factors of natural number.
    Written 2000-08-24
  • FIRST_DIGIT
    This function returns the first significant digit.
    Modified 2001-01-11
  • IMAG
    This function returns the imaginary component of a complex number.
    Written 2000-06-09
  • ODD
    This function returns 1 if the input is odd, 0 otherwise.
    Modified 2000-08-23
  • partial_factorial
    This function calculates the partial factorial n!/(n-m)!.
    Written 2004-11-22
  • PLUS
    This function returns 1 if the input is positive, 0 otherwise.
    Modified 2000-07-10
  • REAL
    This function returns the real component of a complex number.
    Written 2000-06-09
  • SIGN
    This function returns the sign of the input variable.
    Modified 2011-11-06


Miscellaneous
  • BREAKLINE
    This function breaks a line of text into pieces less than or equal to a maximum length. Text is broken on whitespace.
    Written 2002-05-08
  • CONSTANTS
    This procedure returns the values of some absolute constants.
    Modified 2002-08-09
  • HMAN
    Play the "Hangman" word guessing game. Each time you issue the hman command a single game is played (guess one word).
    Written 2001-04-30
  • IDL_LIB_HTML
    This procedure creates the web page listing of a library's IDL utilities.
    Modified 2018-09-18
  • PRINTP
    Print text to the terminal and suppress the carriage return at the end of the line. This allows more characters to be added to the same line.
    Written 1999-09-29
  • SET_EDGE
    Fill the boundary of a two dimensional array with a value.
    Written 2002-04-11
  • SWAP
    This procedure will swap the values of two variables.
    Written 2002-02-12
  • trace_dependency
    This procedure plots a diagram showing the dependency tree of the requested IDL programs and returns the list of dependencies.
    Modified 2018-08-10
  • VAR_TYPE
    This function returns the IDL code of the variable type.
    Modified 2011-11-06


Optimal Detection Package v2.1
  • CPAR_OLS
    This function computes 1-D and m-D parametric confidence intervals from ordinary least squares regression.
    Modified 2004-06-28
  • CPAR_TLS
    This function computes 1-D and m-D parametric confidence intervals from total least squares regression.
    Modified 2004-06-28
  • FCDF
    This function does not do anything but its existence allows the GENDETEC family of programs to be compatible with PV_Wave.
    Modified 2004-06-28
  • GENDETEC
    This procedure computes confidence intervals on undetermined model parameters by multiple regression using observational constraints.
    Modified 2004-06-28
  • INVERT1K
    This function computes the inverse of a real square symmetric matrix and checks the solution.
    Modified 2004-06-28
  • LINMOD
    This function performs multiple linear regression given an optional prewhitening operator, externally specified noise realisation, and optional noise on the independent variables.
    Modified 2004-06-28
  • REGOLS
    This function performs multiple ordinary least squares regression.
    Modified 2004-06-28
  • REGTLS
    This function performs multiple total least squares regression.
    Modified 2004-06-28
  • SVDPVW
    This procedure is a singular value decomposition (SVD) routine for PV-Wave.
    Modified 2004-06-28
  • TOTAL_1D
    This function is a manual implementation of the IDL total function to get around the fact that PV-Wave cannot cope with totalling along a dimension.
    Modified 2004-06-28


Optimal Detection Package v3.1.2
  • algebra_to_matrix
    This function parses algebraic statements into a matrix for use in matrix algebra.
    Modified 2012-02-15
  • BETAS_HIST
    This function produces n-dimensional histograms of the beta scaling factors from the gendetec Optimal Detection Package.
    Modified 2012-01-24
  • CPAR_OLS
    This function computes 1-D and m-D parametric confidence intervals from ordinary least squares regression.
    Modified 2012-02-14
  • CPAR_TLS
    This function computes 1-D and m-D parametric confidence intervals from total least squares regression.
    Modified 2012-09-26
  • DEMO_GENDETEC
    This function is a simple example demonstration of how to use the Optimal Detection Package. All inputs are optional.
    Modified 2012-01-24
  • GENDETEC
    This procedure computes confidence intervals on undetermined model parameters by multiple regression using observational constraints.
    Modified 2012-03-15
  • GENDETEC_COMPATIBILITY
    This procedure is a wrapper for gendetec.pro v3.1.0 which allows simultaneous use of the v3.0.0 and v3.1.0 input/output keyword parameter names.
    Modified 2012-03-15
  • LINMOD
    This function performs multiple linear regression given an optional prewhitening operator, externally specified noise realisation, and optional noise on the independent variables.
    Modified 2012-02-15
  • REGOLS
    This function performs multiple ordinary least squares regression.
    Modified 2011-11-06
  • REGTLS
    This function performs multiple total least squares (TLS) regression, including the extension of the error-in-variables (EIV) approach.
    Modified 2012-09-26
  • SPHERE_SAMPLING
    This function determines the number of points to sample along the surface of a multi-dimensional sphere based on a suggestion.
    Written 2011-10-14


Physics
  • POTEM
    Compute the potential temperature of a parcel of seawater at a reference pressure using the Bryden 1973 polynomial for adiabatic lapse rate and Runge=Kutta 4th order integration algorithm.
    Written 1999-03-31
  • STANDARD_ATM
    This function calculates the pressure at a given altitude in the troposphere, assuming a uniform, dry atmosphere.
    Modified 2002-08-12


Statistics
  • MODE
    This function calculates the mode of an input array.
    Written 2016-10-20
  • PDF
    This procedure estimates the one or two dimensional probability density function of a given data set.
    Modified 2012-01-24
  • PDF_TO_CDF
    This function estimates a cumulative distribution function from a given probability density function.
    Modified 2011-04-13
  • QUANTILE_THRESHOLD
    This function estimates the thresholds in the input data array corresponding to the specified quantiles.
    Modified 2012-07-05
  • SAMPLE_PDF
    This function randomly samples a given probability density function.
    Modified 2011-04-13
  • THRESHOLD_QUANTILE
    This function estimates the quantiles of the given thresholds in the input data array.
    Modified 2012-07-05


Strings
  • EXPAND_TABS
    Replace tab characters in a text string with spaces.
    Written 2001-04-02
  • latex_char.pro
    This function substitutes LaTeX character codes for non-English characters.
    Written 2018-06-03
  • ORDINAL
    This function returns the ordinal value of the input number.
    Modified 2001-02-15
  • STR
    This function converts an integer or floating point number to a string.
    Modified 2006-02-17
  • STRING_FROM_VECTOR
    This function converts a vector to a single string containing the vector's entries separated by commas.
    Modified 2004-06-16
  • string_substitute
    This function substitutes a character sequence within an input string.
    Written 2018-06-03
  • STRMERGE
    Merge two string arrays.
    Modified 2002-07-23
  • WRITTEN_NUMBER
    This function returns the written form of the input number.
    Written 2001-02-15


Time series analysis
  • CROSS_SPEC
    This function estimates the power cross-spectrum of two vectors.
    Written 2004-07-13
  • EMD
    This function estimates the empirical mode decomposition of a given data vector.
    Modified 2005-08-05
  • EXTREMA
    This function returns the locations of the local extrema in a given time series.
    Written 2003-10-09
  • FILTER
    This function returns a smoothed version of the input vector.
    Modified 2009-01-05
  • FILTER_ND
    This function returns a smoothed version of an N-dimensional input array.
    Modified 2005-08-05
  • filter_window
    This function returns a desired filter window of desired width.
    Modified 2005-10-21
  • FIRST_DIFF
    This function returns the first difference vector of the input.
    Modified 2000-07-10
  • HILBERT_SPEC
    This function estimates the Hilbert-Huang amplitude spectrum of an input matrix of time series (e.g. intrinsic mode functions).
    Modified 2005-08-05
  • MONTE_CARLO_AR1
    This function returns a Monte Carlo generated time series which preserves the distributional and AR(1) properties of the original series.
    Modified 2005-10-23
  • PCA
    This procedure calculates the principal components and empirical orthogonal functions of a given data set.
    Modified 2012-01-23
  • shengzwiers.pro
    This function applies the Sheng and Zwiers method for adjusting averaged data such that the original averaged values are re-obtained upon averaging of higher frequency data themselves calculated through linear interpolation from the adjusted data. See Sheng and Zwiers (1998) and http://www-pcmdi.llnl.gov/projects/amip/AMIP2EXPDSN/BCS/amip2bcs.php for more details.
    Modified 2018-09-13
  • shengzwiers_weights.pro
    This function returns the interpolation weighting matrix used in the Sheng and Zwiers (1998) algorithm for variance adjustment for interpolation.
    Modified 2017-09-20
  • TREND
    This function calculates the least-squares linear trend in the input vector.
    Modified 2015-09-15
  • UNWRAP
    This function unwraps angular time series such that is it continuous.
    Written 2004-10-25
  • zero_cross
    This function returns the number of zero crossings in a given time series.
    Written 2003-10-09

News
  • mask_lonlatmonth.pro has been superceded by mask_lonlattime.pro and process_lonlatmonth.pro. It was removed from the library on 2008-04-25.
  • A .tar archive file containing the entire routine library was added on 2007-05-24; see above to download it.
  • giorgi_regions.pro was replaced with ipcc_regions.pro on 2006-01-12.
  • A separate webpage for the Optimal Detection Package was created on 2005-09-02 here.
  • A separate webpage for the Optimal Detection Package was created on 2005-09-02 here.
  • SUM and SUM_ROW were removed on 2005-08-05 as they are superceded by IDL's TOTAL function.
  • A number of routines were removed from the library on 2003-11-19 because they were too system specific. These are CDIAC_PLOT, CDIAC_READ, CRU_PLOT, EDIT_REGIONS, GLOBETOPOG, PLOT_PRECIP, PLOT_WEATHER, READ_GLOBE_TOPOG, READ_PARTICLES, READ_REGION_MASK, READ_TERM, SSTOPOG, VANCOUVER_ISLAND, WRITE_HORZ_REGIONS. PRODUCT was also removed as it is superceded by IDL's PRODUCT function.

Maintained by: dastone@runbox.com
Last updated: 18 September 2018


© Copyright 2017-2018 Dáithí Stone