inclass_code_examples

=Basic Stats Lecture demo code fragments=

=IDL: anyone can download and run it in 7-minute demo mode (file writing disabled but screen figures can be made and captured), no license needed for that.=

code format="idl" cdf2idl, 'air.mon.ltm.nc' @air.mon.ltm.idl
 * Quick grabs of the data using cdf2idl

cdf2idl, 'olr.mon.ltm.nc' @olr.mon.ltm.idl

mo = indgen(12)+1 ;;; Month axis

plot, air print, total(air) / n_elements(air) print, mean(air)
 * it is just a bunch of numbers

help hlp, air;;; Oh, it is in C not K
 * no, it is a multidimensional array:

air_barx = total(air, 1) / n_elements(air[*,0,0]) contour, air_barx, lat, mo, /fill, nlevels=23, xtit='lat', ytit='month'
 * Longitude average

air_barxt = total(air_barx, 2)/12. plot, lat, air_barxt, xtit='lat', ytit='T (C)'
 * Time average of that

air_barxty = total(air_barxt)/n_elements(lat) print, air_barxty
 * Latitude average of that **CAUTION! Simple average over lat bins is not an area average!**

coslat = cos(lat *!pi / 180.) air_bartA = total(air_barxt*coslat) / $ total( coslat) print, air_bartA code
 * Latitude average, weighted by cos(lat)

=GrADS: uses the MERRA reanalysis remote connection functions like merra_monthly2d.gs= code merra_monthly2d met set t 300 set gxout shaded

t = t2m-273.2 d t cbar

tbarx = ave(t,lon=0,lon=360) clear d tbarx

tbary = ave(t, lat=-90, lat=90) clear d tbary

tbarxy = ave(tbary,lon=0,lon=360) d tbarxy code