For example, we would like to convert temperature (T) and pressure (p) into potential temperature (theta). Again this is something we will use over and over again, so its good to write a small program to do it.
We know,
where is the reference pressure (normally 1000 hPa) and =0.286
Make a file called temp_to_theta.pro
Function temp_to_theta,temp,press ;Function to convert temperature (K) and pressure (hPa) to potential temperaure (theta, K) using a reference pressure of 1000~hPa. RoverCp=0.286 ref_press=1000. theta=temp*(ref_press/press)^RoverCp return,theta end
You can use this to convert zero degrees Celsius (273.15 K) at 900 hPa to a potential temperature using,
.compile temp_to_theta theta=temp_to_theta(273.15,900.)
Now write a program to convert potential temperature to temperature.