{"id":1724,"date":"2015-10-27T10:14:25","date_gmt":"2015-10-27T15:14:25","guid":{"rendered":"http:\/\/www.nomad.priv.at\/researchblog\/?p=1724"},"modified":"2016-02-24T22:19:53","modified_gmt":"2016-02-25T03:19:53","slug":"working-with-netcdf-data-in-matlab","status":"publish","type":"post","link":"http:\/\/www.nomad.priv.at\/researchblog\/?p=1724","title":{"rendered":"Working with netCDF data in Matlab"},"content":{"rendered":"<p>It took a bit of time, but here are some simple procedures to work with netCDF output that I get from my atmospheric chemistry model runs in Matlab.<\/p>\n<p>Here is an example for pollutant concentrations obtained in .nc format from a <a href=\"http:\/\/rolf-sander.net\/messy\/mecca\/\">CAABA\/MECCA<\/a> run:<\/p>\n<pre class=\"brush: matlabkey; title: ; notranslate\" title=\"\">\r\n% Read 4D-double data from .nc file for the following variables\r\ntime = ncread('caaba_mecca.nc','time');\r\no3_data = ncread('caaba_mecca.nc','O3');\r\noh_data = ncread('caaba_mecca.nc','OH');\r\nno_data = ncread('caaba_mecca.nc','NO');\r\nno2_data = ncread('caaba_mecca.nc','NO2');\r\nch4_data = ncread('caaba_mecca.nc','CH4');\r\nco_data = ncread('caaba_mecca.nc','CO');\r\n\r\n% Extract concentration data from 4D double matrix and write to new variable\r\no3_data2 = squeeze(o3_data(1,1,1,:));\r\noh_data2 = squeeze(oh_data(1,1,1,:));\r\nno_data2 = squeeze(no_data(1,1,1,:));\r\nno2_data2 = squeeze(no2_data(1,1,1,:));\r\nch4_data2 = squeeze(ch4_data(1,1,1,:));\r\nco_data2 = squeeze(co_data(1,1,1,:));\r\n<\/pre>\n<p>Starting here you can resume regular Matlab code to work with the variables defined<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It took a bit of time, but here are some simple procedures to work with netCDF output that I get from my atmospheric chemistry model runs in Matlab. Here is an example for pollutant concentrations obtained in .nc format from a CAABA\/MECCA run: % Read 4D-double data from .nc file for the following variables time &hellip; <a href=\"http:\/\/www.nomad.priv.at\/researchblog\/?p=1724\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Working with netCDF data in Matlab<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[512,4],"tags":[],"class_list":["post-1724","post","type-post","status-publish","format-standard","hentry","category-matlab","category-research"],"_links":{"self":[{"href":"http:\/\/www.nomad.priv.at\/researchblog\/index.php?rest_route=\/wp\/v2\/posts\/1724","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.nomad.priv.at\/researchblog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.nomad.priv.at\/researchblog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.nomad.priv.at\/researchblog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.nomad.priv.at\/researchblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1724"}],"version-history":[{"count":3,"href":"http:\/\/www.nomad.priv.at\/researchblog\/index.php?rest_route=\/wp\/v2\/posts\/1724\/revisions"}],"predecessor-version":[{"id":1727,"href":"http:\/\/www.nomad.priv.at\/researchblog\/index.php?rest_route=\/wp\/v2\/posts\/1724\/revisions\/1727"}],"wp:attachment":[{"href":"http:\/\/www.nomad.priv.at\/researchblog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1724"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.nomad.priv.at\/researchblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1724"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.nomad.priv.at\/researchblog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1724"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}