-
Notifications
You must be signed in to change notification settings - Fork 11
conv_pp_files
There is a handy utility called Xconv/convsh
, which converts Met Office UM output files into different formats. Here's a handy step-by-step for turning .pp files into NetCDF files.
- Download
Xconv
andconvsh
from here: http://badc.nerc.ac.uk/help/software/xconv/index.html. If using Windows, get bothXconv
andconvsh
. If using Linux, getXconv
and create symbolic link toconvsh
(ln -s xconv1.91 convsh1.91
). - Create text file named
conv2nc.tcl
and into it copy the code from here: http://www.met.rdg.ac.uk/~jeff/xconv/example2.html. Omit the first line#!/home/jeff/bin/convsh
. You may have noticed that this script will convert multiple .pp files into a single NetCDF file. Feel free to adapt my batch file below to do the same, and upload it to the Wiki. - Windows users: follow the instructions here to process files individually: http://badc.nerc.ac.uk/help/software/xconv/xconv_windows.html (Xconv). This should also work for Linux users.
- Windows users: you can also process multiple .pp files using a batch file. I haven't been able to find an elegant solution in the time I have available, but here's an inelegant one which works (as long as you don't have any spaces in the path to your folder):
- Create a text file named
run_Xconv.bat
. - Copy the following script into it:
@echo off
rem Batch file to convert Met Office .pp files to NetCDF format
rem Karen Amoudry, 18 June 2013, National Oceanography Centre, Liverpool
setlocal EnableDelayedExpansion
call :treeProcess
:treeProcess
for %%f in (*.pp) do (
set outname=%%~nf.nc
set "cmd_str=convsh1.91.exe < conv2nc.tcl -i %%~ff -o !outname!"
echo !cmd_str!
)
echo ^@echo off
for /D %%d in (*) do (
cd %%d
call :treeProcess
cd ..
)
exit /b
- Place
run_Xconv.bat
,convsh1.91.exe
andconv2nc.tcl
in a parent folder above the .pp files you want to process. - Open a command window, navigate to the folder containing the files from step (c) and type the following:
run_Xconv.bat > out.bat
- When this script finishes, in your command window, type the following:
out.bat > log.txt
- You should now have all your NetCDF files in the same directory as the files from step (c).
- For extra credit, write a batch file to put the NetCDF files back in the original folder structure and upload it to the Wiki. I couldn't make this work in the time I had available!
Linux users: in principle, you should be able to create a nice shell script to do the same operations as step (4). I haven't, because my files are in Windows. If you produce one, please put it on the Wiki!
The FVCOM toolbox includes a function pp2nc.m
which calls convsh to do the conversion of a number of files. It therefore still requires the convsh installation, but it can be included in an existing FVCOM workflow more easily. The function relies on using a convsh script included with the FVCOM toolbox (which is originally taken from here). A simple use case is shown below.
files = {'/path/to/file1.pp', '/path/to/file2.pp', '/path/to/file3.pp'};
convsh = '/users/modellers/pica/bin/convsh';
tcl = '/users/modellers/pica/MATLAB/fvcom-toolbox/utilities/pp2nc.tcl';
pp2nc(files, convsh, tcl);
N.B. The path to the convsh binary will need to be edited in the pp2nc.tcl script (change the first list to point to your convsh binary).
For questions regarding FVCOM, to contribute to the wiki please subscribe to the mailing list uk-fvcom mailing list If you would like to cite FVCOM, please refer to its main publication and/or URLs.
Background
=== FVCOM Wiki ===
User guide
-
Additional information of less frequent usage in no particular order