Skip to content
This repository was archived by the owner on Apr 18, 2018. It is now read-only.

Commit fde9baa

Browse files
committed
examples of reading output in MATLAB and Python
1 parent 07d1579 commit fde9baa

File tree

1 file changed

+64
-18
lines changed

1 file changed

+64
-18
lines changed

doc/getting_started/getting_started.rst

Lines changed: 64 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,16 @@ and model diagnostics is described in chap_diagnosticsio.
598598
MDSIO output files
599599
~~~~~~~~~~~~~~~~~~
600600

601-
The “traditional” output files are generated by the ``mdsio`` package (link to section_mdsio).
601+
The “traditional” output files are generated by the ``mdsio`` package
602+
(link to section_mdsio).The ``mdsio`` model data are written according to a
603+
“meta/data” file format. Each variable is associated with two files with
604+
suffix names ``.data`` and ``.meta``. The ``.data`` file contains the
605+
data written in binary form (big endian by default). The ``.meta`` file
606+
is a “header” file that contains information about the size and the
607+
structure of the ``.data`` file. This way of organizing the output is
608+
particularly useful when running multi-processors calculations.
609+
610+
602611
At a minimum, the instantaneous “state” of the model is written out,
603612
which is made of the following files:
604613

@@ -654,18 +663,31 @@ append `NetCDF files <http://www.unidata.ucar.edu/software/netcdf/>`_. Unlike th
654663
placed within a subdirectory with a name such as ``mnc_output_`` (by default, NetCDF tries to append, rather than overwrite, existing files,
655664
so a unique output directory is helpful for each separate run).
656665

666+
667+
The MNC output files are all in the “self-describing” NetCDF format and
668+
can thus be browsed and/or plotted using tools such as:
669+
670+
- `ncdump <https://www.unidata.ucar.edu/software/netcdf/netcdf-4/newdocs/netcdf/ncdump.html>`_ is a utility which is typically included with every NetCDF
671+
install, and converts the NetCDF binaries into formatted ASCII text files.
672+
673+
- `ncview <http://meteora.ucsd.edu/~pierce/ncview_home_page.html>`_ is a very convenient and quick way to plot NetCDF
674+
data and it runs on most platforms. `Panoply <https://www.giss.nasa.gov/tools/panoply/>`_ is a similar alternative.
675+
676+
- Matlab, GrADS, IDL and other common post-processing environments provide
677+
built-in NetCDF interfaces.
678+
679+
657680
Looking at the output
658681
---------------------
659682

660-
The traditional or ``mdsio`` model data are written according to a
661-
“meta/data” file format. Each variable is associated with two files with
662-
suffix names ``.data`` and ``.meta``. The ``.data`` file contains the
663-
data written in binary form (big endian by default). The ``.meta`` file
664-
is a “header” file that contains information about the size and the
665-
structure of the ``.data`` file. This way of organizing the output is
666-
particularly useful when running multi-processors calculations. The repository
667-
version of the model includes a few Matlab utilities to read output
668-
files written in this format. The Matlab scripts are located in the
683+
MATLAB
684+
~~~~~~
685+
686+
MDSIO output
687+
############
688+
689+
The repository includes a few Matlab utilities to read output
690+
files written in the ``mdsio`` format. The Matlab scripts are located in the
669691
directory ``utils/matlab`` under the root tree. The script ``rdmds.m``
670692
reads the data. Look at the comments inside the script to see how to use
671693
it.
@@ -686,20 +708,44 @@ Some examples of reading and visualizing some output in Matlab:
686708
>> eta=rdmds('Eta',[0:10:100]);
687709
>> for n=1:11; imagesc(eta(:,:,n)');axis ij;colorbar;pause(.5);end
688710

711+
712+
NetCDF
713+
######
714+
689715
Similar scripts for netCDF output (``rdmnc.m``) are available and they
690716
are described in Section [sec:pkg:mnc].
691717

692-
The MNC output files are all in the “self-describing” NetCDF format and
693-
can thus be browsed and/or plotted using tools such as:
694718

695-
- `ncdump <https://www.unidata.ucar.edu/software/netcdf/netcdf-4/newdocs/netcdf/ncdump.html>`_ is a utility which is typically included with every NetCDF
696-
install, and converts the NetCDF binaries into formatted ASCII text files.
719+
Python
720+
~~~~~~
697721

698-
- `ncview <http://meteora.ucsd.edu/~pierce/ncview_home_page.html>`_ is a very convenient and quick way to plot NetCDF
699-
data and it runs on most platforms. `Panoply <https://www.giss.nasa.gov/tools/panoply/>`_ is similar alternative.
722+
MDSIO output
723+
############
700724

701-
- Matlab, GrADS, IDL and other common post-processing environments provide
702-
built-in NetCDF interfaces.
725+
The repository includes Python scripts for reading the ``mdsio`` format under ``utils/python``. The following example shows how to load in some data:
726+
727+
::
728+
729+
# python
730+
import mds
731+
732+
Eta = mds.rdmds('Eta', itrs=10)
733+
734+
The docstring for ``mds.rdmds`` contains much more detail about using this function and the options that it takes.
735+
736+
NetCDF output
737+
#############
738+
739+
The NetCDF output is currently produced with one file per processor. This means the individual tiles need to be stitched together to create a single NetCDF file that spans the model domain. The script ``gluemncbig.py`` in the ``utils/python`` folder can do this efficiently from the command line.
740+
741+
The following example shows how to use the `xarray package <http://xarray.pydata.org/>`_ to read the resulting NetCDF file into python:
742+
743+
::
744+
745+
# python
746+
import xarray as xr
747+
748+
Eta = xr.open_dataset('Eta.nc')
703749

704750

705751
.. _chap_modelExamples:

0 commit comments

Comments
 (0)