Skip to content

Instantly share code, notes, and snippets.

View adamabernathy's full-sized avatar
👋

Adam C. Abernathy adamabernathy

👋
View GitHub Profile
@adamabernathy
adamabernathy / write-netcdf-idl
Last active August 29, 2015 14:20
How to write NetCDF files in IDL.
; Set up the file & handler
n_profiles = n_elements(lat) ; just pick any of your data arrays
fid=ncdf_create('FILENAME-GOES-HERE'+'.nc',/CLOBBER)
d=indgen(2,/LONG) ; number of dimensions that will be created
; Set Dimensions
d[0]=ncdf_dimdef(fid,'n_profiles',n_profiles) ; length 'j'
d[1]=ncdf_dimdef(fid,'n_bins',n_bins) ; length 'i'
; Define variables to be stored
@adamabernathy
adamabernathy / plot-starter-idl
Created May 6, 2015 03:05
Starter code for plotting in IDL
; ---------------------------------------------------------------------
; Plot the results
; ---------------------------------------------------------------------
; Configure display
; Load and modify color pallet. Using IDL 8.0 friendly pallet
common colors, r_orig,g_orig,b_orig,r_curr,g_curr,b_curr
loadct,12,/silent
!p.background=!d.n_colors-1
@adamabernathy
adamabernathy / save-csv-array-idl
Last active August 29, 2015 14:22
Save a value to a CSV file
; We have an array of values to save to a CSV file
delim = ','
output_file = 'orbits.txt'
data_to_save=make_array(2, /string, value=-999)
data_to_save[0] = string(orbit_syear)
data_to_save[1] = string(orbit_sdoy, format='(I03)')
data_to_save[2] = string(orbit, format='(I05)')
@adamabernathy
adamabernathy / show-a-lat-lon-box-idl
Created June 23, 2015 16:03
Print a Lat/Lon box to a console window in IDL.
pro print_loi_box,nlat,slat,elon,wlon
; Box dimensions - Comment out for real use.
nlat=90.0
slat=-43.0
wlon=-70
elon=180.0
; Graphic parts
lg_offset = ' '
@adamabernathy
adamabernathy / read-hdf5-variable-idl
Created June 24, 2015 21:11
Read a variable from a HDF5 file in IDL
function get_hdf5,f,branch,var_name
fid = h5f_open(f) ; open file
gid = h5g_open(fid,branch) ; access the branch
did = h5d_open(gid,var_name) ; access the variable
var = h5d_read(did) ; read the variable
h5d_close,did ; close the variable
h5f_close,fid ; close file
/***********************************************************************
* File name: penny.ino *
* *
* Purpose: Logs data from an array of digital weather sensors and *
* stores the data in CSV format on a standard SD Card. *
* *
* - File references: *
* Name I/O Description *
* ---------------------------------------------------------------- *
* *
@adamabernathy
adamabernathy / thermocouple.ino
Last active April 7, 2016 21:04
Arduino Thermocouple
/* Thermocouple */
void setup() {
Serial.begin(9600);
}
void loop() {
int sensorValue = analogRead(A1);
; pconfig
pconfig = {current:1, xrange:[0, 10], thick:1.5}
p = plot(x, y, name='my_plot', $
_EXTRA = pconfig, $
dimensions = [700, 800], $
title = 'My Awesome Plot', $
ytitle = 'F(x)')
@adamabernathy
adamabernathy / batch-rename.sh
Created April 27, 2016 19:39
Rename file extensions in batch mode
for file in *.html; do
mv "$file" "`basename $file .html`.txt"
done
@adamabernathy
adamabernathy / plot-js-windrose.html
Last active August 31, 2021 11:23
Uses HighCharts.js to plot a windrose from SynopticLabs' API
<!DOCTYPE html>
<html>
<head>
<title>Wind Rose Example</title>
<!-- You need to import these -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-more.js"></script>