<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://climate-cms.wikis.unsw.edu.au/index.php?action=history&amp;feed=atom&amp;title=Interpolating_NetCDF_files_to_different_grids</id>
	<title>Interpolating NetCDF files to different grids - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://climate-cms.wikis.unsw.edu.au/index.php?action=history&amp;feed=atom&amp;title=Interpolating_NetCDF_files_to_different_grids"/>
	<link rel="alternate" type="text/html" href="http://climate-cms.wikis.unsw.edu.au/index.php?title=Interpolating_NetCDF_files_to_different_grids&amp;action=history"/>
	<updated>2026-11-20T03:59:47Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.0</generator>
	<entry>
		<id>http://climate-cms.wikis.unsw.edu.au/index.php?title=Interpolating_NetCDF_files_to_different_grids&amp;diff=1272&amp;oldid=prev</id>
		<title>S.wales at 04:53, 16 July 2019</title>
		<link rel="alternate" type="text/html" href="http://climate-cms.wikis.unsw.edu.au/index.php?title=Interpolating_NetCDF_files_to_different_grids&amp;diff=1272&amp;oldid=prev"/>
		<updated>2019-07-16T04:53:59Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 04:53, 16 July 2019&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In order to use files from a reanalysis dataset as input to a model it is necessary to convert the input data to the model's resolution.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In order to use files from a reanalysis dataset as input to a model it is necessary to convert the input data to the model's resolution.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Interpolating to a new resolution is a conceptually simple operation, it can be thought of as a sparse matrix multiplication '''s''' '''W''' = '''t''', where the weight matrix '''W''' says how each point in the source grid '''s''' gets mapped to the target grid '''t'''. A number of libraries are available both to calculate the weight matrix between different grids, as well as to perform the matrix multiplication. The Oasis coupler uses the [http://www.mcs.anl.gov/research/projects/mct/ &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;| &lt;/del&gt;MCT] library for converting between different grids in coupled models. The [https://www.earthsystemcog.org/projects/esmf/ &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;| &lt;/del&gt;Earth System Modelling Framework (ESMF)] also has functions for interpolation, as well as a command-line tool to calculate weights offline which we'll cover here.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Interpolating to a new resolution is a conceptually simple operation, it can be thought of as a sparse matrix multiplication '''s''' '''W''' = '''t''', where the weight matrix '''W''' says how each point in the source grid '''s''' gets mapped to the target grid '''t'''. A number of libraries are available both to calculate the weight matrix between different grids, as well as to perform the matrix multiplication. The Oasis coupler uses the [http://www.mcs.anl.gov/research/projects/mct/ &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;MCT] library for converting between different grids in coupled models. The [https://www.earthsystemcog.org/projects/esmf/ &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;Earth System Modelling Framework (ESMF)] also has functions for interpolation, as well as a command-line tool to calculate weights offline which we'll cover here.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Doing the weight generation offline means you can re-use the weights matrix, which is handy if you have a lot of files to process. The weight generation is also the most resource intensive part of the process.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Doing the weight generation offline means you can re-use the weights matrix, which is handy if you have a lot of files to process. The weight generation is also the most resource intensive part of the process.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;NCAR have an [https://climatedataguide.ucar.edu/climate-data-tools-and-analysis/regridding-overview overview of regridding] where you can find some pros and cons of different regridding types&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=Creating a weights file with ESMF_RegridWeightGen= &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=Creating a weights file with ESMF_RegridWeightGen= &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>S.wales</name></author>
		
	</entry>
	<entry>
		<id>http://climate-cms.wikis.unsw.edu.au/index.php?title=Interpolating_NetCDF_files_to_different_grids&amp;diff=1203&amp;oldid=prev</id>
		<title>S.wales at 00:16, 2 July 2019</title>
		<link rel="alternate" type="text/html" href="http://climate-cms.wikis.unsw.edu.au/index.php?title=Interpolating_NetCDF_files_to_different_grids&amp;diff=1203&amp;oldid=prev"/>
		<updated>2019-07-02T00:16:46Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 00:16, 2 July 2019&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l48&quot; &gt;Line 48:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 48:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &amp;lt;span style=&amp;quot;font-family:monospace&amp;quot;&amp;gt;--netcdf4&amp;lt;/span&amp;gt;: Output in NetCDF4 format&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &amp;lt;span style=&amp;quot;font-family:monospace&amp;quot;&amp;gt;--netcdf4&amp;lt;/span&amp;gt;: Output in NetCDF4 format&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;For a full list of flags, as well as details on the source grid formats, see the [http://www.earthsystemmodeling.org/esmf_releases/public/&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;ESMF_6_3_0rp1&lt;/del&gt;/ESMF_refdoc/node3.html#SECTION03020000000000000000 &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;| &lt;/del&gt;ESMF_RegridWeightGen documentation]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;For a full list of flags, as well as details on the source grid formats, see the [http://www.earthsystemmodeling.org/esmf_releases/public/&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;last&lt;/ins&gt;/ESMF_refdoc/node3.html#SECTION03020000000000000000 ESMF_RegridWeightGen documentation]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Regridding Masked Fields== &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Regridding Masked Fields== &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>S.wales</name></author>
		
	</entry>
	<entry>
		<id>http://climate-cms.wikis.unsw.edu.au/index.php?title=Interpolating_NetCDF_files_to_different_grids&amp;diff=900&amp;oldid=prev</id>
		<title>S.wales at 05:04, 21 March 2019</title>
		<link rel="alternate" type="text/html" href="http://climate-cms.wikis.unsw.edu.au/index.php?title=Interpolating_NetCDF_files_to_different_grids&amp;diff=900&amp;oldid=prev"/>
		<updated>2019-03-21T05:04:28Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 05:04, 21 March 2019&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l62&quot; &gt;Line 62:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 62:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;ncks --map weights.nc input.nc output.nc&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;ncks --map weights.nc input.nc output.nc&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category: Data]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>S.wales</name></author>
		
	</entry>
	<entry>
		<id>http://climate-cms.wikis.unsw.edu.au/index.php?title=Interpolating_NetCDF_files_to_different_grids&amp;diff=176&amp;oldid=prev</id>
		<title>ScottWales: Imported from Wikispaces</title>
		<link rel="alternate" type="text/html" href="http://climate-cms.wikis.unsw.edu.au/index.php?title=Interpolating_NetCDF_files_to_different_grids&amp;diff=176&amp;oldid=prev"/>
		<updated>2016-07-12T06:19:49Z</updated>

		<summary type="html">&lt;p&gt;Imported from Wikispaces&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;In order to use files from a reanalysis dataset as input to a model it is necessary to convert the input data to the model's resolution.&lt;br /&gt;
&lt;br /&gt;
Interpolating to a new resolution is a conceptually simple operation, it can be thought of as a sparse matrix multiplication '''s''' '''W''' = '''t''', where the weight matrix '''W''' says how each point in the source grid '''s''' gets mapped to the target grid '''t'''. A number of libraries are available both to calculate the weight matrix between different grids, as well as to perform the matrix multiplication. The Oasis coupler uses the [http://www.mcs.anl.gov/research/projects/mct/ | MCT] library for converting between different grids in coupled models. The [https://www.earthsystemcog.org/projects/esmf/ | Earth System Modelling Framework (ESMF)] also has functions for interpolation, as well as a command-line tool to calculate weights offline which we'll cover here.&lt;br /&gt;
&lt;br /&gt;
Doing the weight generation offline means you can re-use the weights matrix, which is handy if you have a lot of files to process. The weight generation is also the most resource intensive part of the process.&lt;br /&gt;
&lt;br /&gt;
=Creating a weights file with ESMF_RegridWeightGen= &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;span style=&amp;quot;font-family:monospace&amp;quot;&amp;gt;ESMF_RegridWeightGen&amp;lt;/span&amp;gt; program reads grid information directly from a CF-NetCDF file to create the regridding weights. You can also define masks for both source and target grids using the missing values from a field in each file.&lt;br /&gt;
&lt;br /&gt;
Creating the weights can use quite a lot of resources for high-resolution files, it is best to submit this to the queue. The following resources worked for interpolating a 7600x3600 source data set to 1536x1152 (UM n768):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#PBS -l ncpus=16&lt;br /&gt;
#PBS -l mem=64&lt;br /&gt;
#PBS -l walltime=30:00&lt;br /&gt;
#PBS -l wd&lt;br /&gt;
&lt;br /&gt;
module load esmf openmpi&lt;br /&gt;
ulimit -s unlimited&lt;br /&gt;
mpirun ESMF_RegridWeightGen -t GRIDSPEC -m neareststod  \&lt;br /&gt;
    -s SOURCE.nc --src_missingvalue SOURCE_FIELD \&lt;br /&gt;
    -d TARGET.nc --dst_missingvalue TARGET_FIELD \&lt;br /&gt;
    -w weights.nc--netcdf4&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Useful Flags== &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;span style=&amp;quot;font-family:monospace&amp;quot;&amp;gt;-t&amp;lt;/span&amp;gt;: Defines the type of the grid data, possible options are:&lt;br /&gt;
** &amp;lt;span style=&amp;quot;font-family:monospace&amp;quot;&amp;gt;GRIDSPEC&amp;lt;/span&amp;gt;: Read the grid from a CF-NetCDF file&lt;br /&gt;
** &amp;lt;span style=&amp;quot;font-family:monospace&amp;quot;&amp;gt;SCRIP&amp;lt;/span&amp;gt;: Read the grid in SCRIP format&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;span style=&amp;quot;font-family:monospace&amp;quot;&amp;gt;-m&amp;lt;/span&amp;gt;: Defines the regridding method, possible options are:&lt;br /&gt;
** &amp;lt;span style=&amp;quot;font-family:monospace&amp;quot;&amp;gt;bilinear&amp;lt;/span&amp;gt;: Bilinear interpolation&lt;br /&gt;
** &amp;lt;span style=&amp;quot;font-family:monospace&amp;quot;&amp;gt;patch&amp;lt;/span&amp;gt;: Higher-order interpolation&lt;br /&gt;
** &amp;lt;span style=&amp;quot;font-family:monospace&amp;quot;&amp;gt;neareststod&amp;lt;/span&amp;gt;: Map each target point to the closest point in the source grid (only a single source point will map to a given target point)&lt;br /&gt;
** &amp;lt;span style=&amp;quot;font-family:monospace&amp;quot;&amp;gt;nearestdtos&amp;lt;/span&amp;gt;: Map each source point to the closest point in the target grid (multiple source points can map to a single target point)&lt;br /&gt;
** &amp;lt;span style=&amp;quot;font-family:monospace&amp;quot;&amp;gt;conserve&amp;lt;/span&amp;gt;: Conservative remapping (requires extra boundary information to calculate the grid cell areas, see documentation)&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;span style=&amp;quot;font-family:monospace&amp;quot;&amp;gt;-s SOURCE.nc&amp;lt;/span&amp;gt;: Sample file that you'd like to regrid&lt;br /&gt;
* &amp;lt;span style=&amp;quot;font-family:monospace&amp;quot;&amp;gt;-src_missingvalue SOURCE_FIELD}}: A field from {{SOURCE.nc}} which defines the mask of the source grid (it should have either the {{_FillValue}} or {{missing_value&amp;lt;/span&amp;gt; attribute set)&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;span style=&amp;quot;font-family:monospace&amp;quot;&amp;gt;-d TARGET.nc&amp;lt;/span&amp;gt;: Sample file with the target grid&lt;br /&gt;
* &amp;lt;span style=&amp;quot;font-family:monospace&amp;quot;&amp;gt;-dst_missingvalue TARGET_FIELD}}: A field from {{TARGET.nc}} which defines the mask of the target grid (it should have either the {{_FillValue}} or {{missing_value&amp;lt;/span&amp;gt; attribute set)&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;span style=&amp;quot;font-family:monospace&amp;quot;&amp;gt;-w weights.nc&amp;lt;/span&amp;gt;: Output file for the regridding weights&lt;br /&gt;
* &amp;lt;span style=&amp;quot;font-family:monospace&amp;quot;&amp;gt;--netcdf4&amp;lt;/span&amp;gt;: Output in NetCDF4 format&lt;br /&gt;
&lt;br /&gt;
For a full list of flags, as well as details on the source grid formats, see the [http://www.earthsystemmodeling.org/esmf_releases/public/ESMF_6_3_0rp1/ESMF_refdoc/node3.html#SECTION03020000000000000000 | ESMF_RegridWeightGen documentation]&lt;br /&gt;
&lt;br /&gt;
==Regridding Masked Fields== &lt;br /&gt;
&lt;br /&gt;
If either your source or target grids need to be masked it is possible that some of the points in the target grid will not be present in the source grid - for instance if a lakes are present in one file but not the other. If this is the case ESMF_RegridWeightGen will error out, printing a message to its log file. To avoid this you can either change to the &amp;lt;span style=&amp;quot;font-family:monospace&amp;quot;&amp;gt;neareststod}} interpolation method or ignore the missing values error with the {{--ignore&amp;lt;/span&amp;gt; flag then add the missing points back in after interpolating your files.&lt;br /&gt;
&lt;br /&gt;
=Regridding files with ncks= &lt;br /&gt;
&lt;br /&gt;
Once you have the weights file it's simple to convert data to the target grid using &amp;lt;span style=&amp;quot;font-family:monospace&amp;quot;&amp;gt;ncks&amp;lt;/span&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
module load nco&lt;br /&gt;
ncks --map weights.nc input.nc output.nc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>ScottWales</name></author>
		
	</entry>
</feed>