Difference between revisions of "Matlab Scripts"

From WikiROMS
Jump to navigationJump to search
(Created page with "''''''Bold text''''''<div class="title">Matlab Scripts</div>__NOTOC__ <!-- Edit Template:Matlab_Scripts_TOC to modify this Table of Contents--> <div style="float: left;margin: 0…")   (change visibility)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
''''''Bold text''''''<div class="title">Matlab Scripts</div>__NOTOC__
<div class="title">Matlab Scripts</div>__NOTOC__


<!-- Edit Template:Matlab_Scripts_TOC to modify this Table of Contents-->
<!-- Edit Template:Matlab_Scripts_TOC to modify this Table of Contents-->
Line 8: Line 8:
==Introduction==
==Introduction==


These pages describe a variety of Matlab scripts that can be used to pre-processing and post-processing ROMS data.  Since all the data in ROMS is managed with NetCDF files, some of these scripts use a NetCDF interface to Matlab to process the data.  There are several interfaces for Matlab available from third parties.  The most widely used interface are '''MEXNC''' and '''SNCTOOLS'''.
These pages describe a variety of Matlab scripts that can be used for pre-processing and post-processing ROMS data.  Since all the data in ROMS is managed with NetCDF files, some of these scripts use a NetCDF interface to Matlab to process the data.  There are several interfaces for Matlab available from third parties.  The most widely used interfaces are '''MEXNC''' and '''SNCTOOLS'''.


{{note}} '''However''', starting Matlab version '''2012a''', released on Feb 9, 2012, the '''native''' interface to NetCDF is the preferred method for processing NetCDF data in the scripts distributed in the ROMS repository '''matlab''' and described here. The '''native''' interface was introduced in Matlab version '''2008b''' for '''NetCDF-3''' type files.  The '''NetCDF-4''' support started in version '''2010b'''.  The support for '''HDF5''' files was completed in version '''2011a'''.  The '''OpenDAP''' support began in version '''2012a'''.  If your Matlab version is older than 2008b, we highly recommend to update to the newest version.  However, in the basic generic scripts we have switches for older versions to activate either the '''MEXNC''' interface for standard NetCDF files and the '''SNCTOOLS''' interface to process NetCDF files on an '''OpenDAP''' server.
{{note}} '''However''', starting with Matlab version '''2012a''', released on Feb 9, 2012, the '''native''' interface to NetCDF is the preferred method for processing NetCDF data in the scripts distributed in the ROMS repository '''matlab''' and described here. The '''native''' interface was introduced in Matlab version '''2008b''' for '''NetCDF-3''' type files.  The '''NetCDF-4''' support started in version '''2010b'''.  The support for '''HDF5''' files was completed in version '''2011a'''.  The '''OpenDAP''' support began in version '''2012a'''.  If your Matlab version is older than '''2008b''', we highly recommend that you update to the newest version.  However, in the basic generic scripts we have switches for older versions to activate either the '''MEXNC''' interface for standard NetCDF files and the '''SNCTOOLS''' interface to process NetCDF files on an '''OpenDAP''' server.


Programming in Matlab is easy.  However, good and efficient programming in Matlab requires skill and time. We usually become better at it the more that we practice.  I started programming in Matlab in the earlier 1990's. If I look back at my earlier scripts, they were horrendous and extremely inefficient. There were some scripts that would take around 30 minutes to execute. I can rewrite those scripts nowadays and if will take seconds to execute.  So we learn over the years how to program very efficiently.  We are constantly learning new tricks and new functions.  As ROMS, Matlab is always evolving.  Plotting in Matlab take also skill.  There is a lot of paper in the literature with very poor Matlab plots...
Programming in Matlab is easy.  However, good and efficient programming in Matlab requires skill and time. We usually become better at it the more that we practice.  I started programming in Matlab in the earlier 1990's. If I look back at my earlier scripts, they were horrendous and extremely inefficient. There were some scripts that would take around 30 minutes to execute. I can rewrite those scripts nowadays and it will take seconds to execute.  So we learn over the years how to program very efficiently.  We are constantly learning new tricks and new functions.  Just like ROMS, Matlab is always evolving.  Plotting in Matlab also takes skill.  There are a lot of papers in the literature with very poor Matlab plots...


==Repositories==
==Repositories==
Line 18: Line 18:
To check-out the scripts described here from the ROMS repository '''matlab''', enter:
To check-out the scripts described here from the ROMS repository '''matlab''', enter:


     <span class="red">svn checkout <nowiki>https://www.myroms.org/svn/src/matlab</nowiki> MyDir</span>
     <span class="red">svn checkout <nowiki>https://www.myroms.org/svn/src/matlab</nowiki></span> '''MyDir'''


where '''MyDir''' is the destination directory on your local computer. It will be created if not found. If your '''username''' on your local computer is not the same as your ROMS username you will need to pass the '''--username''' option to '''svn''':
where '''MyDir''' is the destination directory on your local computer. It will be created if not found. If your '''username''' on your local computer is not the same as your ROMS username you will need to pass the '''--username''' option to '''svn''':


     <span class="red">svn checkout --username joe_roms <nowiki>https://www.myroms.org/svn/src/matlab</nowiki> MyDir</span>
     <span class="red">svn checkout --username joe_roms <nowiki>https://www.myroms.org/svn/src/matlab</nowiki></span> '''MyDir'''


Although not necessary nowadays, the '''MEXNC''' interface can be downloaded from:
Although not necessary nowadays, the '''MEXNC''' interface can be downloaded from:


     <span class="red">svn checkout <nowiki> https://mexcdf.svn.sourceforge.net/svnroot/mexcdf/mexnc/trunk</nowiki> MyDir</span>
     <span class="red">svn checkout <nowiki> https://mexcdf.svn.sourceforge.net/svnroot/mexcdf/mexnc/trunk</nowiki></span> '''MyDir'''


and the '''SNCTOOLS''' interface can be downloaded from:
and the '''SNCTOOLS''' interface can be downloaded from:


     <span class="red">svn checkout <nowiki> https://mexcdf.svn.sourceforge.net/svnroot/mexcdf/snctools/trunk></nowiki> MyDir</span>
     <span class="red">svn checkout <nowiki> https://mexcdf.svn.sourceforge.net/svnroot/mexcdf/snctools/trunk</nowiki></span> '''MyDir'''


But recall that both the '''MEXNC''' and '''SNCTOOLS''' interfaces are obsolete if you have Matlab Version '''2008b''' or newer and Matlab Version '''2012a''' for accessing NetCDF files on an '''OpenDAP''' server. See description in the [[Matlab_Scripts#Introduction|above]].
But recall that both the '''MEXNC''' and '''SNCTOOLS''' interfaces are obsolete if you have Matlab Version '''2008b''' or newer and Matlab Version '''2012a''' for accessing NetCDF files on an '''OpenDAP''' server. See description in the [[Matlab_Scripts#Introduction|above]].
Line 50: Line 50:
           /mexrect                    Curvilinear and rectilinear program
           /mexrect                    Curvilinear and rectilinear program
           /mexsepeli                  Sepeli conformal mapping
           /mexsepeli                  Sepeli conformal mapping
      /netcdf                        NetCDF data processing scripts
       /seagrid                        SeaGrid generation GUI
       /seagrid                        SeaGrid generation GUI
       /seawater                      Seawater properties scripts
       /seawater                      Seawater properties scripts
       /utility                        Miscellaneous all purpose scripts
       /utility                        Miscellaneous all purpose scripts
       /startup.m                      Use script configuration for Matlab
       /startup.m                      User script for configuring Matlab
  </span>
  </span>


The <span class="blue">mexinside</span> program is kind obsolete since Matlab offer the <span class="blue">inpolygon</span> with the same functionality.
The <span class="blue">mexinside</span> program is kind of obsolete since Matlab offers <span class="blue">inpolygon</span> with the same functionality.

Revision as of 15:39, 2 May 2012

Matlab Scripts

Introduction

These pages describe a variety of Matlab scripts that can be used for pre-processing and post-processing ROMS data. Since all the data in ROMS is managed with NetCDF files, some of these scripts use a NetCDF interface to Matlab to process the data. There are several interfaces for Matlab available from third parties. The most widely used interfaces are MEXNC and SNCTOOLS.

Note However, starting with Matlab version 2012a, released on Feb 9, 2012, the native interface to NetCDF is the preferred method for processing NetCDF data in the scripts distributed in the ROMS repository matlab and described here. The native interface was introduced in Matlab version 2008b for NetCDF-3 type files. The NetCDF-4 support started in version 2010b. The support for HDF5 files was completed in version 2011a. The OpenDAP support began in version 2012a. If your Matlab version is older than 2008b, we highly recommend that you update to the newest version. However, in the basic generic scripts we have switches for older versions to activate either the MEXNC interface for standard NetCDF files and the SNCTOOLS interface to process NetCDF files on an OpenDAP server.

Programming in Matlab is easy. However, good and efficient programming in Matlab requires skill and time. We usually become better at it the more that we practice. I started programming in Matlab in the earlier 1990's. If I look back at my earlier scripts, they were horrendous and extremely inefficient. There were some scripts that would take around 30 minutes to execute. I can rewrite those scripts nowadays and it will take seconds to execute. So we learn over the years how to program very efficiently. We are constantly learning new tricks and new functions. Just like ROMS, Matlab is always evolving. Plotting in Matlab also takes skill. There are a lot of papers in the literature with very poor Matlab plots...

Repositories

To check-out the scripts described here from the ROMS repository matlab, enter:

   svn checkout https://www.myroms.org/svn/src/matlab MyDir

where MyDir is the destination directory on your local computer. It will be created if not found. If your username on your local computer is not the same as your ROMS username you will need to pass the --username option to svn:

   svn checkout --username joe_roms https://www.myroms.org/svn/src/matlab MyDir

Although not necessary nowadays, the MEXNC interface can be downloaded from:

   svn checkout  https://mexcdf.svn.sourceforge.net/svnroot/mexcdf/mexnc/trunk MyDir

and the SNCTOOLS interface can be downloaded from:

   svn checkout  https://mexcdf.svn.sourceforge.net/svnroot/mexcdf/snctools/trunk MyDir

But recall that both the MEXNC and SNCTOOLS interfaces are obsolete if you have Matlab Version 2008b or newer and Matlab Version 2012a for accessing NetCDF files on an OpenDAP server. See description in the above.

Directory Structure

The ROMS matlab repository has the following structure:

matlab/                               Main directory
      /4dvar                          4D-Var observations processing scripts
      /bathymetry                     ROMS Grid bathymetry extraction and processing scripts
      /bin                            Repository processing .bash and .sh scripts 
      /boundary                       Lateral boundary conditions processing scripts
      /coastlines                     Coastline extraction scripts
      /initial                        Initial conditions and climatology processing scripts
      /landmask                       Land/Sea masking processing scripts and GUIs
      /mex/                           MEX interface to C and Fortran programs
          /mexinside                  inside program
          /mexrect                    Curvilinear and rectilinear program
          /mexsepeli                  Sepeli conformal mapping
      /netcdf                         NetCDF data processing scripts
      /seagrid                        SeaGrid generation GUI
      /seawater                       Seawater properties scripts
      /utility                        Miscellaneous all purpose scripts
      /startup.m                      User script for configuring Matlab

The mexinside program is kind of obsolete since Matlab offers inpolygon with the same functionality.