Skip to content

NetCDF manipulation

Helen Burns edited this page Aug 19, 2018 · 2 revisions

Manipulation of model files

Once the model is spun up you will have 10 or 20-year chunks of model run in 128 tiles, with either yearly or monthly data.

The yearly data is useful for spin up diagnostics and internal variability, but for Reynolds decomposition we time-averaged outputs.

Here we can use tools provided by MITgcm to stitch the tiles together and NCO tools to put our output into a useful format. I will then suggest a directory structure complementary to the tools I developed for analysis but not necessary.

Tidying STDOUT

STDOUT provides a record of all the input files and how the model was run, this may be useful when bug finding or questioning results later, however, you probably don't want to keep one for every tile. I wrote a useful bash script for removing all but one and naming it simply output to prevent accidentally rerunning script and removing it later

That script can be found here

Glueing the tiles

MITgcm comes with a number of tools to do this. The best being found: MITgcm/MITgcm/utils/python/MITgcmutils/scripts/gluemncbig

A simple overview of glueing the domain tiles together would be for each diagnostic .nc file to run:

gluemncbig -qo T1-T2Var.nc T1-T2Var.mnc/mnc_out_0*/Var.*.nc &

based on naming convention T1 = start year, T2 = end year and Var = variable descriptor.

gluemncbig is very well documented please read the python file for more information.

Averaging

NCO tools are very useful and time-saving please find a brief overview of them here

For Reynolds averaging you will want to average over many years so I have included a file glue_all that gives an example of glue model runs and averaging. Note the wait command that insists on the glueing being completed before averaging.

For examining spin up information you may wish to examine yearly information by utilising ncrat

ncrcat T1-T2_var.nc T2-T3_var.nc .... TEND-1-TEND_var.nc -o T1-TEND_Var.nc

If you do this for a long period of time this may be very memory intensive and you may require tools like ncks to do 1 variable at a time.