CAM Aquaplanet + Model Postprocessing Minmin Fu 3/30/2018 Aquaplanet?
• GCM configuration devoid of topography, land, and sea ice; totally water covered. • Usually with a fixed SST: sometimes an interactive surface temperature is needed e.g. ‘‘slab-ocean model. • Aquaplanets remove interactions with the land surface and the zonal symmetry removes a dimension from the analysis allowing shorter integrations. • Aquaplanet simulations can be surprisingly Earth like, providing a laboratory to facilitate understanding results from observations or more comprehensive simulations [Medeiros and Stevens, 2011]. CAM in Aquaplanet
• Fixed SST compsets: FC4AQUAP (CAM4), FC5AQUAP (CAM5) ./create_newcase -case ${CASEROOT} -mach ${MACHINE} -res ${RES} -compset ${COMPSET}
• Slab ocean: not officially supported, some info can be found at: http://www.cesm.ucar.edu/models/simpler-models/files/CAM_aqua_som_description.pdf SST Configuration
• Default SST prescribed by equation above. • 27C SST at equator decaying to 0C at 60 degrees latitude. • Can be modified in file: /cesm1_2_2_1/models/atm/cam/src/utils/ cam_aqua/ocn_comp.F90 Custom SST from .nc file
• Can change analytical SST pattern, but it’s kind of hard. • Overview: • -user_compset 2000_CAM4_DLND%NULL_DICE%NULL_DOCN%DOM_SROF_SGLC_ SWAV (Null Land and Ice models) • Feed SST pattern into data ocean model • Modify land and ocean fractions in /glade/p/cesmdata/inputdata/share/domains/ • Modify Topography to be flat in /glade/p/cesmdata/inputdata/atm/cam/topo/USGS- gtopo30_1.9x2.5_remap_c050602.nc • Change domain file locations in user namelist. • orb_eccen = 0. orb_obliq = 0. orb_mvelp = 0. orb_mode = ‘fixed_parameters’ Results How to deal with data
• Typically models will output a bunch of netCDF (.nc) files. • But sometimes we need to do more sophisticated analysis using Matlab or Python. What’s the best and most efficient way to read them? Table of Contents
• Matlab Users • ncread, netCDF • Python Users • pynio, scipy, netCDF • NCO operators • Quick way to pre-process data • So what’s faster? • Should you use NCO operators? Which package works the fastest? Refresher: ncdump and ncview
• Thanks to Ned for introducing this last time. • To look at just the header information (also called the schema or metadata): ncdump -h test.nc • To look at header and coordinate information, but not the data: ncdump -c test.nc • ncview: a nice box with buttons pops up. Matlab: ncread
• Primary tool: read in files using ncread. E.g. ncread(‘test.nc’,'lon') ncread(‘test.nc’,'U',[1,1,26,1],[144 96 1 365]) • ncdisp: basically does the same thing as ncdump, but inside Matlab. ncdisp(‘testfile.nc’) Matlab
• netcdf: interact with the NetCDF Library through Matlab. You do lower level tasks, can modify dimensions, etc.
nc=netcdf.open(file,'NOWRITE'); varid = netcdf.inqVarID(nc,’lon'); lon=double(netcdf.getVar(nc,varid)); netcdf.close(nc); Python (1/3): PyNio
• Discovered this recently, made by UCAR. • Some people online claim it is faster than the NetCDF package, maybe by a little bit?
import Nio file = '/glade/scratch/mjfu/cl_129/atm/hist/T_all.nc' f = Nio.open_file(file,'r', format="netcdf") data = f.variables['T'] print data.shape Python (2/3): Scipy
from scipy.io import netcdf file = '/glade/scratch/mjfu/cl_129/atm/hist/T_all.nc' f = netcdf.netcdf_file(file, 'r') data = f.variables[’T'] print data.shape Python (3/3): Netcdf
from netCDF4 import Dataset file = '/glade/scratch/mjfu/cl_129/atm/hist/T_all.nc' dataset = Dataset(file,'r') data = dataset.variables[T'] print data.shape CDO and NCO operators
• Command line programs. • Run very fast. (extract and concat from 20 years took me one minute) • If you plan to run the analysis many times, it may be worth it preprocess with CDO and NCO. • They basically do the same thing. Extract and Concatenate
• NCO: • ncrcat cl_129.cam.h1* -v 'T' T_all.nc
• CDO: • cdo -select,name=T,U (the variables) cl_119.cam.h1* (all filenames) output.nc (output file name)
• Single dimension? Means: seasonal and all time
Ensemble Mean
• NCO: • ncrcat cl_129.cam.h1* -v 'T' T_all.nc
• CDO: • cdo -select,name=T,U (the variables) cl_119.cam.h1* (all filenames) output.nc (output file name) Divergence and Vorticity
• I personally consider these two to be super handy. Tips
• Use NCO as much as possible, it is fast. • You can combine NCO and matlab/python e.g. using matlab’s System command. • Read in 20 years of zonal wind by ncread, then concat in matlab: 20 minutes • NCO operators + Ncread: ~ 2 minutes (but uses some more disk space) Some more tips
• Do not define a matrix first in matlab, then do • A = zeros(144,96) • A = ncread(….) • This slows down the read a lot since Matlab will translate from netCDF4.Variable object to a matlab object. Conclusions
• Thanks for your attention. • Please share with everybody if you have your own tips and tricks.